ETH Price: $3,474.02 (+3.14%)
Gas: 4.18 Gwei

Contract

0xE3e0E805CBC94D59547C36A9eb6d09c7D5425F94
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Repay Loan194636602024-03-18 19:08:59281 days ago1710788939IN
0xE3e0E805...7D5425F94
0 ETH0.0063895247.38034118
Create Loan192576962024-02-18 22:39:23310 days ago1708295963IN
0xE3e0E805...7D5425F94
0 ETH0.0095624321.63706854
Repay Loan192388822024-02-16 7:08:23312 days ago1708067303IN
0xE3e0E805...7D5425F94
0 ETH0.0032294223.94722106
Create Loan190285062024-01-17 18:52:47342 days ago1705517567IN
0xE3e0E805...7D5425F94
0 ETH0.0143467232.81530606
Liquidate Loan190100352024-01-15 4:56:11344 days ago1705294571IN
0xE3e0E805...7D5425F94
0 ETH0.0019475517.11987058
Create Loan187932702023-12-15 18:22:23375 days ago1702664543IN
0xE3e0E805...7D5425F94
0 ETH0.025157659.21567381
Repay Loan187534062023-12-10 4:23:59380 days ago1702182239IN
0xE3e0E805...7D5425F94
0 ETH0.0028299520.98498606
Create Loan185664332023-11-14 0:02:59407 days ago1699920179IN
0xE3e0E805...7D5425F94
0 ETH0.0210960145.95490745
Repay Loan183419682023-10-13 14:07:47438 days ago1697206067IN
0xE3e0E805...7D5425F94
0 ETH0.0022573815.49251188
Repay Loan183364112023-10-12 19:26:23439 days ago1697138783IN
0xE3e0E805...7D5425F94
0 ETH0.001395218.32427469
Liquidate Loan183203442023-10-10 13:26:23441 days ago1696944383IN
0xE3e0E805...7D5425F94
0 ETH0.001048319.15459207
Liquidate Loan183203382023-10-10 13:25:11441 days ago1696944311IN
0xE3e0E805...7D5425F94
0 ETH0.000928439.08337664
Liquidate Loan183203302023-10-10 13:23:35441 days ago1696944215IN
0xE3e0E805...7D5425F94
0 ETH0.00087968.84799832
Liquidate Loan183203272023-10-10 13:22:59441 days ago1696944179IN
0xE3e0E805...7D5425F94
0 ETH0.000985088.96607002
Liquidate Loan183203172023-10-10 13:20:59441 days ago1696944059IN
0xE3e0E805...7D5425F94
0 ETH0.001029448.42651073
Liquidate Loan183203062023-10-10 13:18:47441 days ago1696943927IN
0xE3e0E805...7D5425F94
0 ETH0.000656679.1363749
Liquidate Loan183203022023-10-10 13:17:59441 days ago1696943879IN
0xE3e0E805...7D5425F94
0 ETH0.001255859.50668977
Liquidate Loan183131792023-10-09 13:21:23442 days ago1696857683IN
0xE3e0E805...7D5425F94
0 ETH0.0008740810.07678128
Liquidate Loan183131682023-10-09 13:19:11442 days ago1696857551IN
0xE3e0E805...7D5425F94
0 ETH0.000838979.16495697
Liquidate Loan183131632023-10-09 13:18:11442 days ago1696857491IN
0xE3e0E805...7D5425F94
0 ETH0.001058619.74402415
Liquidate Loan183130882023-10-09 13:03:11442 days ago1696856591IN
0xE3e0E805...7D5425F94
0 ETH0.000961138.84685445
Create Loan182366432023-09-28 20:34:11453 days ago1695933251IN
0xE3e0E805...7D5425F94
0 ETH0.004010059.69034876
Create Loan181722682023-09-19 20:13:59462 days ago1695154439IN
0xE3e0E805...7D5425F94
0 ETH0.0077170817.32110449
Liquidate Loan180986092023-09-09 11:43:23472 days ago1694259803IN
0xE3e0E805...7D5425F94
0 ETH0.0010913811.06075891
Create Loan180674622023-09-05 3:01:35476 days ago1693882895IN
0xE3e0E805...7D5425F94
0 ETH0.0052014112.21458595
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
LiqdLending

Compiler Version
v0.8.14+commit.80d49f37

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 22 : LiqdLending.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.14;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

import "./interfaces/ICryptoPunksMarket.sol";
import "./LendingCore.sol";

error InvalidSender();
error UnknownTokenType();

