Contract 0x3028B3A1133Ba8dD499F37ef6B0158F8BC38f849

 
Txn Hash
Method
Block
From
To
Value
0x6c77b80d5687196665744a11ed37f34e7b5c76b340069cf538b8b2d11ac72d30Set Whitelist NF...143885392022-03-15 2:36:29197 days 19 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  0x3028b3a1133ba8dd499f37ef6b0158f8bc38f8490 Ether0.00093701 20.17646059
0xc766baf7ca62bf350720c9bb10c377bd947d16fb7c5aa0ffa3d913709f8e61b0Set Whitelist NF...143060642022-03-02 6:47:32210 days 15 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  0x3028b3a1133ba8dd499f37ef6b0158f8bc38f8490 Ether0.0019311 41.58195821
0x6af7fca2519148738ab32f078646d26fc29e4c2c34d4fba9863f12ac47cc47aaSet Whitelist NF...142733672022-02-25 5:17:21215 days 16 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  0x3028b3a1133ba8dd499f37ef6b0158f8bc38f8490 Ether0.00206318 44.42583084
0x7e83c0bb1cf2d912e3975de5c7d33c1ce0d029f488daa696002aa887522d832eSet Whitelist NF...142661042022-02-24 2:25:09216 days 19 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  0x3028b3a1133ba8dd499f37ef6b0158f8bc38f8490 Ether0.00204558 44.04696499
0xbc019309248aef1ee922dfbcdc46592cbc6b8749b96f55a5546bb5753b4dc05cSet Whitelist NF...142613592022-02-23 8:51:36217 days 13 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  0x3028b3a1133ba8dd499f37ef6b0158f8bc38f8490 Ether0.00208984 45
0xac3a8d4e53a73d0fe60cbae533836efb69a8d05b194aa6f0781bc0c8de09872aSet Whitelist NF...142613592022-02-23 8:51:36217 days 13 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  0x3028b3a1133ba8dd499f37ef6b0158f8bc38f8490 Ether0.00208984 45
0xa1a0cd678fe88036c48c911aae645b0d9fd7973156bffd50ae127c2a699f15baSet Whitelist ER...142613462022-02-23 8:48:37217 days 13 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  0x3028b3a1133ba8dd499f37ef6b0158f8bc38f8490 Ether0.00202799 43.64751437
0xbfeae0c4677291ca9647a086e9c142c90f2d73ad0f3915099ed7b0d8ce41c88cUpdate Royalty F...142613192022-02-23 8:41:43217 days 13 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  0x3028b3a1133ba8dd499f37ef6b0158f8bc38f8490 Ether0.0023628 50
0xb089dff2f3756b86def404ed116a1305dbd04d91ef20810ff1d6321462a04cfa0x60806040142612982022-02-23 8:36:15217 days 13 hrs ago0x599fee527720d7539e7b67a0048ef88f8c4680d2 IN  Create: MantleFinanceV10 Ether0.17792865 43.21027037
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MantleFinanceV1

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 16 : mantle_v1.sol
pragma solidity ^0.8.0;
// SPDX-License-Identifier: MIT

//Mantle Finance - https://mantlefi.com/
//
//                      ooO
//                     ooOOOo
//                   oOOOOOOoooo
//                 ooOOOooo  oooo
//                /vvv V\
//               /V V   V\ 
//              /V  V    V\          
//             /           \          ALL HAIL LIQUIDITY!!!!!
//            /             \               /
//           /               \   	 o          o
//          /                 \     /-   o     /-
//  /\     /                   \   /\  -/-    /\
//                                     /\

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";

interface IRoyaltyFeeManager {
    function calculateRoyaltyFeeAndGetRecipient(
        address collection,
        uint256 tokenId,
        uint256 amount
    ) external view returns (address, uint256);
}

