Address Details
contract

0x89cea15F68950DF830dFE3630d635a9eD79478F5

Contract Name
ERC20NFTBond
Creator
0x9378a4–07b185 at 0x5e50d5–f4a820
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
24331184
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
ERC20NFTBond




Optimization enabled
true
Compiler version
v0.8.13+commit.abaa5c0e




Optimization runs
200
EVM Version
london




Verified at
2023-01-16T11:30:34.158852Z

contracts/nftbond/ERC20NFTBond.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

import "./NFTBond.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";

/**
 * @title ERC20NFTBond
 * @dev Contains functions related to buying and liquidating bonds,
 * and borrowing and returning funds when the principal is ERC20 token
 * @author Ethichub
 */
contract ERC20NFTBond is NFTBond {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    IERC20Upgradeable private principalToken;
    IERC20Upgradeable private collateralToken;

    struct NFTParams {
        string name;
        string symbol;
        string baseUri;
    }

    function initialize(
        address _principalToken,
        address _collateralToken,
        NFTParams calldata _nftParams,
        address _accessManager,
        uint256[] calldata _interests,
        uint256[] calldata _maturities
    )
    external initializer {
        principalToken = IERC20Upgradeable(_principalToken);
        collateralToken = IERC20Upgradeable(_collateralToken);
        __NFTBond_init(_nftParams.name, _nftParams.symbol, _nftParams.baseUri);
        __CollateralizedBondGranter_init(_collateralToken);
        __InterestParameters_init(_interests, _maturities);
        __AccessManaged_init(_accessManager);
    }

    /**
     * @dev External function to buy a bond and returns the tokenId of the bond
     * when the contract is active
     * @param tokenUri string
     * @param beneficiary address
     * @param maturity uint256
     * @param principal uint256
     * @param nftHash bytes32
     * @param setApprove bool
     * @param nonce uint256
     * @param signature bytes
     */
    function buyBond(
        string calldata tokenUri,
        address beneficiary,
        uint256 maturity,
        uint256 principal,
        bytes32 nftHash,
        bool setApprove,
        uint256 nonce,
        bytes memory signature
    )
    external whenNotPaused returns (uint256) {
        return super._buyBond(tokenUri, beneficiary, maturity, principal, nftHash, setApprove, nonce, signature);
    }

    /**
     * @dev External function to redeem a bond and returns the amount of the bond
     */
    function redeemBond(uint256 tokenId) external returns (uint256) {
        return super._redeemBond(tokenId); 
    }

    function principalTokenAddress() external view returns (address) {
        return address(principalToken);
    }

    function pause() external onlyRole(PAUSER) {
        _pause();
    }

    function unpause() external onlyRole(PAUSER) {
        _unpause();
    }

    /**
     * @dev Transfers from the buyer to this contract the principal token amount
     */
    function _beforeBondPurchased(
        string calldata tokenUri,
        address beneficiary,
        uint256 maturity,
        uint256 principal
    )
    internal override {
        super._beforeBondPurchased(tokenUri, beneficiary, maturity, principal);
        principalToken.safeTransferFrom(beneficiary, address(this), principal);
    }

    /**
     * @dev Transfers to the owner of the bond the amount of the bond when the contract has
     * liquidity, if not will send the correspondent amount of collateral
     */
    function _afterBondRedeemed(
        uint256 tokenId,
        uint256 amount,
        address beneficiary
    ) 
    internal override {
        Bond memory bond = bonds[tokenId];
        super._afterBondRedeemed(tokenId, amount, beneficiary);
        if (principalToken.balanceOf(address(this)) < amount) {
            uint256 porcentageOfCollateral = 100 - (principalToken.balanceOf(address(this)) * 100 / amount);
            uint256 amountOfCollateral = (bond.principal * porcentageOfCollateral / 100) * collateralMultiplier;
            principalToken.safeTransfer(beneficiary, principalToken.balanceOf(address(this)));
            if (collateralToken.balanceOf(address(this)) < amountOfCollateral) {
                collateralToken.safeTransfer(beneficiary, collateralToken.balanceOf(address(this)));
            } else {
                collateralToken.safeTransfer(beneficiary, amountOfCollateral);
            }
        } else {
            principalToken.safeTransfer(beneficiary, amount);
        }
    }

    /**
     * @dev Transfers to the recipient the amount of liquidity available in this contract
     */
    function _beforeRequestLiquidity(address destination, uint256 amount) internal override {
        principalToken.safeTransfer(destination, amount);
        super._beforeRequestLiquidity(destination, amount);
    }

    /**
     * @dev Transfers from the borrower the amount of liquidity borrowed
     */
    function _afterReturnLiquidity(uint256 amount) internal override {
        super._afterReturnLiquidity(amount);
        principalToken.safeTransferFrom(msg.sender, address(this), amount);
    }

    function _pause() internal override {
        super._pause();
    }

    function _unpause() internal override {
        super._unpause();
    }

    uint256[49] private __gap;
}
        

/_openzeppelin/contracts/access/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;
}
          

/_openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}
          

/_openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

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

/_openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}
          

/_openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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. Equivalent to `reinitializer(1)`.
     */
    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.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so 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.
     *
     * 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.
     */
    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.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }
}
          

/_openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate that the this implementation remains valid after an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

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

/_openzeppelin/contracts-upgradeable/security/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;
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/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);
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/extensions/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);
}
          

/_openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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");
        }
    }
}
          

/_openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.0;