/// @notice liqd lending and borrowing contract
contract LiqdLending is
    ReentrancyGuard,
    ERC721Holder,
    ERC1155Holder,
    LendingCore
{
    using SafeERC20 for IERC20;

    address private constant ETH_ADDRESS =
        0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

    address public DAO; // solhint-disable-line var-name-mixedcase
    uint256 public id;
    bool public onlyExitLoan;
    mapping(bytes => bool) public cancelledSignatures;
    uint256 internal durationUnit = 86400; // Unit: 1 day
    bool internal canChangeDurationUnit;
    mapping(bytes => bool) internal usedSignatures;
    mapping(address => mapping(uint256 => address)) internal escrow;

    constructor(
        address _DAO, // solhint-disable-line var-name-mixedcase
        bool _canChangeDurationUnit
    ) {
        require(_DAO != address(0), "ZERO_ADDRESS");
        DAO = _DAO;
        canChangeDurationUnit = _canChangeDurationUnit;
    }

    /// @notice Borrowers transfer their nft as collateral to Vault and get paid from the lenders.
    /// @param _payload structure LoanPayload
    /// @param _sig user's signed message
    /// @return currentId id of the created loan
    function createLoan(LoanPayload memory _payload, bytes memory _sig)
        external
        payable
        nonReentrant
        returns (uint256 currentId)
    {
        require(!usedSignatures[_sig], "This signature is already used");
        require(!cancelledSignatures[_sig], "This signature is not valid");

        bytes32 _payloadHash = keccak256(
            abi.encode(
                _payload.borrower,
                _payload.nftAddress,
                _payload.currency,
                _payload.nftTokenId,
                _payload.duration,
                _payload.expiration,
                _payload.loanAmount,
                _payload.apr,
                _payload.nftTokenType
            )
        );

        bytes32 messageHash = keccak256(
            abi.encodePacked("\x19Ethereum Signed Message:\n32", _payloadHash)
        );
        if (msg.sender == _payload.borrower) {
            require(
                ECDSA.recover(messageHash, _sig) == _payload.lender,
                "INVALID_SIGNATURE_LENDER"
            );
        } else if (msg.sender == _payload.lender) {
            require(
                ECDSA.recover(messageHash, _sig) == _payload.borrower,
                "INVALID_SIGNATURE_BORROWER"
            );
        } else {
            revert InvalidSender();
        }

        currentId = _createLoan(_payload);
        usedSignatures[_sig] = true;
    }

    /// @notice Borrowers transfer their nft as collateral to Vault and get paid from the lenders.
    /// @param _payload structure LoanPayload
    /// @param _sig lender's signed message
    /// @return currentId id of the created loan
    function createCOffer(LoanPayload memory _payload, bytes memory _sig)
        external
        payable
        nonReentrant
        returns (uint256 currentId)
    {
        require(!usedSignatures[_sig], "This signature is already used");
        require(!cancelledSignatures[_sig], "This signature is not valid");
        require(msg.sender == _payload.borrower, "The caller is not borrower");

        bytes32 _payloadHash = keccak256(
            abi.encode(
                _payload.lender,
                _payload.nftAddress,
                _payload.currency,
                _payload.duration,
                _payload.expiration,
                _payload.loanAmount,
                _payload.apr,
                _payload.nftTokenType
            )
        );

        bytes32 messageHash = keccak256(
            abi.encodePacked("\x19Ethereum Signed Message:\n32", _payloadHash)
        );
        require(
            ECDSA.recover(messageHash, _sig) == _payload.lender,
            "INVALID_SIGNATURE"
        );

        currentId = _createLoan(_payload);
        usedSignatures[_sig] = true;
    }

    /// @notice internal function to create loan
    /// @param _payload structure LoanPayload
    /// @return currentId id of the created loan
    function _createLoan(LoanPayload memory _payload)
        internal
        returns (uint256 currentId)
    {
        require(!onlyExitLoan, "ONLY_EXIT_LOAN");
        require(_payload.expiration >= block.timestamp, "EXPIRED_SIGNATURE"); // solhint-disable-line not-rely-on-time
        require(availableCurrencies[_payload.currency], "NOT_ALLOWED_CURRENCY");
        require(_payload.duration > 0, "ZERO_DURATION");

        uint256 platformFee = calculatePlatformFee(
            _payload.loanAmount,
            platformFees[_payload.currency]
        );

        currentId = id;
        loans[currentId] = Loan({
            nftAddress: _payload.nftAddress,
            nftTokenId: _payload.nftTokenId,
            startTime: block.timestamp, // solhint-disable-line not-rely-on-time
            endTime: block.timestamp + (_payload.duration * durationUnit), // solhint-disable-line not-rely-on-time
            currency: _payload.currency,
            loanAmount: _payload.loanAmount,
            amountDue: calculateDueAmount(
                _payload.loanAmount,
                _payload.apr,
                _payload.duration
            ),
            status: Status.CREATED,
            borrower: _payload.borrower,
            lender: _payload.lender,
            nftTokenType: _payload.nftTokenType
        });
        escrow[_payload.nftAddress][_payload.nftTokenId] = _payload.borrower;

        transferNFT(
            _payload.borrower,
            address(this),
            _payload.nftAddress,
            _payload.nftTokenId,
            _payload.nftTokenType,
            false
        );

        if (_payload.currency != ETH_ADDRESS) {
            IERC20(_payload.currency).safeTransferFrom(
                _payload.lender,
                _payload.borrower,
                _payload.loanAmount - platformFee
            );
            if (platformFee > 0) {
                IERC20(_payload.currency).safeTransferFrom(
                    _payload.lender,
                    DAO,
                    platformFee
                );
            }
        } else {
            require(
                msg.value >= _payload.loanAmount + platformFee,
                "ETH value is not enough."
            );
            (bool toSuccess, ) = _payload.borrower.call{ // solhint-disable-line avoid-low-level-calls
                value: _payload.loanAmount - platformFee
            }("");
            require(toSuccess, "Transfer failed");
            if (platformFee > 0) {
                (bool daoSuccess, ) = DAO.call{value: platformFee}(""); // solhint-disable-line avoid-low-level-calls
                require(daoSuccess, "Transfer failed to DAO");
            }
        }

        emit LoanCreated(
            _payload.lender,
            _payload.borrower,
            _payload.nftAddress,
            _payload.nftTokenId,
            currentId,
            _payload.currency,
            _payload.loanAmount,
            platformFee
        );

        ++id;
    }

    /// @notice Borrower pays back for loan
    /// @param _loanId the id of loans
    /// @param _amountDue amount is needed to pay
    function repayLoan(uint256 _loanId, uint256 _amountDue)
        external
        payable
        nonReentrant
    {
        Loan storage loan = loans[_loanId];
        address loanCurrency = loan.currency;
        require(loan.borrower == msg.sender, "WRONG_MSG_SENDER");
        require(loan.status == Status.CREATED, "NOT_LOAN_CREATED");
        require(block.timestamp <= loan.endTime, "EXPIRED_LOAN"); // solhint-disable-line not-rely-on-time
        require(
            (msg.value > 0 &&
                loanCurrency == address(0) &&
                msg.value >= _amountDue &&
                _amountDue >= loan.amountDue) ||
                (loanCurrency != address(0) &&
                    msg.value == 0 &&
                    _amountDue >= loan.amountDue),
            "Pay back amount is not enough."
        );

        loan.status = Status.REPAID;
        delete escrow[loan.nftAddress][loan.nftTokenId];
        transferNFT(
            address(this),
            loan.borrower,
            loan.nftAddress,
            loan.nftTokenId,
            loan.nftTokenType,
            true
        );
        if (loan.currency != ETH_ADDRESS) {
            IERC20(loan.currency).safeTransferFrom(
                msg.sender,
                loan.lender,
                _amountDue
            );
        } else {
            require(msg.value >= _amountDue, "ETH value is not enough.");
            (bool toSuccess, ) = loan.lender.call{value: _amountDue}(""); // solhint-disable-line avoid-low-level-calls
            require(toSuccess, "Transfer failed");
            if (msg.value > _amountDue) {
                (bool retSuccess, ) = payable(msg.sender).call{ // solhint-disable-line avoid-low-level-calls
                    value: msg.value - _amountDue
                }("");
                require(retSuccess, "Transfer back failed");
            }
        }

        emit LoanLiquidated(
            loan.lender,
            loan.borrower,
            loan.nftAddress,
            loan.nftTokenId,
            _loanId
        );
    }

    /// @notice Lender can liquidate loan item if loan is not paid
    /// @param _loanId the id of loans
    function liquidateLoan(uint256 _loanId) external nonReentrant {
        Loan storage loan = loans[_loanId];
        require(loan.status == Status.CREATED, "LOAN_FINISHED");
        require(block.timestamp >= loan.endTime, "NOT_EXPIRED_LOAN"); // solhint-disable-line not-rely-on-time

        loan.status = Status.LIQUIDATED;
        delete escrow[loan.nftAddress][loan.nftTokenId];
        transferNFT(
            address(this),
            loan.lender,
            loan.nftAddress,
            loan.nftTokenId,
            loan.nftTokenType,
            true
        );

        emit LoanTerminated(
            loan.lender,
            loan.borrower,
            loan.nftAddress,
            loan.nftTokenId,
            _loanId
        );
    }

    /// @notice Set onlyExistLoan by owner
    /// @param _value value
    function setOnlyExitLoan(bool _value) external onlyOwner {
        onlyExitLoan = _value;
    }

    /// @notice Set cancelled signatures by client
    /// @param _sig user's signed message
    /// @return status result of this function
    function setCancelledSignature(bytes memory _sig) external returns (bool) {
        cancelledSignatures[_sig] = true;
        return true;
    }

    /// @notice Change durationUnit by owner
    /// @param _value value
    function changeDurationUnit(uint256 _value) external onlyOwner {
        require(canChangeDurationUnit, "NOT_CHANGE_DURATION_UNIT");
        durationUnit = _value;
    }

    /// @notice Standard method to send nft from an account to another
    function transferNFT(
        address _from,
        address _to,
        address _nftAddress,
        uint256 _nftTokenId,
        uint8 _nftTokenType,
        bool _punkTransfer
    ) internal {
        if (_nftTokenType == 0) {
            IERC721(_nftAddress).safeTransferFrom(_from, _to, _nftTokenId);
        } else if (_nftTokenType == 1) {
            IERC1155(_nftAddress).safeTransferFrom(
                _from,
                _to,
                _nftTokenId,
                1,
                "0x00"
            );
        } else if (_nftTokenType == 2) {
            if (_punkTransfer) {
                ICryptoPunksMarket(_nftAddress).transferPunk(_to, _nftTokenId);
            } else {
                ICryptoPunksMarket(_nftAddress).buyPunk(_nftTokenId);
            }
        } else {
            revert UnknownTokenType();
        }
    }

    /// @notice Ability to withdraw NFT which was airdropped/sent by mistake to lending contract by transferring it into DAO account
    /// @param _contractAddress NFT contract address
    /// @param _tokenId NFT token id
    /// @param _nftTokenType NFT token type (0 - ERC721, 1 - ERC1155, 2 - CryptoPunks)
    /// @param _punkTransfer true if transfer, false if buy
    function withdrawNft(address _contractAddress, uint256 _tokenId, uint8 _nftTokenType, bool _punkTransfer) external {
        require(escrow[_contractAddress][_tokenId] == address(0), "NFT_IN_ESCROW");

        transferNFT(
            address(this),
            DAO,
            _contractAddress,
            _tokenId,
            _nftTokenType,
            _punkTransfer
        );
    }

    /// @notice Ability to withdraw any ERC20 token which was airdropped/sent by mistake to lending contract by transferring it into DAO account
    /// @param _tokenAddress ERC20 token address
    function withdrawToken(address _tokenAddress) external {
        IERC20(_tokenAddress).safeTransfer(DAO, IERC20(_tokenAddress).balanceOf(address(this)));
    }

}

File 2 of 22 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

import "./ERC1155Receiver.sol";

/**
 * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 *
 * @dev _Available since v3.1._
 */
contract ERC1155Holder is ERC1155Receiver {
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

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

File 7 of 22 : ERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../IERC1155Receiver.sol";
import "../../../utils/introspection/ERC165.sol";

/**
 * @dev _Available since v3.1._
 */
abstract contract ERC1155Receiver is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }
}