//Mantle Finance - NFT Collateralized P2P Lending Contract, Part of the logic refers to the contract of https://opensea.io/, https://nftfi.com/, https://looksrare.org/
contract MantleFinanceV1 is Ownable, ERC721, ReentrancyGuard, Pausable {
    using Strings for uint256;
    using SafeMath for uint256;
    using ECDSA for bytes32;

    // NOTE: these hashes are derived and verified in the constructor.
    // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
    bytes32 private constant _EIP_712_DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
    // keccak256("MantleFinanceV1")
    bytes32 private constant _NAME_HASH = 0xaba6aa90b1d7c4077fcd4112d89757c977ec45dd567696446208806c35fa3fe3;
    // keccak256(bytes("1"))
    bytes32 private constant _VERSION_HASH = 0xc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6;
    bytes32 private constant _BORROWER_TYPEHASH = 0x107182850da2230853efed1dfd0ea3fd85b39a3b9b0a5381ea9fd5dba147aac0;
    bytes32 private constant _LENDER_TYPEHASH = 0x1f0d56b2c9f2a40bbf20b01d1b8dcfe864e4dba64eb65c598bb0de477236473a;


    //This contract complies with the ERC-721 standard, and Lender will get a Promissory Note NFT on each Loan begin. 
    //This NFT is also destroyed during repayment and claimed.
    //Note that transferring this PN means that you no longer have the rights to claim and get repayment.
    constructor() ERC721("Mantle Fianace Promissory Note", "Mantle PN") {
        require(keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)") == _EIP_712_DOMAIN_TYPEHASH, "_EIP_712_DOMAIN_TYPEHASH error");
        require(keccak256(bytes("MantleFinanceV1")) == _NAME_HASH, "_NAME_HASH error");
        require(keccak256(bytes("1")) == _VERSION_HASH, "_VERSION_HASH error");
        require(keccak256("BorrowerOrder(uint256 nftCollateralId,uint256 borrowerNonce,address nftCollateralContract,address borrower,uint256 expireTime,uint256 chainId)") == _BORROWER_TYPEHASH, "_BORROWER_TYPEHASH error");
        require(keccak256("LenderOrder(uint256 loanPrincipalAmount,uint256 repaymentAmount,uint256 nftCollateralId,uint256 loanDuration,uint256 adminFee,uint256 lenderNonce,address nftCollateralContract,address loanERC20,address lender,uint256 expireTime,uint256 chainId)") == _LENDER_TYPEHASH, "_LENDER_TYPEHASH error");
    }

    //Whitelist of NFT projects and ERC-20 
    mapping (address => bool) public whitelistForAllowedERC20;
    mapping (address => bool) public whitelistForAllowedNFT;

    //The current total loan and the ongoing loans in the protocol
    uint256 public totalNumLoans = 0;
    uint256 public totalActiveLoans = 0;

    //This is where the loans are actually stored in the protocol.
    //Note that we separate whether the claimed or repayment have been done. 
    //The content of loanIdToLoan will be deleted during repayment and claimed.
    mapping (uint256 => Loan) public loanIdToLoan;
    mapping (uint256 => bool) public loanRepaidOrClaimed;

    //Royalty Fee Manager, refers to the structure of https://looksrare.org/
    IRoyaltyFeeManager public royaltyFeeManager;

    //The fees charged from the protocol, note: the fees are charged to Lender at the time of repayment. (25 = 0.25%, 100 = 1%)
    uint256 public adminFee = 500;

    //The protocol uses its own Nonce to maintain security, avoid duplication of signatures and reduce gas costs
    mapping (address => mapping (uint256 => bool)) private _nonceOfSigning;

    //Other parameters
    uint256 public maximumLoanDuration = 53 weeks;
    uint256 public maximumNumberOfActiveLoans = 100;

    string private _baseURIExtended;

    struct Loan {
        uint256 loanId;
        uint256 loanPrincipalAmount;
        uint256 repaymentAmount;
        uint256 nftCollateralId;
        uint64 loanStartTime;
        uint32 loanDuration;
        uint32 loanAdminFee;
        address[2] nftCollateralContractAndloanERC20;
        address borrower;
    }

    struct BorrowerOrder {
        uint256 nftCollateralId;
        uint256 borrowerNonce;
        address nftCollateralContract;
        address borrower;
        uint256 expireTime;
        uint256 chainId;
    }

    struct LenderOrder {
        uint256 loanPrincipalAmount;
        uint256 repaymentAmount;
        uint256 nftCollateralId;
        uint256 loanDuration;
        uint256 adminFee;
        uint256 lenderNonce;
        address nftCollateralContract;
        address loanERC20;
        address lender;
        uint256 expireTime;
        uint256 chainId;
    }


    //Events

    event LoanStarted(
        uint256 loanId,
        address borrower,
        address lender,
        uint256 loanPrincipalAmount,
        uint256 maximumRepaymentAmount,
        uint256 nftCollateralId,
        uint256 loanStartTime,
        uint256 loanDuration,
        address nftCollateralContract,
        address loanERC20Denomination
    );

    event LoanRepaid(
        uint256 loanId,
        address borrower,
        address lender,
        uint256[2] loanPrincipalAmountAndRepaymentAmount,
        uint256 nftCollateralId,
        uint256[3] amountPaidToLenderAndAdminFeeAndRoyaltyFee,
        address[2] nftCollateralContractAndloanERC20Denomination
    );

    event LoanClaimed(
        uint256 loanId,
        address borrower,
        address lender,
        uint256 loanPrincipalAmount,
        uint256 nftCollateralId,
        uint256 loanMaturityDate,
        uint256 loanClaimedDate,
        address nftCollateralContract
    );

    event AdminFeeUpdated(
        uint256 newAdminFee
    );

    event NonceUsed(
        address user,
        uint nonce
    );

    event NewRoyaltyFeeManager(
        address indexed royaltyFeeManager
    );

    event RoyaltyPayment(
        address indexed collection,
        uint256 indexed tokenId,
        address indexed royaltyRecipient,
        address currency,
        uint256 amount
    );

    //Main function
   
    function beginLoan(
        uint256 _loanPrincipalAmount,
        uint256 _repaymentAmount,
        uint256 _nftCollateralId,
        uint256 _loanDuration,
        uint256 _adminFee,
        uint256[2] memory _borrowerAndLenderNonces,
        address[2] memory _contract,
        address _lender,
        uint256[2] memory _ExpireTime,
        bytes memory _borrowerSignature,
        bytes memory _lenderSignature
    ) public whenNotPaused nonReentrant {

        //Whitelist check
        require(whitelistForAllowedNFT[_contract[0]], 'This NFT project is currently not on the ERC-721 whitelist'); 
        require(whitelistForAllowedERC20[_contract[1]], 'This ERC-20 token is currently not on the ERC-20 whitelist');

        //Lending logic check
        require(maximumLoanDuration >= _loanDuration, 'The loan period must shorter than the protocol limit');
        require(_repaymentAmount >= _loanPrincipalAmount, 'Protocol does not accept negative interest rate loan cases');
        require(_loanDuration >= 0, 'Loan duration needs to be set');
        require(_adminFee == adminFee, 'The admin fee in signature is different from the preset, and lender needs to sign again');

        //Nonce check
        require(_nonceOfSigning[msg.sender][_borrowerAndLenderNonces[0]] == false, 'Borrowers Nonce has been used. The order has been established, or Borrower has cancelled the Offer');
        require(_nonceOfSigning[_lender][_borrowerAndLenderNonces[1]] == false, 'Lenders Nonce has been used. The order has been established, or Lender has cancelled the listing');

        //Set borrower and Lender's Nonce to use state
        _nonceOfSigning[msg.sender][_borrowerAndLenderNonces[0]] = true;
        _nonceOfSigning[_lender][_borrowerAndLenderNonces[1]] = true;

        Loan memory loan = Loan({
            loanId: totalNumLoans, //currentLoanId,
            loanPrincipalAmount: _loanPrincipalAmount,
            repaymentAmount: _repaymentAmount,
            nftCollateralId: _nftCollateralId,
            loanStartTime: uint64(block.timestamp), //_loanStartTime
            loanDuration: uint32(_loanDuration),
            loanAdminFee: uint32(_adminFee),
            nftCollateralContractAndloanERC20: _contract,
            borrower: msg.sender //borrower
        });

        //Check Borrower's signature, double-check if borrower wants to lend this NFT, and check if the signature has expired
        require(isValidBorrowerSignature(
            loan.nftCollateralId,
            _borrowerAndLenderNonces[0],//_borrowerNonce,
            loan.nftCollateralContractAndloanERC20[0],
            msg.sender,      //borrower,
            _ExpireTime[0],
            _borrowerSignature
        ), 'Borrower signature is invalid');

        //Check Lender's signature, confirm again whether lender has Offer this NFT, and confirm whether the signature has expired
        require(isValidLenderSignature(
            loan.loanPrincipalAmount,
            loan.repaymentAmount,
            loan.nftCollateralId,
            loan.loanDuration,
            loan.loanAdminFee,
            _borrowerAndLenderNonces[1],//_lenderNonce,
            loan.nftCollateralContractAndloanERC20,
            _lender,
            _ExpireTime[1],
            _lenderSignature
        ), 'Lender signature is invalid');

        //Put Loan into the mapping
        loanIdToLoan[totalNumLoans] = loan;
        totalNumLoans = totalNumLoans.add(1);
        totalActiveLoans = totalActiveLoans.add(1);
        require(totalActiveLoans <= maximumNumberOfActiveLoans, 'Contract has reached the maximum number of active loans allowed by admins');

        //Transfer fund and collateralized NFT to the protocol
        IERC721(loan.nftCollateralContractAndloanERC20[0]).transferFrom(msg.sender, address(this), loan.nftCollateralId);
        IERC20(loan.nftCollateralContractAndloanERC20[1]).transferFrom(_lender, msg.sender, loan.loanPrincipalAmount);

        //Mint Mantle Fianance 的 Promissory Note
        //Lenders have to be aware that the system will perform claimed and repayment according to the owner of this note
        _mint(_lender, loan.loanId);
        
        emit LoanStarted(
            loan.loanId,
            msg.sender,      //borrower,
            _lender,
            loan.loanPrincipalAmount,
            loan.repaymentAmount,
            loan.nftCollateralId,
            block.timestamp,             //_loanStartTime
            loan.loanDuration,
            loan.nftCollateralContractAndloanERC20[0],
            loan.nftCollateralContractAndloanERC20[1]
        );

        emit NonceUsed(
            msg.sender,
            _borrowerAndLenderNonces[0]
        );

        emit NonceUsed(
            _lender,
            _borrowerAndLenderNonces[1]
        );
    }

    function payBackLoan(uint256 _loanId) external nonReentrant {
        //Check if the loan has been repaid, or claimed
        require(loanRepaidOrClaimed[_loanId] == false, 'Loan has already been repaid or claimed');
        loanRepaidOrClaimed[_loanId] = true;

        //Get detail in the loan
        Loan memory loan = loanIdToLoan[_loanId];
        require(msg.sender == loan.borrower, 'Only the borrower can pay back a loan and reclaim the underlying NFT');

        //Take the final lender of this Loan and repay
        address lender = ownerOf(_loanId);
        uint256 interestDue = (loan.repaymentAmount).sub(loan.loanPrincipalAmount);

        uint256 adminFeePay = _computeAdminFee(interestDue, uint256(loan.loanAdminFee));
        
        (address royaltyFeeRecipient, uint256 royaltyFeeAmount) = royaltyFeeManager.calculateRoyaltyFeeAndGetRecipient(loan.nftCollateralContractAndloanERC20[0], loan.nftCollateralId, interestDue);

        if ((royaltyFeeRecipient != address(0)) && (royaltyFeeAmount != 0)) {
            IERC20(loan.nftCollateralContractAndloanERC20[1]).transferFrom(loan.borrower, royaltyFeeRecipient, royaltyFeeAmount);

            emit RoyaltyPayment(loan.nftCollateralContractAndloanERC20[0], loan.nftCollateralId, royaltyFeeRecipient, loan.nftCollateralContractAndloanERC20[1], royaltyFeeAmount);
        }
        
        uint256 payoffAmount = ((loan.loanPrincipalAmount).add(interestDue)).sub(adminFeePay).sub(royaltyFeeAmount);

        //Reduce the amount of ongoing loans in the protocol
        totalActiveLoans = totalActiveLoans.sub(1);

        //Transfer fee and return funds
        IERC20(loan.nftCollateralContractAndloanERC20[1]).transferFrom(loan.borrower, lender, payoffAmount);
        IERC20(loan.nftCollateralContractAndloanERC20[1]).transferFrom(loan.borrower, owner(), adminFeePay);

        //Burn Mantle Finance Promissory Note
        _burn(_loanId);

        //Transfer the collateralized NFT to Borrower
        require(_transferNftToAddress(
            loan.nftCollateralContractAndloanERC20[0],
            loan.nftCollateralId,
            loan.borrower
        ), 'NFT was not successfully transferred');

        emit LoanRepaid(
            _loanId,
            loan.borrower,
            lender,
            [loan.loanPrincipalAmount, loan.repaymentAmount],
            loan.nftCollateralId,
            [payoffAmount, adminFee, royaltyFeeAmount],
            [loan.nftCollateralContractAndloanERC20[0], loan.nftCollateralContractAndloanERC20[1]]
        );

        delete loanIdToLoan[_loanId];
    }

    function claimOverdueLoan(uint256 _loanId) external nonReentrant {
        //Check if the loan has been repaid, or claimeded
        require(loanRepaidOrClaimed[_loanId] == false, 'Loan has already been repaid or claimed');
        loanRepaidOrClaimed[_loanId] = true;

        //Get detail in the loan and check if it's overdue and can be claimed
        Loan memory loan = loanIdToLoan[_loanId];
        uint256 loanMaturityDate = (uint256(loan.loanStartTime)).add(uint256(loan.loanDuration));
        require(block.timestamp > loanMaturityDate, 'Loan is not overdue yet');

        //Reduce the amount of ongoing loans in the protocol
        totalActiveLoans = totalActiveLoans.sub(1);

        //Take the final lender of this Loan and claim nft
        address lender = ownerOf(_loanId);

        require(_transferNftToAddress(
            loan.nftCollateralContractAndloanERC20[0],
            loan.nftCollateralId,
            lender
        ), 'NFT was not successfully transferred');

        //Burn Mantle Finance Promissory Note
        _burn(_loanId);

        emit LoanClaimed(
            _loanId,
            loan.borrower,
            lender,
            loan.loanPrincipalAmount,
            loan.nftCollateralId,
            loanMaturityDate,
            block.timestamp,
            loan.nftCollateralContractAndloanERC20[0]
        );

         delete loanIdToLoan[_loanId];
    }

    function setNonceUsed(uint256 _nonce) external {
        require(_nonceOfSigning[msg.sender][_nonce] == false, 'This Nonce has been used, the order has been established, or the Offer has been cancelled');
        _nonceOfSigning[msg.sender][_nonce] = true;

        emit NonceUsed(
            msg.sender,
            _nonce
        );
    }

    //Admin

    function setWhitelistERC20(address _erc20, bool _bool) external onlyOwner {
        whitelistForAllowedERC20[_erc20] = _bool;
    }

    function setWhitelistNFTContract(address _erc721, bool _bool) external onlyOwner {
        whitelistForAllowedNFT[_erc721] = _bool;
    }

    function updateMaximumLoanDuration(uint256 _newMaximumLoanDuration) external onlyOwner {
        require(_newMaximumLoanDuration <= uint256(~uint32(0)), 'loan duration cannot exceed space alotted in struct');
        maximumLoanDuration = _newMaximumLoanDuration;
    }

    function updateMaximumNumberOfActiveLoans(uint256 _newMaximumNumberOfActiveLoans) external onlyOwner {
        maximumNumberOfActiveLoans = _newMaximumNumberOfActiveLoans;
    }

    function updateAdminFee(uint256 _newAdminFee) external onlyOwner {
        require(_newAdminFee <= 10000, 'By definition, basis points cannot exceed 10000');
        adminFee = _newAdminFee;
        emit AdminFeeUpdated(_newAdminFee);
    }

    function updateRoyaltyFeeManager(address _royaltyFeeManager) external onlyOwner {
        require(_royaltyFeeManager != address(0), "Owner: Cannot be null address");
        royaltyFeeManager = IRoyaltyFeeManager(_royaltyFeeManager);
        emit NewRoyaltyFeeManager(_royaltyFeeManager);
    }

    //View

    function isValidBorrowerSignature(
        uint256 _nftCollateralId,
        uint256 _borrowerNonce,
        address _nftCollateralContract,
        address _borrower,
        uint256 _expireTime,
        bytes memory _borrowerSignature
    ) public view returns(bool) {
        if(_borrower == address(0)){
            return false;
        } else {
            uint256 chainId;
            chainId = getChainID();
            BorrowerOrder memory order = BorrowerOrder({
                nftCollateralId: _nftCollateralId,
                borrowerNonce: _borrowerNonce,
                nftCollateralContract: _nftCollateralContract,
                borrower: _borrower,
                expireTime: _expireTime,
                chainId: chainId
            });

            bytes32 messageWithEthSignPrefix = borrowerHashToSign(order);

            if(block.timestamp < _expireTime){
                return (messageWithEthSignPrefix.recover(_borrowerSignature) == _borrower);
            }else{
                return false;
            }
        }
    }

    function isValidLenderSignature(
        uint256 _loanPrincipalAmount,
        uint256 _repaymentAmount,
        uint256 _nftCollateralId,
        uint256 _loanDuration,
        uint256 _adminFee,
        uint256 _lenderNonce,
        address[2] memory _nftCollateralContractAndloanERC20,
        address _lender,
        uint256 _expireTime,
        bytes memory _lenderSignature
    ) public view returns(bool) {
        if(_lender == address(0)){
            return false;
        } else {
            uint256 chainId;
            chainId = getChainID();
            LenderOrder memory order = LenderOrder({
                loanPrincipalAmount: _loanPrincipalAmount,
                repaymentAmount: _repaymentAmount,
                nftCollateralId: _nftCollateralId,
                loanDuration: _loanDuration,
                adminFee: _adminFee,
                lenderNonce: _lenderNonce,
                nftCollateralContract: _nftCollateralContractAndloanERC20[0],
                loanERC20: _nftCollateralContractAndloanERC20[1],
                lender: _lender,
                expireTime: _expireTime,
                chainId: chainId
            });

            bytes32 messageWithEthSignPrefix = lenderHashToSign(order);
            if(block.timestamp < _expireTime){
                return (messageWithEthSignPrefix.recover(_lenderSignature) == _lender);
            }else{
                return false;
            }
        }
    }

    function getNonceIsUsed(address _user, uint256 _nonce) public view returns (bool) {
        return _nonceOfSigning[_user][_nonce];
    }

    function getChainID() public view returns (uint256) {
        uint256 id;
        assembly {
            id := chainid()
        }
        return id;
    }

    //Internal

    function _computeAdminFee(uint256 _interestDue, uint256 _adminFee) internal pure returns (uint256) {
    	return (_interestDue.mul(_adminFee)).div(10000);
    }

    function _transferNftToAddress(address _nftContract, uint256 _nftId, address _recipient) internal returns (bool) {
        // Agree that the ERC-721 contract is willing to let this contract transfer
        _nftContract.call(abi.encodeWithSelector(IERC721(_nftContract).approve.selector, address(this), _nftId));

        (bool success, ) = _nftContract.call(abi.encodeWithSelector(IERC721(_nftContract).transferFrom.selector, address(this), _recipient, _nftId));
        return success;
    }

    /**
     * @dev Derive the domain separator for EIP-712 signatures.
     * @return The domain separator.
     */
    function _deriveDomainSeparator() private view returns (bytes32) {
        uint256 chainId;
        chainId = getChainID();
        return keccak256(
            abi.encode(
                _EIP_712_DOMAIN_TYPEHASH, // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
                _NAME_HASH, // keccak256("MantleFinanceV1")
                _VERSION_HASH, // keccak256(bytes("1"))
                chainId, // NOTE: this is fixed, need to use solidity 0.5+ or make external call to support!
                address(this)
            )
        );
    }
    
    /**
     * @dev Hash an order, returning the hash that a client must sign via EIP-712 including the message prefix
     * @param order Order to hash
     * @return Hash of message prefix and order hash per Ethereum format
     */
    function borrowerHashToSign(BorrowerOrder memory order)
        internal
        view
        returns (bytes32)
    {
        return keccak256(
            abi.encodePacked("\x19\x01", _deriveDomainSeparator(), keccak256(abi.encode(_BORROWER_TYPEHASH,order))
        ));
    }
    
    function lenderHashToSign(LenderOrder memory order)
        internal
        view
        returns (bytes32)
    {
        return keccak256(
            abi.encodePacked("\x19\x01", _deriveDomainSeparator(), keccak256(abi.encode(_LENDER_TYPEHASH,order))
        ));
    }

    function setBaseURI(string memory baseURI_) external onlyOwner {
        _baseURIExtended = baseURI_;
    }

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

    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), 'ERC721Metadata: URI query for nonexistent token');
        return string(abi.encodePacked(_baseURI(), tokenId.toString()));
    }

    /**
     * @dev called by the owner to pause, triggers stopped state
     */
    function pause() public onlyOwner whenNotPaused {
        _pause();
        emit Paused(msg.sender);
    }

    /**
     * @dev called by the owner to unpause, returns to normal state
     */
    function unpause() public onlyOwner whenPaused {
        _unpause();
        emit Unpaused(msg.sender);
    }

    fallback() external payable {
        revert();
    }
}