import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
    using AddressUpgradeable for address;
    using StringsUpgradeable for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __ERC721_init_unchained(name_, symbol_);
    }

    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

        _balances[to] += 1;
        _owners[tokenId] = to;

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

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

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721Upgradeable.ownerOf(tokenId);

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

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

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

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

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

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

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

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC721: approve to caller");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

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

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

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
     * transferred to `to`.
     * - When `from` is zero, `tokenId` will be minted for `to`.
     * - When `to` is zero, ``from``'s `tokenId` will be burned.
     * - `from` 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 tokenId
    ) 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.
     * - `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 tokenId
    ) internal virtual {}

    /**
     * @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[44] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/token/ERC721/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);
}
          

/_openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @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);
}
          

/_openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721Burnable.sol)

pragma solidity ^0.8.0;

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

/**
 * @title ERC721 Burnable Token
 * @dev ERC721 Token that can be burned (destroyed).
 */
abstract contract ERC721BurnableUpgradeable is Initializable, ContextUpgradeable, ERC721Upgradeable {
    function __ERC721Burnable_init() internal onlyInitializing {
    }

    function __ERC721Burnable_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev Burns `tokenId`. See {ERC721-_burn}.
     *
     * Requirements:
     *
     * - The caller must own `tokenId` or be an approved operator.
     */
    function burn(uint256 tokenId) public virtual {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner nor approved");
        _burn(tokenId);
    }

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

/_openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)

pragma solidity ^0.8.0;

import "../ERC721Upgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
    function __ERC721Enumerable_init() internal onlyInitializing {
    }

    function __ERC721Enumerable_init_unchained() internal onlyInitializing {
    }
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @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[46] private __gap;
}
          

/_openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721URIStorage.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev ERC721 token with storage based token URI management.
 */
abstract contract ERC721URIStorageUpgradeable is Initializable, ERC721Upgradeable {
    function __ERC721URIStorage_init() internal onlyInitializing {
    }

    function __ERC721URIStorage_init_unchained() internal onlyInitializing {
    }
    using StringsUpgradeable for uint256;

    // Optional mapping for token URIs
    mapping(uint256 => string) private _tokenURIs;

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

        string memory _tokenURI = _tokenURIs[tokenId];
        string memory base = _baseURI();

        // If there is no base URI, return the token URI.
        if (bytes(base).length == 0) {
            return _tokenURI;
        }
        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
        if (bytes(_tokenURI).length > 0) {
            return string(abi.encodePacked(base, _tokenURI));
        }

        return super.tokenURI(tokenId);
    }

    /**
     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
        require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
        _tokenURIs[tokenId] = _tokenURI;
    }

    /**
     * @dev See {ERC721-_burn}. This override additionally checks to see if a
     * token-specific URI was set for the token, and if so, it deletes the token URI from
     * the storage mapping.
     */
    function _burn(uint256 tokenId) internal virtual override {
        super._burn(tokenId);

        if (bytes(_tokenURIs[tokenId]).length != 0) {
            delete _tokenURIs[tokenId];
        }
    }

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

/_openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol

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

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

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

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

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

/_openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol

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

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

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

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

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

/_openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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 functionCall(target, data, "Address: low-level call failed");
    }

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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);
            }
        }
    }
}
          

/_openzeppelin/contracts-upgradeable/utils/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;
}
          

/_openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library CountersUpgradeable {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

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

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}
          

/_openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}
          

/_openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    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);
    }
}
          

/_openzeppelin/contracts-upgradeable/utils/introspection/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;
}
          

/_openzeppelin/contracts-upgradeable/utils/introspection/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);
}
          

/contracts/Roles.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

bytes32 constant DEFAULT_ADMIN_ROLE = bytes32(0);

bytes32 constant INTEREST_PARAMETERS_SETTER  = keccak256("INTEREST_PARAMETERS_SETTER");
bytes32 constant COLLATERAL_BOND_SETTER  = keccak256("COLLATERAL_BOND_SETTER");
bytes32 constant LIQUIDITY_REQUESTER  = keccak256("LIQUIDITY_REQUESTER");
bytes32 constant PAUSER  = keccak256("PAUSER");
bytes32 constant UPGRADER  = keccak256("UPGRADER");
bytes32 constant MINTER = keccak256("MINTER");
          

/contracts/access/AccessManagedUpgradeable.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

import "@openzeppelin/contracts/access/IAccessControl.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../Roles.sol";

abstract contract AccessManagedUpgradeable is Initializable {
    IAccessControl private _accessControl;

    event AccessManagerUpdated(address indexed newAddressManager);

    modifier onlyRole(bytes32 role) {
        require(_hasRole(role, msg.sender), "AccessManagedUpgradeable::Missing Role");
        _;
    }

    function __AccessManaged_init(address manager) internal initializer {
        _accessControl = IAccessControl(manager);
        emit AccessManagerUpdated(manager);
    }

    function setAccessManager(address newManager) public onlyRole(DEFAULT_ADMIN_ROLE) {
        _accessControl = IAccessControl(newManager);
        emit AccessManagerUpdated(newManager);
    }

    function _hasRole(bytes32 role, address account) internal view returns (bool) {
        return _accessControl.hasRole(role, account);
    }

    uint256[49] private __gap;
}
          

/contracts/bond/BondGranter.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

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

/**
 * @title BondGranter
 * @dev This contract contains functions related to the emission or withdrawal of the bonds
 * @author Ethichub
 */
abstract contract BondGranter is Initializable, InterestParameters, InterestCalculator {
    struct Bond {
        uint256 mintingDate;
        uint256 maturity;
        uint256 principal;
        uint256 interest;
        bool redeemed;
    }

    mapping(uint256 => Bond) public bonds;

    event BondIssued(uint256 tokenId, uint256 mintingDate, uint256 maturity, uint256 principal, uint256 interest);
    event BondRedeemed(uint256 tokenId, uint256 redeemDate, uint256 maturity, uint256 withdrawn, uint256 interest);

    /**
     * @dev Assigns a bond with its parameters
     * @param tokenId uint256
     * @param maturity uint256 seconds
     * @param principal uint256 in wei
     *
     * Requirements:
     *
     * - Principal amount can not be 0
     * - Maturity must be greater than the first element of the set of interests
     */
    function _issueBond(uint256 tokenId, uint256 maturity, uint256 principal) internal virtual {
        require(principal > 0, "BondGranter::Principal is 0");
        require(maturity >= maturities[0], "BondGranter::Maturity must be greater than the first interest");
        uint256 interest = super.getInterestForMaturity(maturity);
        bonds[tokenId] = Bond(block.timestamp, maturity, principal, interest, false);
        emit BondIssued(tokenId, block.timestamp, maturity, principal, interest);
    }

    /**
     * @dev Checks eligilibility to redeem the bond and returns its value
     * @param tokenId uint256
     */
    function _redeemBond(uint256 tokenId) internal virtual returns (uint256) {
        Bond memory bond = bonds[tokenId];
        require((bond.maturity + bond.mintingDate) < block.timestamp, "BondGranter::Can't redeem yet");
        require(!bond.redeemed, "BondGranter::Already redeemed");
        bonds[tokenId].redeemed = true;
        emit BondRedeemed(tokenId, block.timestamp, bond.maturity, _bondValue(tokenId), bond.interest);
        return _bondValue(tokenId);
    }

    /**
     * @dev Returns the actual value of the bond with its interest
     * @param tokenId uint256
     */
    function _bondValue(uint256 tokenId) internal view virtual returns (uint256) {
        Bond memory bond = bonds[tokenId];
        return bond.principal + bond.principal * super.simpleInterest(bond.interest, bond.maturity) / 100 / 1000000000000000000;
    }

    uint256[49] private __gap;

}
          

/contracts/bond/CollateralizedBondGranter.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "./BondGranter.sol";

/**
 * @title CollateralizedBondGranter
 * @dev This contract contains functions related to the emission or withdrawal of
 * the bonds with collateral
 * @author Ethichub
 */
abstract contract CollateralizedBondGranter is BondGranter {
    using SafeERC20Upgradeable for IERC20Upgradeable;
    IERC20Upgradeable private _collateralToken;

    uint256 public collateralMultiplier;
    uint256 public totalCollateralizedAmount;

    mapping(uint256 => uint256) public collaterals;

    event CollateralMultiplierUpdated(uint256 collateralMultiplier);
    event CollateralAssigned(uint256 tokenId, uint256 collateralAmount);
    event CollateralReleased(uint256 tokenId, uint256 collateralAmount);
    event CollateralExcessRemoved(address indexed destination);

    function __CollateralizedBondGranter_init(
        address collateralToken
    )
    internal initializer {
        collateralMultiplier = 5;
        _collateralToken = IERC20Upgradeable(collateralToken);
    }

    function collateralTokenAddress() external view returns (address) {
        return address(_collateralToken);
    }

    /**
     * @dev Sets the number by which the amount of the collateral must be multiplied.
     * In this version will be 5
     * @param multiplierIndex uint256
     */
    function setCollateralMultiplier(uint256 multiplierIndex) external onlyRole(COLLATERAL_BOND_SETTER) {
        require(multiplierIndex > 0, "CollateralizedBondGranter::multiplierIndex is 0");
        collateralMultiplier = multiplierIndex;
        emit CollateralMultiplierUpdated(collateralMultiplier);
    }

    /**
     * @dev Function to withdraw the rest of the collateral that remains in the contract
     * to a specified address
     * @param destination address
     */
    function removeExcessOfCollateral(address destination) external onlyRole(COLLATERAL_BOND_SETTER) {
        uint256 excessAmount = _collateralToken.balanceOf(address(this)) - totalCollateralizedAmount;
        _collateralToken.safeTransfer(destination, excessAmount);
        emit CollateralExcessRemoved(destination);
    }

    /**
     * @dev Issues a bond with calculated collateral
     * @param tokenId uint256
     * @param maturity uint256 seconds
     * @param principal uint256 in wei
     *
     * Requirement:
     *
     * - The contract must have enough collateral
     */
    function _issueBond(
        uint256 tokenId,
        uint256 maturity,
        uint256 principal
    ) internal override {
        require(_hasCollateral(principal), "CBG::Not enough collateral");
        super._issueBond(tokenId, maturity, principal);
        uint256 collateralAmount = _calculateCollateralBondAmount(principal);
        totalCollateralizedAmount = totalCollateralizedAmount + collateralAmount;
        collaterals[tokenId] = collateralAmount;
        emit CollateralAssigned(tokenId, collateralAmount);
    }

    /**
     * @dev Updates totalCollateralizedAmount when a bond is redeemed
     * @param tokenId uint256
     */
    function _redeemBond(uint256 tokenId) internal virtual override returns (uint256) {
        uint256 bondValue = super._redeemBond(tokenId);
        uint256 collateralAmount = collaterals[tokenId];
        totalCollateralizedAmount = totalCollateralizedAmount - collateralAmount;
        emit CollateralReleased(tokenId, collateralAmount);
        return bondValue;
    }

    /**
     * @dev Returns the amount of collateral that links to the bond
     * @param principal uint256
     */
    function _calculateCollateralBondAmount(uint256 principal) internal view returns (uint256) {
        return principal * collateralMultiplier;
    }

    /**
     * @dev Return true if the balace of the contract minus totalCollateralizedAmount is greater or equal to
     * the amount of the bond's collateral
     * @param principal uint256
     */
    function _hasCollateral(uint256 principal) internal view returns (bool) {
        if (_collateralToken.balanceOf(address(this)) - totalCollateralizedAmount >= principal * collateralMultiplier) {
            return true;
        }
        return false;
    }

    uint256[49] private __gap;
}
          

/contracts/bond/InterestParameters.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../interfaces/IInterestParameters.sol";
import "../access/AccessManagedUpgradeable.sol";
import "../Roles.sol";

/**
 * @title InterestParameters
 * @dev Contains functions related to interests and maturities for the bonds
 * @author Ethichub
 */
abstract contract InterestParameters is Initializable, IInterestParameters, AccessManagedUpgradeable {
    uint256[] public interests;
    uint256[] public maturities;
    uint256 public maxParametersLength;

    function __InterestParameters_init(
        uint256[] calldata _interests,
        uint256[] calldata _maturities
    )
    internal initializer {
        maxParametersLength = 3;
        _setInterestParameters(_interests, _maturities);
    }

    function setInterestParameters(
        uint256[] calldata _interests,
        uint256[] calldata _maturities
    )
    external override onlyRole(INTEREST_PARAMETERS_SETTER) {
        _setInterestParameters(_interests, _maturities);
    }

    function setMaxInterestParams(uint256 value) external override onlyRole(INTEREST_PARAMETERS_SETTER) {
        _setMaxInterestParams(value);
    }

    function getInterestForMaturity(uint256 maturity) public view override returns (uint256) {
        return _getInterestForMaturity(maturity);
    }

    /**
     * @dev Sets the parameters of interests and maturities
     * @param _interests set of interests per second in wei
     * @param _maturities set of maturities in second
     *
     * Requirements:
     *
     * - The length of the array of interests can not be 0
     * - The length of the array of interests can not be greater than maxParametersLength
     * - The length of the array of interests and maturities must be the same
     * - The value of maturities must be in ascending order
     * - The values of interest and maturities can not be 0
     */
    function _setInterestParameters(
        uint256[] calldata _interests,
        uint256[] calldata _maturities
    )
    internal {
        require(_interests.length > 0, "InterestParameters::Interest must be greater than 0");
        require(_interests.length <= maxParametersLength, "InterestParameters::Interest parameters is greater than max parameters");
        require(_interests.length == _maturities.length, "InterestParameters::Unequal input length");
        for (uint256 i = 0; i < _interests.length; ++i) {
            if (i != 0) {
                require(_maturities[i-1] < _maturities[i], "InterestParameters::Unordered maturities");
            }
            require(_interests[i] > 0, "InterestParameters::Can't set zero interest");
            require(_maturities[i] > 0, "InterestParameters::Can't set zero maturity");
        }
        interests = _interests;
        maturities = _maturities;
        emit InterestParametersSet(interests, maturities);
    }

    /**
     * @dev Sets the maximum length of interests and maturities parameters
     * @param value uint256
     *
     * Requirement:
     *
     * - The length value can not be 0
     */
    function _setMaxInterestParams(uint256 value) internal {
        require(value > 0, "InterestParameters::Interest length is 0");
        maxParametersLength = value;
        emit MaxInterestParametersSet(value);
    }

    /**
     * @dev Checks the interest correspondant to the maturity.
     * Needs at least 1 maturity / interest pair.
     * Returns interest per second
     * @param maturity duration of the bond in seconds
     */
    function _getInterestForMaturity(uint256 maturity) internal view returns (uint256) {
        require(maturity >= maturities[0], "InterestParameters::Maturity must be greater than first interest");
        for (uint256 i = interests.length - 1; i >= 0; --i) {
            if (maturity >= maturities[i]) {
                return interests[i];
            }
        }
        return interests[0];
    }

    uint256[49] private __gap;
}
          

/contracts/borrowing/LiquidityRequester.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../interfaces/ILiquidityRequester.sol";
import "../access/AccessManagedUpgradeable.sol";
import "../Roles.sol";

/**
 * @title LiquidityRequester
 * @dev Contains functions related to withdraw or return liquidity to the contract for borrowing
 * Increments every time money is taking out for lending projects, decrements every time is returned
 * @author Ethichub
 */
abstract contract LiquidityRequester is Initializable, ILiquidityRequester, AccessManagedUpgradeable {
    uint256 public totalBorrowed;

    event LiquidityRequested(uint256 totalBorrowed, address indexed destination);
    event LiquidityReturned(uint256 totalBorrowed, address indexed destination);

    /**
     * @dev External function to withdraw liquidity for borrowing
     * @param destination address of recipient
     * @param amount uint256 in wei
     *
     * Requirement:
     *
     * - Only the role LIQUIDITY_REQUESTER can call this function
     */
    function requestLiquidity(address destination, uint256 amount) public virtual override onlyRole(LIQUIDITY_REQUESTER) returns (uint256) {
        return _requestLiquidity(destination, amount);
    }

    /**
     * @dev External function to return liquidity from borrowing
     * @param amount uint256 in wei
     */
    function returnLiquidity(uint256 amount) public payable virtual override returns (uint256) {
        return _returnLiquidity(amount);
    }

    /**
     * @dev Internal function to withdraw liquidity for borrowing
     * Updates and returns totalBorrowed
     * @param destination address of recipient
     * @param amount uint256 in wei
     */
    function _requestLiquidity(address destination, uint256 amount) internal returns (uint256) {
        totalBorrowed = totalBorrowed + amount;
        emit LiquidityRequested(totalBorrowed, destination);
        return totalBorrowed;
    }

    /**
     * @dev Internal function to return liquidity from borrowing
     * Updates and returns totalBorrowed
     * @param amount uint256 in wei
     */
    function _returnLiquidity(uint256 amount) internal returns (uint256) {
        totalBorrowed = totalBorrowed - amount;
        emit LiquidityReturned(totalBorrowed, msg.sender);
        return totalBorrowed;
    }
    
    uint256[49] private __gap;
}
          

/contracts/interfaces/IInterestCalculator.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

interface IInterestCalculator {
  /**
   * @dev Calculates interest per second that is int 1e18
   * @param maturity duration of the bond in seconds
   * @param interest per second
   * @return simple interest per second that is int 1e18
   */
  function simpleInterest(uint256 interest, uint256 maturity) external view returns (uint256);
}


          

/contracts/interfaces/IInterestParameters.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

interface IInterestParameters {
    event InterestParametersSet(uint256[] interests, uint256[] maturities);
    event MaxInterestParametersSet(uint256 value);
    /**
     * Set interests and maturities params, all in seconds 
     */
    function setInterestParameters(uint256[] calldata interests, uint256[] calldata maturities) external;
    function setMaxInterestParams(uint256 value) external;
    function getInterestForMaturity(uint256 maturity) external returns (uint256);
}
          

/contracts/interfaces/ILiquidityRequester.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

interface ILiquidityRequester {
    /**
     * Increments every time money is taking out for lending projects, decrements every time is returned
     */
    function requestLiquidity(address destination, uint256 amount) external returns (uint256);
    function returnLiquidity(uint256 amount) external payable returns (uint256);
}
          

/contracts/nftbond/NFTBond.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

import "../token/NFT.sol";
import "../bond/CollateralizedBondGranter.sol";
import "../borrowing/LiquidityRequester.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";

/**
 * @title NFTBond
 * @dev Contains functions related to buying and liquidating bonds, and borrowing and returning funds
 * @author Ethichub
 */
abstract contract NFTBond is NFT, CollateralizedBondGranter, LiquidityRequester, PausableUpgradeable {
    function __NFTBond_init(
        string calldata _name,
        string calldata _symbol,
        string calldata _baseUri
    )
    internal initializer {
        __NFT_init(_name, _symbol, _baseUri);
    }

    /**
     * @dev Returns updated totalBorrowed
     * @param amount uint256 in wei
     */
    function returnLiquidity(uint256 amount) public payable virtual override returns (uint256) {
        _beforeReturnLiquidity();
        super.returnLiquidity(amount);
        _afterReturnLiquidity(amount);
        return totalBorrowed;
    }

    /**
     * @dev Requests totalBorrowed
     * @param destination address of recipient
     * @param amount uint256 in wei
     */
    function requestLiquidity(address destination, uint256 amount) public override whenNotPaused returns (uint256) {
        _beforeRequestLiquidity(destination, amount);
        super.requestLiquidity(destination, amount);
        return totalBorrowed;
    }

    /**
     * @dev Returns assigned tokenId of the bond
     */
    function _buyBond(
        string calldata tokenUri,
        address beneficiary,
        uint256 maturity,
        uint256 principal,
        bytes32 nftHash,
        bool setApprove,
        uint256 nonce,
        bytes memory signature
    )
    internal returns (uint256) {
        require(msg.sender == beneficiary, "NFTBond::Beneficiary != sender");
        _beforeBondPurchased(tokenUri, beneficiary, maturity, principal);
        uint256 tokenId = _safeMintBySig(tokenUri, beneficiary, nftHash, setApprove, nonce, signature);
        super._issueBond(tokenId, maturity, principal);
        _afterBondPurchased(tokenUri, beneficiary, maturity, principal, tokenId);
        return tokenId;
    }
    
    /**
     * @dev Returns the amunt that corresponds to the bond
     */
    function _redeemBond(uint256 tokenId) internal virtual override returns (uint256) {
        uint256 amount = super._redeemBond(tokenId); 
        address beneficiary = ownerOf(tokenId);
        _afterBondRedeemed(tokenId, amount, beneficiary);
        return amount;
    }
    
    function _beforeBondPurchased(
        string calldata tokenUri,
        address beneficiary,
        uint256 maturity,
        uint256 principal
    ) internal virtual {}

    function _afterBondPurchased(
        string calldata tokenUri,
        address beneficiary,
        uint256 maturity,
        uint256 principal,
        uint256 tokenId
    ) internal virtual {}

    function _beforeBondRedeemed(uint256 tokenId, uint256 value) internal virtual {}

    function _afterBondRedeemed(uint256 tokenId, uint256 value, address beneficiary) internal virtual {}

    function _beforeRequestLiquidity(address destination, uint256 amount) internal virtual {}

    function _afterRequestLiquidity(address destination) internal virtual {}

    function _beforeReturnLiquidity() internal virtual {}

    function _afterReturnLiquidity(uint256 amount) internal virtual {}

    uint256[49] private __gap;
}
          

/contracts/token/NFT.sol

// SPDX-License-Identifier: AGPLv3
pragma solidity 0.8.13;

import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
import "../access/AccessManagedUpgradeable.sol";

abstract contract NFT is Initializable, ERC721Upgradeable, ERC721EnumerableUpgradeable, ERC721URIStorageUpgradeable, ERC721BurnableUpgradeable, UUPSUpgradeable, AccessManagedUpgradeable {
    using CountersUpgradeable for CountersUpgradeable.Counter;
    
    CountersUpgradeable.Counter private _tokenIdCounter;
    string private _baseTokenURI;
    mapping(uint256 => bool) private _nonces;

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() initializer {}

    function __NFT_init(
        string calldata _name,
        string calldata _symbol,
        string calldata _baseUri
    )
    internal initializer {
        __ERC721_init(_name, _symbol);
        __ERC721Enumerable_init();
        __ERC721URIStorage_init();
        __ERC721Burnable_init();
        __UUPSUpgradeable_init();
        _setBaseURI(_baseUri);
    }

    function tokenURI(uint256 tokenId)
        public
        view
        override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
        returns (string memory)
    {
        return super.tokenURI(tokenId);
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return _baseTokenURI;
    }

    function _safeMint(address to, string calldata uri) internal returns (uint256) {
        uint256 tokenId = _tokenIdCounter.current();
        _tokenIdCounter.increment();
        _safeMint(to, tokenId);
        _setTokenURI(tokenId, uri);
        return tokenId;
    }

    function _safeMintBySig (string calldata uri, address to, bytes32 nftHash, bool setApprove, uint256 nonce, bytes memory signature) internal returns (uint256) {
        bytes32 messageHash = keccak256(abi.encode(uri, to, nftHash, address(this), setApprove, nonce, block.chainid));
        bytes32 ethSignedMessageHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", messageHash));
        (bytes32 r, bytes32 s, uint8 v) = _splitSignature(signature);

        address miningSigner = ecrecover(ethSignedMessageHash, v, r, s);
        require(_hasRole(MINTER, miningSigner), "NFT::Invalid Signature");

        return _safeMint(to, uri);
    }

    function _beforeTokenTransfer(address from, address to, uint256 tokenId)
        internal
        override(ERC721Upgradeable, ERC721EnumerableUpgradeable)
    {
        super._beforeTokenTransfer(from, to, tokenId);
    }

    function _authorizeUpgrade(address newImplementation)
        internal
        onlyRole(UPGRADER)
        override
    {}

    // The following functions are overrides required by Solidity.

    function _burn(uint256 tokenId)
        internal
        override(ERC721Upgradeable, ERC721URIStorageUpgradeable)
    {
        super._burn(tokenId);
    }

    function _setBaseURI(string calldata _baseUri) private {
      _baseTokenURI = _baseUri;
    }

    function _splitSignature(bytes memory _sig) private pure returns (bytes32 r, bytes32 s, uint8 v) {
        require(_sig.length == 65, "Invalid Signature length");
        assembly {
            r := mload(add(_sig, 32))
            s := mload(add(_sig, 64))
            v := byte(0, mload(add(_sig, 96)))
        }
    }
    uint256[49] private __gap;
}
          

/contracts/utils/InterestCalculator.sol

// SPDX-License-Identifier: GPLv3
pragma solidity 0.8.13;

import "../interfaces/IInterestCalculator.sol";

abstract contract InterestCalculator is IInterestCalculator {
  function simpleInterest(uint256 interest, uint256 maturity) public view virtual override returns (uint256) {
    return _simpleInterest(interest, maturity);
  }

  function _simpleInterest(uint256 interest, uint256 maturity) internal view virtual returns (uint256) {
    return maturity * interest;
  }
}
          

Contract ABI

[{"type":"event","name":"AccessManagerUpdated","inputs":[{"type":"address","name":"newAddressManager","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"AdminChanged","inputs":[{"type":"address","name":"previousAdmin","internalType":"address","indexed":false},{"type":"address","name":"newAdmin","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"approved","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"ApprovalForAll","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"BeaconUpgraded","inputs":[{"type":"address","name":"beacon","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"BondIssued","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"mintingDate","internalType":"uint256","indexed":false},{"type":"uint256","name":"maturity","internalType":"uint256","indexed":false},{"type":"uint256","name":"principal","internalType":"uint256","indexed":false},{"type":"uint256","name":"interest","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"BondRedeemed","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"redeemDate","internalType":"uint256","indexed":false},{"type":"uint256","name":"maturity","internalType":"uint256","indexed":false},{"type":"uint256","name":"withdrawn","internalType":"uint256","indexed":false},{"type":"uint256","name":"interest","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"CollateralAssigned","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"collateralAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"CollateralExcessRemoved","inputs":[{"type":"address","name":"destination","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"CollateralMultiplierUpdated","inputs":[{"type":"uint256","name":"collateralMultiplier","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"CollateralReleased","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"collateralAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"InterestParametersSet","inputs":[{"type":"uint256[]","name":"interests","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"maturities","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"event","name":"LiquidityRequested","inputs":[{"type":"uint256","name":"totalBorrowed","internalType":"uint256","indexed":false},{"type":"address","name":"destination","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"LiquidityReturned","inputs":[{"type":"uint256","name":"totalBorrowed","internalType":"uint256","indexed":false},{"type":"address","name":"destination","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"MaxInterestParametersSet","inputs":[{"type":"uint256","name":"value","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Paused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"Unpaused","inputs":[{"type":"address","name":"account","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Upgraded","inputs":[{"type":"address","name":"implementation","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"approve","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"mintingDate","internalType":"uint256"},{"type":"uint256","name":"maturity","internalType":"uint256"},{"type":"uint256","name":"principal","internalType":"uint256"},{"type":"uint256","name":"interest","internalType":"uint256"},{"type":"bool","name":"redeemed","internalType":"bool"}],"name":"bonds","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"burn","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"buyBond","inputs":[{"type":"string","name":"tokenUri","internalType":"string"},{"type":"address","name":"beneficiary","internalType":"address"},{"type":"uint256","name":"maturity","internalType":"uint256"},{"type":"uint256","name":"principal","internalType":"uint256"},{"type":"bytes32","name":"nftHash","internalType":"bytes32"},{"type":"bool","name":"setApprove","internalType":"bool"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"bytes","name":"signature","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"collateralMultiplier","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"collateralTokenAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"collaterals","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getApproved","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getInterestForMaturity","inputs":[{"type":"uint256","name":"maturity","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_principalToken","internalType":"address"},{"type":"address","name":"_collateralToken","internalType":"address"},{"type":"tuple","name":"_nftParams","internalType":"struct ERC20NFTBond.NFTParams","components":[{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"symbol","internalType":"string"},{"type":"string","name":"baseUri","internalType":"string"}]},{"type":"address","name":"_accessManager","internalType":"address"},{"type":"uint256[]","name":"_interests","internalType":"uint256[]"},{"type":"uint256[]","name":"_maturities","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"interests","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isApprovedForAll","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maturities","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maxParametersLength","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"name","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"ownerOf","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"pause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"paused","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"principalTokenAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"proxiableUUID","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"redeemBond","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeExcessOfCollateral","inputs":[{"type":"address","name":"destination","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"requestLiquidity","inputs":[{"type":"address","name":"destination","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"returnLiquidity","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"safeTransferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAccessManager","inputs":[{"type":"address","name":"newManager","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setApprovalForAll","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCollateralMultiplier","inputs":[{"type":"uint256","name":"multiplierIndex","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setInterestParameters","inputs":[{"type":"uint256[]","name":"_interests","internalType":"uint256[]"},{"type":"uint256[]","name":"_maturities","internalType":"uint256[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMaxInterestParams","inputs":[{"type":"uint256","name":"value","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"simpleInterest","inputs":[{"type":"uint256","name":"interest","internalType":"uint256"},{"type":"uint256","name":"maturity","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"symbol","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenByIndex","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"tokenOfOwnerByIndex","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"tokenURI","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalBorrowed","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalCollateralizedAmount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalSupply","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferFrom","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unpause","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"upgradeTo","inputs":[{"type":"address","name":"newImplementation","internalType":"address"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"upgradeToAndCall","inputs":[{"type":"address","name":"newImplementation","internalType":"address"},{"type":"bytes","name":"data","internalType":"bytes"}]}]
              

Contract Creation Code

0x60a0604052306080523480156200001557600080fd5b50600054610100900460ff1615808015620000375750600054600160ff909116105b8062000067575062000054306200014160201b620015561760201c565b15801562000067575060005460ff166001145b620000cf5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840160405180910390fd5b6000805460ff191660011790558015620000f3576000805461ff0019166101001790555b80156200013a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5062000150565b6001600160a01b03163b151590565b608051614fae6200018860003960008181610d4901528181610d8901528181610ede01528181610f1e01526110440152614fae6000f3fe6080604052600436106102725760003560e01c80635f1c17c01161014f578063a22cb465116100c1578063c95808041161007a578063c95808041461077e578063e066d7be1461079e578063e985e9c5146107be578063f68d321114610807578063fab7364f14610827578063fec77fc71461084757600080fd5b8063a22cb465146106bf578063a3aca8d7146106df578063a6a5fe70146106fe578063aa097f151461071e578063b88d4fde1461073e578063c87b56dd1461075e57600080fd5b806370a082311161011357806370a08231146106275780637124f198146106475780638456cb591461065e578063928c91d51461067357806395d89b411461069357806399a49fa3146106a857600080fd5b80635f1c17c0146105305780636352211e146105a857806363ba5972146105c857806368d9c707146105e85780636d9dd2011461060857600080fd5b80632f745c59116101e857806344104627116101ac57806344104627146104a55780634c19386c146104b85780634f1ef286146104cf5780634f6ccce7146104e257806352d1902d146105025780635c975abb1461051757600080fd5b80632f745c59146104105780633659cfe6146104305780633f4ba83a1461045057806342842e0e1461046557806342966c681461048557600080fd5b806313a377841161023a57806313a377841461035657806318160ddd1461036d578063221e03d11461038257806323b872dd146103a257806324c1173b146103c257806326413005146103f057600080fd5b806301ffc9a714610277578063042a2077146102ac57806306fdde03146102da578063081812fc146102fc578063095ea7b314610334575b600080fd5b34801561028357600080fd5b50610297610292366004614435565b610867565b60405190151581526020015b60405180910390f35b3480156102b857600080fd5b506102cc6102c7366004614452565b610878565b6040519081526020016102a3565b3480156102e657600080fd5b506102ef610883565b6040516102a391906144c3565b34801561030857600080fd5b5061031c610317366004614452565b610915565b6040516001600160a01b0390911681526020016102a3565b34801561034057600080fd5b5061035461034f3660046144f2565b61093c565b005b34801561036257600080fd5b506102cc6101f95481565b34801561037957600080fd5b506099546102cc565b34801561038e57600080fd5b5061035461039d366004614452565b610a56565b3480156103ae57600080fd5b506103546103bd36600461451c565b610b43565b3480156103ce57600080fd5b506102cc6103dd366004614452565b6102606020526000908152604090205481565b3480156103fc57600080fd5b5061035461040b3660046145a4565b610b75565b34801561041c57600080fd5b506102cc61042b3660046144f2565b610ca9565b34801561043c57600080fd5b5061035461044b366004614673565b610d3f565b34801561045c57600080fd5b50610354610e1e565b34801561047157600080fd5b5061035461048036600461451c565b610e6d565b34801561049157600080fd5b506103546104a0366004614452565b610e88565b6102cc6104b3366004614452565b610eb6565b3480156104c457600080fd5b506102cc6102925481565b6103546104dd366004614731565b610ed4565b3480156104ee57600080fd5b506102cc6104fd366004614452565b610fa4565b34801561050e57600080fd5b506102cc611037565b34801561052357600080fd5b506102c45460ff16610297565b34801561053c57600080fd5b5061057e61054b366004614452565b61022b60205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a0016102a3565b3480156105b457600080fd5b5061031c6105c3366004614452565b6110ea565b3480156105d457600080fd5b506103546105e3366004614673565b61114a565b3480156105f457600080fd5b5061035461060336600461477f565b611262565b34801561061457600080fd5b5061025d546001600160a01b031661031c565b34801561063357600080fd5b506102cc610642366004614673565b6112bc565b34801561065357600080fd5b506102cc61025f5481565b34801561066a57600080fd5b50610354611342565b34801561067f57600080fd5b506102cc61068e366004614452565b611391565b34801561069f57600080fd5b506102ef6113b3565b3480156106b457600080fd5b506102cc61025e5481565b3480156106cb57600080fd5b506103546106da366004614804565b6113c2565b3480156106eb57600080fd5b50610327546001600160a01b031661031c565b34801561070a57600080fd5b506102cc6107193660046144f2565b6113cd565b34801561072a57600080fd5b506102cc610739366004614452565b6113f7565b34801561074a57600080fd5b5061035461075936600461483b565b611408565b34801561076a57600080fd5b506102ef610779366004614452565b611440565b34801561078a57600080fd5b50610354610799366004614673565b61144b565b3480156107aa57600080fd5b506103546107b9366004614452565b6114bf565b3480156107ca57600080fd5b506102976107d93660046148a3565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b34801561081357600080fd5b506102cc6108223660046148d6565b61150f565b34801561083357600080fd5b506102cc610842366004614452565b611522565b34801561085357600080fd5b506102cc6108623660046148f8565b61152d565b600061087282611565565b92915050565b60006108728261158a565b606060658054610892906149d7565b80601f01602080910402602001604051908101604052809291908181526020018280546108be906149d7565b801561090b5780601f106108e05761010080835404028352916020019161090b565b820191906000526020600020905b8154815290600101906020018083116108ee57829003601f168201915b5050505050905090565b6000610920826115b7565b506000908152606960205260409020546001600160a01b031690565b6000610947826110ea565b9050806001600160a01b0316836001600160a01b0316036109b95760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806109d557506109d581336107d9565b610a475760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c000060648201526084016109b0565b610a518383611616565b505050565b7fffbea09aa6ccdb51b9246608f93ddcb03ccbf4f8da455f76d2de9b16aa0c3b0f610a818133611684565b610a9d5760405162461bcd60e51b81526004016109b090614a11565b60008211610b055760405162461bcd60e51b815260206004820152602f60248201527f436f6c6c61746572616c697a6564426f6e644772616e7465723a3a6d756c746960448201526e0706c696572496e646578206973203608c1b60648201526084016109b0565b61025e8290556040518281527f33fcf02cfde4d18783a9298b81728011eb2804b07211acca921806dd910554e9906020015b60405180910390a15050565b610b4e335b826116fb565b610b6a5760405162461bcd60e51b81526004016109b090614a57565b610a5183838361177a565b600054610100900460ff1615808015610b955750600054600160ff909116105b80610baf5750303b158015610baf575060005460ff166001145b610bcb5760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015610bee576000805461ff0019166101001790555b61032780546001600160a01b03808c166001600160a01b0319928316179092556103288054928b1692909116919091179055610c4c610c2d8880614af3565b610c3a60208b018b614af3565b610c4760408d018d614af3565b611921565b610c55886119e5565b610c6185858585611ab0565b610c6a86611b75565b8015610c9e576000805461ff001916905560405160018152600080516020614f328339815191529060200160405180910390a15b505050505050505050565b6000610cb4836112bc565b8210610d165760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016109b0565b506001600160a01b03919091166000908152609760209081526040808320938352929052205490565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610d875760405162461bcd60e51b81526004016109b090614b3a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610dd0600080516020614f12833981519152546001600160a01b031690565b6001600160a01b031614610df65760405162461bcd60e51b81526004016109b090614b86565b610dff81611c66565b60408051600080825260208201909252610e1b91839190611cad565b50565b7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c610e498133611684565b610e655760405162461bcd60e51b81526004016109b090614a11565b610e1b611e18565b610a5183838360405180602001604052806000815250611408565b610e9133610b48565b610ead5760405162461bcd60e51b81526004016109b090614a57565b610e1b81611e22565b6000610ec182611e2b565b50610ecb82611e36565b50506102925490565b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003610f1c5760405162461bcd60e51b81526004016109b090614b3a565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316610f65600080516020614f12833981519152546001600160a01b031690565b6001600160a01b031614610f8b5760405162461bcd60e51b81526004016109b090614b86565b610f9482611c66565b610fa082826001611cad565b5050565b6000610faf60995490565b82106110125760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016109b0565b6099828154811061102557611025614bd2565b90600052602060002001549050919050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146110d75760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c000000000000000060648201526084016109b0565b50600080516020614f1283398151915290565b6000818152606760205260408120546001600160a01b0316806108725760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016109b0565b7fffbea09aa6ccdb51b9246608f93ddcb03ccbf4f8da455f76d2de9b16aa0c3b0f6111758133611684565b6111915760405162461bcd60e51b81526004016109b090614a11565b61025f5461025d546040516370a0823160e01b8152306004820152600092916001600160a01b0316906370a0823190602401602060405180830381865afa1580156111e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112049190614be8565b61120e9190614c17565b61025d54909150611229906001600160a01b03168483611e4f565b6040516001600160a01b038416907f510b59e824b7f92bc078d2b00466c73c8ce23ab07b38d4e252ccf3dbc403b13a90600090a2505050565b7fdb444f04a7bba67ab27c39f659b1329f776358e660a1985afdd1881c5172d50c61128d8133611684565b6112a95760405162461bcd60e51b81526004016109b090614a11565b6112b585858585611eb2565b5050505050565b60006001600160a01b0382166113265760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016109b0565b506001600160a01b031660009081526068602052604090205490565b7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c61136d8133611684565b6113895760405162461bcd60e51b81526004016109b090614a11565b610e1b612218565b6101f881815481106113a257600080fd5b600091825260209091200154905081565b606060668054610892906149d7565b610fa0338383612220565b60006113d76122ee565b6113e18383612335565b6113eb838361234d565b50506102925492915050565b6101f781815481106113a257600080fd5b61141233836116fb565b61142e5760405162461bcd60e51b81526004016109b090614a57565b61143a848484846123a0565b50505050565b6060610872826123d3565b60006114578133611684565b6114735760405162461bcd60e51b81526004016109b090614a11565b61019180546001600160a01b0319166001600160a01b0384169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a25050565b7fdb444f04a7bba67ab27c39f659b1329f776358e660a1985afdd1881c5172d50c6114ea8133611684565b6115065760405162461bcd60e51b81526004016109b090614a11565b610fa0826124ce565b600061151b838361256b565b9392505050565b600061087282612577565b60006115376122ee565b6115488a8a8a8a8a8a8a8a8a612682565b9a9950505050505050505050565b6001600160a01b03163b151590565b60006001600160e01b0319821663780e9d6360e01b1480610872575061087282612707565b60008061159683612757565b905060006115a3846110ea565b90506115b08483836127ca565b5092915050565b6000818152606760205260409020546001600160a01b0316610e1b5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016109b0565b600081815260696020526040902080546001600160a01b0319166001600160a01b038416908117909155819061164b826110ea565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b61019154604051632474521560e21b8152600481018490526001600160a01b03838116602483015260009216906391d1485490604401602060405180830381865afa1580156116d7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151b9190614c2e565b600080611707836110ea565b9050806001600160a01b0316846001600160a01b0316148061174e57506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff165b806117725750836001600160a01b031661176784610915565b6001600160a01b0316145b949350505050565b826001600160a01b031661178d826110ea565b6001600160a01b0316146117f15760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016109b0565b6001600160a01b0382166118535760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016109b0565b61185e838383612b0c565b611869600082611616565b6001600160a01b0383166000908152606860205260408120805460019290611892908490614c17565b90915550506001600160a01b03821660009081526068602052604081208054600192906118c0908490614c4b565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600054610100900460ff16158080156119415750600054600160ff909116105b8061195b5750303b15801561195b575060005460ff166001145b6119775760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff19166001179055801561199a576000805461ff0019166101001790555b6119a8878787878787612b17565b80156119dc576000805461ff001916905560405160018152600080516020614f328339815191529060200160405180910390a15b50505050505050565b600054610100900460ff1615808015611a055750600054600160ff909116105b80611a1f5750303b158015611a1f575060005460ff166001145b611a3b5760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015611a5e576000805461ff0019166101001790555b600561025e5561025d80546001600160a01b0319166001600160a01b0384161790558015610fa0576000805461ff001916905560405160018152600080516020614f3283398151915290602001610b37565b600054610100900460ff1615808015611ad05750600054600160ff909116105b80611aea5750303b158015611aea575060005460ff166001145b611b065760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015611b29576000805461ff0019166101001790555b60036101f955611b3b85858585611eb2565b80156112b5576000805461ff001916905560405160018152600080516020614f328339815191529060200160405180910390a15050505050565b600054610100900460ff1615808015611b955750600054600160ff909116105b80611baf5750303b158015611baf575060005460ff166001145b611bcb5760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015611bee576000805461ff0019166101001790555b61019180546001600160a01b0319166001600160a01b0384169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a28015610fa0576000805461ff001916905560405160018152600080516020614f3283398151915290602001610b37565b7fa615a8afb6fffcb8c6809ac0997b5c9c12b8cc97651150f14c8f6203168cff4c611c918133611684565b610fa05760405162461bcd60e51b81526004016109b090614a11565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611ce057610a5183612c2d565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611d3a575060408051601f3d908101601f19168201909252611d3791810190614be8565b60015b611d9d5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016109b0565b600080516020614f128339815191528114611e0c5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016109b0565b50610a51838383612cc9565b611e20612cee565b565b610e1b81612d41565b600061087282612d81565b61032754610e1b906001600160a01b0316333084612dd6565b6040516001600160a01b038316602482015260448101829052610a5190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e0e565b82611f1b5760405162461bcd60e51b815260206004820152603360248201527f496e746572657374506172616d65746572733a3a496e746572657374206d75736044820152720742062652067726561746572207468616e203606c1b60648201526084016109b0565b6101f954831115611fa35760405162461bcd60e51b815260206004820152604660248201527f496e746572657374506172616d65746572733a3a496e7465726573742070617260448201527f616d65746572732069732067726561746572207468616e206d617820706172616064820152656d657465727360d01b608482015260a4016109b0565b8281146120035760405162461bcd60e51b815260206004820152602860248201527f496e746572657374506172616d65746572733a3a556e657175616c20696e70756044820152670e840d8cadccee8d60c31b60648201526084016109b0565b60005b838110156121b85780156120b05782828281811061202657612026614bd2565b90506020020135838360018461203c9190614c17565b81811061204b5761204b614bd2565b90506020020135106120b05760405162461bcd60e51b815260206004820152602860248201527f496e746572657374506172616d65746572733a3a556e6f726465726564206d61604482015267747572697469657360c01b60648201526084016109b0565b60008585838181106120c4576120c4614bd2565b905060200201351161212c5760405162461bcd60e51b815260206004820152602b60248201527f496e746572657374506172616d65746572733a3a43616e277420736574207a6560448201526a1c9bc81a5b9d195c995cdd60aa1b60648201526084016109b0565b600083838381811061214057612140614bd2565b90506020020135116121a85760405162461bcd60e51b815260206004820152602b60248201527f496e746572657374506172616d65746572733a3a43616e277420736574207a6560448201526a726f206d6174757269747960a81b60648201526084016109b0565b6121b181614c63565b9050612006565b506121c66101f7858561429e565b506121d46101f8838361429e565b507f91aa66ebbdff56917c78b5c120f6d06478db9de6e2a1937fa036d4cfc670b3806101f76101f860405161220a929190614cbc565b60405180910390a150505050565b611e20612ee0565b816001600160a01b0316836001600160a01b0316036122815760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109b0565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6102c45460ff1615611e205760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016109b0565b61032754610fa0906001600160a01b03168383611e4f565b60007facf51390d5668c4ea7251f9c38e251ee71b47dfd0caa814f297de9e0bac5e51a61237a8133611684565b6123965760405162461bcd60e51b81526004016109b090614a11565b6117728484612f1e565b6123ab84848461177a565b6123b784848484612f7e565b61143a5760405162461bcd60e51b81526004016109b090614ce1565b60606123de826115b7565b600082815260c96020526040812080546123f7906149d7565b80601f0160208091040260200160405190810160405280929190818152602001828054612423906149d7565b80156124705780601f1061244557610100808354040283529160200191612470565b820191906000526020600020905b81548152906001019060200180831161245357829003601f168201915b50505050509050600061248161307f565b90508051600003612493575092915050565b8151156124c55780826040516020016124ad929190614d33565b60405160208183030381529060405292505050919050565b6117728461308f565b6000811161252f5760405162461bcd60e51b815260206004820152602860248201527f496e746572657374506172616d65746572733a3a496e746572657374206c656e604482015267067746820697320360c41b60648201526084016109b0565b6101f98190556040518181527f7b63f4ec6021f2c51474ff321e4a01fb4464f2f4b23e36848374cb98c5fc20c69060200160405180910390a150565b600061151b8383614d62565b60006101f860008154811061258e5761258e614bd2565b9060005260206000200154821015612610576040805162461bcd60e51b81526020600482015260248101919091527f496e746572657374506172616d65746572733a3a4d61747572697479206d757360448201527f742062652067726561746572207468616e20666972737420696e74657265737460648201526084016109b0565b6101f75460009061262390600190614c17565b90505b6101f8818154811061263a5761263a614bd2565b90600052602060002001548310612672576101f7818154811061265f5761265f614bd2565b9060005260206000200154915050919050565b61267b81614d81565b9050612626565b6000336001600160a01b038916146126dc5760405162461bcd60e51b815260206004820152601e60248201527f4e4654426f6e643a3a42656e656669636961727920213d2073656e646572000060448201526064016109b0565b6126e98a8a8a8a8a6130f5565b60006126fa8b8b8b8989898961310e565b90506115488189896132ab565b60006001600160e01b031982166380ac58cd60e01b148061273857506001600160e01b03198216635b5e139f60e01b145b8061087257506301ffc9a760e01b6001600160e01b0319831614610872565b60008061276383613374565b6000848152610260602052604090205461025f5491925090612786908290614c17565b61025f5560408051858152602081018390527fd6513284110ca9c03fb9099da6d3e2c1c34761de7886e2185080cc9a91a46307910160405180910390a15092915050565b600083815261022b6020908152604091829020825160a081018452815481526001820154928101929092526002810154928201929092526003820154606082015260049091015460ff1615156080820152610327546040516370a0823160e01b815230600482015284916001600160a01b0316906370a0823190602401602060405180830381865afa158015612864573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128889190614be8565b1015612af457610327546040516370a0823160e01b815230600482015260009185916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156128dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129009190614be8565b61290b906064614d62565b6129159190614dae565b612920906064614c17565b9050600061025e54606483856040015161293a9190614d62565b6129449190614dae565b61294e9190614d62565b610327546040516370a0823160e01b81523060048201529192506129d69186916001600160a01b0316906370a0823190602401602060405180830381865afa15801561299e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c29190614be8565b610327546001600160a01b03169190611e4f565b610328546040516370a0823160e01b815230600482015282916001600160a01b0316906370a0823190602401602060405180830381865afa158015612a1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a439190614be8565b1015612ad557610328546040516370a0823160e01b8152306004820152612ad09186916001600160a01b03909116906370a0823190602401602060405180830381865afa158015612a98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612abc9190614be8565b610328546001600160a01b03169190611e4f565b612aed565b61032854612aed906001600160a01b03168583611e4f565b505061143a565b6103275461143a906001600160a01b03168385611e4f565b610a518383836134f8565b600054610100900460ff1615808015612b375750600054600160ff909116105b80612b515750303b158015612b51575060005460ff166001145b612b6d5760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015612b90576000805461ff0019166101001790555b612c0387878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b0181900481028201810190925289815292508991508890819084018382808284376000920191909152506135b092505050565b612c0b6135e1565b612c136135e1565b612c1b6135e1565b612c236135e1565b6119a88383613608565b6001600160a01b0381163b612c9a5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016109b0565b600080516020614f1283398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612cd283613615565b600082511180612cdf5750805b15610a515761143a8383613655565b612cf6613749565b6102c4805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b612d4a81613793565b600081815260c9602052604090208054612d63906149d7565b159050610e1b57600081815260c960205260408120610e1b916142e9565b60008161029254612d929190614c17565b61029281905560405190815233907f821f69b649b4ff849458de484066b9e25fe68c53f7f0a55d306f848ea293278b9060200160405180910390a250506102925490565b6040516001600160a01b038085166024830152831660448201526064810182905261143a9085906323b872dd60e01b90608401611e7b565b6000612e63826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661383a9092919063ffffffff16565b805190915015610a515780806020019051810190612e819190614c2e565b610a515760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109b0565b612ee86122ee565b6102c4805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d243390565b60008161029254612f2f9190614c4b565b6102928190556040519081526001600160a01b038416907fac432273479238f0f38c0d1ad7690a74d1d7b4e6ffbf41b56427b234900c5b419060200160405180910390a2506102925492915050565b60006001600160a01b0384163b1561307457604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612fc2903390899088908890600401614dc2565b6020604051808303816000875af1925050508015612ffd575060408051601f3d908101601f19168201909252612ffa91810190614dff565b60015b61305a573d80801561302b576040519150601f19603f3d011682016040523d82523d6000602084013e613030565b606091505b5080516000036130525760405162461bcd60e51b81526004016109b090614ce1565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611772565b506001949350505050565b60606101c48054610892906149d7565b606061309a826115b7565b60006130a461307f565b905060008151116130c4576040518060200160405280600081525061151b565b806130ce84613849565b6040516020016130df929190614d33565b6040516020818303038152906040529392505050565b610327546112b5906001600160a01b0316843084612dd6565b6000808888888830898946604051602001613130989796959493929190614e1c565b60405160208183030381529060405280519060200120905060008160405160200161318791907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60405160208183030381529060405280519060200120905060008060006131ad8761394a565b9250925092506000600185838686604051600081526020016040526040516131f1949392919093845260ff9290921660208401526040830152606082015260800190565b6020604051602081039080840390855afa158015613213573d6000803e3d6000fd5b5050506020604051035190506132497ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc982611684565b61328e5760405162461bcd60e51b81526020600482015260166024820152754e46543a3a496e76616c6964205369676e617475726560501b60448201526064016109b0565b6132998c8f8f6139be565b9e9d5050505050505050505050505050565b6132b481613a26565b6133005760405162461bcd60e51b815260206004820152601a60248201527f4342473a3a4e6f7420656e6f75676820636f6c6c61746572616c00000000000060448201526064016109b0565b61330b838383613ac7565b600061331682613c74565b90508061025f546133279190614c4b565b61025f556000848152610260602090815260409182902083905581518681529081018390527f5310a2e5496b1103f5c7f354cfe0b41dd7ff20dbd3c6dd4bf37a603b0a798a80910161220a565b600081815261022b60209081526040808320815160a081018352815480825260018301549482018590526002830154938201939093526003820154606082015260049091015460ff16151560808201529142916133d091614c4b565b1061341d5760405162461bcd60e51b815260206004820152601d60248201527f426f6e644772616e7465723a3a43616e27742072656465656d2079657400000060448201526064016109b0565b80608001511561346f5760405162461bcd60e51b815260206004820152601d60248201527f426f6e644772616e7465723a3a416c72656164792072656465656d656400000060448201526064016109b0565b600083815261022b60209081526040909120600401805460ff191660011790558101517f0d86f13da21bbb9ea8b3571c34bdf7db9caa1679d65b063dc8e8149e878c42d090849042906134c183613c85565b606086810151604080519687526020870195909552858501939093528401526080830152519081900360a00190a161151b83613c85565b6001600160a01b0383166135535761354e81609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b613576565b816001600160a01b0316836001600160a01b031614613576576135768382613d21565b6001600160a01b03821661358d57610a5181613dbe565b826001600160a01b0316826001600160a01b031614610a5157610a518282613e6d565b600054610100900460ff166135d75760405162461bcd60e51b81526004016109b090614e80565b610fa08282613eb1565b600054610100900460ff16611e205760405162461bcd60e51b81526004016109b090614e80565b610a516101c48383614323565b61361e81612c2d565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6136bd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016109b0565b600080846001600160a01b0316846040516136d89190614ecb565b600060405180830381855af49150503d8060008114613713576040519150601f19603f3d011682016040523d82523d6000602084013e613718565b606091505b50915091506137408282604051806060016040528060278152602001614f5260279139613eff565b95945050505050565b6102c45460ff16611e205760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016109b0565b600061379e826110ea565b90506137ac81600084612b0c565b6137b7600083611616565b6001600160a01b03811660009081526068602052604081208054600192906137e0908490614c17565b909155505060008281526067602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60606117728484600085613f38565b6060816000036138705750506040805180820190915260018152600360fc1b602082015290565b8160005b811561389a578061388481614c63565b91506138939050600a83614dae565b9150613874565b60008167ffffffffffffffff8111156138b5576138b561468e565b6040519080825280601f01601f1916602001820160405280156138df576020820181803683370190505b5090505b8415611772576138f4600183614c17565b9150613901600a86614ee7565b61390c906030614c4b565b60f81b81838151811061392157613921614bd2565b60200101906001600160f81b031916908160001a905350613943600a86614dae565b94506138e3565b600080600083516041146139a05760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964205369676e6174757265206c656e677468000000000000000060448201526064016109b0565b50505060208101516040820151606090920151909260009190911a90565b6000806139cb6101c35490565b90506139dc6101c380546001019055565b6139e68582614069565b6117728185858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061408392505050565b600061025e5482613a379190614d62565b61025f5461025d546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015613a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613aa89190614be8565b613ab29190614c17565b10613abf57506001919050565b506000919050565b60008111613b175760405162461bcd60e51b815260206004820152601b60248201527f426f6e644772616e7465723a3a5072696e636970616c2069732030000000000060448201526064016109b0565b6101f8600081548110613b2c57613b2c614bd2565b9060005260206000200154821015613bac5760405162461bcd60e51b815260206004820152603d60248201527f426f6e644772616e7465723a3a4d61747572697479206d75737420626520677260448201527f6561746572207468616e2074686520666972737420696e74657265737400000060648201526084016109b0565b6000613bb783611522565b6040805160a081018252428082526020808301888152838501888152606085018781526000608087018181528d825261022b9095528790209551865591516001860155516002850155516003840155516004909201805492151560ff199093169290921790915590519192507ff85bac85818c407f3199795fa7499707f0d6325b8be140584c13f7295502cdca9161220a918791879087908790948552602085019390935260408401919091526060830152608082015260a00190565b600061025e54826108729190614d62565b600081815261022b60209081526040808320815160a08101835281548152600182015493810184905260028201549281019290925260038101546060830181905260049091015460ff16151560808301529091670de0b6b3a764000091606491613cef919061150f565b8360400151613cfe9190614d62565b613d089190614dae565b613d129190614dae565b816040015161151b9190614c4b565b60006001613d2e846112bc565b613d389190614c17565b600083815260986020526040902054909150808214613d8b576001600160a01b03841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b5060009182526098602090815260408084208490556001600160a01b039094168352609781528383209183525290812055565b609954600090613dd090600190614c17565b6000838152609a602052604081205460998054939450909284908110613df857613df8614bd2565b906000526020600020015490508060998381548110613e1957613e19614bd2565b6000918252602080832090910192909255828152609a90915260408082208490558582528120556099805480613e5157613e51614efb565b6001900381819060005260206000200160009055905550505050565b6000613e78836112bc565b6001600160a01b039093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b600054610100900460ff16613ed85760405162461bcd60e51b81526004016109b090614e80565b8151613eeb906065906020850190614396565b508051610a51906066906020840190614396565b60608315613f0e57508161151b565b825115613f1e5782518084602001fd5b8160405162461bcd60e51b81526004016109b091906144c3565b606082471015613f995760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109b0565b6001600160a01b0385163b613ff05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109b0565b600080866001600160a01b0316858760405161400c9190614ecb565b60006040518083038185875af1925050503d8060008114614049576040519150601f19603f3d011682016040523d82523d6000602084013e61404e565b606091505b509150915061405e828286613eff565b979650505050505050565b610fa082826040518060200160405280600081525061411d565b6000828152606760205260409020546001600160a01b03166140fe5760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b60648201526084016109b0565b600082815260c9602090815260409091208251610a5192840190614396565b6141278383614150565b6141346000848484612f7e565b610a515760405162461bcd60e51b81526004016109b090614ce1565b6001600160a01b0382166141a65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109b0565b6000818152606760205260409020546001600160a01b03161561420b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109b0565b61421760008383612b0c565b6001600160a01b0382166000908152606860205260408120805460019290614240908490614c4b565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280548282559060005260206000209081019282156142d9579160200282015b828111156142d95782358255916020019190600101906142be565b506142e592915061440a565b5090565b5080546142f5906149d7565b6000825580601f10614305575050565b601f016020900490600052602060002090810190610e1b919061440a565b82805461432f906149d7565b90600052602060002090601f01602090048101928261435157600085556142d9565b82601f1061436a5782800160ff198235161785556142d9565b828001600101855582156142d957918201828111156142d95782358255916020019190600101906142be565b8280546143a2906149d7565b90600052602060002090601f0160209004810192826143c457600085556142d9565b82601f106143dd57805160ff19168380011785556142d9565b828001600101855582156142d9579182015b828111156142d95782518255916020019190600101906143ef565b5b808211156142e5576000815560010161440b565b6001600160e01b031981168114610e1b57600080fd5b60006020828403121561444757600080fd5b813561151b8161441f565b60006020828403121561446457600080fd5b5035919050565b60005b8381101561448657818101518382015260200161446e565b8381111561143a5750506000910152565b600081518084526144af81602086016020860161446b565b601f01601f19169290920160200192915050565b60208152600061151b6020830184614497565b80356001600160a01b03811681146144ed57600080fd5b919050565b6000806040838503121561450557600080fd5b61450e836144d6565b946020939093013593505050565b60008060006060848603121561453157600080fd5b61453a846144d6565b9250614548602085016144d6565b9150604084013590509250925092565b60008083601f84011261456a57600080fd5b50813567ffffffffffffffff81111561458257600080fd5b6020830191508360208260051b850101111561459d57600080fd5b9250929050565b60008060008060008060008060c0898b0312156145c057600080fd5b6145c9896144d6565b97506145d760208a016144d6565b9650604089013567ffffffffffffffff808211156145f457600080fd5b908a01906060828d03121561460857600080fd5b81975061461760608c016144d6565b965060808b013591508082111561462d57600080fd5b6146398c838d01614558565b909650945060a08b013591508082111561465257600080fd5b5061465f8b828c01614558565b999c989b5096995094979396929594505050565b60006020828403121561468557600080fd5b61151b826144d6565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126146b557600080fd5b813567ffffffffffffffff808211156146d0576146d061468e565b604051601f8301601f19908116603f011681019082821181831017156146f8576146f861468e565b8160405283815286602085880101111561471157600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561474457600080fd5b61474d836144d6565b9150602083013567ffffffffffffffff81111561476957600080fd5b614775858286016146a4565b9150509250929050565b6000806000806040858703121561479557600080fd5b843567ffffffffffffffff808211156147ad57600080fd5b6147b988838901614558565b909650945060208701359150808211156147d257600080fd5b506147df87828801614558565b95989497509550505050565b8015158114610e1b57600080fd5b80356144ed816147eb565b6000806040838503121561481757600080fd5b614820836144d6565b91506020830135614830816147eb565b809150509250929050565b6000806000806080858703121561485157600080fd5b61485a856144d6565b9350614868602086016144d6565b925060408501359150606085013567ffffffffffffffff81111561488b57600080fd5b614897878288016146a4565b91505092959194509250565b600080604083850312156148b657600080fd5b6148bf836144d6565b91506148cd602084016144d6565b90509250929050565b600080604083850312156148e957600080fd5b50508035926020909101359150565b60008060008060008060008060006101008a8c03121561491757600080fd5b893567ffffffffffffffff8082111561492f57600080fd5b818c0191508c601f83011261494357600080fd5b81358181111561495257600080fd5b8d602082850101111561496457600080fd5b602083019b50809a505061497a60208d016144d6565b985060408c0135975060608c0135965060808c0135955061499d60a08d016147f9565b945060c08c0135935060e08c01359150808211156149ba57600080fd5b506149c78c828d016146a4565b9150509295985092959850929598565b600181811c908216806149eb57607f821691505b602082108103614a0b57634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526026908201527f4163636573734d616e616765645570677261646561626c653a3a4d697373696e6040820152656720526f6c6560d01b606082015260800190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000808335601e19843603018112614b0a57600080fd5b83018035915067ffffffffffffffff821115614b2557600080fd5b60200191503681900382131561459d57600080fd5b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215614bfa57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015614c2957614c29614c01565b500390565b600060208284031215614c4057600080fd5b815161151b816147eb565b60008219821115614c5e57614c5e614c01565b500190565b600060018201614c7557614c75614c01565b5060010190565b6000815480845260208085019450836000528060002060005b83811015614cb157815487529582019560019182019101614c95565b509495945050505050565b604081526000614ccf6040830185614c7c565b82810360208401526137408185614c7c565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351614d4581846020880161446b565b835190830190614d5981836020880161446b565b01949350505050565b6000816000190483118215151615614d7c57614d7c614c01565b500290565b600081614d9057614d90614c01565b506000190190565b634e487b7160e01b600052601260045260246000fd5b600082614dbd57614dbd614d98565b500490565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090614df590830184614497565b9695505050505050565b600060208284031215614e1157600080fd5b815161151b8161441f565b60e081528760e08201526000610100898b828501376000838b018201526001600160a01b039889166020840152604083019790975250939095166060840152901515608083015260a082015260c0810192909252601f909201601f19160101919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251614edd81846020870161446b565b9190910192915050565b600082614ef657614ef6614d98565b500690565b634e487b7160e01b600052603160045260246000fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206ab5315221b6c46450ee5bbbeeb04be917d2921b57790ca48d88563e86b9cf6064736f6c634300080d0033

Deployed ByteCode

0x6080604052600436106102725760003560e01c80635f1c17c01161014f578063a22cb465116100c1578063c95808041161007a578063c95808041461077e578063e066d7be1461079e578063e985e9c5146107be578063f68d321114610807578063fab7364f14610827578063fec77fc71461084757600080fd5b8063a22cb465146106bf578063a3aca8d7146106df578063a6a5fe70146106fe578063aa097f151461071e578063b88d4fde1461073e578063c87b56dd1461075e57600080fd5b806370a082311161011357806370a08231146106275780637124f198146106475780638456cb591461065e578063928c91d51461067357806395d89b411461069357806399a49fa3146106a857600080fd5b80635f1c17c0146105305780636352211e146105a857806363ba5972146105c857806368d9c707146105e85780636d9dd2011461060857600080fd5b80632f745c59116101e857806344104627116101ac57806344104627146104a55780634c19386c146104b85780634f1ef286146104cf5780634f6ccce7146104e257806352d1902d146105025780635c975abb1461051757600080fd5b80632f745c59146104105780633659cfe6146104305780633f4ba83a1461045057806342842e0e1461046557806342966c681461048557600080fd5b806313a377841161023a57806313a377841461035657806318160ddd1461036d578063221e03d11461038257806323b872dd146103a257806324c1173b146103c257806326413005146103f057600080fd5b806301ffc9a714610277578063042a2077146102ac57806306fdde03146102da578063081812fc146102fc578063095ea7b314610334575b600080fd5b34801561028357600080fd5b50610297610292366004614435565b610867565b60405190151581526020015b60405180910390f35b3480156102b857600080fd5b506102cc6102c7366004614452565b610878565b6040519081526020016102a3565b3480156102e657600080fd5b506102ef610883565b6040516102a391906144c3565b34801561030857600080fd5b5061031c610317366004614452565b610915565b6040516001600160a01b0390911681526020016102a3565b34801561034057600080fd5b5061035461034f3660046144f2565b61093c565b005b34801561036257600080fd5b506102cc6101f95481565b34801561037957600080fd5b506099546102cc565b34801561038e57600080fd5b5061035461039d366004614452565b610a56565b3480156103ae57600080fd5b506103546103bd36600461451c565b610b43565b3480156103ce57600080fd5b506102cc6103dd366004614452565b6102606020526000908152604090205481565b3480156103fc57600080fd5b5061035461040b3660046145a4565b610b75565b34801561041c57600080fd5b506102cc61042b3660046144f2565b610ca9565b34801561043c57600080fd5b5061035461044b366004614673565b610d3f565b34801561045c57600080fd5b50610354610e1e565b34801561047157600080fd5b5061035461048036600461451c565b610e6d565b34801561049157600080fd5b506103546104a0366004614452565b610e88565b6102cc6104b3366004614452565b610eb6565b3480156104c457600080fd5b506102cc6102925481565b6103546104dd366004614731565b610ed4565b3480156104ee57600080fd5b506102cc6104fd366004614452565b610fa4565b34801561050e57600080fd5b506102cc611037565b34801561052357600080fd5b506102c45460ff16610297565b34801561053c57600080fd5b5061057e61054b366004614452565b61022b60205260009081526040902080546001820154600283015460038401546004909401549293919290919060ff1685565b6040805195865260208601949094529284019190915260608301521515608082015260a0016102a3565b3480156105b457600080fd5b5061031c6105c3366004614452565b6110ea565b3480156105d457600080fd5b506103546105e3366004614673565b61114a565b3480156105f457600080fd5b5061035461060336600461477f565b611262565b34801561061457600080fd5b5061025d546001600160a01b031661031c565b34801561063357600080fd5b506102cc610642366004614673565b6112bc565b34801561065357600080fd5b506102cc61025f5481565b34801561066a57600080fd5b50610354611342565b34801561067f57600080fd5b506102cc61068e366004614452565b611391565b34801561069f57600080fd5b506102ef6113b3565b3480156106b457600080fd5b506102cc61025e5481565b3480156106cb57600080fd5b506103546106da366004614804565b6113c2565b3480156106eb57600080fd5b50610327546001600160a01b031661031c565b34801561070a57600080fd5b506102cc6107193660046144f2565b6113cd565b34801561072a57600080fd5b506102cc610739366004614452565b6113f7565b34801561074a57600080fd5b5061035461075936600461483b565b611408565b34801561076a57600080fd5b506102ef610779366004614452565b611440565b34801561078a57600080fd5b50610354610799366004614673565b61144b565b3480156107aa57600080fd5b506103546107b9366004614452565b6114bf565b3480156107ca57600080fd5b506102976107d93660046148a3565b6001600160a01b039182166000908152606a6020908152604080832093909416825291909152205460ff1690565b34801561081357600080fd5b506102cc6108223660046148d6565b61150f565b34801561083357600080fd5b506102cc610842366004614452565b611522565b34801561085357600080fd5b506102cc6108623660046148f8565b61152d565b600061087282611565565b92915050565b60006108728261158a565b606060658054610892906149d7565b80601f01602080910402602001604051908101604052809291908181526020018280546108be906149d7565b801561090b5780601f106108e05761010080835404028352916020019161090b565b820191906000526020600020905b8154815290600101906020018083116108ee57829003601f168201915b5050505050905090565b6000610920826115b7565b506000908152606960205260409020546001600160a01b031690565b6000610947826110ea565b9050806001600160a01b0316836001600160a01b0316036109b95760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b03821614806109d557506109d581336107d9565b610a475760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c000060648201526084016109b0565b610a518383611616565b505050565b7fffbea09aa6ccdb51b9246608f93ddcb03ccbf4f8da455f76d2de9b16aa0c3b0f610a818133611684565b610a9d5760405162461bcd60e51b81526004016109b090614a11565b60008211610b055760405162461bcd60e51b815260206004820152602f60248201527f436f6c6c61746572616c697a6564426f6e644772616e7465723a3a6d756c746960448201526e0706c696572496e646578206973203608c1b60648201526084016109b0565b61025e8290556040518281527f33fcf02cfde4d18783a9298b81728011eb2804b07211acca921806dd910554e9906020015b60405180910390a15050565b610b4e335b826116fb565b610b6a5760405162461bcd60e51b81526004016109b090614a57565b610a5183838361177a565b600054610100900460ff1615808015610b955750600054600160ff909116105b80610baf5750303b158015610baf575060005460ff166001145b610bcb5760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015610bee576000805461ff0019166101001790555b61032780546001600160a01b03808c166001600160a01b0319928316179092556103288054928b1692909116919091179055610c4c610c2d8880614af3565b610c3a60208b018b614af3565b610c4760408d018d614af3565b611921565b610c55886119e5565b610c6185858585611ab0565b610c6a86611b75565b8015610c9e576000805461ff001916905560405160018152600080516020614f328339815191529060200160405180910390a15b505050505050505050565b6000610cb4836112bc565b8210610d165760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016109b0565b506001600160a01b03919091166000908152609760209081526040808320938352929052205490565b6001600160a01b037f00000000000000000000000089cea15f68950df830dfe3630d635a9ed79478f5163003610d875760405162461bcd60e51b81526004016109b090614b3a565b7f00000000000000000000000089cea15f68950df830dfe3630d635a9ed79478f56001600160a01b0316610dd0600080516020614f12833981519152546001600160a01b031690565b6001600160a01b031614610df65760405162461bcd60e51b81526004016109b090614b86565b610dff81611c66565b60408051600080825260208201909252610e1b91839190611cad565b50565b7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c610e498133611684565b610e655760405162461bcd60e51b81526004016109b090614a11565b610e1b611e18565b610a5183838360405180602001604052806000815250611408565b610e9133610b48565b610ead5760405162461bcd60e51b81526004016109b090614a57565b610e1b81611e22565b6000610ec182611e2b565b50610ecb82611e36565b50506102925490565b6001600160a01b037f00000000000000000000000089cea15f68950df830dfe3630d635a9ed79478f5163003610f1c5760405162461bcd60e51b81526004016109b090614b3a565b7f00000000000000000000000089cea15f68950df830dfe3630d635a9ed79478f56001600160a01b0316610f65600080516020614f12833981519152546001600160a01b031690565b6001600160a01b031614610f8b5760405162461bcd60e51b81526004016109b090614b86565b610f9482611c66565b610fa082826001611cad565b5050565b6000610faf60995490565b82106110125760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016109b0565b6099828154811061102557611025614bd2565b90600052602060002001549050919050565b6000306001600160a01b037f00000000000000000000000089cea15f68950df830dfe3630d635a9ed79478f516146110d75760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c000000000000000060648201526084016109b0565b50600080516020614f1283398151915290565b6000818152606760205260408120546001600160a01b0316806108725760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016109b0565b7fffbea09aa6ccdb51b9246608f93ddcb03ccbf4f8da455f76d2de9b16aa0c3b0f6111758133611684565b6111915760405162461bcd60e51b81526004016109b090614a11565b61025f5461025d546040516370a0823160e01b8152306004820152600092916001600160a01b0316906370a0823190602401602060405180830381865afa1580156111e0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112049190614be8565b61120e9190614c17565b61025d54909150611229906001600160a01b03168483611e4f565b6040516001600160a01b038416907f510b59e824b7f92bc078d2b00466c73c8ce23ab07b38d4e252ccf3dbc403b13a90600090a2505050565b7fdb444f04a7bba67ab27c39f659b1329f776358e660a1985afdd1881c5172d50c61128d8133611684565b6112a95760405162461bcd60e51b81526004016109b090614a11565b6112b585858585611eb2565b5050505050565b60006001600160a01b0382166113265760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016109b0565b506001600160a01b031660009081526068602052604090205490565b7f539440820030c4994db4e31b6b800deafd503688728f932addfe7a410515c14c61136d8133611684565b6113895760405162461bcd60e51b81526004016109b090614a11565b610e1b612218565b6101f881815481106113a257600080fd5b600091825260209091200154905081565b606060668054610892906149d7565b610fa0338383612220565b60006113d76122ee565b6113e18383612335565b6113eb838361234d565b50506102925492915050565b6101f781815481106113a257600080fd5b61141233836116fb565b61142e5760405162461bcd60e51b81526004016109b090614a57565b61143a848484846123a0565b50505050565b6060610872826123d3565b60006114578133611684565b6114735760405162461bcd60e51b81526004016109b090614a11565b61019180546001600160a01b0319166001600160a01b0384169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a25050565b7fdb444f04a7bba67ab27c39f659b1329f776358e660a1985afdd1881c5172d50c6114ea8133611684565b6115065760405162461bcd60e51b81526004016109b090614a11565b610fa0826124ce565b600061151b838361256b565b9392505050565b600061087282612577565b60006115376122ee565b6115488a8a8a8a8a8a8a8a8a612682565b9a9950505050505050505050565b6001600160a01b03163b151590565b60006001600160e01b0319821663780e9d6360e01b1480610872575061087282612707565b60008061159683612757565b905060006115a3846110ea565b90506115b08483836127ca565b5092915050565b6000818152606760205260409020546001600160a01b0316610e1b5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b60448201526064016109b0565b600081815260696020526040902080546001600160a01b0319166001600160a01b038416908117909155819061164b826110ea565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b61019154604051632474521560e21b8152600481018490526001600160a01b03838116602483015260009216906391d1485490604401602060405180830381865afa1580156116d7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151b9190614c2e565b600080611707836110ea565b9050806001600160a01b0316846001600160a01b0316148061174e57506001600160a01b038082166000908152606a602090815260408083209388168352929052205460ff165b806117725750836001600160a01b031661176784610915565b6001600160a01b0316145b949350505050565b826001600160a01b031661178d826110ea565b6001600160a01b0316146117f15760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b60648201526084016109b0565b6001600160a01b0382166118535760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016109b0565b61185e838383612b0c565b611869600082611616565b6001600160a01b0383166000908152606860205260408120805460019290611892908490614c17565b90915550506001600160a01b03821660009081526068602052604081208054600192906118c0908490614c4b565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600054610100900460ff16158080156119415750600054600160ff909116105b8061195b5750303b15801561195b575060005460ff166001145b6119775760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff19166001179055801561199a576000805461ff0019166101001790555b6119a8878787878787612b17565b80156119dc576000805461ff001916905560405160018152600080516020614f328339815191529060200160405180910390a15b50505050505050565b600054610100900460ff1615808015611a055750600054600160ff909116105b80611a1f5750303b158015611a1f575060005460ff166001145b611a3b5760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015611a5e576000805461ff0019166101001790555b600561025e5561025d80546001600160a01b0319166001600160a01b0384161790558015610fa0576000805461ff001916905560405160018152600080516020614f3283398151915290602001610b37565b600054610100900460ff1615808015611ad05750600054600160ff909116105b80611aea5750303b158015611aea575060005460ff166001145b611b065760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015611b29576000805461ff0019166101001790555b60036101f955611b3b85858585611eb2565b80156112b5576000805461ff001916905560405160018152600080516020614f328339815191529060200160405180910390a15050505050565b600054610100900460ff1615808015611b955750600054600160ff909116105b80611baf5750303b158015611baf575060005460ff166001145b611bcb5760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015611bee576000805461ff0019166101001790555b61019180546001600160a01b0319166001600160a01b0384169081179091556040517fa5bc17e575e3b53b23d0e93e121a5a66d1de4d5edb4dfde6027b14d79b7f2b9c90600090a28015610fa0576000805461ff001916905560405160018152600080516020614f3283398151915290602001610b37565b7fa615a8afb6fffcb8c6809ac0997b5c9c12b8cc97651150f14c8f6203168cff4c611c918133611684565b610fa05760405162461bcd60e51b81526004016109b090614a11565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615611ce057610a5183612c2d565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611d3a575060408051601f3d908101601f19168201909252611d3791810190614be8565b60015b611d9d5760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b60648201526084016109b0565b600080516020614f128339815191528114611e0c5760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b60648201526084016109b0565b50610a51838383612cc9565b611e20612cee565b565b610e1b81612d41565b600061087282612d81565b61032754610e1b906001600160a01b0316333084612dd6565b6040516001600160a01b038316602482015260448101829052610a5190849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612e0e565b82611f1b5760405162461bcd60e51b815260206004820152603360248201527f496e746572657374506172616d65746572733a3a496e746572657374206d75736044820152720742062652067726561746572207468616e203606c1b60648201526084016109b0565b6101f954831115611fa35760405162461bcd60e51b815260206004820152604660248201527f496e746572657374506172616d65746572733a3a496e7465726573742070617260448201527f616d65746572732069732067726561746572207468616e206d617820706172616064820152656d657465727360d01b608482015260a4016109b0565b8281146120035760405162461bcd60e51b815260206004820152602860248201527f496e746572657374506172616d65746572733a3a556e657175616c20696e70756044820152670e840d8cadccee8d60c31b60648201526084016109b0565b60005b838110156121b85780156120b05782828281811061202657612026614bd2565b90506020020135838360018461203c9190614c17565b81811061204b5761204b614bd2565b90506020020135106120b05760405162461bcd60e51b815260206004820152602860248201527f496e746572657374506172616d65746572733a3a556e6f726465726564206d61604482015267747572697469657360c01b60648201526084016109b0565b60008585838181106120c4576120c4614bd2565b905060200201351161212c5760405162461bcd60e51b815260206004820152602b60248201527f496e746572657374506172616d65746572733a3a43616e277420736574207a6560448201526a1c9bc81a5b9d195c995cdd60aa1b60648201526084016109b0565b600083838381811061214057612140614bd2565b90506020020135116121a85760405162461bcd60e51b815260206004820152602b60248201527f496e746572657374506172616d65746572733a3a43616e277420736574207a6560448201526a726f206d6174757269747960a81b60648201526084016109b0565b6121b181614c63565b9050612006565b506121c66101f7858561429e565b506121d46101f8838361429e565b507f91aa66ebbdff56917c78b5c120f6d06478db9de6e2a1937fa036d4cfc670b3806101f76101f860405161220a929190614cbc565b60405180910390a150505050565b611e20612ee0565b816001600160a01b0316836001600160a01b0316036122815760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c65720000000000000060448201526064016109b0565b6001600160a01b038381166000818152606a6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6102c45460ff1615611e205760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b60448201526064016109b0565b61032754610fa0906001600160a01b03168383611e4f565b60007facf51390d5668c4ea7251f9c38e251ee71b47dfd0caa814f297de9e0bac5e51a61237a8133611684565b6123965760405162461bcd60e51b81526004016109b090614a11565b6117728484612f1e565b6123ab84848461177a565b6123b784848484612f7e565b61143a5760405162461bcd60e51b81526004016109b090614ce1565b60606123de826115b7565b600082815260c96020526040812080546123f7906149d7565b80601f0160208091040260200160405190810160405280929190818152602001828054612423906149d7565b80156124705780601f1061244557610100808354040283529160200191612470565b820191906000526020600020905b81548152906001019060200180831161245357829003601f168201915b50505050509050600061248161307f565b90508051600003612493575092915050565b8151156124c55780826040516020016124ad929190614d33565b60405160208183030381529060405292505050919050565b6117728461308f565b6000811161252f5760405162461bcd60e51b815260206004820152602860248201527f496e746572657374506172616d65746572733a3a496e746572657374206c656e604482015267067746820697320360c41b60648201526084016109b0565b6101f98190556040518181527f7b63f4ec6021f2c51474ff321e4a01fb4464f2f4b23e36848374cb98c5fc20c69060200160405180910390a150565b600061151b8383614d62565b60006101f860008154811061258e5761258e614bd2565b9060005260206000200154821015612610576040805162461bcd60e51b81526020600482015260248101919091527f496e746572657374506172616d65746572733a3a4d61747572697479206d757360448201527f742062652067726561746572207468616e20666972737420696e74657265737460648201526084016109b0565b6101f75460009061262390600190614c17565b90505b6101f8818154811061263a5761263a614bd2565b90600052602060002001548310612672576101f7818154811061265f5761265f614bd2565b9060005260206000200154915050919050565b61267b81614d81565b9050612626565b6000336001600160a01b038916146126dc5760405162461bcd60e51b815260206004820152601e60248201527f4e4654426f6e643a3a42656e656669636961727920213d2073656e646572000060448201526064016109b0565b6126e98a8a8a8a8a6130f5565b60006126fa8b8b8b8989898961310e565b90506115488189896132ab565b60006001600160e01b031982166380ac58cd60e01b148061273857506001600160e01b03198216635b5e139f60e01b145b8061087257506301ffc9a760e01b6001600160e01b0319831614610872565b60008061276383613374565b6000848152610260602052604090205461025f5491925090612786908290614c17565b61025f5560408051858152602081018390527fd6513284110ca9c03fb9099da6d3e2c1c34761de7886e2185080cc9a91a46307910160405180910390a15092915050565b600083815261022b6020908152604091829020825160a081018452815481526001820154928101929092526002810154928201929092526003820154606082015260049091015460ff1615156080820152610327546040516370a0823160e01b815230600482015284916001600160a01b0316906370a0823190602401602060405180830381865afa158015612864573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128889190614be8565b1015612af457610327546040516370a0823160e01b815230600482015260009185916001600160a01b03909116906370a0823190602401602060405180830381865afa1580156128dc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129009190614be8565b61290b906064614d62565b6129159190614dae565b612920906064614c17565b9050600061025e54606483856040015161293a9190614d62565b6129449190614dae565b61294e9190614d62565b610327546040516370a0823160e01b81523060048201529192506129d69186916001600160a01b0316906370a0823190602401602060405180830381865afa15801561299e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c29190614be8565b610327546001600160a01b03169190611e4f565b610328546040516370a0823160e01b815230600482015282916001600160a01b0316906370a0823190602401602060405180830381865afa158015612a1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a439190614be8565b1015612ad557610328546040516370a0823160e01b8152306004820152612ad09186916001600160a01b03909116906370a0823190602401602060405180830381865afa158015612a98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612abc9190614be8565b610328546001600160a01b03169190611e4f565b612aed565b61032854612aed906001600160a01b03168583611e4f565b505061143a565b6103275461143a906001600160a01b03168385611e4f565b610a518383836134f8565b600054610100900460ff1615808015612b375750600054600160ff909116105b80612b515750303b158015612b51575060005460ff166001145b612b6d5760405162461bcd60e51b81526004016109b090614aa5565b6000805460ff191660011790558015612b90576000805461ff0019166101001790555b612c0387878080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050604080516020601f8b0181900481028201810190925289815292508991508890819084018382808284376000920191909152506135b092505050565b612c0b6135e1565b612c136135e1565b612c1b6135e1565b612c236135e1565b6119a88383613608565b6001600160a01b0381163b612c9a5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b60648201526084016109b0565b600080516020614f1283398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b612cd283613615565b600082511180612cdf5750805b15610a515761143a8383613655565b612cf6613749565b6102c4805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b612d4a81613793565b600081815260c9602052604090208054612d63906149d7565b159050610e1b57600081815260c960205260408120610e1b916142e9565b60008161029254612d929190614c17565b61029281905560405190815233907f821f69b649b4ff849458de484066b9e25fe68c53f7f0a55d306f848ea293278b9060200160405180910390a250506102925490565b6040516001600160a01b038085166024830152831660448201526064810182905261143a9085906323b872dd60e01b90608401611e7b565b6000612e63826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661383a9092919063ffffffff16565b805190915015610a515780806020019051810190612e819190614c2e565b610a515760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016109b0565b612ee86122ee565b6102c4805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612d243390565b60008161029254612f2f9190614c4b565b6102928190556040519081526001600160a01b038416907fac432273479238f0f38c0d1ad7690a74d1d7b4e6ffbf41b56427b234900c5b419060200160405180910390a2506102925492915050565b60006001600160a01b0384163b1561307457604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612fc2903390899088908890600401614dc2565b6020604051808303816000875af1925050508015612ffd575060408051601f3d908101601f19168201909252612ffa91810190614dff565b60015b61305a573d80801561302b576040519150601f19603f3d011682016040523d82523d6000602084013e613030565b606091505b5080516000036130525760405162461bcd60e51b81526004016109b090614ce1565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611772565b506001949350505050565b60606101c48054610892906149d7565b606061309a826115b7565b60006130a461307f565b905060008151116130c4576040518060200160405280600081525061151b565b806130ce84613849565b6040516020016130df929190614d33565b6040516020818303038152906040529392505050565b610327546112b5906001600160a01b0316843084612dd6565b6000808888888830898946604051602001613130989796959493929190614e1c565b60405160208183030381529060405280519060200120905060008160405160200161318791907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60405160208183030381529060405280519060200120905060008060006131ad8761394a565b9250925092506000600185838686604051600081526020016040526040516131f1949392919093845260ff9290921660208401526040830152606082015260800190565b6020604051602081039080840390855afa158015613213573d6000803e3d6000fd5b5050506020604051035190506132497ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc982611684565b61328e5760405162461bcd60e51b81526020600482015260166024820152754e46543a3a496e76616c6964205369676e617475726560501b60448201526064016109b0565b6132998c8f8f6139be565b9e9d5050505050505050505050505050565b6132b481613a26565b6133005760405162461bcd60e51b815260206004820152601a60248201527f4342473a3a4e6f7420656e6f75676820636f6c6c61746572616c00000000000060448201526064016109b0565b61330b838383613ac7565b600061331682613c74565b90508061025f546133279190614c4b565b61025f556000848152610260602090815260409182902083905581518681529081018390527f5310a2e5496b1103f5c7f354cfe0b41dd7ff20dbd3c6dd4bf37a603b0a798a80910161220a565b600081815261022b60209081526040808320815160a081018352815480825260018301549482018590526002830154938201939093526003820154606082015260049091015460ff16151560808201529142916133d091614c4b565b1061341d5760405162461bcd60e51b815260206004820152601d60248201527f426f6e644772616e7465723a3a43616e27742072656465656d2079657400000060448201526064016109b0565b80608001511561346f5760405162461bcd60e51b815260206004820152601d60248201527f426f6e644772616e7465723a3a416c72656164792072656465656d656400000060448201526064016109b0565b600083815261022b60209081526040909120600401805460ff191660011790558101517f0d86f13da21bbb9ea8b3571c34bdf7db9caa1679d65b063dc8e8149e878c42d090849042906134c183613c85565b606086810151604080519687526020870195909552858501939093528401526080830152519081900360a00190a161151b83613c85565b6001600160a01b0383166135535761354e81609980546000838152609a60205260408120829055600182018355919091527f72a152ddfb8e864297c917af52ea6c1c68aead0fee1a62673fcc7e0c94979d000155565b613576565b816001600160a01b0316836001600160a01b031614613576576135768382613d21565b6001600160a01b03821661358d57610a5181613dbe565b826001600160a01b0316826001600160a01b031614610a5157610a518282613e6d565b600054610100900460ff166135d75760405162461bcd60e51b81526004016109b090614e80565b610fa08282613eb1565b600054610100900460ff16611e205760405162461bcd60e51b81526004016109b090614e80565b610a516101c48383614323565b61361e81612c2d565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6136bd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b60648201526084016109b0565b600080846001600160a01b0316846040516136d89190614ecb565b600060405180830381855af49150503d8060008114613713576040519150601f19603f3d011682016040523d82523d6000602084013e613718565b606091505b50915091506137408282604051806060016040528060278152602001614f5260279139613eff565b95945050505050565b6102c45460ff16611e205760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b60448201526064016109b0565b600061379e826110ea565b90506137ac81600084612b0c565b6137b7600083611616565b6001600160a01b03811660009081526068602052604081208054600192906137e0908490614c17565b909155505060008281526067602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60606117728484600085613f38565b6060816000036138705750506040805180820190915260018152600360fc1b602082015290565b8160005b811561389a578061388481614c63565b91506138939050600a83614dae565b9150613874565b60008167ffffffffffffffff8111156138b5576138b561468e565b6040519080825280601f01601f1916602001820160405280156138df576020820181803683370190505b5090505b8415611772576138f4600183614c17565b9150613901600a86614ee7565b61390c906030614c4b565b60f81b81838151811061392157613921614bd2565b60200101906001600160f81b031916908160001a905350613943600a86614dae565b94506138e3565b600080600083516041146139a05760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964205369676e6174757265206c656e677468000000000000000060448201526064016109b0565b50505060208101516040820151606090920151909260009190911a90565b6000806139cb6101c35490565b90506139dc6101c380546001019055565b6139e68582614069565b6117728185858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061408392505050565b600061025e5482613a379190614d62565b61025f5461025d546040516370a0823160e01b81523060048201526001600160a01b03909116906370a0823190602401602060405180830381865afa158015613a84573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613aa89190614be8565b613ab29190614c17565b10613abf57506001919050565b506000919050565b60008111613b175760405162461bcd60e51b815260206004820152601b60248201527f426f6e644772616e7465723a3a5072696e636970616c2069732030000000000060448201526064016109b0565b6101f8600081548110613b2c57613b2c614bd2565b9060005260206000200154821015613bac5760405162461bcd60e51b815260206004820152603d60248201527f426f6e644772616e7465723a3a4d61747572697479206d75737420626520677260448201527f6561746572207468616e2074686520666972737420696e74657265737400000060648201526084016109b0565b6000613bb783611522565b6040805160a081018252428082526020808301888152838501888152606085018781526000608087018181528d825261022b9095528790209551865591516001860155516002850155516003840155516004909201805492151560ff199093169290921790915590519192507ff85bac85818c407f3199795fa7499707f0d6325b8be140584c13f7295502cdca9161220a918791879087908790948552602085019390935260408401919091526060830152608082015260a00190565b600061025e54826108729190614d62565b600081815261022b60209081526040808320815160a08101835281548152600182015493810184905260028201549281019290925260038101546060830181905260049091015460ff16151560808301529091670de0b6b3a764000091606491613cef919061150f565b8360400151613cfe9190614d62565b613d089190614dae565b613d129190614dae565b816040015161151b9190614c4b565b60006001613d2e846112bc565b613d389190614c17565b600083815260986020526040902054909150808214613d8b576001600160a01b03841660009081526097602090815260408083208584528252808320548484528184208190558352609890915290208190555b5060009182526098602090815260408084208490556001600160a01b039094168352609781528383209183525290812055565b609954600090613dd090600190614c17565b6000838152609a602052604081205460998054939450909284908110613df857613df8614bd2565b906000526020600020015490508060998381548110613e1957613e19614bd2565b6000918252602080832090910192909255828152609a90915260408082208490558582528120556099805480613e5157613e51614efb565b6001900381819060005260206000200160009055905550505050565b6000613e78836112bc565b6001600160a01b039093166000908152609760209081526040808320868452825280832085905593825260989052919091209190915550565b600054610100900460ff16613ed85760405162461bcd60e51b81526004016109b090614e80565b8151613eeb906065906020850190614396565b508051610a51906066906020840190614396565b60608315613f0e57508161151b565b825115613f1e5782518084602001fd5b8160405162461bcd60e51b81526004016109b091906144c3565b606082471015613f995760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016109b0565b6001600160a01b0385163b613ff05760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016109b0565b600080866001600160a01b0316858760405161400c9190614ecb565b60006040518083038185875af1925050503d8060008114614049576040519150601f19603f3d011682016040523d82523d6000602084013e61404e565b606091505b509150915061405e828286613eff565b979650505050505050565b610fa082826040518060200160405280600081525061411d565b6000828152606760205260409020546001600160a01b03166140fe5760405162461bcd60e51b815260206004820152602e60248201527f45524337323155524953746f726167653a2055524920736574206f66206e6f6e60448201526d32bc34b9ba32b73a103a37b5b2b760911b60648201526084016109b0565b600082815260c9602090815260409091208251610a5192840190614396565b6141278383614150565b6141346000848484612f7e565b610a515760405162461bcd60e51b81526004016109b090614ce1565b6001600160a01b0382166141a65760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016109b0565b6000818152606760205260409020546001600160a01b03161561420b5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e7465640000000060448201526064016109b0565b61421760008383612b0c565b6001600160a01b0382166000908152606860205260408120805460019290614240908490614c4b565b909155505060008181526067602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280548282559060005260206000209081019282156142d9579160200282015b828111156142d95782358255916020019190600101906142be565b506142e592915061440a565b5090565b5080546142f5906149d7565b6000825580601f10614305575050565b601f016020900490600052602060002090810190610e1b919061440a565b82805461432f906149d7565b90600052602060002090601f01602090048101928261435157600085556142d9565b82601f1061436a5782800160ff198235161785556142d9565b828001600101855582156142d957918201828111156142d95782358255916020019190600101906142be565b8280546143a2906149d7565b90600052602060002090601f0160209004810192826143c457600085556142d9565b82601f106143dd57805160ff19168380011785556142d9565b828001600101855582156142d9579182015b828111156142d95782518255916020019190600101906143ef565b5b808211156142e5576000815560010161440b565b6001600160e01b031981168114610e1b57600080fd5b60006020828403121561444757600080fd5b813561151b8161441f565b60006020828403121561446457600080fd5b5035919050565b60005b8381101561448657818101518382015260200161446e565b8381111561143a5750506000910152565b600081518084526144af81602086016020860161446b565b601f01601f19169290920160200192915050565b60208152600061151b6020830184614497565b80356001600160a01b03811681146144ed57600080fd5b919050565b6000806040838503121561450557600080fd5b61450e836144d6565b946020939093013593505050565b60008060006060848603121561453157600080fd5b61453a846144d6565b9250614548602085016144d6565b9150604084013590509250925092565b60008083601f84011261456a57600080fd5b50813567ffffffffffffffff81111561458257600080fd5b6020830191508360208260051b850101111561459d57600080fd5b9250929050565b60008060008060008060008060c0898b0312156145c057600080fd5b6145c9896144d6565b97506145d760208a016144d6565b9650604089013567ffffffffffffffff808211156145f457600080fd5b908a01906060828d03121561460857600080fd5b81975061461760608c016144d6565b965060808b013591508082111561462d57600080fd5b6146398c838d01614558565b909650945060a08b013591508082111561465257600080fd5b5061465f8b828c01614558565b999c989b5096995094979396929594505050565b60006020828403121561468557600080fd5b61151b826144d6565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126146b557600080fd5b813567ffffffffffffffff808211156146d0576146d061468e565b604051601f8301601f19908116603f011681019082821181831017156146f8576146f861468e565b8160405283815286602085880101111561471157600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806040838503121561474457600080fd5b61474d836144d6565b9150602083013567ffffffffffffffff81111561476957600080fd5b614775858286016146a4565b9150509250929050565b6000806000806040858703121561479557600080fd5b843567ffffffffffffffff808211156147ad57600080fd5b6147b988838901614558565b909650945060208701359150808211156147d257600080fd5b506147df87828801614558565b95989497509550505050565b8015158114610e1b57600080fd5b80356144ed816147eb565b6000806040838503121561481757600080fd5b614820836144d6565b91506020830135614830816147eb565b809150509250929050565b6000806000806080858703121561485157600080fd5b61485a856144d6565b9350614868602086016144d6565b925060408501359150606085013567ffffffffffffffff81111561488b57600080fd5b614897878288016146a4565b91505092959194509250565b600080604083850312156148b657600080fd5b6148bf836144d6565b91506148cd602084016144d6565b90509250929050565b600080604083850312156148e957600080fd5b50508035926020909101359150565b60008060008060008060008060006101008a8c03121561491757600080fd5b893567ffffffffffffffff8082111561492f57600080fd5b818c0191508c601f83011261494357600080fd5b81358181111561495257600080fd5b8d602082850101111561496457600080fd5b602083019b50809a505061497a60208d016144d6565b985060408c0135975060608c0135965060808c0135955061499d60a08d016147f9565b945060c08c0135935060e08c01359150808211156149ba57600080fd5b506149c78c828d016146a4565b9150509295985092959850929598565b600181811c908216806149eb57607f821691505b602082108103614a0b57634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526026908201527f4163636573734d616e616765645570677261646561626c653a3a4d697373696e6040820152656720526f6c6560d01b606082015260800190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000808335601e19843603018112614b0a57600080fd5b83018035915067ffffffffffffffff821115614b2557600080fd5b60200191503681900382131561459d57600080fd5b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b600060208284031215614bfa57600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015614c2957614c29614c01565b500390565b600060208284031215614c4057600080fd5b815161151b816147eb565b60008219821115614c5e57614c5e614c01565b500190565b600060018201614c7557614c75614c01565b5060010190565b6000815480845260208085019450836000528060002060005b83811015614cb157815487529582019560019182019101614c95565b509495945050505050565b604081526000614ccf6040830185614c7c565b82810360208401526137408185614c7c565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351614d4581846020880161446b565b835190830190614d5981836020880161446b565b01949350505050565b6000816000190483118215151615614d7c57614d7c614c01565b500290565b600081614d9057614d90614c01565b506000190190565b634e487b7160e01b600052601260045260246000fd5b600082614dbd57614dbd614d98565b500490565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090614df590830184614497565b9695505050505050565b600060208284031215614e1157600080fd5b815161151b8161441f565b60e081528760e08201526000610100898b828501376000838b018201526001600160a01b039889166020840152604083019790975250939095166060840152901515608083015260a082015260c0810192909252601f909201601f19160101919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60008251614edd81846020870161446b565b9190910192915050565b600082614ef657614ef6614d98565b500690565b634e487b7160e01b600052603160045260246000fdfe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212206ab5315221b6c46450ee5bbbeeb04be917d2921b57790ca48d88563e86b9cf6064736f6c634300080d0033