File 8 of 22 : draft-IERC20Permit.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 IERC20Permit {
    /**
     * @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);
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../utils/Address.sol";

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

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

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

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

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

    function safeDecreaseAllowance(
        IERC20 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(
        IERC20Permit 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(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

File 16 of 22 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./math/Math.sol";

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

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

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

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

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

File 21 of 22 : ICryptoPunksMarket.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.14;

interface ICryptoPunksMarket {
    function buyPunk(uint256 punkIndex) external payable;

    function transferPunk(address to, uint256 punkIndex) external;
}

File 22 of 22 : LendingCore.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.14;

import "@openzeppelin/contracts/access/Ownable.sol";

/// @notice Core contract for liqd lending and borrowing
contract LendingCore is Ownable {
    enum Status {
        CREATED,
        REPAID,
        LIQUIDATED
    }

    struct Loan {
        address nftAddress; // address of nft
        address borrower; // address of borrower
        address lender; // address of lender
        address currency; // address of loans' currency
        Status status; // loan status
        uint256 nftTokenId; // unique identifier of NFT that the borrower uses as collateral
        uint256 startTime; // loan start date
        uint256 endTime; // loan end date
        uint256 loanAmount; // amount lender gives borrower
        uint256 amountDue; // loanAmount + interest that needs to be paid back by borrower
        uint8 nftTokenType; // token type ERC721: 0, ERC1155: 1, Other like CryptoPunk: 2
    }

    struct LoanPayload {
        address lender;
        address borrower;
        address nftAddress;
        address currency;
        uint256 nftTokenId;
        uint256 duration;
        uint256 expiration;
        uint256 loanAmount;
        uint256 apr; // 100 = 1%
        uint8 nftTokenType;
    }

    uint256 internal constant SECONDS_FOR_YEAR = 31540000;
    mapping(uint256 => Loan) public loans;
    mapping(address => bool) public availableCurrencies;
    mapping(address => uint256) public platformFees; // 100 = 1%

    ///
    /// events
    ///

    event LoanCreated(
        address indexed lender,
        address indexed borrower,
        address indexed nftAddress,
        uint256 nftTokenId,
        uint256 loanId,
        address currency,
        uint256 loanAmount,
        uint256 fee
    );

    event LoanLiquidated(
        address indexed lender,
        address indexed borrower,
        address indexed nftAddress,
        uint256 nftTokenId,
        uint256 loanId
    );

    event LoanTerminated(
        address indexed lender,
        address indexed borrower,
        address indexed nftAddress,
        uint256 nftTokenId,
        uint256 loanId
    );

    event PlatformFeeUpdated(address indexed currency, uint256 platformFee);

    ///
    /// management
    ///

    /// @notice Set platform fee by owner
    /// @param _currency the currency of loan
    /// @param _platformFee platform fee for each currency
    function setPlatformFee(address _currency, uint256 _platformFee)
        external
        onlyOwner
    {
        require(_platformFee < 1000, "TOO_HIGH_PLATFORM_FEE");
        availableCurrencies[_currency] = true;
        platformFees[_currency] = _platformFee;

        emit PlatformFeeUpdated(_currency, _platformFee);
    }

    /// @notice Remove currency
    /// @param _currency the currency of loan
    function removeCurrency(address _currency) external onlyOwner {
        require(availableCurrencies[_currency], "CURRENCY_NOT_EXIST");
        availableCurrencies[_currency] = false;
        platformFees[_currency] = 0;

        emit PlatformFeeUpdated(_currency, 0);
    }

    ///
    /// business logic
    ///

    /// @notice Calculate dueAmount
    /// @param _loanAmount amount of loan
    /// @param _apr apr of loan
    /// @param _duration duration of loan
    function calculateDueAmount(
        uint256 _loanAmount,
        uint256 _apr,
        uint256 _duration
    ) internal pure returns (uint256) {
        return
            _loanAmount +
            ((_loanAmount * _apr * _duration * 86400) /
                SECONDS_FOR_YEAR /
                10000);
    }

    /// @notice Calculate platform fee
    /// @param _loanAmount amount of loan
    /// @param _platformFee platform fee for each currency
    function calculatePlatformFee(uint256 _loanAmount, uint256 _platformFee)
        internal
        pure
        returns (uint256)
    {
        return (_loanAmount * _platformFee) / 10000;
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_DAO","type":"address"},{"internalType":"bool","name":"_canChangeDurationUnit","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InvalidSender","type":"error"},{"inputs":[],"name":"UnknownTokenType","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lender","type":"address"},{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"nftAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanId","type":"uint256"},{"indexed":false,"internalType":"address","name":"currency","type":"address"},{"indexed":false,"internalType":"uint256","name":"loanAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"LoanCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lender","type":"address"},{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"nftAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanId","type":"uint256"}],"name":"LoanLiquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"lender","type":"address"},{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"nftAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanId","type":"uint256"}],"name":"LoanTerminated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"currency","type":"address"},{"indexed":false,"internalType":"uint256","name":"platformFee","type":"uint256"}],"name":"PlatformFeeUpdated","type":"event"},{"inputs":[],"name":"DAO","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"availableCurrencies","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"cancelledSignatures","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"changeDurationUnit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"lender","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"nftAddress","type":"address"},{"internalType":"address","name":"currency","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"loanAmount","type":"uint256"},{"internalType":"uint256","name":"apr","type":"uint256"},{"internalType":"uint8","name":"nftTokenType","type":"uint8"}],"internalType":"struct LendingCore.LoanPayload","name":"_payload","type":"tuple"},{"internalType":"bytes","name":"_sig","type":"bytes"}],"name":"createCOffer","outputs":[{"internalType":"uint256","name":"currentId","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"lender","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"nftAddress","type":"address"},{"internalType":"address","name":"currency","type":"address"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"uint256","name":"duration","type":"uint256"},{"internalType":"uint256","name":"expiration","type":"uint256"},{"internalType":"uint256","name":"loanAmount","type":"uint256"},{"internalType":"uint256","name":"apr","type":"uint256"},{"internalType":"uint8","name":"nftTokenType","type":"uint8"}],"internalType":"struct LendingCore.LoanPayload","name":"_payload","type":"tuple"},{"internalType":"bytes","name":"_sig","type":"bytes"}],"name":"createLoan","outputs":[{"internalType":"uint256","name":"currentId","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"id","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_loanId","type":"uint256"}],"name":"liquidateLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"loans","outputs":[{"internalType":"address","name":"nftAddress","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"address","name":"lender","type":"address"},{"internalType":"address","name":"currency","type":"address"},{"internalType":"enum LendingCore.Status","name":"status","type":"uint8"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"loanAmount","type":"uint256"},{"internalType":"uint256","name":"amountDue","type":"uint256"},{"internalType":"uint8","name":"nftTokenType","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"onlyExitLoan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"platformFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_currency","type":"address"}],"name":"removeCurrency","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_loanId","type":"uint256"},{"internalType":"uint256","name":"_amountDue","type":"uint256"}],"name":"repayLoan","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes","name":"_sig","type":"bytes"}],"name":"setCancelledSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_value","type":"bool"}],"name":"setOnlyExitLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_currency","type":"address"},{"internalType":"uint256","name":"_platformFee","type":"uint256"}],"name":"setPlatformFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contractAddress","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint8","name":"_nftTokenType","type":"uint8"},{"internalType":"bool","name":"_punkTransfer","type":"bool"}],"name":"withdrawNft","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6080604052620151806009553480156200001857600080fd5b5060405162002ccc38038062002ccc8339810160408190526200003b916200011f565b60016000556200004b33620000cd565b6001600160a01b038216620000955760405162461bcd60e51b815260206004820152600c60248201526b5a45524f5f4144445245535360a01b604482015260640160405180910390fd5b600580546001600160a01b0319166001600160a01b039390931692909217909155600a805460ff19169115159190911790556200016d565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080604083850312156200013357600080fd5b82516001600160a01b03811681146200014b57600080fd5b602084015190925080151581146200016257600080fd5b809150509250929050565b612b4f806200017d6000396000f3fe6080604052600436106101665760003560e01c80638da5cb5b116100d1578063c5d3a1071161008a578063e1ec3c6811610064578063e1ec3c6814610463578063f23a6e61146104fe578063f2fde38b1461052a578063fb59e9241461054a57600080fd5b8063c5d3a10714610410578063ccdd9f5d14610430578063d24ff5f71461045057600080fd5b80638da5cb5b1461033c5780638db1afb11461036e57806398fabd3a1461038e578063a730756a146103ae578063af640d0f146103ce578063bc197c81146103e457600080fd5b806332e8bc721161012357806332e8bc7214610286578063364f7615146102c157806366934e19146102e1578063715018a6146102f457806389476069146103095780638a700b531461032957600080fd5b806301ffc9a71461016b578063034e7861146101a0578063150b7a02146101db5780631858398a146102145780631af42c0f146102365780631f1d469014610266575b600080fd5b34801561017757600080fd5b5061018b6101863660046123ef565b610564565b60405190151581526020015b60405180910390f35b3480156101ac57600080fd5b5061018b6101bb3660046124fa565b805160208183018101805160088252928201919093012091525460ff1681565b3480156101e757600080fd5b506101fb6101f636600461254b565b61059b565b6040516001600160e01b03199091168152602001610197565b34801561022057600080fd5b5061023461022f3660046125b3565b6105ac565b005b34801561024257600080fd5b5061018b6102513660046125cc565b60036020526000908152604090205460ff1681565b34801561027257600080fd5b5061018b6102813660046124fa565b610610565b34801561029257600080fd5b506102b36102a13660046125cc565b60046020526000908152604090205481565b604051908152602001610197565b3480156102cd57600080fd5b506102346102dc366004612606565b61064c565b6102b36102ef366004612655565b6106d0565b34801561030057600080fd5b50610234610a28565b34801561031557600080fd5b506102346103243660046125cc565b610a3c565b610234610337366004612739565b610ac4565b34801561034857600080fd5b506001546001600160a01b03165b6040516001600160a01b039091168152602001610197565b34801561037a57600080fd5b5061023461038936600461275b565b610f39565b34801561039a57600080fd5b50600554610356906001600160a01b031681565b3480156103ba57600080fd5b506102346103c9366004612785565b610fef565b3480156103da57600080fd5b506102b360065481565b3480156103f057600080fd5b506101fb6103ff366004612817565b63bc197c8160e01b95945050505050565b34801561041c57600080fd5b5061023461042b3660046125cc565b61100a565b34801561043c57600080fd5b5061023461044b3660046125b3565b6110ce565b6102b361045e366004612655565b611265565b34801561046f57600080fd5b506104e761047e3660046125b3565b600260208190526000918252604090912080546001820154928201546003830154600484015460058501546006860154600787015460088801546009909801546001600160a01b03978816998816989688169786169660ff600160a01b9097048716969091168b565b6040516101979b9a999897969594939291906128d7565b34801561050a57600080fd5b506101fb610519366004612964565b63f23a6e6160e01b95945050505050565b34801561053657600080fd5b506102346105453660046125cc565b61150d565b34801561055657600080fd5b5060075461018b9060ff1681565b60006001600160e01b03198216630271189760e51b148061059557506301ffc9a760e01b6001600160e01b03198316145b92915050565b630a85bd0160e11b5b949350505050565b6105b4611583565b600a5460ff1661060b5760405162461bcd60e51b815260206004820152601860248201527f4e4f545f4348414e47455f4455524154494f4e5f554e4954000000000000000060448201526064015b60405180910390fd5b600955565b6000600160088360405161062491906129f5565b908152604051908190036020019020805491151560ff19909216919091179055506001919050565b6001600160a01b038481166000908152600c6020908152604080832087845290915290205416156106af5760405162461bcd60e51b815260206004820152600d60248201526c4e46545f494e5f455343524f5760981b6044820152606401610602565b6005546106ca9030906001600160a01b0316868686866115dd565b50505050565b60006106da611758565b600b826040516106ea91906129f5565b9081526040519081900360200190205460ff161561074a5760405162461bcd60e51b815260206004820152601e60248201527f54686973207369676e617475726520697320616c7265616479207573656400006044820152606401610602565b60088260405161075a91906129f5565b9081526040519081900360200190205460ff16156107ba5760405162461bcd60e51b815260206004820152601b60248201527f54686973207369676e6174757265206973206e6f742076616c696400000000006044820152606401610602565b6020808401516040808601516060870151608088015160a089015160c08a015160e08b01516101008c01516101208d0151975160009a61084a9a9991016001600160a01b03998a16815297891660208901529590971660408701526060860193909352608085019190915260a084015260c083015260e082019290925260ff919091166101008201526101200190565b6040516020818303038152906040528051906020012090506000816040516020016108a191907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60405160208183030381529060405280519060200120905084602001516001600160a01b0316336001600160a01b0316036109465784516001600160a01b03166108eb82866117b1565b6001600160a01b0316146109415760405162461bcd60e51b815260206004820152601860248201527f494e56414c49445f5349474e41545552455f4c454e44455200000000000000006044820152606401610602565b6109de565b84516001600160a01b031633036109c55784602001516001600160a01b031661096f82866117b1565b6001600160a01b0316146109415760405162461bcd60e51b815260206004820152601a60248201527f494e56414c49445f5349474e41545552455f424f52524f5745520000000000006044820152606401610602565b604051636edaef2f60e11b815260040160405180910390fd5b6109e7856117d5565b92506001600b856040516109fb91906129f5565b908152604051908190036020019020805491151560ff199092169190911790555061059590506001600055565b610a30611583565b610a3a6000611e4b565b565b6005546040516370a0823160e01b8152306004820152610ac1916001600160a01b0390811691908416906370a0823190602401602060405180830381865afa158015610a8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab09190612a11565b6001600160a01b0384169190611e9d565b50565b610acc611758565b6000828152600260205260409020600381015460018201546001600160a01b0391821691163314610b325760405162461bcd60e51b815260206004820152601060248201526f2ba927a723afa6a9a3afa9a2a72222a960811b6044820152606401610602565b60006003830154600160a01b900460ff166002811115610b5457610b546128c1565b14610b945760405162461bcd60e51b815260206004820152601060248201526f1393d517d313d05397d0d4915055115160821b6044820152606401610602565b8160060154421115610bd75760405162461bcd60e51b815260206004820152600c60248201526b22ac2824a922a22fa627a0a760a11b6044820152606401610602565b600034118015610bee57506001600160a01b038116155b8015610bfa5750823410155b8015610c0a575081600801548310155b80610c3657506001600160a01b03811615801590610c26575034155b8015610c36575081600801548310155b610c825760405162461bcd60e51b815260206004820152601e60248201527f506179206261636b20616d6f756e74206973206e6f7420656e6f7567682e00006044820152606401610602565b60038201805460ff60a01b1916600160a01b17905581546001600160a01b039081166000908152600c602090815260408083206004870180548552925290912080546001600160a01b0319169055600180850154855492546009870154610cf79530959381169493169260ff909116906115dd565b60038201546001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610d475760028201546003830154610d42916001600160a01b039182169133911686611f05565b610ecb565b82341015610d925760405162461bcd60e51b815260206004820152601860248201527722aa24103b30b63ab29034b9903737ba1032b737bab3b41760411b6044820152606401610602565b60028201546040516000916001600160a01b03169085908381818185875af1925050503d8060008114610de1576040519150601f19603f3d011682016040523d82523d6000602084013e610de6565b606091505b5050905080610e295760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610602565b83341115610ec957600033610e3e8634612a40565b604051600081818185875af1925050503d8060008114610e7a576040519150601f19603f3d011682016040523d82523d6000602084013e610e7f565b606091505b5050905080610ec75760405162461bcd60e51b8152602060048201526014602482015273151c985b9cd9995c88189858dac819985a5b195960621b6044820152606401610602565b505b505b815460018301546002840154600485015460408051918252602082018990526001600160a01b039485169493841693909216917f1648de52e237e2cfe4fa99e1e1c008accb6165f17ba2f9d9622d697c98b15a1d910160405180910390a45050610f356001600055565b5050565b610f41611583565b6103e88110610f8a5760405162461bcd60e51b8152602060048201526015602482015274544f4f5f484947485f504c4154464f524d5f46454560581b6044820152606401610602565b6001600160a01b0382166000818152600360209081526040808320805460ff19166001179055600482529182902084905590518381527fd8149d5d7695ec014cad0238fa3120dfa5fa8330c3d19b451f2bdc7587f37d84910160405180910390a25050565b610ff7611583565b6007805460ff1916911515919091179055565b611012611583565b6001600160a01b03811660009081526003602052604090205460ff1661106f5760405162461bcd60e51b815260206004820152601260248201527110d55494915390d657d393d517d1561254d560721b6044820152606401610602565b6001600160a01b0381166000818152600360209081526040808320805460ff1916905560048252808320839055519182527fd8149d5d7695ec014cad0238fa3120dfa5fa8330c3d19b451f2bdc7587f37d84910160405180910390a250565b6110d6611758565b6000818152600260205260408120906003820154600160a01b900460ff166002811115611105576111056128c1565b146111425760405162461bcd60e51b815260206004820152600d60248201526c1313d05397d192539254d21151609a1b6044820152606401610602565b80600601544210156111895760405162461bcd60e51b815260206004820152601060248201526f2727aa2fa2ac2824a922a22fa627a0a760811b6044820152606401610602565b60038101805460ff60a01b1916600160a11b17905580546001600160a01b039081166000908152600c602090815260408083206004860180548552925290912080546001600160a01b031916905560028301548354915460098501546111fc9430949381169316919060ff1660016115dd565b805460018201546002830154600484015460408051918252602082018790526001600160a01b039485169493841693909216917f0bf28c16d70e6ac2c46b9946c64fe9dad4ca68e6edbba1f773ebe679c53b90fa910160405180910390a450610ac16001600055565b600061126f611758565b600b8260405161127f91906129f5565b9081526040519081900360200190205460ff16156112df5760405162461bcd60e51b815260206004820152601e60248201527f54686973207369676e617475726520697320616c7265616479207573656400006044820152606401610602565b6008826040516112ef91906129f5565b9081526040519081900360200190205460ff161561134f5760405162461bcd60e51b815260206004820152601b60248201527f54686973207369676e6174757265206973206e6f742076616c696400000000006044820152606401610602565b82602001516001600160a01b0316336001600160a01b0316146113b45760405162461bcd60e51b815260206004820152601a60248201527f5468652063616c6c6572206973206e6f7420626f72726f7765720000000000006044820152606401610602565b60008360000151846040015185606001518660a001518760c001518860e001518961010001518a610120015160405160200161143c9897969594939291906001600160a01b03988916815296881660208801529490961660408601526060850192909252608084015260a083015260c082019290925260ff9190911660e08201526101000190565b60405160208183030381529060405280519060200120905060008160405160200161149391907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60405160208183030381529060405280519060200120905084600001516001600160a01b03166114c382866117b1565b6001600160a01b0316146109de5760405162461bcd60e51b8152602060048201526011602482015270494e56414c49445f5349474e415455524560781b6044820152606401610602565b611515611583565b6001600160a01b03811661157a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610602565b610ac181611e4b565b6001546001600160a01b03163314610a3a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610602565b8160ff1660000361165857604051632142170760e11b81526001600160a01b0387811660048301528681166024830152604482018590528516906342842e0e906064015b600060405180830381600087803b15801561163b57600080fd5b505af115801561164f573d6000803e3d6000fd5b50505050611750565b8160ff166001036116c457604051637921219560e11b81526001600160a01b038781166004808401919091528782166024840152604483018690526001606484015260a0608484015260a4830152630307830360e41b60c483015285169063f242432a9060e401611621565b8160ff1660020361173757801561170a576040516322dca8bb60e21b81526001600160a01b03868116600483015260248201859052851690638b72a2ec90604401611621565b60405163104c9fd360e31b8152600481018490526001600160a01b03851690638264fe9890602401611621565b604051633a26203b60e11b815260040160405180910390fd5b505050505050565b6002600054036117aa5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610602565b6002600055565b60008060006117c08585611f3d565b915091506117cd81611f82565b509392505050565b60075460009060ff161561181c5760405162461bcd60e51b815260206004820152600e60248201526d27a7262cafa2ac24aa2fa627a0a760911b6044820152606401610602565b428260c0015110156118645760405162461bcd60e51b8152602060048201526011602482015270455850495245445f5349474e415455524560781b6044820152606401610602565b60608201516001600160a01b031660009081526003602052604090205460ff166118c75760405162461bcd60e51b81526020600482015260146024820152734e4f545f414c4c4f5745445f43555252454e435960601b6044820152606401610602565b60008260a001511161190b5760405162461bcd60e51b815260206004820152600d60248201526c2d22a927afa22aa920aa24a7a760991b6044820152606401610602565b60e082015160608301516001600160a01b03166000908152600460205260408120549091611938916120cc565b9050600654915060405180610160016040528084604001516001600160a01b0316815260200184602001516001600160a01b0316815260200184600001516001600160a01b0316815260200184606001516001600160a01b03168152602001600060028111156119aa576119aa6128c1565b8152602001846080015181526020014281526020016009548560a001516119d19190612a57565b6119db9042612a76565b81526020018460e001518152602001611a028560e001518661010001518760a001516120ec565b815261012085015160ff1660209182015260008481526002808352604091829020845181546001600160a01b03199081166001600160a01b0392831617835594860151600183018054871691831691909117905592850151818301805486169185169190911790556060850151600382018054958616919094169081178455608086015191949193926001600160a81b03199092161790600160a01b908490811115611ab057611ab06128c1565b021790555060a0820151600482015560c0820151600582015560e082015160068201556101008201516007820155610120808301516008830155610140909201516009909101805460ff191660ff90921691909117905560208481018051604080880180516001600160a01b039081166000908152600c875283812060808c0180518352975292832080546001600160a01b031916919094161790925591519051925193870151611b689491933093909291906115dd565b60608301516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14611bf157611bc383600001518460200151838660e00151611bad9190612a40565b60608701516001600160a01b0316929190611f05565b8015611bec5782516005546060850151611bec926001600160a01b039182169290911684611f05565b611d95565b808360e00151611c019190612a76565b341015611c4b5760405162461bcd60e51b815260206004820152601860248201527722aa24103b30b63ab29034b9903737ba1032b737bab3b41760411b6044820152606401610602565b600083602001516001600160a01b0316828560e00151611c6b9190612a40565b604051600081818185875af1925050503d8060008114611ca7576040519150601f19603f3d011682016040523d82523d6000602084013e611cac565b606091505b5050905080611cef5760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610602565b8115611d93576005546040516000916001600160a01b03169084908381818185875af1925050503d8060008114611d42576040519150601f19603f3d011682016040523d82523d6000602084013e611d47565b606091505b5050905080611d915760405162461bcd60e51b81526020600482015260166024820152755472616e73666572206661696c656420746f2044414f60501b6044820152606401610602565b505b505b82604001516001600160a01b031683602001516001600160a01b031684600001516001600160a01b03167ff5de925b1da772c8030ecd826bee784e752cae0acf04ff2fcb079acad86896b186608001518688606001518960e0015188604051611e2995949392919094855260208501939093526001600160a01b039190911660408401526060830152608082015260a00190565b60405180910390a4600660008154611e4090612a8e565b909155509092915050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516001600160a01b038316602482015260448101829052611f0090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612136565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526106ca9085906323b872dd60e01b90608401611ec9565b6000808251604103611f735760208301516040840151606085015160001a611f6787828585612208565b94509450505050611f7b565b506000905060025b9250929050565b6000816004811115611f9657611f966128c1565b03611f9e5750565b6001816004811115611fb257611fb26128c1565b03611fff5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610602565b6002816004811115612013576120136128c1565b036120605760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610602565b6003816004811115612074576120746128c1565b03610ac15760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610602565b60006127106120db8385612a57565b6120e59190612aa7565b9392505050565b60006127106301e14320836121018688612a57565b61210b9190612a57565b6121189062015180612a57565b6121229190612aa7565b61212c9190612aa7565b6105a49085612a76565b600061218b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166122cc9092919063ffffffff16565b805190915015611f0057808060200190518101906121a99190612ac9565b611f005760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610602565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561223f57506000905060036122c3565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612293573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166122bc576000600192509250506122c3565b9150600090505b94509492505050565b60606105a4848460008585600080866001600160a01b031685876040516122f391906129f5565b60006040518083038185875af1925050503d8060008114612330576040519150601f19603f3d011682016040523d82523d6000602084013e612335565b606091505b509150915061234687838387612351565b979650505050505050565b606083156123c05782516000036123b9576001600160a01b0385163b6123b95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610602565b50816105a4565b6105a483838151156123d55781518083602001fd5b8060405162461bcd60e51b81526004016106029190612ae6565b60006020828403121561240157600080fd5b81356001600160e01b0319811681146120e557600080fd5b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff8111828210171561245357612453612419565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561248257612482612419565b604052919050565b600082601f83011261249b57600080fd5b813567ffffffffffffffff8111156124b5576124b5612419565b6124c8601f8201601f1916602001612459565b8181528460208386010111156124dd57600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561250c57600080fd5b813567ffffffffffffffff81111561252357600080fd5b6105a48482850161248a565b80356001600160a01b038116811461254657600080fd5b919050565b6000806000806080858703121561256157600080fd5b61256a8561252f565b93506125786020860161252f565b925060408501359150606085013567ffffffffffffffff81111561259b57600080fd5b6125a78782880161248a565b91505092959194509250565b6000602082840312156125c557600080fd5b5035919050565b6000602082840312156125de57600080fd5b6120e58261252f565b803560ff8116811461254657600080fd5b8015158114610ac157600080fd5b6000806000806080858703121561261c57600080fd5b6126258561252f565b93506020850135925061263a604086016125e7565b9150606085013561264a816125f8565b939692955090935050565b60008082840361016081121561266a57600080fd5b6101408082121561267a57600080fd5b61268261242f565b915061268d8561252f565b825261269b6020860161252f565b60208301526126ac6040860161252f565b60408301526126bd6060860161252f565b60608301526080850135608083015260a085013560a083015260c085013560c083015260e085013560e08301526101008086013581840152506101206127048187016125e7565b9083015290925083013567ffffffffffffffff81111561272357600080fd5b61272f8582860161248a565b9150509250929050565b6000806040838503121561274c57600080fd5b50508035926020909101359150565b6000806040838503121561276e57600080fd5b6127778361252f565b946020939093013593505050565b60006020828403121561279757600080fd5b81356120e5816125f8565b600082601f8301126127b357600080fd5b8135602067ffffffffffffffff8211156127cf576127cf612419565b8160051b6127de828201612459565b92835284810182019282810190878511156127f857600080fd5b83870192505b84831015612346578235825291830191908301906127fe565b600080600080600060a0868803121561282f57600080fd5b6128388661252f565b94506128466020870161252f565b9350604086013567ffffffffffffffff8082111561286357600080fd5b61286f89838a016127a2565b9450606088013591508082111561288557600080fd5b61289189838a016127a2565b935060808801359150808211156128a757600080fd5b506128b48882890161248a565b9150509295509295909350565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b038c811682528b811660208301528a811660408301528916606082015261016081016003891061291e57634e487b7160e01b600052602160045260246000fd5b8860808301528760a08301528660c08301528560e0830152846101008301528361012083015261295461014083018460ff169052565b9c9b505050505050505050505050565b600080600080600060a0868803121561297c57600080fd5b6129858661252f565b94506129936020870161252f565b93506040860135925060608601359150608086013567ffffffffffffffff8111156129bd57600080fd5b6128b48882890161248a565b60005b838110156129e45781810151838201526020016129cc565b838111156106ca5750506000910152565b60008251612a078184602087016129c9565b9190910192915050565b600060208284031215612a2357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015612a5257612a52612a2a565b500390565b6000816000190483118215151615612a7157612a71612a2a565b500290565b60008219821115612a8957612a89612a2a565b500190565b600060018201612aa057612aa0612a2a565b5060010190565b600082612ac457634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215612adb57600080fd5b81516120e5816125f8565b6020815260008251806020840152612b058160408501602087016129c9565b601f01601f1916919091016040019291505056fea26469706673582212207040fa406ff8c29ca8383a5f359c75d98757b5c8aa6453080710443d5a75d69964736f6c634300080e003300000000000000000000000066a98cfcd5a0dcb4e578089e1d89134a3124f0b10000000000000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x6080604052600436106101665760003560e01c80638da5cb5b116100d1578063c5d3a1071161008a578063e1ec3c6811610064578063e1ec3c6814610463578063f23a6e61146104fe578063f2fde38b1461052a578063fb59e9241461054a57600080fd5b8063c5d3a10714610410578063ccdd9f5d14610430578063d24ff5f71461045057600080fd5b80638da5cb5b1461033c5780638db1afb11461036e57806398fabd3a1461038e578063a730756a146103ae578063af640d0f146103ce578063bc197c81146103e457600080fd5b806332e8bc721161012357806332e8bc7214610286578063364f7615146102c157806366934e19146102e1578063715018a6146102f457806389476069146103095780638a700b531461032957600080fd5b806301ffc9a71461016b578063034e7861146101a0578063150b7a02146101db5780631858398a146102145780631af42c0f146102365780631f1d469014610266575b600080fd5b34801561017757600080fd5b5061018b6101863660046123ef565b610564565b60405190151581526020015b60405180910390f35b3480156101ac57600080fd5b5061018b6101bb3660046124fa565b805160208183018101805160088252928201919093012091525460ff1681565b3480156101e757600080fd5b506101fb6101f636600461254b565b61059b565b6040516001600160e01b03199091168152602001610197565b34801561022057600080fd5b5061023461022f3660046125b3565b6105ac565b005b34801561024257600080fd5b5061018b6102513660046125cc565b60036020526000908152604090205460ff1681565b34801561027257600080fd5b5061018b6102813660046124fa565b610610565b34801561029257600080fd5b506102b36102a13660046125cc565b60046020526000908152604090205481565b604051908152602001610197565b3480156102cd57600080fd5b506102346102dc366004612606565b61064c565b6102b36102ef366004612655565b6106d0565b34801561030057600080fd5b50610234610a28565b34801561031557600080fd5b506102346103243660046125cc565b610a3c565b610234610337366004612739565b610ac4565b34801561034857600080fd5b506001546001600160a01b03165b6040516001600160a01b039091168152602001610197565b34801561037a57600080fd5b5061023461038936600461275b565b610f39565b34801561039a57600080fd5b50600554610356906001600160a01b031681565b3480156103ba57600080fd5b506102346103c9366004612785565b610fef565b3480156103da57600080fd5b506102b360065481565b3480156103f057600080fd5b506101fb6103ff366004612817565b63bc197c8160e01b95945050505050565b34801561041c57600080fd5b5061023461042b3660046125cc565b61100a565b34801561043c57600080fd5b5061023461044b3660046125b3565b6110ce565b6102b361045e366004612655565b611265565b34801561046f57600080fd5b506104e761047e3660046125b3565b600260208190526000918252604090912080546001820154928201546003830154600484015460058501546006860154600787015460088801546009909801546001600160a01b03978816998816989688169786169660ff600160a01b9097048716969091168b565b6040516101979b9a999897969594939291906128d7565b34801561050a57600080fd5b506101fb610519366004612964565b63f23a6e6160e01b95945050505050565b34801561053657600080fd5b506102346105453660046125cc565b61150d565b34801561055657600080fd5b5060075461018b9060ff1681565b60006001600160e01b03198216630271189760e51b148061059557506301ffc9a760e01b6001600160e01b03198316145b92915050565b630a85bd0160e11b5b949350505050565b6105b4611583565b600a5460ff1661060b5760405162461bcd60e51b815260206004820152601860248201527f4e4f545f4348414e47455f4455524154494f4e5f554e4954000000000000000060448201526064015b60405180910390fd5b600955565b6000600160088360405161062491906129f5565b908152604051908190036020019020805491151560ff19909216919091179055506001919050565b6001600160a01b038481166000908152600c6020908152604080832087845290915290205416156106af5760405162461bcd60e51b815260206004820152600d60248201526c4e46545f494e5f455343524f5760981b6044820152606401610602565b6005546106ca9030906001600160a01b0316868686866115dd565b50505050565b60006106da611758565b600b826040516106ea91906129f5565b9081526040519081900360200190205460ff161561074a5760405162461bcd60e51b815260206004820152601e60248201527f54686973207369676e617475726520697320616c7265616479207573656400006044820152606401610602565b60088260405161075a91906129f5565b9081526040519081900360200190205460ff16156107ba5760405162461bcd60e51b815260206004820152601b60248201527f54686973207369676e6174757265206973206e6f742076616c696400000000006044820152606401610602565b6020808401516040808601516060870151608088015160a089015160c08a015160e08b01516101008c01516101208d0151975160009a61084a9a9991016001600160a01b03998a16815297891660208901529590971660408701526060860193909352608085019190915260a084015260c083015260e082019290925260ff919091166101008201526101200190565b6040516020818303038152906040528051906020012090506000816040516020016108a191907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60405160208183030381529060405280519060200120905084602001516001600160a01b0316336001600160a01b0316036109465784516001600160a01b03166108eb82866117b1565b6001600160a01b0316146109415760405162461bcd60e51b815260206004820152601860248201527f494e56414c49445f5349474e41545552455f4c454e44455200000000000000006044820152606401610602565b6109de565b84516001600160a01b031633036109c55784602001516001600160a01b031661096f82866117b1565b6001600160a01b0316146109415760405162461bcd60e51b815260206004820152601a60248201527f494e56414c49445f5349474e41545552455f424f52524f5745520000000000006044820152606401610602565b604051636edaef2f60e11b815260040160405180910390fd5b6109e7856117d5565b92506001600b856040516109fb91906129f5565b908152604051908190036020019020805491151560ff199092169190911790555061059590506001600055565b610a30611583565b610a3a6000611e4b565b565b6005546040516370a0823160e01b8152306004820152610ac1916001600160a01b0390811691908416906370a0823190602401602060405180830381865afa158015610a8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab09190612a11565b6001600160a01b0384169190611e9d565b50565b610acc611758565b6000828152600260205260409020600381015460018201546001600160a01b0391821691163314610b325760405162461bcd60e51b815260206004820152601060248201526f2ba927a723afa6a9a3afa9a2a72222a960811b6044820152606401610602565b60006003830154600160a01b900460ff166002811115610b5457610b546128c1565b14610b945760405162461bcd60e51b815260206004820152601060248201526f1393d517d313d05397d0d4915055115160821b6044820152606401610602565b8160060154421115610bd75760405162461bcd60e51b815260206004820152600c60248201526b22ac2824a922a22fa627a0a760a11b6044820152606401610602565b600034118015610bee57506001600160a01b038116155b8015610bfa5750823410155b8015610c0a575081600801548310155b80610c3657506001600160a01b03811615801590610c26575034155b8015610c36575081600801548310155b610c825760405162461bcd60e51b815260206004820152601e60248201527f506179206261636b20616d6f756e74206973206e6f7420656e6f7567682e00006044820152606401610602565b60038201805460ff60a01b1916600160a01b17905581546001600160a01b039081166000908152600c602090815260408083206004870180548552925290912080546001600160a01b0319169055600180850154855492546009870154610cf79530959381169493169260ff909116906115dd565b60038201546001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14610d475760028201546003830154610d42916001600160a01b039182169133911686611f05565b610ecb565b82341015610d925760405162461bcd60e51b815260206004820152601860248201527722aa24103b30b63ab29034b9903737ba1032b737bab3b41760411b6044820152606401610602565b60028201546040516000916001600160a01b03169085908381818185875af1925050503d8060008114610de1576040519150601f19603f3d011682016040523d82523d6000602084013e610de6565b606091505b5050905080610e295760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610602565b83341115610ec957600033610e3e8634612a40565b604051600081818185875af1925050503d8060008114610e7a576040519150601f19603f3d011682016040523d82523d6000602084013e610e7f565b606091505b5050905080610ec75760405162461bcd60e51b8152602060048201526014602482015273151c985b9cd9995c88189858dac819985a5b195960621b6044820152606401610602565b505b505b815460018301546002840154600485015460408051918252602082018990526001600160a01b039485169493841693909216917f1648de52e237e2cfe4fa99e1e1c008accb6165f17ba2f9d9622d697c98b15a1d910160405180910390a45050610f356001600055565b5050565b610f41611583565b6103e88110610f8a5760405162461bcd60e51b8152602060048201526015602482015274544f4f5f484947485f504c4154464f524d5f46454560581b6044820152606401610602565b6001600160a01b0382166000818152600360209081526040808320805460ff19166001179055600482529182902084905590518381527fd8149d5d7695ec014cad0238fa3120dfa5fa8330c3d19b451f2bdc7587f37d84910160405180910390a25050565b610ff7611583565b6007805460ff1916911515919091179055565b611012611583565b6001600160a01b03811660009081526003602052604090205460ff1661106f5760405162461bcd60e51b815260206004820152601260248201527110d55494915390d657d393d517d1561254d560721b6044820152606401610602565b6001600160a01b0381166000818152600360209081526040808320805460ff1916905560048252808320839055519182527fd8149d5d7695ec014cad0238fa3120dfa5fa8330c3d19b451f2bdc7587f37d84910160405180910390a250565b6110d6611758565b6000818152600260205260408120906003820154600160a01b900460ff166002811115611105576111056128c1565b146111425760405162461bcd60e51b815260206004820152600d60248201526c1313d05397d192539254d21151609a1b6044820152606401610602565b80600601544210156111895760405162461bcd60e51b815260206004820152601060248201526f2727aa2fa2ac2824a922a22fa627a0a760811b6044820152606401610602565b60038101805460ff60a01b1916600160a11b17905580546001600160a01b039081166000908152600c602090815260408083206004860180548552925290912080546001600160a01b031916905560028301548354915460098501546111fc9430949381169316919060ff1660016115dd565b805460018201546002830154600484015460408051918252602082018790526001600160a01b039485169493841693909216917f0bf28c16d70e6ac2c46b9946c64fe9dad4ca68e6edbba1f773ebe679c53b90fa910160405180910390a450610ac16001600055565b600061126f611758565b600b8260405161127f91906129f5565b9081526040519081900360200190205460ff16156112df5760405162461bcd60e51b815260206004820152601e60248201527f54686973207369676e617475726520697320616c7265616479207573656400006044820152606401610602565b6008826040516112ef91906129f5565b9081526040519081900360200190205460ff161561134f5760405162461bcd60e51b815260206004820152601b60248201527f54686973207369676e6174757265206973206e6f742076616c696400000000006044820152606401610602565b82602001516001600160a01b0316336001600160a01b0316146113b45760405162461bcd60e51b815260206004820152601a60248201527f5468652063616c6c6572206973206e6f7420626f72726f7765720000000000006044820152606401610602565b60008360000151846040015185606001518660a001518760c001518860e001518961010001518a610120015160405160200161143c9897969594939291906001600160a01b03988916815296881660208801529490961660408601526060850192909252608084015260a083015260c082019290925260ff9190911660e08201526101000190565b60405160208183030381529060405280519060200120905060008160405160200161149391907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60405160208183030381529060405280519060200120905084600001516001600160a01b03166114c382866117b1565b6001600160a01b0316146109de5760405162461bcd60e51b8152602060048201526011602482015270494e56414c49445f5349474e415455524560781b6044820152606401610602565b611515611583565b6001600160a01b03811661157a5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610602565b610ac181611e4b565b6001546001600160a01b03163314610a3a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610602565b8160ff1660000361165857604051632142170760e11b81526001600160a01b0387811660048301528681166024830152604482018590528516906342842e0e906064015b600060405180830381600087803b15801561163b57600080fd5b505af115801561164f573d6000803e3d6000fd5b50505050611750565b8160ff166001036116c457604051637921219560e11b81526001600160a01b038781166004808401919091528782166024840152604483018690526001606484015260a0608484015260a4830152630307830360e41b60c483015285169063f242432a9060e401611621565b8160ff1660020361173757801561170a576040516322dca8bb60e21b81526001600160a01b03868116600483015260248201859052851690638b72a2ec90604401611621565b60405163104c9fd360e31b8152600481018490526001600160a01b03851690638264fe9890602401611621565b604051633a26203b60e11b815260040160405180910390fd5b505050505050565b6002600054036117aa5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610602565b6002600055565b60008060006117c08585611f3d565b915091506117cd81611f82565b509392505050565b60075460009060ff161561181c5760405162461bcd60e51b815260206004820152600e60248201526d27a7262cafa2ac24aa2fa627a0a760911b6044820152606401610602565b428260c0015110156118645760405162461bcd60e51b8152602060048201526011602482015270455850495245445f5349474e415455524560781b6044820152606401610602565b60608201516001600160a01b031660009081526003602052604090205460ff166118c75760405162461bcd60e51b81526020600482015260146024820152734e4f545f414c4c4f5745445f43555252454e435960601b6044820152606401610602565b60008260a001511161190b5760405162461bcd60e51b815260206004820152600d60248201526c2d22a927afa22aa920aa24a7a760991b6044820152606401610602565b60e082015160608301516001600160a01b03166000908152600460205260408120549091611938916120cc565b9050600654915060405180610160016040528084604001516001600160a01b0316815260200184602001516001600160a01b0316815260200184600001516001600160a01b0316815260200184606001516001600160a01b03168152602001600060028111156119aa576119aa6128c1565b8152602001846080015181526020014281526020016009548560a001516119d19190612a57565b6119db9042612a76565b81526020018460e001518152602001611a028560e001518661010001518760a001516120ec565b815261012085015160ff1660209182015260008481526002808352604091829020845181546001600160a01b03199081166001600160a01b0392831617835594860151600183018054871691831691909117905592850151818301805486169185169190911790556060850151600382018054958616919094169081178455608086015191949193926001600160a81b03199092161790600160a01b908490811115611ab057611ab06128c1565b021790555060a0820151600482015560c0820151600582015560e082015160068201556101008201516007820155610120808301516008830155610140909201516009909101805460ff191660ff90921691909117905560208481018051604080880180516001600160a01b039081166000908152600c875283812060808c0180518352975292832080546001600160a01b031916919094161790925591519051925193870151611b689491933093909291906115dd565b60608301516001600160a01b031673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14611bf157611bc383600001518460200151838660e00151611bad9190612a40565b60608701516001600160a01b0316929190611f05565b8015611bec5782516005546060850151611bec926001600160a01b039182169290911684611f05565b611d95565b808360e00151611c019190612a76565b341015611c4b5760405162461bcd60e51b815260206004820152601860248201527722aa24103b30b63ab29034b9903737ba1032b737bab3b41760411b6044820152606401610602565b600083602001516001600160a01b0316828560e00151611c6b9190612a40565b604051600081818185875af1925050503d8060008114611ca7576040519150601f19603f3d011682016040523d82523d6000602084013e611cac565b606091505b5050905080611cef5760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610602565b8115611d93576005546040516000916001600160a01b03169084908381818185875af1925050503d8060008114611d42576040519150601f19603f3d011682016040523d82523d6000602084013e611d47565b606091505b5050905080611d915760405162461bcd60e51b81526020600482015260166024820152755472616e73666572206661696c656420746f2044414f60501b6044820152606401610602565b505b505b82604001516001600160a01b031683602001516001600160a01b031684600001516001600160a01b03167ff5de925b1da772c8030ecd826bee784e752cae0acf04ff2fcb079acad86896b186608001518688606001518960e0015188604051611e2995949392919094855260208501939093526001600160a01b039190911660408401526060830152608082015260a00190565b60405180910390a4600660008154611e4090612a8e565b909155509092915050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516001600160a01b038316602482015260448101829052611f0090849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612136565b505050565b6040516001600160a01b03808516602483015283166044820152606481018290526106ca9085906323b872dd60e01b90608401611ec9565b6000808251604103611f735760208301516040840151606085015160001a611f6787828585612208565b94509450505050611f7b565b506000905060025b9250929050565b6000816004811115611f9657611f966128c1565b03611f9e5750565b6001816004811115611fb257611fb26128c1565b03611fff5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610602565b6002816004811115612013576120136128c1565b036120605760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610602565b6003816004811115612074576120746128c1565b03610ac15760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610602565b60006127106120db8385612a57565b6120e59190612aa7565b9392505050565b60006127106301e14320836121018688612a57565b61210b9190612a57565b6121189062015180612a57565b6121229190612aa7565b61212c9190612aa7565b6105a49085612a76565b600061218b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166122cc9092919063ffffffff16565b805190915015611f0057808060200190518101906121a99190612ac9565b611f005760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610602565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561223f57506000905060036122c3565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612293573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166122bc576000600192509250506122c3565b9150600090505b94509492505050565b60606105a4848460008585600080866001600160a01b031685876040516122f391906129f5565b60006040518083038185875af1925050503d8060008114612330576040519150601f19603f3d011682016040523d82523d6000602084013e612335565b606091505b509150915061234687838387612351565b979650505050505050565b606083156123c05782516000036123b9576001600160a01b0385163b6123b95760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610602565b50816105a4565b6105a483838151156123d55781518083602001fd5b8060405162461bcd60e51b81526004016106029190612ae6565b60006020828403121561240157600080fd5b81356001600160e01b0319811681146120e557600080fd5b634e487b7160e01b600052604160045260246000fd5b604051610140810167ffffffffffffffff8111828210171561245357612453612419565b60405290565b604051601f8201601f1916810167ffffffffffffffff8111828210171561248257612482612419565b604052919050565b600082601f83011261249b57600080fd5b813567ffffffffffffffff8111156124b5576124b5612419565b6124c8601f8201601f1916602001612459565b8181528460208386010111156124dd57600080fd5b816020850160208301376000918101602001919091529392505050565b60006020828403121561250c57600080fd5b813567ffffffffffffffff81111561252357600080fd5b6105a48482850161248a565b80356001600160a01b038116811461254657600080fd5b919050565b6000806000806080858703121561256157600080fd5b61256a8561252f565b93506125786020860161252f565b925060408501359150606085013567ffffffffffffffff81111561259b57600080fd5b6125a78782880161248a565b91505092959194509250565b6000602082840312156125c557600080fd5b5035919050565b6000602082840312156125de57600080fd5b6120e58261252f565b803560ff8116811461254657600080fd5b8015158114610ac157600080fd5b6000806000806080858703121561261c57600080fd5b6126258561252f565b93506020850135925061263a604086016125e7565b9150606085013561264a816125f8565b939692955090935050565b60008082840361016081121561266a57600080fd5b6101408082121561267a57600080fd5b61268261242f565b915061268d8561252f565b825261269b6020860161252f565b60208301526126ac6040860161252f565b60408301526126bd6060860161252f565b60608301526080850135608083015260a085013560a083015260c085013560c083015260e085013560e08301526101008086013581840152506101206127048187016125e7565b9083015290925083013567ffffffffffffffff81111561272357600080fd5b61272f8582860161248a565b9150509250929050565b6000806040838503121561274c57600080fd5b50508035926020909101359150565b6000806040838503121561276e57600080fd5b6127778361252f565b946020939093013593505050565b60006020828403121561279757600080fd5b81356120e5816125f8565b600082601f8301126127b357600080fd5b8135602067ffffffffffffffff8211156127cf576127cf612419565b8160051b6127de828201612459565b92835284810182019282810190878511156127f857600080fd5b83870192505b84831015612346578235825291830191908301906127fe565b600080600080600060a0868803121561282f57600080fd5b6128388661252f565b94506128466020870161252f565b9350604086013567ffffffffffffffff8082111561286357600080fd5b61286f89838a016127a2565b9450606088013591508082111561288557600080fd5b61289189838a016127a2565b935060808801359150808211156128a757600080fd5b506128b48882890161248a565b9150509295509295909350565b634e487b7160e01b600052602160045260246000fd5b6001600160a01b038c811682528b811660208301528a811660408301528916606082015261016081016003891061291e57634e487b7160e01b600052602160045260246000fd5b8860808301528760a08301528660c08301528560e0830152846101008301528361012083015261295461014083018460ff169052565b9c9b505050505050505050505050565b600080600080600060a0868803121561297c57600080fd5b6129858661252f565b94506129936020870161252f565b93506040860135925060608601359150608086013567ffffffffffffffff8111156129bd57600080fd5b6128b48882890161248a565b60005b838110156129e45781810151838201526020016129cc565b838111156106ca5750506000910152565b60008251612a078184602087016129c9565b9190910192915050565b600060208284031215612a2357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015612a5257612a52612a2a565b500390565b6000816000190483118215151615612a7157612a71612a2a565b500290565b60008219821115612a8957612a89612a2a565b500190565b600060018201612aa057612aa0612a2a565b5060010190565b600082612ac457634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215612adb57600080fd5b81516120e5816125f8565b6020815260008251806020840152612b058160408501602087016129c9565b601f01601f1916919091016040019291505056fea26469706673582212207040fa406ff8c29ca8383a5f359c75d98757b5c8aa6453080710443d5a75d69964736f6c634300080e0033

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

00000000000000000000000066a98cfcd5a0dcb4e578089e1d89134a3124f0b10000000000000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : _DAO (address): 0x66a98CfCd5A0dCB4E578089E1D89134A3124F0b1
Arg [1] : _canChangeDurationUnit (bool): False

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000066a98cfcd5a0dcb4e578089e1d89134a3124f0b1
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000000


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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