File 2 of 16 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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
    }

    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");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' 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) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        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.
            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 if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } 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 (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // 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 3 of 16 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 4 of 16 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 5 of 16 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

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

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

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

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

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

File 6 of 16 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        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 7 of 16 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

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

File 8 of 16 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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`, 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 be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

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

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

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

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

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _beforeTokenTransfer(from, to, tokenId);

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

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

        emit Transfer(from, to, tokenId);

        _afterTokenTransfer(from, to, tokenId);
    }

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

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

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

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

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

File 10 of 16 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

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

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

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

File 11 of 16 : 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 12 of 16 : 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 13 of 16 : 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 14 of 16 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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 functionCall(target, data, "Address: low-level call failed");
    }

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

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

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

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

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

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

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

    /**
     * @dev 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) {
        require(isContract(target), "Address: delegate call to non-contract");

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

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

pragma solidity ^0.8.0;

import "../IERC721.sol";

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

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

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

File 16 of 16 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newAdminFee","type":"uint256"}],"name":"AdminFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"loanId","type":"uint256"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"loanPrincipalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftCollateralId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanMaturityDate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanClaimedDate","type":"uint256"},{"indexed":false,"internalType":"address","name":"nftCollateralContract","type":"address"}],"name":"LoanClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"loanId","type":"uint256"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256[2]","name":"loanPrincipalAmountAndRepaymentAmount","type":"uint256[2]"},{"indexed":false,"internalType":"uint256","name":"nftCollateralId","type":"uint256"},{"indexed":false,"internalType":"uint256[3]","name":"amountPaidToLenderAndAdminFeeAndRoyaltyFee","type":"uint256[3]"},{"indexed":false,"internalType":"address[2]","name":"nftCollateralContractAndloanERC20Denomination","type":"address[2]"}],"name":"LoanRepaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"loanId","type":"uint256"},{"indexed":false,"internalType":"address","name":"borrower","type":"address"},{"indexed":false,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"loanPrincipalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maximumRepaymentAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftCollateralId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanStartTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanDuration","type":"uint256"},{"indexed":false,"internalType":"address","name":"nftCollateralContract","type":"address"},{"indexed":false,"internalType":"address","name":"loanERC20Denomination","type":"address"}],"name":"LoanStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"royaltyFeeManager","type":"address"}],"name":"NewRoyaltyFeeManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"NonceUsed","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"royaltyRecipient","type":"address"},{"indexed":false,"internalType":"address","name":"currency","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RoyaltyPayment","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"adminFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_loanPrincipalAmount","type":"uint256"},{"internalType":"uint256","name":"_repaymentAmount","type":"uint256"},{"internalType":"uint256","name":"_nftCollateralId","type":"uint256"},{"internalType":"uint256","name":"_loanDuration","type":"uint256"},{"internalType":"uint256","name":"_adminFee","type":"uint256"},{"internalType":"uint256[2]","name":"_borrowerAndLenderNonces","type":"uint256[2]"},{"internalType":"address[2]","name":"_contract","type":"address[2]"},{"internalType":"address","name":"_lender","type":"address"},{"internalType":"uint256[2]","name":"_ExpireTime","type":"uint256[2]"},{"internalType":"bytes","name":"_borrowerSignature","type":"bytes"},{"internalType":"bytes","name":"_lenderSignature","type":"bytes"}],"name":"beginLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_loanId","type":"uint256"}],"name":"claimOverdueLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getChainID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"getNonceIsUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftCollateralId","type":"uint256"},{"internalType":"uint256","name":"_borrowerNonce","type":"uint256"},{"internalType":"address","name":"_nftCollateralContract","type":"address"},{"internalType":"address","name":"_borrower","type":"address"},{"internalType":"uint256","name":"_expireTime","type":"uint256"},{"internalType":"bytes","name":"_borrowerSignature","type":"bytes"}],"name":"isValidBorrowerSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_loanPrincipalAmount","type":"uint256"},{"internalType":"uint256","name":"_repaymentAmount","type":"uint256"},{"internalType":"uint256","name":"_nftCollateralId","type":"uint256"},{"internalType":"uint256","name":"_loanDuration","type":"uint256"},{"internalType":"uint256","name":"_adminFee","type":"uint256"},{"internalType":"uint256","name":"_lenderNonce","type":"uint256"},{"internalType":"address[2]","name":"_nftCollateralContractAndloanERC20","type":"address[2]"},{"internalType":"address","name":"_lender","type":"address"},{"internalType":"uint256","name":"_expireTime","type":"uint256"},{"internalType":"bytes","name":"_lenderSignature","type":"bytes"}],"name":"isValidLenderSignature","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"loanIdToLoan","outputs":[{"internalType":"uint256","name":"loanId","type":"uint256"},{"internalType":"uint256","name":"loanPrincipalAmount","type":"uint256"},{"internalType":"uint256","name":"repaymentAmount","type":"uint256"},{"internalType":"uint256","name":"nftCollateralId","type":"uint256"},{"internalType":"uint64","name":"loanStartTime","type":"uint64"},{"internalType":"uint32","name":"loanDuration","type":"uint32"},{"internalType":"uint32","name":"loanAdminFee","type":"uint32"},{"internalType":"address","name":"borrower","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"loanRepaidOrClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumLoanDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maximumNumberOfActiveLoans","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_loanId","type":"uint256"}],"name":"payBackLoan","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"royaltyFeeManager","outputs":[{"internalType":"contract IRoyaltyFeeManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI_","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"setNonceUsed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_erc20","type":"address"},{"internalType":"bool","name":"_bool","type":"bool"}],"name":"setWhitelistERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_erc721","type":"address"},{"internalType":"bool","name":"_bool","type":"bool"}],"name":"setWhitelistNFTContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalActiveLoans","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalNumLoans","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newAdminFee","type":"uint256"}],"name":"updateAdminFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMaximumLoanDuration","type":"uint256"}],"name":"updateMaximumLoanDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMaximumNumberOfActiveLoans","type":"uint256"}],"name":"updateMaximumNumberOfActiveLoans","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_royaltyFeeManager","type":"address"}],"name":"updateRoyaltyFeeManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistForAllowedERC20","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelistForAllowedNFT","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

60806040526000600b556000600c556101f46010556301e91c8060125560646013553480156200002e57600080fd5b506040518060400160405280601e81526020017f4d616e746c65204669616e6163652050726f6d6973736f7279204e6f746500008152506040518060400160405280600981526020016826b0b73a363290282760b91b815250620000a16200009b6200011e60201b60201c565b62000122565b8151620000b690600190602085019062000172565b508051620000cc90600290602084019062000172565b50506001600755506008805460ff19169055604080518082018252600f81526e4d616e746c6546696e616e6365563160881b602091820152815180830190925260018252603160f81b91015262000255565b3390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b828054620001809062000218565b90600052602060002090601f016020900481019282620001a45760008555620001ef565b82601f10620001bf57805160ff1916838001178555620001ef565b82800160010185558215620001ef579182015b82811115620001ef578251825591602001919060010190620001d2565b50620001fd92915062000201565b5090565b5b80821115620001fd576000815560010162000202565b600181811c908216806200022d57607f821691505b602082108114156200024f57634e487b7160e01b600052602260045260246000fd5b50919050565b61466480620002656000396000f3fe6080604052600436106102675760003560e01c806370a0823111610144578063c5498769116100b6578063dc63af411161007a578063dc63af41146107f3578063e5a6034414610809578063e985e9c514610839578063eaccaf6514610882578063f2fde38b14610898578063f5ba51ee146108b857600080fd5b8063c5498769146106a0578063c5bc3b53146106c0578063c81bd7a6146106e0578063c87b56dd146107b3578063cff1b6ef146107d357600080fd5b80638da5cb5b116101085780638da5cb5b146105f757806395d89b4114610615578063a0be06f91461062a578063a22cb46514610640578063b1bb36e114610660578063b88d4fde1461068057600080fd5b806370a082311461056d578063715018a61461058d5780638456cb59146105a25780638495c046146105b757806387e4401f146105d757600080fd5b806342842e0e116101dd5780635c975abb116101a15780635c975abb146104b55780635e0e01d4146104cd5780636352211e146104ed578063643f6e321461050d578063670c1e511461052d5780636faa8b3f1461054d57600080fd5b806342842e0e1461042c57806347948d921461044c57806355f804b31461046c578063564b81ef1461048c5780635794fefc1461049f57600080fd5b80631582593b1161022f5780631582593b14610363578063192b355d146103835780631bd75f1b146103a757806323b872dd146103d757806333e959b5146103f75780633f4ba83a1461041757600080fd5b806301ffc9a71461026c57806306fdde03146102a1578063081812fc146102c357806308805d70146102fb578063095ea7b314610341575b600080fd5b34801561027857600080fd5b5061028c610287366004613da6565b6108e8565b60405190151581526020015b60405180910390f35b3480156102ad57600080fd5b506102b661093a565b60405161029891906141fa565b3480156102cf57600080fd5b506102e36102de366004613e28565b6109cc565b6040516001600160a01b039091168152602001610298565b34801561030757600080fd5b5061028c610316366004613d2f565b6001600160a01b03919091166000908152601160209081526040808320938352929052205460ff1690565b34801561034d57600080fd5b5061036161035c366004613d2f565b610a66565b005b34801561036f57600080fd5b5061028c61037e366004613e41565b610b7c565b34801561038f57600080fd5b5061039960125481565b604051908152602001610298565b3480156103b357600080fd5b5061028c6103c2366004613e28565b600e6020526000908152604090205460ff1681565b3480156103e357600080fd5b506103616103f2366004613c55565b610c2b565b34801561040357600080fd5b50610361610412366004613d01565b610c5c565b34801561042357600080fd5b50610361610cb1565b34801561043857600080fd5b50610361610447366004613c55565b610d62565b34801561045857600080fd5b50610361610467366004613e28565b610d7d565b34801561047857600080fd5b50610361610487366004613de0565b610e1c565b34801561049857600080fd5b5046610399565b3480156104ab57600080fd5b50610399600b5481565b3480156104c157600080fd5b5060085460ff1661028c565b3480156104d957600080fd5b506103616104e8366004613ebe565b610e5d565b3480156104f957600080fd5b506102e3610508366004613e28565b61186f565b34801561051957600080fd5b50610361610528366004613e28565b6118e6565b34801561053957600080fd5b5061028c610548366004613fa0565b611915565b34801561055957600080fd5b50610361610568366004613e28565b611a1e565b34801561057957600080fd5b50610399610588366004613bff565b6120d2565b34801561059957600080fd5b50610361612159565b3480156105ae57600080fd5b5061036161218f565b3480156105c357600080fd5b506103616105d2366004613d01565b612214565b3480156105e357600080fd5b50600f546102e3906001600160a01b031681565b34801561060357600080fd5b506000546001600160a01b03166102e3565b34801561062157600080fd5b506102b6612269565b34801561063657600080fd5b5061039960105481565b34801561064c57600080fd5b5061036161065b366004613d01565b612278565b34801561066c57600080fd5b5061036161067b366004613e28565b612283565b34801561068c57600080fd5b5061036161069b366004613c96565b612399565b3480156106ac57600080fd5b506103616106bb366004613bff565b6123d1565b3480156106cc57600080fd5b506103616106db366004613e28565b61249b565b3480156106ec57600080fd5b5061075d6106fb366004613e28565b600d6020526000908152604090208054600182015460028301546003840154600485015460079095015493949293919290916001600160401b0382169163ffffffff600160401b8204811692600160601b90920416906001600160a01b031688565b6040805198895260208901979097529587019490945260608601929092526001600160401b0316608085015263ffffffff90811660a08501521660c08301526001600160a01b031660e082015261010001610298565b3480156107bf57600080fd5b506102b66107ce366004613e28565b6127aa565b3480156107df57600080fd5b506103616107ee366004613e28565b612861565b3480156107ff57600080fd5b50610399600c5481565b34801561081557600080fd5b5061028c610824366004613bff565b600a6020526000908152604090205460ff1681565b34801561084557600080fd5b5061028c610854366004613c1c565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b34801561088e57600080fd5b5061039960135481565b3480156108a457600080fd5b506103616108b3366004613bff565b61292a565b3480156108c457600080fd5b5061028c6108d3366004613bff565b60096020526000908152604090205460ff1681565b60006001600160e01b031982166380ac58cd60e01b148061091957506001600160e01b03198216635b5e139f60e01b145b8061093457506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600180546109499061451d565b80601f01602080910402602001604051908101604052809291908181526020018280546109759061451d565b80156109c25780601f10610997576101008083540402835291602001916109c2565b820191906000526020600020905b8154815290600101906020018083116109a557829003601f168201915b5050505050905090565b6000818152600360205260408120546001600160a01b0316610a4a5760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600560205260409020546001600160a01b031690565b6000610a718261186f565b9050806001600160a01b0316836001600160a01b03161415610adf5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b6064820152608401610a41565b336001600160a01b0382161480610afb5750610afb8133610854565b610b6d5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c00000000000000006064820152608401610a41565b610b7783836129c5565b505050565b60006001600160a01b038416610b9457506000610c21565b600046905060006040518060c001604052808a8152602001898152602001886001600160a01b03168152602001876001600160a01b031681526020018681526020018381525090506000610be782612a33565b905085421015610c19576001600160a01b038716610c058287612b14565b6001600160a01b0316149350505050610c21565b600093505050505b9695505050505050565b610c353382612b38565b610c515760405162461bcd60e51b8152600401610a4190614349565b610b77838383612c2f565b6000546001600160a01b03163314610c865760405162461bcd60e51b8152600401610a4190614314565b6001600160a01b03919091166000908152600960205260409020805460ff1916911515919091179055565b6000546001600160a01b03163314610cdb5760405162461bcd60e51b8152600401610a4190614314565b60085460ff16610d245760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a41565b610d2c612dcb565b6040513381527f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa906020015b60405180910390a1565b610b7783838360405180602001604052806000815250612399565b6000546001600160a01b03163314610da75760405162461bcd60e51b8152600401610a4190614314565b63ffffffff811115610e175760405162461bcd60e51b815260206004820152603360248201527f6c6f616e206475726174696f6e2063616e6e6f742065786365656420737061636044820152721948185b1bdd1d1959081a5b881cdd1c9d58dd606a1b6064820152608401610a41565b601255565b6000546001600160a01b03163314610e465760405162461bcd60e51b8152600401610a4190614314565b8051610e599060149060208401906139ca565b5050565b60085460ff1615610e805760405162461bcd60e51b8152600401610a41906142a3565b60026007541415610ea35760405162461bcd60e51b8152600401610a419061439a565b600260075584516001600160a01b03166000908152600a602052604090205460ff16610f375760405162461bcd60e51b815260206004820152603a60248201527f54686973204e46542070726f6a6563742069732063757272656e746c79206e6f60448201527f74206f6e20746865204552432d3732312077686974656c6973740000000000006064820152608401610a41565b6020808601516001600160a01b031660009081526009909152604090205460ff16610fca5760405162461bcd60e51b815260206004820152603a60248201527f54686973204552432d323020746f6b656e2069732063757272656e746c79206e60448201527f6f74206f6e20746865204552432d32302077686974656c6973740000000000006064820152608401610a41565b8760125410156110395760405162461bcd60e51b815260206004820152603460248201527f546865206c6f616e20706572696f64206d7573742073686f72746572207468616044820152731b881d1a19481c1c9bdd1bd8dbdb081b1a5b5a5d60621b6064820152608401610a41565b8a8a10156110af5760405162461bcd60e51b815260206004820152603a60248201527f50726f746f636f6c20646f6573206e6f7420616363657074206e65676174697660448201527f6520696e7465726573742072617465206c6f616e2063617365730000000000006064820152608401610a41565b601054871461114c5760405162461bcd60e51b815260206004820152605760248201527f5468652061646d696e2066656520696e207369676e617475726520697320646960448201527f66666572656e742066726f6d20746865207072657365742c20616e64206c656e60648201527f646572206e6565647320746f207369676e20616761696e000000000000000000608482015260a401610a41565b3360009081526011602090815260408083208951845290915290205460ff161561120f5760405162461bcd60e51b815260206004820152606260248201527f426f72726f77657273204e6f6e636520686173206265656e20757365642e205460448201527f6865206f7264657220686173206265656e2065737461626c69736865642c206f60648201527f7220426f72726f776572206861732063616e63656c6c656420746865204f666660848201526132b960f11b60a482015260c401610a41565b6001600160a01b038416600090815260116020908152604080832089830151845290915290205460ff16156112d25760405162461bcd60e51b815260206004820152606060248201527f4c656e64657273204e6f6e636520686173206265656e20757365642e2054686560448201527f206f7264657220686173206265656e2065737461626c69736865642c206f722060648201527f4c656e646572206861732063616e63656c6c656420746865206c697374696e67608482015260a401610a41565b3360008181526011602081815260408084208b51855282528084208054600160ff1991821681179092556001600160a01b038b1686529383528185208c84015186528352938190208054909316909317909155815161012081018352600b5481529081018e90529081018c9052606081018b9052426001600160401b0316608082015263ffffffff8a811660a0830152891660c082015260e081018790526101008101829052875187518651929361138f938e9392919088610b7c565b6113db5760405162461bcd60e51b815260206004820152601d60248201527f426f72726f776572207369676e617475726520697320696e76616c69640000006044820152606401610a41565b61142f8160200151826040015183606001518460a0015163ffffffff168560c0015163ffffffff168c600160028110611416576114166145c9565b602002015160e08801518c8c600160200201518b611915565b61147b5760405162461bcd60e51b815260206004820152601b60248201527f4c656e646572207369676e617475726520697320696e76616c696400000000006044820152606401610a41565b600b546000908152600d6020908152604091829020835181559083015160018201559082015160028083019190915560608301516003830155608083015160048301805460a086015160c08701516001600160401b039094166bffffffffffffffffffffffff1990921691909117600160401b63ffffffff928316021763ffffffff60601b1916600160601b919093160291909117905560e0830151839291611528916005840191613a4e565b506101009190910151600790910180546001600160a01b0319166001600160a01b03909216919091179055600b54611561906001612e59565b600b55600c54611572906001612e59565b600c81905560135410156116005760405162461bcd60e51b815260206004820152604960248201527f436f6e747261637420686173207265616368656420746865206d6178696d756d60448201527f206e756d626572206f6620616374697665206c6f616e7320616c6c6f7765642060648201526862792061646d696e7360b81b608482015260a401610a41565b60e08101515160608201516040516323b872dd60e01b81526001600160a01b03909216916323b872dd9161163a91339130916004016140ea565b600060405180830381600087803b15801561165457600080fd5b505af1158015611668573d6000803e3d6000fd5b5050505060e0810151602090810151908201516040516323b872dd60e01b81526001600160a01b03909216916323b872dd916116aa91899133916004016140ea565b602060405180830381600087803b1580156116c457600080fd5b505af11580156116d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116fc9190613d89565b5061170b858260000151612e6c565b7f336358a9d4ae2e712e954197ce98726d99e37a99478cbd2a4e0101eb8b5a10db81600001513387846020015185604001518660600151428860a001518960e0015160006002811061175f5761175f6145c9565b602002015160e08b0151600160209081029190910151604080519b8c526001600160a01b039a8b16928c0192909252978916908a01526060890195909552608088019390935260a087019190915260c086015263ffffffff1660e08501528216610100840152166101208201526101400160405180910390a186516040805133815260208101929092527f2af71f10069c28afc67c3752e87e0e4616a97948d33c8f404a856c0c334b3e01910160405180910390a1602080880151604080516001600160a01b0389168152928301919091527f2af71f10069c28afc67c3752e87e0e4616a97948d33c8f404a856c0c334b3e01910160405180910390a15050600160075550505050505050505050565b6000818152600360205260408120546001600160a01b0316806109345760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610a41565b6000546001600160a01b031633146119105760405162461bcd60e51b8152600401610a4190614314565b601355565b60006001600160a01b03841661192d57506000611a10565b600046905060006040518061016001604052808e81526020018d81526020018c81526020018b81526020018a815260200189815260200188600060028110611977576119776145c9565b60200201516001600160a01b031681526020018860016002811061199d5761199d6145c9565b60200201516001600160a01b03168152602001876001600160a01b0316815260200186815260200183815250905060006119d682612fae565b905085421015611a08576001600160a01b0387166119f48287612b14565b6001600160a01b0316149350505050611a10565b600093505050505b9a9950505050505050505050565b60026007541415611a415760405162461bcd60e51b8152600401610a419061439a565b60026007556000818152600e602052604090205460ff1615611a755760405162461bcd60e51b8152600401610a41906142cd565b6000818152600e60209081526040808320805460ff19166001908117909155600d8352818420825161012081018452815481529181015493820193909352600280840154828401526003840154606083015260048401546001600160401b038116608084015263ffffffff600160401b8204811660a0850152600160601b9091041660c083015282518084019384905291939260e085019291600585019182845b81546001600160a01b03168152600190910190602001808311611b16575050509183525050600791909101546001600160a01b03908116602090920191909152610100820151919250163314611be25760405162461bcd60e51b8152602060048201526044602482018190527f4f6e6c792074686520626f72726f7765722063616e20706179206261636b2061908201527f206c6f616e20616e64207265636c61696d2074686520756e6465726c79696e676064820152630813919560e21b608482015260a401610a41565b6000611bed8361186f565b90506000611c0c83602001518460400151612feb90919063ffffffff16565b90506000611c24828560c0015163ffffffff16612ff7565b600f5460e0860151516060870151604051637a7b1afd60e11b81526001600160a01b0392831660048201526024810191909152604481018690529293506000928392919091169063f4f635fa90606401604080518083038186803b158015611c8b57600080fd5b505afa158015611c9f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cc39190613d5b565b90925090506001600160a01b03821615801590611cdf57508015155b15611dd45760e0860151602001516101008701516040516323b872dd60e01b81526001600160a01b03909216916323b872dd91611d2291869086906004016140ea565b602060405180830381600087803b158015611d3c57600080fd5b505af1158015611d50573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d749190613d89565b50606086015160e08701518051602091820151604080516001600160a01b039283168152938401869052868216949391909216917f27c4f0403323142b599832f26acd21c74a9e5b809f2215726e244a4ac588cd7d910160405180910390a45b6000611dfb82611df586611df5898c60200151612e5990919063ffffffff16565b90612feb565b600c54909150611e0c906001612feb565b600c5560e0870151602001516101008801516040516323b872dd60e01b81526001600160a01b03909216916323b872dd91611e4d918a9086906004016140ea565b602060405180830381600087803b158015611e6757600080fd5b505af1158015611e7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e9f9190613d89565b5060e0870151600160200201516001600160a01b03166323b872dd886101000151611ed26000546001600160a01b031690565b876040518463ffffffff1660e01b8152600401611ef1939291906140ea565b602060405180830381600087803b158015611f0b57600080fd5b505af1158015611f1f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f439190613d89565b50611f4d8861300f565b60e0870151516060880151610100890151611f699291906130aa565b611f855760405162461bcd60e51b8152600401610a419061425f565b7f071379c612e3408927d1518bc971d715322af6826b555652cc2f228122f4f0d9888861010001518860405180604001604052808c6020015181526020018c604001518152508b60600151604051806060016040528088815260200160105481526020018981525060405180604001604052808f60e0015160006002811061200f5761200f6145c9565b60200201516001600160a01b03166001600160a01b031681526020018f60e00151600160028110612042576120426145c9565b60200201516001600160a01b0316905260405161206597969594939291906143d1565b60405180910390a150505060009485525050600d602052505060408120818155600180820183905560028201839055600382018390556004820180546001600160801b0319169055600582018390556006820192909255600790810180546001600160a01b031916905555565b60006001600160a01b03821661213d5760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610a41565b506001600160a01b031660009081526004602052604090205490565b6000546001600160a01b031633146121835760405162461bcd60e51b8152600401610a4190614314565b61218d60006131fb565b565b6000546001600160a01b031633146121b95760405162461bcd60e51b8152600401610a4190614314565b60085460ff16156121dc5760405162461bcd60e51b8152600401610a41906142a3565b6121e461324b565b6040513381527f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25890602001610d58565b6000546001600160a01b0316331461223e5760405162461bcd60e51b8152600401610a4190614314565b6001600160a01b03919091166000908152600a60205260409020805460ff1916911515919091179055565b6060600280546109499061451d565b610e593383836132a3565b33600090815260116020908152604080832084845290915290205460ff161561233a5760405162461bcd60e51b815260206004820152605960248201527f54686973204e6f6e636520686173206265656e20757365642c20746865206f7260448201527f64657220686173206265656e2065737461626c69736865642c206f722074686560648201527f204f6666657220686173206265656e2063616e63656c6c656400000000000000608482015260a401610a41565b336000818152601160209081526040808320858452825291829020805460ff19166001179055815192835282018390527f2af71f10069c28afc67c3752e87e0e4616a97948d33c8f404a856c0c334b3e0191015b60405180910390a150565b6123a33383612b38565b6123bf5760405162461bcd60e51b8152600401610a4190614349565b6123cb84848484613372565b50505050565b6000546001600160a01b031633146123fb5760405162461bcd60e51b8152600401610a4190614314565b6001600160a01b0381166124515760405162461bcd60e51b815260206004820152601d60248201527f4f776e65723a2043616e6e6f74206265206e756c6c20616464726573730000006044820152606401610a41565b600f80546001600160a01b0319166001600160a01b0383169081179091556040517f80e3874461ebbd918ac3e81da0a92e5e51387d70f337237c9123e48d20e5a50890600090a250565b600260075414156124be5760405162461bcd60e51b8152600401610a419061439a565b60026007556000818152600e602052604090205460ff16156124f25760405162461bcd60e51b8152600401610a41906142cd565b6000818152600e60209081526040808320805460ff19166001908117909155600d8352818420825161012081018452815481529181015493820193909352600280840154828401526003840154606083015260048401546001600160401b038116608084015263ffffffff600160401b8204811660a0850152600160601b9091041660c083015282518084019384905291939260e085019291600585019182845b81546001600160a01b03168152600190910190602001808311612593575050509183525050600791909101546001600160a01b031660209091015260a081015160808201519192506000916125fd916001600160401b039091169063ffffffff90811690612e5916565b905080421161264e5760405162461bcd60e51b815260206004820152601760248201527f4c6f616e206973206e6f74206f766572647565207965740000000000000000006044820152606401610a41565b600c5461265c906001612feb565b600c55600061266a8461186f565b60e084015151606085015191925061268291836130aa565b61269e5760405162461bcd60e51b8152600401610a419061425f565b6126a78461300f565b7fea8e591c28ec8a6328811d6cd88ba23ef134276c0ad0f02d1fbaee80e275b16b84846101000151838660200151876060015187428a60e001516000600281106126f3576126f36145c9565b6020908102919091015160408051998a526001600160a01b03988916928a0192909252958716908801526060870193909352608086019190915260a085015260c08401521660e08201526101000160405180910390a15050506000908152600d60205260408120818155600180820183905560028201839055600382018390556004820180546001600160801b0319169055600582018390556006820192909255600790810180546001600160a01b031916905555565b6000818152600360205260409020546060906001600160a01b03166128295760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b6064820152608401610a41565b6128316133a5565b61283a836133b4565b60405160200161284b9291906140bb565b6040516020818303038152906040529050919050565b6000546001600160a01b0316331461288b5760405162461bcd60e51b8152600401610a4190614314565b6127108111156128f55760405162461bcd60e51b815260206004820152602f60248201527f427920646566696e6974696f6e2c20626173697320706f696e74732063616e6e60448201526e06f742065786365656420313030303608c1b6064820152608401610a41565b60108190556040518181527f36a705a6c19db3ef2d8bf55ca55188c8499831bdf4fb8cd76fc1cf98b740bd279060200161238e565b6000546001600160a01b031633146129545760405162461bcd60e51b8152600401610a4190614314565b6001600160a01b0381166129b95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a41565b6129c2816131fb565b50565b600081815260056020526040902080546001600160a01b0319166001600160a01b03841690811790915581906129fa8261186f565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000612a3d6134b1565b604080517f107182850da2230853efed1dfd0ea3fd85b39a3b9b0a5381ea9fd5dba147aac0602080830191909152855182840152850151606080830191909152918501516001600160a01b03908116608080840191909152928601511660a0808301919091529185015160c08201529084015160e0820152610100015b60405160208183030381529060405280519060200120604051602001612af792919061190160f01b81526002810192909252602282015260420190565b604051602081830303815290604052805190602001209050919050565b6000806000612b238585613554565b91509150612b30816135c4565b509392505050565b6000818152600360205260408120546001600160a01b0316612bb15760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a41565b6000612bbc8361186f565b9050806001600160a01b0316846001600160a01b03161480612bf75750836001600160a01b0316612bec846109cc565b6001600160a01b0316145b80612c2757506001600160a01b0380821660009081526006602090815260408083209388168352929052205460ff165b949350505050565b826001600160a01b0316612c428261186f565b6001600160a01b031614612ca65760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610a41565b6001600160a01b038216612d085760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a41565b612d136000826129c5565b6001600160a01b0383166000908152600460205260408120805460019290612d3c9084906144da565b90915550506001600160a01b0382166000908152600460205260408120805460019290612d6a90849061448f565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60085460ff16612e145760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a41565b6008805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b039091168152602001610d58565b6000612e65828461448f565b9392505050565b6001600160a01b038216612ec25760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a41565b6000818152600360205260409020546001600160a01b031615612f275760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a41565b6001600160a01b0382166000908152600460205260408120805460019290612f5090849061448f565b909155505060008181526003602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6000612fb86134b1565b604051612aba907f1f0d56b2c9f2a40bbf20b01d1b8dcfe864e4dba64eb65c598bb0de477236473a908590602001614141565b6000612e6582846144da565b6000612e65612710613009858561377f565b9061378b565b600061301a8261186f565b90506130276000836129c5565b6001600160a01b03811660009081526004602052604081208054600192906130509084906144da565b909155505060008281526003602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b60408051306024820152604480820185905282518083039091018152606490910182526020810180516001600160e01b031663095ea7b360e01b17905290516000916001600160a01b03861691613101919061409f565b6000604051808303816000865af19150503d806000811461313e576040519150601f19603f3d011682016040523d82523d6000602084013e613143565b606091505b5050506000846001600160a01b03166323b872dd60e01b30858760405160240161316f939291906140ea565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b03199094169390931790925290516131ad919061409f565b6000604051808303816000865af19150503d80600081146131ea576040519150601f19603f3d011682016040523d82523d6000602084013e6131ef565b606091505b50909695505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60085460ff161561326e5760405162461bcd60e51b8152600401610a41906142a3565b6008805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612e413390565b816001600160a01b0316836001600160a01b031614156133055760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a41565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61337d848484612c2f565b61338984848484613797565b6123cb5760405162461bcd60e51b8152600401610a419061420d565b6060601480546109499061451d565b6060816133d85750506040805180820190915260018152600360fc1b602082015290565b8160005b811561340257806133ec81614558565b91506133fb9050600a836144a7565b91506133dc565b6000816001600160401b0381111561341c5761341c6145df565b6040519080825280601f01601f191660200182016040528015613446576020820181803683370190505b5090505b8415612c275761345b6001836144da565b9150613468600a86614573565b61347390603061448f565b60f81b818381518110613488576134886145c9565b60200101906001600160f81b031916908160001a9053506134aa600a866144a7565b945061344a565b604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527faba6aa90b1d7c4077fcd4112d89757c977ec45dd567696446208806c35fa3fe3828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b60008082516041141561358b5760208301516040840151606085015160001a61357f878285856138a4565b945094505050506135bd565b8251604014156135b557602083015160408401516135aa868383613991565b9350935050506135bd565b506000905060025b9250929050565b60008160048111156135d8576135d86145b3565b14156135e15750565b60018160048111156135f5576135f56145b3565b14156136435760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610a41565b6002816004811115613657576136576145b3565b14156136a55760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610a41565b60038160048111156136b9576136b96145b3565b14156137125760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610a41565b6004816004811115613726576137266145b3565b14156129c25760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610a41565b6000612e6582846144bb565b6000612e6582846144a7565b60006001600160a01b0384163b1561389957604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906137db90339089908890889060040161410e565b602060405180830381600087803b1580156137f557600080fd5b505af1925050508015613825575060408051601f3d908101601f1916820190925261382291810190613dc3565b60015b61387f573d808015613853576040519150601f19603f3d011682016040523d82523d6000602084013e613858565b606091505b5080516138775760405162461bcd60e51b8152600401610a419061420d565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612c27565b506001949350505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156138db5750600090506003613988565b8460ff16601b141580156138f357508460ff16601c14155b156139045750600090506004613988565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613958573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661398157600060019250925050613988565b9150600090505b94509492505050565b6000806001600160ff1b038316816139ae60ff86901c601b61448f565b90506139bc878288856138a4565b935093505050935093915050565b8280546139d69061451d565b90600052602060002090601f0160209004810192826139f85760008555613a3e565b82601f10613a1157805160ff1916838001178555613a3e565b82800160010185558215613a3e579182015b82811115613a3e578251825591602001919060010190613a23565b50613a4a929150613a96565b5090565b8260028101928215613a3e579160200282015b82811115613a3e57825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190613a61565b5b80821115613a4a5760008155600101613a97565b60006001600160401b0380841115613ac557613ac56145df565b604051601f8501601f19908116603f01168101908282118183101715613aed57613aed6145df565b81604052809350858152868686011115613b0657600080fd5b858560208301376000602087830101525050509392505050565b8035613b2b816145f5565b919050565b600082601f830112613b4157600080fd5b613b49614467565b808385604086011115613b5b57600080fd5b60005b6002811015613b87578135613b72816145f5565b84526020938401939190910190600101613b5e565b509095945050505050565b600082601f830112613ba357600080fd5b613bab614467565b808385604086011115613bbd57600080fd5b60005b6002811015613b87578135845260209384019390910190600101613bc0565b600082601f830112613bf057600080fd5b612e6583833560208501613aab565b600060208284031215613c1157600080fd5b8135612e65816145f5565b60008060408385031215613c2f57600080fd5b8235613c3a816145f5565b91506020830135613c4a816145f5565b809150509250929050565b600080600060608486031215613c6a57600080fd5b8335613c75816145f5565b92506020840135613c85816145f5565b929592945050506040919091013590565b60008060008060808587031215613cac57600080fd5b8435613cb7816145f5565b93506020850135613cc7816145f5565b92506040850135915060608501356001600160401b03811115613ce957600080fd5b613cf587828801613bdf565b91505092959194509250565b60008060408385031215613d1457600080fd5b8235613d1f816145f5565b91506020830135613c4a8161460a565b60008060408385031215613d4257600080fd5b8235613d4d816145f5565b946020939093013593505050565b60008060408385031215613d6e57600080fd5b8251613d79816145f5565b6020939093015192949293505050565b600060208284031215613d9b57600080fd5b8151612e658161460a565b600060208284031215613db857600080fd5b8135612e6581614618565b600060208284031215613dd557600080fd5b8151612e6581614618565b600060208284031215613df257600080fd5b81356001600160401b03811115613e0857600080fd5b8201601f81018413613e1957600080fd5b612c2784823560208401613aab565b600060208284031215613e3a57600080fd5b5035919050565b60008060008060008060c08789031215613e5a57600080fd5b86359550602087013594506040870135613e73816145f5565b93506060870135613e83816145f5565b92506080870135915060a08701356001600160401b03811115613ea557600080fd5b613eb189828a01613bdf565b9150509295509295509295565b60008060008060008060008060008060006101c08c8e031215613ee057600080fd5b8b359a5060208c0135995060408c0135985060608c0135975060808c01359650613f0d8d60a08e01613b92565b9550613f1c8d60e08e01613b30565b9450613f2b6101208d01613b20565b9350613f3b8d6101408e01613b92565b92506001600160401b03806101808e01351115613f5757600080fd5b613f688e6101808f01358f01613bdf565b9250806101a08e01351115613f7c57600080fd5b50613f8e8d6101a08e01358e01613bdf565b90509295989b509295989b9093969950565b6000806000806000806000806000806101608b8d031215613fc057600080fd5b8a35995060208b0135985060408b0135975060608b0135965060808b0135955060a08b01359450613ff48c60c08d01613b30565b93506101008b0135614005816145f5565b92506101208b013591506101408b01356001600160401b0381111561402957600080fd5b6140358d828e01613bdf565b9150509295989b9194979a5092959850565b8060005b60028110156123cb5781516001600160a01b031684526020938401939091019060010161404b565b6000815180845261408b8160208601602086016144f1565b601f01601f19169290920160200192915050565b600082516140b18184602087016144f1565b9190910192915050565b600083516140cd8184602088016144f1565b8351908301906140e18183602088016144f1565b01949350505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090610c2190830184614073565b60006101808201905083825282516020830152602083015160408301526040830151606083015260608301516080830152608083015160a083015260a083015160c083015260c08301516141a060e08401826001600160a01b03169052565b5060e08301516101006141bd818501836001600160a01b03169052565b84015190506101206141d9848201836001600160a01b03169052565b84015161014084810191909152909301516101609092019190915292915050565b602081526000612e656020830184614073565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60208082526024908201527f4e465420776173206e6f74207375636365737366756c6c79207472616e7366656040820152631c9c995960e21b606082015260800190565b60208082526010908201526f14185d5cd8589b194e881c185d5cd95960821b604082015260600190565b60208082526027908201527f4c6f616e2068617320616c7265616479206265656e20726570616964206f722060408201526618db185a5b595960ca1b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b8781526001600160a01b038781166020808401919091529087166040830152610160820190606083018760005b600281101561441b578151835291830191908301906001016143fe565b5050508560a084015260c083018560005b60038110156144495781518352918301919083019060010161442c565b5050505061445b610120830184614047565b98975050505050505050565b604080519081016001600160401b0381118282101715614489576144896145df565b60405290565b600082198211156144a2576144a2614587565b500190565b6000826144b6576144b661459d565b500490565b60008160001904831182151516156144d5576144d5614587565b500290565b6000828210156144ec576144ec614587565b500390565b60005b8381101561450c5781810151838201526020016144f4565b838111156123cb5750506000910152565b600181811c9082168061453157607f821691505b6020821081141561455257634e487b7160e01b600052602260045260246000fd5b50919050565b600060001982141561456c5761456c614587565b5060010190565b6000826145825761458261459d565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b03811681146129c257600080fd5b80151581146129c257600080fd5b6001600160e01b0319811681146129c257600080fdfea26469706673582212209a955f68b9b152424234611ccff40c15f2243e6381659ec28f814e5e503fe20564736f6c63430008070033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.

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.