ETH Price: $2,273.39 (+0.10%)

Contract

0xC28F7Ee92Cd6619e8eEC6A70923079fBAFb86196
 

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Liquidate171580132023-04-30 9:36:47497 days ago1682847407IN
X2Y2: NFT Loan V1
0 ETH0.0046944332.28171383
Repay169303492023-03-29 3:42:23529 days ago1680061343IN
X2Y2: NFT Loan V1
0 ETH0.0008228528.16558779
Repay169294112023-03-29 0:33:11529 days ago1680049991IN
X2Y2: NFT Loan V1
0 ETH0.0006548522.41492113
Liquidate169147582023-03-26 23:06:47531 days ago1679872007IN
X2Y2: NFT Loan V1
0 ETH0.0022363617.04740199
Repay168413102023-03-16 15:31:11542 days ago1678980671IN
X2Y2: NFT Loan V1
0 ETH0.0058291232.45165049
Liquidate167663712023-03-06 2:33:11552 days ago1678069991IN
X2Y2: NFT Loan V1
0 ETH0.007837354.28247519
Liquidate167526762023-03-04 4:20:59554 days ago1677903659IN
X2Y2: NFT Loan V1
0 ETH0.0020447317.08761606
Repay167522732023-03-04 2:59:59554 days ago1677898799IN
X2Y2: NFT Loan V1
0 ETH0.0034935617.96010681
Liquidate167444592023-03-03 0:34:23555 days ago1677803663IN
X2Y2: NFT Loan V1
0 ETH0.002558721.78451632
Liquidate167444572023-03-03 0:33:59555 days ago1677803639IN
X2Y2: NFT Loan V1
0 ETH0.0025882222.03589907
Liquidate167444532023-03-03 0:33:11555 days ago1677803591IN
X2Y2: NFT Loan V1
0 ETH0.0028584521.79777791
Repay167274582023-02-28 15:10:11558 days ago1677597011IN
X2Y2: NFT Loan V1
0 ETH0.0064713734.63724111
Liquidate167263382023-02-28 11:23:47558 days ago1677583427IN
X2Y2: NFT Loan V1
0 ETH0.0019881116.20781362
Repay167252512023-02-28 7:43:59558 days ago1677570239IN
X2Y2: NFT Loan V1
0 ETH0.0034067717.90883033
Repay167252082023-02-28 7:35:23558 days ago1677569723IN
X2Y2: NFT Loan V1
0 ETH0.0028140216.73172275
Repay167251142023-02-28 7:16:11558 days ago1677568571IN
X2Y2: NFT Loan V1
0 ETH0.0034686618.45004259
Repay167250382023-02-28 7:00:23558 days ago1677567623IN
X2Y2: NFT Loan V1
0 ETH0.0033983718.68993544
Repay167245352023-02-28 5:18:47558 days ago1677561527IN
X2Y2: NFT Loan V1
0 ETH0.0023570415.02853474
Repay167244202023-02-28 4:55:11558 days ago1677560111IN
X2Y2: NFT Loan V1
0 ETH0.0021944215.24804057
Liquidate167243512023-02-28 4:41:11558 days ago1677559271IN
X2Y2: NFT Loan V1
0 ETH0.0020674516.5
Repay167230802023-02-28 0:23:59558 days ago1677543839IN
X2Y2: NFT Loan V1
0 ETH0.0033762118.90725442
Repay167230592023-02-28 0:19:47558 days ago1677543587IN
X2Y2: NFT Loan V1
0 ETH0.0039160720.96375302
Repay167230412023-02-28 0:16:11558 days ago1677543371IN
X2Y2: NFT Loan V1
0 ETH0.0042492322.74727823
Repay167230272023-02-28 0:13:11558 days ago1677543191IN
X2Y2: NFT Loan V1
0 ETH0.0041993822.48039769
Repay167230092023-02-28 0:09:23558 days ago1677542963IN
X2Y2: NFT Loan V1
0 ETH0.0052274527.9839575
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
XY3

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 30 : XY3.sol
pragma solidity 0.8.4;

import "./IXY3.sol";
import "./DataTypes.sol";
import "./LoanStatus.sol";
import "./Config.sol";
import "./utils/SigningUtils.sol";
import "./IDelegate.sol";

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";


contract XY3 is IXY3, Config, LoanStatus {
    using SafeERC20 for IERC20;

    
    mapping(uint32 => LoanDetail) public override loanDetails;

    
    mapping(address => mapping(uint256 => bool)) internal _invalidNonce;

    
    mapping(address => uint256) internal _offerCancelTimestamp;

    
    modifier loanIsOpen(uint32 _loanId) {
        require(getLoanState(_loanId).status == StatusType.NEW, "Loan is not open");
        _;
    }

    
    address public delegate;
    
    constructor(
        address _admin,
        address _ticketToken,
        address _delegate
    ) Config(_admin) LoanStatus(_ticketToken) {
        delegate = _delegate;
    }

    

    
    function borrow(
        Offer memory _offer,
        uint256 _nftId,
        bool _isCollectionOffer,
        Signature memory _lenderSignature,
        Signature memory _brokerSignature
    ) external override whenNotPaused nonReentrant {
        _loanSanityChecks(_offer);
        _borrow(
            _createLoanDetail(_offer, _nftId, _isCollectionOffer),
            _offer,
            _nftId,
            _isCollectionOffer,
            _lenderSignature,
            _brokerSignature
        );
    }

    
    function repay(uint32 _loanId) external override nonReentrant loanIsOpen(_loanId) {
        (
            address borrower,
            address lender,
            LoanDetail memory loan
        ) = _getPartiesAndData(_loanId);

        require(block.timestamp  <= _loanMaturityDate(loan), "Loan is expired");

        (uint256 adminFee, uint256 payoffAmount) = _payoffAndFee(loan);

        
        IDelegate(delegate).erc20Transfer(msg.sender, lender, loan.borrowAsset, payoffAmount);

        
        IDelegate(delegate).erc20Transfer(msg.sender, adminFeeReceiver,loan.borrowAsset, adminFee);

        emit LoanRepaid(
            _loanId,
            borrower,
            lender,
            loan.borrowAmount,
            loan.nftTokenId,
            payoffAmount,
            adminFee,
            loan.nftAsset,
            loan.borrowAsset
        );

        _resolveLoan(_loanId, borrower, loan);
    }

    
    function liquidate(uint32 _loanId) external override nonReentrant loanIsOpen(_loanId) {
        (
            address borrower,
            address lender,
            LoanDetail memory loan
        ) = _getPartiesAndData(_loanId);

        uint256 loanMaturityDate = _loanMaturityDate(loan);
        require(block.timestamp > loanMaturityDate, "Loan is not overdue yet");

        require(msg.sender == lender, "Only lender can liquidate");

        
        emit LoanLiquidated(
            _loanId,
            borrower,
            lender,
            loan.borrowAmount,
            loan.nftTokenId,
            loanMaturityDate,
            block.timestamp,
            loan.nftAsset
        );

        _resolveLoan(_loanId, lender, loan);

    }

    
    function cancelByNonce(uint256 _nonce) override external {
        require(!_invalidNonce[msg.sender][_nonce], "Invalid nonce");
        _invalidNonce[msg.sender][_nonce] = true;
        emit NonceCancelled(msg.sender, _nonce);
    }

    
    function cancelByTimestamp(uint256 _timestamp) override external {
        require(_timestamp < block.timestamp, "Invalid timestamp");
        if (_timestamp >_offerCancelTimestamp[msg.sender]) {
            _offerCancelTimestamp[msg.sender] = _timestamp;
            emit TimeStampCancelled(msg.sender, _timestamp);
        }
    }

    
    function getRepayAmount(uint32 _loanId) external view override returns (uint256) {
        LoanDetail storage loan = loanDetails[_loanId];
        return loan.repayAmount;
    }

    
    function getNonceUsed(address _user, uint256 _nonce) external view override returns (bool) {
        return _invalidNonce[_user][_nonce];
    }

    
    function getTimestampCancelled(address _user) external override view returns (uint256) {
        return _offerCancelTimestamp[_user];
    }
    

    
    function _resolveLoan(
        uint32 _loanId,
        address _nftReceiver,
        LoanDetail memory _loanDetail
    ) internal {
        resolveLoan(_loanId);
        
        IERC721(_loanDetail.nftAsset).safeTransferFrom(address(this), _nftReceiver, _loanDetail.nftTokenId);
        delete loanDetails[_loanId];
    }

    
    function _loanSanityChecks(Offer memory _offer) internal view {
        require(getERC20Permit(_offer.borrowAsset), "Invalid currency");
        require(getERC721Permit(_offer.nftAsset), "Invalid ERC721 token");
        require(uint256(_offer.borrowDuration) <= maxBorrowDuration, "Invalid maximum duration");
        require(uint256(_offer.borrowDuration) >= minBorrowDuration, "Invalid minimum duration");
        require(
            _offer.repayAmount >= _offer.borrowAmount,
            "Invalid interest rate"
        );

        require(
            _offer.adminShare == adminShare,
            "Admin fee changed"
        );
    }

    function _getPartiesAndData(uint32 _loanId)
        internal
        view
        returns (
            address borrower,
            address lender,
            LoanDetail memory loan
        )
    {
        uint256 xy3NftId = getLoanState(_loanId).xy3NftId;
        loan = loanDetails[_loanId];
        borrower = loan.borrower;
        lender = IERC721(ticketToken).ownerOf(xy3NftId);
    }

    
    function _payoffAndFee(LoanDetail memory _loanDetail)
        internal
        pure
        returns (uint256 adminFee, uint256 payoffAmount)
    {
        uint256 interestDue = _loanDetail.repayAmount - _loanDetail.borrowAmount;
        adminFee =  (interestDue * _loanDetail.adminShare) / HUNDRED_PERCENT;
        payoffAmount = _loanDetail.repayAmount - adminFee;
    }

    
    function _borrow(
        LoanDetail memory _loanDetail,
        Offer memory _offer,
        uint256 _nftId,
        bool _isCollection,
        Signature memory _lenderSignature,
        Signature memory _brokerSignature
    ) internal {
        address _lender = _lenderSignature.signer;

        require(!_invalidNonce[_lender][_lenderSignature.nonce], "Lender nonce invalid");
        require(hasRole(SIGNER_ROLE, _brokerSignature.signer),"Invalid broker signer");
        require(_offerCancelTimestamp[_lender] < _offer.timestamp, "Offer cancelled");

        _checkSignatures(_offer, _nftId, _isCollection, _lenderSignature, _brokerSignature);

        _invalidNonce[_lender][_lenderSignature.nonce] = true;

        IDelegate(delegate).erc721Transfer(msg.sender, address(this),_loanDetail.nftAsset, _loanDetail.nftTokenId);

        IDelegate(delegate).erc20Transfer(_lender, msg.sender, _loanDetail.borrowAsset, _loanDetail.borrowAmount);

        
        uint32 loanId = createLoan(_lender);

        
        loanDetails[loanId] = _loanDetail;

        emit LoanStarted(loanId, msg.sender, _lenderSignature.signer, _lenderSignature.nonce, _loanDetail);
    }

    
    function _checkSignatures(Offer memory _offer,uint256 _nftId, bool _isCollection, Signature memory _lenderSignature, Signature memory _brokerSignature) private view {
        if (_isCollection) {
            require(SigningUtils.offerSignatureIsValid(_offer, _lenderSignature), "Lender signature is invalid");
        } else {
            require(SigningUtils.offerSignatureIsValid(_offer, _nftId, _lenderSignature), "Lender signature is invalid");
        }
        require(SigningUtils.offerSignatureIsValid(_offer, _nftId, _brokerSignature), "Signer signature is invalid");
    }

    
    function _createLoanDetail(Offer memory _offer, uint256 _nftId, bool _isCollection) internal view returns (LoanDetail memory) {
        return
            LoanDetail({
                borrowAsset: _offer.borrowAsset,
                borrowAmount: _offer.borrowAmount,
                repayAmount: _offer.repayAmount,
                nftAsset: _offer.nftAsset,
                nftTokenId: _nftId,
                loanStart: uint64(block.timestamp),
                loanDuration: _offer.borrowDuration,
                adminShare: _offer.adminShare,
                borrower: msg.sender,
                isCollection: _isCollection
            });
    }

    
    function _loanMaturityDate(LoanDetail memory loan) private pure returns (uint256) {
        return uint256(loan.loanStart) + uint256(loan.loanDuration);
    }
}

File 2 of 30 : IXY3.sol
pragma solidity 0.8.4;
import "./DataTypes.sol";

interface IXY3 {
    
    event LoanStarted(
        uint32 indexed loanId,
        address indexed borrower,
        address indexed lender,
        uint256 nonce,
        LoanDetail loanDetail
    );

    
    event LoanRepaid(
        uint32 indexed loanId,
        address indexed borrower,
        address indexed lender,
        uint256 borrowAmount,
        uint256 nftTokenId,
        uint256 repayAmount,
        uint256 adminFee,
        address nftAsset,
        address borrowAsset
    );

    
    event NonceCancelled(address lender, uint256 nonce);

    
    event TimeStampCancelled(address lender, uint256 timestamp);

    
    event LoanLiquidated(
        uint32 indexed loanId,
        address indexed borrower,
        address indexed lender,
        uint256 borrowAmount,
        uint256 nftTokenId,
        uint256 loanMaturityDate,
        uint256 loanLiquidationDate,
        address nftAsset
    );

    
    function loanDetails(uint32)
        external
        view
        returns (
            uint256,
            uint256,
            uint256,
            address,
            uint32,
            uint16,
            uint64,
            address,
            address,
            bool
        );

    
    function borrow(
        Offer memory _offer,
        uint256 _nftId,
        bool _isCollectionOffer,
        Signature memory _lenderSignature,
        Signature memory _brokerSignature
    ) external;

    
    function cancelByNonce(uint256 _nonce) external;

    
    function cancelByTimestamp(uint256 _timestamp) external;

    
    function getNonceUsed(address _user, uint256 _nonce)
        external
        view
        returns (bool);

    
    function getTimestampCancelled(address _user)
        external
        view
        returns (uint256);

    
    function repay(uint32 _loanId) external;

    
    function liquidate(uint32 _loanId) external;

    
    function getRepayAmount(uint32 _loanId) external returns (uint256);

}

File 3 of 30 : DataTypes.sol
pragma solidity 0.8.4;




struct Signature {
    uint256 nonce;
    uint256 expiry;
    address signer;
    bytes signature;
}


struct LoanDetail {
    uint256 borrowAmount;
    uint256 repayAmount;
    uint256 nftTokenId;
    address borrowAsset;
    uint32 loanDuration;
    uint16 adminShare;
    uint64 loanStart;
    address nftAsset;
    address borrower;
    bool isCollection;
}


struct Offer {
    uint256 borrowAmount;
    uint256 repayAmount;
    address nftAsset;
    uint32 borrowDuration;
    uint16 adminShare;
    address borrowAsset;
    uint256 timestamp;
}

File 4 of 30 : LoanStatus.sol
pragma solidity 0.8.4;

import "./Xy3Nft.sol";
import "./ILoanStatus.sol";


contract LoanStatus is ILoanStatus {

    event UpdateStatus(
        uint32 indexed loanId,
        uint64 indexed xy3NftId,
        StatusType newStatus
    );

    uint32 public totalNumLoans = 0;
    mapping(uint32 => LoanState) private loanStatus;
    address public ticketToken;

    
    constructor(address _ticketToken) {
        require(
            _ticketToken != address(0),
            "invalid address"
        );
        ticketToken = _ticketToken;
    }

    
    function createLoan(address _lender) internal returns (uint32) {
        
        totalNumLoans += 1;

        uint64 xy3NftId = uint64(
            uint256(keccak256(abi.encodePacked(address(this), totalNumLoans)))
        );

        LoanState memory newLoan = LoanState({
            status: StatusType.NEW,
            xy3NftId: xy3NftId
        });

        
        Xy3Nft(ticketToken).mint(
            _lender,
            xy3NftId,
            abi.encode(totalNumLoans)
        );

        loanStatus[totalNumLoans] = newLoan;
        emit UpdateStatus(totalNumLoans, xy3NftId, StatusType.NEW);

        return totalNumLoans;
    }

    
    function resolveLoan(uint32 _loanId) internal {
        LoanState storage loan = loanStatus[_loanId];
        require(loan.status == StatusType.NEW, "Loan is not a new one");

        loan.status = StatusType.RESOLVED;
        Xy3Nft(ticketToken).burn(loan.xy3NftId);

        emit UpdateStatus(_loanId, loan.xy3NftId, StatusType.RESOLVED);
    }

    
    function getLoanState(uint32 _loanId)
        public
        view
        override
        returns (LoanState memory)
    {
        return loanStatus[_loanId];
    }
}

File 5 of 30 : Config.sol
pragma solidity 0.8.4;

import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "./IConfig.sol";


abstract contract Config is
    AccessControl,
    ERC721Holder,
    Pausable,
    ReentrancyGuard,
    IConfig
{
    
    bytes32 public constant MANAGER_ROLE = keccak256("MANAGER");

    
    bytes32 public constant SIGNER_ROLE = keccak256("SIGNER");

    
    address public adminFeeReceiver;

    
    uint256 public override maxBorrowDuration = 365 days;
    uint256 public override minBorrowDuration = 1 days;

    
    uint16 public override adminShare = 25;
    uint16 public constant HUNDRED_PERCENT = 10000;

    
    mapping(address => bool) private erc20Permits;

    
    mapping(address => bool) private erc721Permits;


    
    constructor(address admin) {
        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        adminFeeReceiver = admin;
    }

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

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

    
    function updateMaxBorrowDuration(uint256 _newMaxBorrowDuration)
        external
        override
        onlyRole(MANAGER_ROLE)
    {
        require(
            _newMaxBorrowDuration >= minBorrowDuration,
            "Invalid duration"
        );
        if(maxBorrowDuration != _newMaxBorrowDuration) {
            maxBorrowDuration = _newMaxBorrowDuration;
            emit MaxBorrowDurationUpdated(_newMaxBorrowDuration);
        }
    }

    
    function updateMinBorrowDuration(uint256 _newMinBorrowDuration)
        external
        override
        onlyRole(MANAGER_ROLE)
    {
        require(
            _newMinBorrowDuration <= maxBorrowDuration,
            "Invalid duration"
        );
        if(minBorrowDuration != _newMinBorrowDuration) {
            minBorrowDuration = _newMinBorrowDuration;
            emit MinBorrowDurationUpdated(_newMinBorrowDuration);
        }
    }

    
    function updateAdminShare(uint16 _newAdminShare)
        external
        override
        onlyRole(MANAGER_ROLE)
    {
        require(
            _newAdminShare <= HUNDRED_PERCENT,
            "basis points > 10000"
        );
        if(adminShare != _newAdminShare) {
            adminShare = _newAdminShare;
            emit AdminFeeUpdated(_newAdminShare);
        }
    }

    
    function updateAdminFeeReceiver(address _newAdminFeeReceiver)
        external
        override
        onlyRole(MANAGER_ROLE)
    {
        require(_newAdminFeeReceiver != address(0), "Invalid receiver address");
        if(adminFeeReceiver != _newAdminFeeReceiver) {
            adminFeeReceiver = _newAdminFeeReceiver;
            emit AdminFeeReceiverUpdated(adminFeeReceiver);
        }
    }

    
    function setERC20Permits(address[] memory _erc20s, bool[] memory _permits)
        external
        override
        onlyRole(MANAGER_ROLE)
    {
        require(
            _erc20s.length == _permits.length,
            "address and permits length mismatch"
        );

        for (uint256 i = 0; i < _erc20s.length; i++) {
            _setERC20Permit(_erc20s[i], _permits[i]);
        }
    }

    
    function setERC721Permits(address[] memory _erc721s, bool[] memory _permits)
        external
        override
        onlyRole(MANAGER_ROLE)
    {
        require(
            _erc721s.length == _permits.length,
            "address and permits length mismatch"
        );

        for (uint256 i = 0; i < _erc721s.length; i++) {
            _setERC721Permit(_erc721s[i], _permits[i]);
        }
    }

    
    function getERC20Permit(address _erc20)
        public
        view
        override
        returns (bool)
    {
        return erc20Permits[_erc20];
    }

    
    function getERC721Permit(address _erc721)
        public
        view
        override
        returns (bool)
    {
        return erc721Permits[_erc721];
    }

    
    function supportsInterface(bytes4 _interfaceId)
        public
        view
        virtual
        override
        returns (bool)
    {
        return
            _interfaceId == type(IERC721Receiver).interfaceId || super.supportsInterface(_interfaceId);
    }

    
    function _setERC20Permit(address _erc20, bool _permit) internal {
        require(_erc20 != address(0), "erc20 is zero address");

        erc20Permits[_erc20] = _permit;

        emit ERC20Permit(_erc20, _permit);
    }

    
    function _setERC721Permit(address _erc721, bool _permit) internal {
        require(_erc721 != address(0), "erc721 is zero address");

        erc721Permits[_erc721] = _permit;

        emit ERC721Permit(_erc721, _permit);
    }
}

File 6 of 30 : SigningUtils.sol
pragma solidity 0.8.4;

import {Offer, Signature} from "../DataTypes.sol";
import "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";


library SigningUtils {
    
    function getChainID() internal view returns (uint256 id) {
        assembly {
            id := chainid()
        }
    }

    

    function offerSignatureIsValid(
        Offer memory _offer,
        uint256 _nftId,
        Signature memory _signature
    ) internal view returns(bool) {
        require(block.timestamp <= _signature.expiry, "Signature expired");
        if (_signature.signer == address(0)) {
            return false;
        } else {
            bytes32 message = keccak256(
                abi.encodePacked(getEncodedOffer(_offer), _nftId, getEncodedSignature(_signature), address(this), getChainID())
            );
            return
                SignatureChecker.isValidSignatureNow(
                    _signature.signer,
                    ECDSA.toEthSignedMessageHash(message),
                    _signature.signature
                );
        }
    }

    
    function offerSignatureIsValid(
        Offer memory _offer,
        Signature memory _signature
    ) internal view returns (bool) {
        require(block.timestamp <= _signature.expiry, "Signature has expired");
        if (_signature.signer == address(0)) {
            return false;
        } else {
            bytes32 message = keccak256(
                abi.encodePacked(getEncodedOffer(_offer), getEncodedSignature(_signature), address(this), getChainID())
            );

            return
                SignatureChecker.isValidSignatureNow(
                    _signature.signer,
                    ECDSA.toEthSignedMessageHash(message),
                    _signature.signature
                );
        }
    }

    
    function getEncodedOffer(Offer memory _offer) internal pure returns (bytes memory data) {
            data = 
                abi.encodePacked(
                    _offer.borrowAsset,
                    _offer.borrowAmount,
                    _offer.repayAmount,
                    _offer.nftAsset,
                    _offer.borrowDuration,
                    _offer.adminShare,
                    _offer.timestamp
                );
    }

    
    function getEncodedSignature(Signature memory _signature) internal pure returns (bytes memory) {
        return abi.encodePacked(_signature.signer, _signature.nonce, _signature.expiry);
    }
}

File 7 of 30 : IDelegate.sol
// SPDX-License-Identifier: Unlicensed

pragma solidity 0.8.4;
pragma abicoder v2;

interface IDelegate {
    function erc20Transfer(
        address sender,
        address receiver,
        address token,
        uint256 amount
    ) external;
    function erc721Transfer(
        address sender,
        address receiver,
        address token,
        uint256 tokenId
    )external;
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 11 of 30 : Xy3Nft.sol
pragma solidity 0.8.4;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Strings.sol";


contract Xy3Nft is ERC721, AccessControl {
    using Strings for uint256;

    
    struct Ticket {
        uint256 loanId;
        address minter;
    }

    
    string public baseURI;

    
    mapping(uint256 => Ticket) public tickets;

    
    bytes32 public constant MINTER_ROLE = keccak256("MINTER");
    bytes32 public constant MANAGER_ROLE = keccak256("MANAGER");

    
    constructor(
        address _admin,
        string memory _name,
        string memory _symbol,
        string memory _customBaseURI
    ) ERC721(_name, _symbol) {
        _setupRole(DEFAULT_ADMIN_ROLE, _admin);
        _setBaseURI(_customBaseURI);
    }

    
    function burn(uint256 _tokenId) external onlyRole(MINTER_ROLE) {
        delete tickets[_tokenId];
        _burn(_tokenId);
    }

    
    function mint(
        address _to,
        uint256 _tokenId,
        bytes calldata _data
    ) external onlyRole(MINTER_ROLE) {
        require(_data.length > 0, "no data");

        uint256 loanId = abi.decode(_data, (uint256));
        tickets[_tokenId] = Ticket({loanId: loanId, minter: msg.sender});
        _safeMint(_to, _tokenId, _data);
    }

    
    function setBaseURI(string memory _customBaseURI)
        external
        onlyRole(MANAGER_ROLE)
    {
        _setBaseURI(_customBaseURI);
    }

    
    function supportsInterface(bytes4 _interfaceId)
        public
        view
        virtual
        override(ERC721, AccessControl)
        returns (bool) 
    {
        return super.supportsInterface(_interfaceId);
    }

    
    function exists(uint256 _tokenId)
        external
        view
        returns (bool)
    {
        return _exists(_tokenId);
    }

    
    function _getChainID() internal view returns (uint256 id) {
        assembly {
            id := chainid()
        }
    }

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

    
    function _setBaseURI(string memory _customBaseURI) internal virtual {
        baseURI = bytes(_customBaseURI).length > 0
            ? string(abi.encodePacked(_customBaseURI, _getChainID().toString(), "/"))
            : "";
    }
}

File 12 of 30 : ILoanStatus.sol
pragma solidity 0.8.4;

interface ILoanStatus {
    
    enum StatusType {
        NOT_EXISTS,
        NEW,
        RESOLVED
    }
    
    
    struct LoanState {
        uint64 xy3NftId;
        StatusType status;
    }

    
    function getLoanState(uint32 _loanId)
        external
        view
        returns (LoanState memory);
}

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

pragma solidity ^0.8.0;

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

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

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        _approve(to, tokenId);
    }

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

        return _tokenApprovals[tokenId];
    }

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

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

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

        _transfer(from, to, tokenId);
    }

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

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

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

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

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

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

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

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

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

        _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 an {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
    }

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

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

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

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning.
     *
     * 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 14 of 30 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

File 17 of 30 : 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 18 of 30 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library 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
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

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

pragma solidity ^0.8.0;

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

File 22 of 30 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

    bool private _paused;

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

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

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

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

File 24 of 30 : 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 25 of 30 : ERC721Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../IERC721Receiver.sol";

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

File 26 of 30 : IConfig.sol
pragma solidity 0.8.4;

interface IConfig {
    
    event AdminFeeUpdated(uint16 newAdminFee);

    
    event MaxBorrowDurationUpdated(uint256 newMaxBorrowDuration);

    
    event MinBorrowDurationUpdated(uint256 newMinBorrowDuration);

    
    event ERC20Permit(address indexed erc20Contract, bool isPermitted);

    
    event ERC721Permit(address indexed erc721Contract, bool isPermitted);

    
    event AdminFeeReceiverUpdated(address);

    
    function maxBorrowDuration() external view returns (uint256);

    
    function minBorrowDuration() external view returns (uint256);

    
    function adminShare() external view returns (uint16);

    
    function updateMaxBorrowDuration(uint256 _newMaxBorrowDuration)
        external;

    
    function updateMinBorrowDuration(uint256 _newMinBorrowDuration)
        external;

    
    function updateAdminShare(uint16 _newAdminShare) external;

    
    function updateAdminFeeReceiver(address _newAdminFeeReceiver) external;

    
    function getERC20Permit(address _erc20) external view returns (bool);

    
    function getERC721Permit(address _erc721) external view returns (bool);

    
    function setERC20Permits(address[] memory _erc20s, bool[] memory _permits)
        external;

    
    function setERC721Permits(address[] memory _erc721s, bool[] memory _permits)
        external;
}

File 27 of 30 : SignatureChecker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.1) (utils/cryptography/SignatureChecker.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";
import "../Address.sol";
import "../../interfaces/IERC1271.sol";

/**
 * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA
 * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like
 * Argent and Gnosis Safe.
 *
 * _Available since v4.1._
 */
library SignatureChecker {
    /**
     * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
     * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.
     *
     * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
     * change through time. It could return true at block N and false at block N+1 (or the opposite).
     */
    function isValidSignatureNow(
        address signer,
        bytes32 hash,
        bytes memory signature
    ) internal view returns (bool) {
        (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);
        if (error == ECDSA.RecoverError.NoError && recovered == signer) {
            return true;
        }

        (bool success, bytes memory result) = signer.staticcall(
            abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)
        );
        return (success &&
            result.length == 32 &&
            abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));
    }
}

File 28 of 30 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.3) (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) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

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

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

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

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

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC1271 standard signature validation method for
 * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
 *
 * _Available since v4.1._
 */
interface IERC1271 {
    /**
     * @dev Should return whether the signature provided is valid for the provided data
     * @param hash      Hash of the data to be signed
     * @param signature Signature byte array associated with _data
     */
    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);
}

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

pragma solidity ^0.8.0;

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_admin","type":"address"},{"internalType":"address","name":"_ticketToken","type":"address"},{"internalType":"address","name":"_delegate","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"","type":"address"}],"name":"AdminFeeReceiverUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"newAdminFee","type":"uint16"}],"name":"AdminFeeUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc20Contract","type":"address"},{"indexed":false,"internalType":"bool","name":"isPermitted","type":"bool"}],"name":"ERC20Permit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Contract","type":"address"},{"indexed":false,"internalType":"bool","name":"isPermitted","type":"bool"}],"name":"ERC721Permit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"loanId","type":"uint32"},{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanMaturityDate","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loanLiquidationDate","type":"uint256"},{"indexed":false,"internalType":"address","name":"nftAsset","type":"address"}],"name":"LoanLiquidated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"loanId","type":"uint32"},{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"repayAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"adminFee","type":"uint256"},{"indexed":false,"internalType":"address","name":"nftAsset","type":"address"},{"indexed":false,"internalType":"address","name":"borrowAsset","type":"address"}],"name":"LoanRepaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"loanId","type":"uint32"},{"indexed":true,"internalType":"address","name":"borrower","type":"address"},{"indexed":true,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"},{"components":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"address","name":"borrowAsset","type":"address"},{"internalType":"uint32","name":"loanDuration","type":"uint32"},{"internalType":"uint16","name":"adminShare","type":"uint16"},{"internalType":"uint64","name":"loanStart","type":"uint64"},{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"bool","name":"isCollection","type":"bool"}],"indexed":false,"internalType":"struct LoanDetail","name":"loanDetail","type":"tuple"}],"name":"LoanStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMaxBorrowDuration","type":"uint256"}],"name":"MaxBorrowDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMinBorrowDuration","type":"uint256"}],"name":"MinBorrowDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"nonce","type":"uint256"}],"name":"NonceCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lender","type":"address"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"TimeStampCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"loanId","type":"uint32"},{"indexed":true,"internalType":"uint64","name":"xy3NftId","type":"uint64"},{"indexed":false,"internalType":"enum ILoanStatus.StatusType","name":"newStatus","type":"uint8"}],"name":"UpdateStatus","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HUNDRED_PERCENT","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SIGNER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminFeeReceiver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminShare","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"uint32","name":"borrowDuration","type":"uint32"},{"internalType":"uint16","name":"adminShare","type":"uint16"},{"internalType":"address","name":"borrowAsset","type":"address"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct Offer","name":"_offer","type":"tuple"},{"internalType":"uint256","name":"_nftId","type":"uint256"},{"internalType":"bool","name":"_isCollectionOffer","type":"bool"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct Signature","name":"_lenderSignature","type":"tuple"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct Signature","name":"_brokerSignature","type":"tuple"}],"name":"borrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"cancelByNonce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_timestamp","type":"uint256"}],"name":"cancelByTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"delegate","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_erc20","type":"address"}],"name":"getERC20Permit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_erc721","type":"address"}],"name":"getERC721Permit","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_loanId","type":"uint32"}],"name":"getLoanState","outputs":[{"components":[{"internalType":"uint64","name":"xy3NftId","type":"uint64"},{"internalType":"enum ILoanStatus.StatusType","name":"status","type":"uint8"}],"internalType":"struct ILoanStatus.LoanState","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"getNonceUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_loanId","type":"uint32"}],"name":"getRepayAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getTimestampCancelled","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"_loanId","type":"uint32"}],"name":"liquidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"","type":"uint32"}],"name":"loanDetails","outputs":[{"internalType":"uint256","name":"borrowAmount","type":"uint256"},{"internalType":"uint256","name":"repayAmount","type":"uint256"},{"internalType":"uint256","name":"nftTokenId","type":"uint256"},{"internalType":"address","name":"borrowAsset","type":"address"},{"internalType":"uint32","name":"loanDuration","type":"uint32"},{"internalType":"uint16","name":"adminShare","type":"uint16"},{"internalType":"uint64","name":"loanStart","type":"uint64"},{"internalType":"address","name":"nftAsset","type":"address"},{"internalType":"address","name":"borrower","type":"address"},{"internalType":"bool","name":"isCollection","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBorrowDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBorrowDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_loanId","type":"uint32"}],"name":"repay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_erc20s","type":"address[]"},{"internalType":"bool[]","name":"_permits","type":"bool[]"}],"name":"setERC20Permits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_erc721s","type":"address[]"},{"internalType":"bool[]","name":"_permits","type":"bool[]"}],"name":"setERC721Permits","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":"ticketToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalNumLoans","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newAdminFeeReceiver","type":"address"}],"name":"updateAdminFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_newAdminShare","type":"uint16"}],"name":"updateAdminShare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMaxBorrowDuration","type":"uint256"}],"name":"updateMaxBorrowDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMinBorrowDuration","type":"uint256"}],"name":"updateMinBorrowDuration","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040526301e13380600455620151806005556006805461ffff191660191790556009805463ffffffff191690553480156200003b57600080fd5b5060405162003ea038038062003ea08339810160408190526200005e91620001d1565b6001805460ff1916815560025581836200007a60008262000113565b600380546001600160a01b0319166001600160a01b039283161790558116620000db5760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b604482015260640160405180910390fd5b600b80546001600160a01b039283166001600160a01b031991821617909155600f8054939092169216919091179055506200021a9050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16620001b0576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556200016f3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b80516001600160a01b0381168114620001cc57600080fd5b919050565b600080600060608486031215620001e6578283fd5b620001f184620001b4565b92506200020160208501620001b4565b91506200021160408501620001b4565b90509250925092565b613c76806200022a6000396000f3fe608060405234801561001057600080fd5b50600436106102ad5760003560e01c80637284ae931161017b578063a217fddf116100d8578063c89e43611161008c578063d5ed4d5a11610071578063d5ed4d5a14610757578063e7610eb11461076a578063ec87621c1461077d57600080fd5b8063c89e436114610731578063d547741f1461074457600080fd5b8063a9825041116100bd578063a9825041146106f8578063ae99c2c81461070b578063b6f38a1e1461071e57600080fd5b8063a217fddf146106dd578063a35524be146106e557600080fd5b806393aa28451161012f57806396087a9f1161011457806396087a9f1461069f5780639ecdda21146106ad578063a1ebf35d146106b657600080fd5b806393aa28451461066d57806395277dd51461067657600080fd5b80638456cb59116101605780638456cb5914610602578063872873be1461060a57806391d148541461063657600080fd5b80637284ae93146104f657806379b64040146105ef57600080fd5b80633f4ba83a116102295780635b5b121d116101dd578063639b2b4d116101c2578063639b2b4d146104b45780636ed93dd0146104c757806370ba25fc146104e357600080fd5b80635b5b121d146104965780635c975abb146104a957600080fd5b806354cc4a781161020e57806354cc4a781461041d578063552f023e146104485780635794fefc1461047157600080fd5b80633f4ba83a146103f557806350015350146103fd57600080fd5b8063150b7a02116102805780632f2ff15d116102655780632f2ff15d146103a3578063359f62e4146103b657806336568abe146103e257600080fd5b8063150b7a021461033b578063248a9ca31461037257600080fd5b806301ffc9a7146102b25780630263952a146102da5780630a9c7563146102ef578063117c121514610302575b600080fd5b6102c56102c036600461362a565b6107a4565b60405190151581526020015b60405180910390f35b6102ed6102e8366004613508565b6107cf565b005b6102ed6102fd3660046135cb565b6108d7565b6102c56103103660046134dd565b6001600160a01b03919091166000908152600d60209081526040808320938352929052205460ff1690565b610359610349366004613473565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020016102d1565b6103956103803660046135cb565b60009081526020819052604090206001015490565b6040519081526020016102d1565b6102ed6103b13660046135fb565b61099a565b6102c56103c436600461343b565b6001600160a01b031660009081526008602052604090205460ff1690565b6102ed6103f03660046135fb565b6109c4565b6102ed610a4c565b61041061040b36600461376a565b610a81565b6040516102d19190613999565b600354610430906001600160a01b031681565b6040516001600160a01b0390911681526020016102d1565b61039561045636600461343b565b6001600160a01b03166000908152600e602052604090205490565b6009546104819063ffffffff1681565b60405163ffffffff90911681526020016102d1565b6102ed6104a436600461376a565b610b20565b60015460ff166102c5565b6102ed6104c23660046135cb565b610d45565b6104d061271081565b60405161ffff90911681526020016102d1565b6102ed6104f136600461343b565b610dff565b61058361050436600461376a565b600c602052600090815260409020805460018201546002830154600384015460048501546005909501549394929391926001600160a01b0380831693600160a01b80850463ffffffff1694600160c01b900461ffff169367ffffffffffffffff8116936801000000000000000090910481169290811691900460ff168a565b604080519a8b5260208b0199909952978901969096526001600160a01b03948516606089015263ffffffff909316608088015261ffff90911660a087015267ffffffffffffffff1660c0860152811660e0850152166101008301521515610120820152610140016102d1565b6102ed6105fd366004613508565b610efa565b6102ed610ff7565b6102c561061836600461343b565b6001600160a01b031660009081526007602052604090205460ff1690565b6102c56106443660046135fb565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b61039560045481565b61039561068436600461376a565b63ffffffff166000908152600c602052604090206001015490565b6006546104d09061ffff1681565b61039560055481565b6103957f2aeb38be3df14d720aeb10a2de6df09b0fb3cd5c5ec256283a22d4593110ca4081565b610395600081565b6102ed6106f3366004613750565b611029565b6102ed6107063660046135cb565b6110fd565b6102ed610719366004613652565b6111b2565b6102ed61072c3660046135cb565b61123d565b600f54610430906001600160a01b031681565b6102ed6107523660046135fb565b611300565b600b54610430906001600160a01b031681565b6102ed61077836600461376a565b611325565b6103957faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c81565b60006001600160e01b03198216630a85bd0160e11b14806107c957506107c9826115ff565b92915050565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c6107f981611666565b815183511461085b5760405162461bcd60e51b815260206004820152602360248201527f6164647265737320616e64207065726d697473206c656e677468206d69736d616044820152620e8c6d60eb1b60648201526084015b60405180910390fd5b60005b83518110156108d1576108bf84828151811061088a57634e487b7160e01b600052603260045260246000fd5b60200260200101518483815181106108b257634e487b7160e01b600052603260045260246000fd5b6020026020010151611670565b806108c981613be4565b91505061085e565b50505050565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c61090181611666565b6004548211156109535760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964206475726174696f6e000000000000000000000000000000006044820152606401610852565b81600554146109965760058290556040518281527fada00761622e18474ad9efbe0dfbbcfdad01ffb7c67e8d41edce1369f8e66f28906020015b60405180910390a15b5050565b6000828152602081905260409020600101546109b581611666565b6109bf8383611726565b505050565b6001600160a01b0381163314610a425760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610852565b61099682826117c4565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c610a7681611666565b610a7e611843565b50565b604080518082019091526000808252602082015263ffffffff82166000908152600a60209081526040918290208251808401909352805467ffffffffffffffff81168452909183019068010000000000000000900460ff166002811115610af857634e487b7160e01b600052602160045260246000fd5b6002811115610b1757634e487b7160e01b600052602160045260246000fd5b90525092915050565b600280541415610b725760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610852565b60028055806001610b8282610a81565b602001516002811115610ba557634e487b7160e01b600052602160045260246000fd5b14610bf25760405162461bcd60e51b815260206004820152601060248201527f4c6f616e206973206e6f74206f70656e000000000000000000000000000000006044820152606401610852565b6000806000610c0085611895565b9250925092506000610c1182611a4f565b9050804211610c625760405162461bcd60e51b815260206004820152601760248201527f4c6f616e206973206e6f74206f766572647565207965740000000000000000006044820152606401610852565b336001600160a01b03841614610cba5760405162461bcd60e51b815260206004820152601960248201527f4f6e6c79206c656e6465722063616e206c6971756964617465000000000000006044820152606401610852565b815160408084015160e0850151825193845260208401919091529082018390524260608301526001600160a01b039081166080830152808516919086169063ffffffff8916907f4fac0ff43299a330bce57d0579985305af580acf256a6d7977083ede81be13269060a00160405180910390a4610d38868484611a75565b5050600160025550505050565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c610d6f81611666565b600554821015610dc15760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964206475726174696f6e000000000000000000000000000000006044820152606401610852565b81600454146109965760048290556040518281527f78e13060dd5049aaff2eee249c07301476e6e5b5a60c65116c3fd872c288e4539060200161098d565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c610e2981611666565b6001600160a01b038216610e7f5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207265636569766572206164647265737300000000000000006044820152606401610852565b6003546001600160a01b0383811691161461099657600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040519081527fb390a6eece33fc2616d0250e8cd5d72a2b7e0d6cb889791d36ec8892a045b0949060200161098d565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c610f2481611666565b8151835114610f815760405162461bcd60e51b815260206004820152602360248201527f6164647265737320616e64207065726d697473206c656e677468206d69736d616044820152620e8c6d60eb1b6064820152608401610852565b60005b83518110156108d157610fe5848281518110610fb057634e487b7160e01b600052603260045260246000fd5b6020026020010151848381518110610fd857634e487b7160e01b600052603260045260246000fd5b6020026020010151611b9b565b80610fef81613be4565b915050610f84565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c61102181611666565b610a7e611c49565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c61105381611666565b61271061ffff831611156110a95760405162461bcd60e51b815260206004820152601460248201527f626173697320706f696e7473203e2031303030300000000000000000000000006044820152606401610852565b60065461ffff838116911614610996576006805461ffff191661ffff84169081179091556040519081527f03017365bbe16943b524030df07e7689168ab63e854d27417498e6f9dc584dab9060200161098d565b42811061114c5760405162461bcd60e51b815260206004820152601160248201527f496e76616c69642074696d657374616d700000000000000000000000000000006044820152606401610852565b336000908152600e6020526040902054811115610a7e57336000818152600e6020908152604091829020849055815192835282018390527fe7258d55b23f4902343add21f328e6d35c5d58bff7fe8bda6f1df7851f04d36a91015b60405180910390a150565b6111ba611c84565b60028054141561120c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610852565b6002805561121985611cd9565b611231611227868686611f19565b8686868686612003565b50506001600255505050565b336000908152600d6020908152604080832084845290915290205460ff16156112a85760405162461bcd60e51b815260206004820152600d60248201527f496e76616c6964206e6f6e6365000000000000000000000000000000000000006044820152606401610852565b336000818152600d60209081526040808320858452825291829020805460ff19166001179055815192835282018390527f26ccf9904b9b2fb069d347553978928fd2fc65efb2638dcbeb8d142e974479f091016111a7565b60008281526020819052604090206001015461131b81611666565b6109bf83836117c4565b6002805414156113775760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610852565b6002805580600161138782610a81565b6020015160028111156113aa57634e487b7160e01b600052602160045260246000fd5b146113f75760405162461bcd60e51b815260206004820152601060248201527f4c6f616e206973206e6f74206f70656e000000000000000000000000000000006044820152606401610852565b600080600061140585611895565b92509250925061141481611a4f565b4211156114635760405162461bcd60e51b815260206004820152600f60248201527f4c6f616e206973206578706972656400000000000000000000000000000000006044820152606401610852565b60008061146f8361248d565b600f54606086015160405163df77783560e01b81523360048201526001600160a01b038981166024830152918216604482015260648101849052939550919350169063df77783590608401600060405180830381600087803b1580156114d457600080fd5b505af11580156114e8573d6000803e3d6000fd5b5050600f54600354606087015160405163df77783560e01b81523360048201526001600160a01b0392831660248201529082166044820152606481018790529116925063df7778359150608401600060405180830381600087803b15801561154f57600080fd5b505af1158015611563573d6000803e3d6000fd5b5050845160408087015160e08801516060808a0151845195865260208601939093529284018790529183018790526001600160a01b039182166080840152811660a083015280881693508816915063ffffffff8a16907f6ee3573bd905753c83bc1aaca3c15bfa36391db95b778bd825eb010645a7ee459060c00160405180910390a46115f1878685611a75565b505060016002555050505050565b60006001600160e01b031982167f7965db0b0000000000000000000000000000000000000000000000000000000014806107c957507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146107c9565b610a7e81336124e4565b6001600160a01b0382166116c65760405162461bcd60e51b815260206004820152601660248201527f657263373231206973207a65726f2061646472657373000000000000000000006044820152606401610852565b6001600160a01b038216600081815260086020908152604091829020805460ff191685151590811790915591519182527f3e0c443872dd01e15f6ca1f8ee12f284a44836f46012e421d74611bf80eda7c191015b60405180910390a25050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610996576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556117803390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1615610996576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b61184b612562565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052819060006118f285610a81565b5163ffffffff8681166000908152600c60209081526040918290208251610140810184528154815260018201549281019290925260028101548284015260038101546001600160a01b038082166060850152600160a01b8083049096166080850152600160c01b90910461ffff1660a084015260048083015467ffffffffffffffff80821660c087015268010000000000000000909104831660e0860152600590930154808316610100860181905296900460ff161515610120850152600b5494517f6352211e000000000000000000000000000000000000000000000000000000008152929096169582018690529398509095509293501690636352211e9060240160206040518083038186803b158015611a0d57600080fd5b505afa158015611a21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a459190613457565b9250509193909250565b6000816080015163ffffffff168260c0015167ffffffffffffffff166107c99190613b0b565b611a7e836125b4565b60e081015160408083015190517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03858116602483015260448201929092529116906342842e0e90606401600060405180830381600087803b158015611af257600080fd5b505af1158015611b06573d6000803e3d6000fd5b50505063ffffffff9093166000908152600c602052604081208181556001810182905560028101919091556003810180547fffffffffffff00000000000000000000000000000000000000000000000000001690556004810180546001600160e01b031916905560050180547fffffffffffffffffffffff000000000000000000000000000000000000000000169055505050565b6001600160a01b038216611bf15760405162461bcd60e51b815260206004820152601560248201527f6572633230206973207a65726f206164647265737300000000000000000000006044820152606401610852565b6001600160a01b038216600081815260076020908152604091829020805460ff191685151590811790915591519182527ff100355be652ecc881568750e6a98c0713e4316f75d5314ebc9039e0acb52f24910161171a565b611c51611c84565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611878565b60015460ff1615611cd75760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610852565b565b60a08101516001600160a01b031660009081526007602052604090205460ff16611d455760405162461bcd60e51b815260206004820152601060248201527f496e76616c69642063757272656e6379000000000000000000000000000000006044820152606401610852565b6040808201516001600160a01b031660009081526008602052205460ff16611daf5760405162461bcd60e51b815260206004820152601460248201527f496e76616c69642045524337323120746f6b656e0000000000000000000000006044820152606401610852565b600454816060015163ffffffff161115611e0b5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206d6178696d756d206475726174696f6e00000000000000006044820152606401610852565b600554816060015163ffffffff161015611e675760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206d696e696d756d206475726174696f6e00000000000000006044820152606401610852565b805160208201511015611ebc5760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420696e746572657374207261746500000000000000000000006044820152606401610852565b600654608082015161ffff908116911614610a7e5760405162461bcd60e51b815260206004820152601160248201527f41646d696e20666565206368616e6765640000000000000000000000000000006044820152606401610852565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915260405180610140016040528085600001518152602001856020015181526020018481526020018560a001516001600160a01b03168152602001856060015163ffffffff168152602001856080015161ffff1681526020014267ffffffffffffffff16815260200185604001516001600160a01b03168152602001336001600160a01b0316815260200183151581525090505b9392505050565b6040808301516001600160a01b0381166000908152600d6020908152838220865183529052919091205460ff161561207d5760405162461bcd60e51b815260206004820152601460248201527f4c656e646572206e6f6e636520696e76616c69640000000000000000000000006044820152606401610852565b6040808301516001600160a01b031660009081527fdb8ccd0e71cbf52bceafef256d2658d12104739e125d9c49583283aa4b756454602052205460ff166121065760405162461bcd60e51b815260206004820152601560248201527f496e76616c69642062726f6b6572207369676e657200000000000000000000006044820152606401610852565b60c08601516001600160a01b0382166000908152600e6020526040902054106121715760405162461bcd60e51b815260206004820152600f60248201527f4f666665722063616e63656c6c656400000000000000000000000000000000006044820152606401610852565b61217e8686868686612737565b6001600160a01b038181166000908152600d602090815260408083208751845290915290819020805460ff19166001179055600f5460e08a01518a83015192517f42f1a25600000000000000000000000000000000000000000000000000000000815233600482015230602482015290841660448201526064810192909252909116906342f1a25690608401600060405180830381600087803b15801561222457600080fd5b505af1158015612238573d6000803e3d6000fd5b5050600f5460608a01518a5160405163df77783560e01b81526001600160a01b038781166004830152336024830152928316604482015260648101919091529116925063df7778359150608401600060405180830381600087803b15801561229f57600080fd5b505af11580156122b3573d6000803e3d6000fd5b5050505060006122c28261284d565b905087600c60008363ffffffff1663ffffffff16815260200190815260200160002060008201518160000155602082015181600101556040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160030160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160030160186101000a81548161ffff021916908361ffff16021790555060c08201518160040160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060e08201518160040160086101000a8154816001600160a01b0302191690836001600160a01b031602179055506101008201518160050160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506101208201518160050160146101000a81548160ff02191690831515021790555090505083604001516001600160a01b0316336001600160a01b03168263ffffffff167f41405b00e0df471a285ab48e999085e2587e99e951ecd148b4c65d5c98735edc87600001518c60405161247b9291906139c5565b60405180910390a45050505050505050565b6000806000836000015184602001516124a69190613b8a565b60a0850151909150612710906124c09061ffff1683613b6b565b6124ca9190613b4b565b92508284602001516124dc9190613b8a565b915050915091565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661099657612520816001600160a01b03166014612a68565b61252b836020612a68565b60405160200161253c92919061389b565b60408051601f198184030181529082905262461bcd60e51b825261085291600401613986565b60015460ff16611cd75760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610852565b63ffffffff81166000908152600a602052604090206001815468010000000000000000900460ff1660028111156125fb57634e487b7160e01b600052602160045260246000fd5b146126485760405162461bcd60e51b815260206004820152601560248201527f4c6f616e206973206e6f742061206e6577206f6e6500000000000000000000006044820152606401610852565b80546802000000000000000068ff0000000000000000198216178255600b546040517f42966c6800000000000000000000000000000000000000000000000000000000815267ffffffffffffffff90921660048301526001600160a01b0316906342966c6890602401600060405180830381600087803b1580156126cb57600080fd5b505af11580156126df573d6000803e3d6000fd5b5050825460405167ffffffffffffffff909116925063ffffffff851691507fa99afb24dca45e3cebef49cd6184255e4623c0bf6c5e87bb6738629ceefa2dac9061272b90600290613978565b60405180910390a35050565b8215612798576127478583612c8f565b6127935760405162461bcd60e51b815260206004820152601b60248201527f4c656e646572207369676e617475726520697320696e76616c696400000000006044820152606401610852565b6127ef565b6127a3858584612db1565b6127ef5760405162461bcd60e51b815260206004820152601b60248201527f4c656e646572207369676e617475726520697320696e76616c696400000000006044820152606401610852565b6127fa858583612db1565b6128465760405162461bcd60e51b815260206004820152601b60248201527f5369676e6572207369676e617475726520697320696e76616c696400000000006044820152606401610852565b5050505050565b60098054600091600191839061286a90849063ffffffff16613b23565b82546101009290920a63ffffffff818102199093169190921691909102179055506009546040513060601b6bffffffffffffffffffffffff1916602082015260e09190911b6001600160e01b031916603482015260009060380160408051808303601f190181528282528051602091820120838301835267ffffffffffffffff81168452600182850152600b54600954845163ffffffff909116938101939093529094506001600160a01b0316916394d008ef9187918691016040516020818303038152906040526040518463ffffffff1660e01b81526004016129509392919061391c565b600060405180830381600087803b15801561296a57600080fd5b505af115801561297e573d6000803e3d6000fd5b505060095463ffffffff166000908152600a602090815260409091208451815467ffffffffffffffff90911667ffffffffffffffff19821681178355928601518695509193509091839168ffffffffffffffffff191617680100000000000000008360028111156129ff57634e487b7160e01b600052602160045260246000fd5b02179055505060095460405167ffffffffffffffff8516925063ffffffff909116907fa99afb24dca45e3cebef49cd6184255e4623c0bf6c5e87bb6738629ceefa2dac90612a4f90600190613978565b60405180910390a3505060095463ffffffff1692915050565b60606000612a77836002613b6b565b612a82906002613b0b565b67ffffffffffffffff811115612aa857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612ad2576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612b1757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612b7057634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612b94846002613b6b565b612b9f906001613b0b565b90505b6001811115612c40577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612bee57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612c1257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612c3981613bcd565b9050612ba2565b508315611ffc5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610852565b60008160200151421115612ce55760405162461bcd60e51b815260206004820152601560248201527f5369676e617475726520686173206578706972656400000000000000000000006044820152606401610852565b60408201516001600160a01b0316612cff575060006107c9565b6000612d0a84612ecb565b612d1384612f98565b3046604051602001612d2894939291906137ee565b604051602081830303815290604052805190602001209050612da98360400151612d9f836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b8560600151612fe0565b9150506107c9565b60008160200151421115612e075760405162461bcd60e51b815260206004820152601160248201527f5369676e617475726520657870697265640000000000000000000000000000006044820152606401610852565b60408201516001600160a01b0316612e2157506000611ffc565b6000612e2c85612ecb565b84612e3685612f98565b3046604051602001612e4c95949392919061383e565b604051602081830303815290604052805190602001209050612ec38360400151612d9f836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b915050611ffc565b60608160a00151826000015183602001518460400151856060015186608001518760c00151604051602001612f829796959493929190606097881b6bffffffffffffffffffffffff199081168252601482019790975260348101959095529290951b909316605483015260e09290921b6001600160e01b031916606882015260f09290921b7fffff00000000000000000000000000000000000000000000000000000000000016606c830152606e820152608e0190565b6040516020818303038152906040529050919050565b6060816040015182600001518360200151604051602001612f829392919060609390931b6bffffffffffffffffffffffff191683526014830191909152603482015260540190565b6000806000612fef858561315e565b9092509050600081600481111561301657634e487b7160e01b600052602160045260246000fd5b1480156130345750856001600160a01b0316826001600160a01b0316145b1561304457600192505050611ffc565b600080876001600160a01b0316631626ba7e60e01b888860405160240161306c929190613957565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b03199094169390931790925290516130bf91906137d2565b600060405180830381855afa9150503d80600081146130fa576040519150601f19603f3d011682016040523d82523d6000602084013e6130ff565b606091505b5091509150818015613112575080516020145b8015613152575080517f1626ba7e000000000000000000000000000000000000000000000000000000009061315090830160209081019084016135e3565b145b98975050505050505050565b6000808251604114156131955760208301516040840151606085015160001a613189878285856131a4565b9450945050505061319d565b506000905060025b9250929050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156131db5750600090506003613288565b8460ff16601b141580156131f357508460ff16601c14155b156132045750600090506004613288565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613258573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661328157600060019250925050613288565b9150600090505b94509492505050565b600082601f8301126132a1578081fd5b813560206132b66132b183613ae7565b613ab6565b80838252828201915082860187848660051b89010111156132d5578586fd5b855b858110156132fa576132e882613307565b845292840192908401906001016132d7565b5090979650505050505050565b8035801515811461331757600080fd5b919050565b600082601f83011261332c578081fd5b813567ffffffffffffffff81111561334657613346613c15565b613359601f8201601f1916602001613ab6565b81815284602083860101111561336d578283fd5b816020850160208301379081016020019190915292915050565b600060808284031215613398578081fd5b6040516080810167ffffffffffffffff82821081831117156133bc576133bc613c15565b816040528293508435835260208501356020840152604085013591506133e182613c2b565b81604084015260608501359150808211156133fb57600080fd5b506134088582860161331c565b6060830152505092915050565b803561ffff8116811461331757600080fd5b803563ffffffff8116811461331757600080fd5b60006020828403121561344c578081fd5b8135611ffc81613c2b565b600060208284031215613468578081fd5b8151611ffc81613c2b565b60008060008060808587031215613488578283fd5b843561349381613c2b565b935060208501356134a381613c2b565b925060408501359150606085013567ffffffffffffffff8111156134c5578182fd5b6134d18782880161331c565b91505092959194509250565b600080604083850312156134ef578182fd5b82356134fa81613c2b565b946020939093013593505050565b6000806040838503121561351a578182fd5b823567ffffffffffffffff80821115613531578384fd5b818501915085601f830112613544578384fd5b813560206135546132b183613ae7565b8083825282820191508286018a848660051b8901011115613573578889fd5b8896505b8487101561359e57803561358a81613c2b565b835260019690960195918301918301613577565b50965050860135925050808211156135b4578283fd5b506135c185828601613291565b9150509250929050565b6000602082840312156135dc578081fd5b5035919050565b6000602082840312156135f4578081fd5b5051919050565b6000806040838503121561360d578182fd5b82359150602083013561361f81613c2b565b809150509250929050565b60006020828403121561363b578081fd5b81356001600160e01b031981168114611ffc578182fd5b600080600080600085870361016081121561366b578384fd5b60e0811215613678578384fd5b50613681613a8d565b8635815260208701356020820152604087013561369d81613c2b565b60408201526136ae60608801613427565b60608201526136bf60808801613415565b608082015260a08701356136d281613c2b565b60a082015260c08781013590820152945060e086013593506136f76101008701613307565b925061012086013567ffffffffffffffff80821115613714578283fd5b61372089838a01613387565b9350610140880135915080821115613736578283fd5b5061374388828901613387565b9150509295509295909350565b600060208284031215613761578081fd5b611ffc82613415565b60006020828403121561377b578081fd5b611ffc82613427565b6000815180845261379c816020860160208601613ba1565b601f01601f19169290920160200192915050565b600381106137ce57634e487b7160e01b600052602160045260246000fd5b9052565b600082516137e4818460208701613ba1565b9190910192915050565b60008551613800818460208a01613ba1565b855190830190613814818360208a01613ba1565b60609590951b6bffffffffffffffffffffffff191694019384525050601482015260340192915050565b60008651613850818460208b01613ba1565b82018681528551613868816020808501908a01613ba1565b60609590951b6bffffffffffffffffffffffff191660209190950190810194909452505060348201526054019392505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516138d3816017850160208801613ba1565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613910816028840160208801613ba1565b01602801949350505050565b6001600160a01b038416815267ffffffffffffffff8316602082015260606040820152600061394e6060830184613784565b95945050505050565b8281526040602082015260006139706040830184613784565b949350505050565b602081016107c982846137b0565b602081526000611ffc6020830184613784565b815167ffffffffffffffff16815260208083015160408301916139be908401826137b0565b5092915050565b6000610160820190508382528251602083015260208301516040830152604083015160608301526060830151613a0660808401826001600160a01b03169052565b50608083015163ffffffff811660a08401525060a083015161ffff811660c08401525060c083015167ffffffffffffffff811660e08401525060e0830151610100613a5b818501836001600160a01b03169052565b8401519050610120613a77848201836001600160a01b03169052565b8401518015156101408501529050509392505050565b60405160e0810167ffffffffffffffff81118282101715613ab057613ab0613c15565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613adf57613adf613c15565b604052919050565b600067ffffffffffffffff821115613b0157613b01613c15565b5060051b60200190565b60008219821115613b1e57613b1e613bff565b500190565b600063ffffffff808316818516808303821115613b4257613b42613bff565b01949350505050565b600082613b6657634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613b8557613b85613bff565b500290565b600082821015613b9c57613b9c613bff565b500390565b60005b83811015613bbc578181015183820152602001613ba4565b838111156108d15750506000910152565b600081613bdc57613bdc613bff565b506000190190565b6000600019821415613bf857613bf8613bff565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610a7e57600080fdfea26469706673582212200940b68a61a9137d65c3629708006f45614eb9460825c7ae2742ada76b023f0e64736f6c634300080400330000000000000000000000001b4b3465b65fb87f869f8eb880ac28099ef43dee0000000000000000000000000e258c84df0f8728ae4a6426ea5fd163eb6b9d1b000000000000000000000000ef887e8b1c06209f59e8ae55d0e625c937344376

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102ad5760003560e01c80637284ae931161017b578063a217fddf116100d8578063c89e43611161008c578063d5ed4d5a11610071578063d5ed4d5a14610757578063e7610eb11461076a578063ec87621c1461077d57600080fd5b8063c89e436114610731578063d547741f1461074457600080fd5b8063a9825041116100bd578063a9825041146106f8578063ae99c2c81461070b578063b6f38a1e1461071e57600080fd5b8063a217fddf146106dd578063a35524be146106e557600080fd5b806393aa28451161012f57806396087a9f1161011457806396087a9f1461069f5780639ecdda21146106ad578063a1ebf35d146106b657600080fd5b806393aa28451461066d57806395277dd51461067657600080fd5b80638456cb59116101605780638456cb5914610602578063872873be1461060a57806391d148541461063657600080fd5b80637284ae93146104f657806379b64040146105ef57600080fd5b80633f4ba83a116102295780635b5b121d116101dd578063639b2b4d116101c2578063639b2b4d146104b45780636ed93dd0146104c757806370ba25fc146104e357600080fd5b80635b5b121d146104965780635c975abb146104a957600080fd5b806354cc4a781161020e57806354cc4a781461041d578063552f023e146104485780635794fefc1461047157600080fd5b80633f4ba83a146103f557806350015350146103fd57600080fd5b8063150b7a02116102805780632f2ff15d116102655780632f2ff15d146103a3578063359f62e4146103b657806336568abe146103e257600080fd5b8063150b7a021461033b578063248a9ca31461037257600080fd5b806301ffc9a7146102b25780630263952a146102da5780630a9c7563146102ef578063117c121514610302575b600080fd5b6102c56102c036600461362a565b6107a4565b60405190151581526020015b60405180910390f35b6102ed6102e8366004613508565b6107cf565b005b6102ed6102fd3660046135cb565b6108d7565b6102c56103103660046134dd565b6001600160a01b03919091166000908152600d60209081526040808320938352929052205460ff1690565b610359610349366004613473565b630a85bd0160e11b949350505050565b6040516001600160e01b031990911681526020016102d1565b6103956103803660046135cb565b60009081526020819052604090206001015490565b6040519081526020016102d1565b6102ed6103b13660046135fb565b61099a565b6102c56103c436600461343b565b6001600160a01b031660009081526008602052604090205460ff1690565b6102ed6103f03660046135fb565b6109c4565b6102ed610a4c565b61041061040b36600461376a565b610a81565b6040516102d19190613999565b600354610430906001600160a01b031681565b6040516001600160a01b0390911681526020016102d1565b61039561045636600461343b565b6001600160a01b03166000908152600e602052604090205490565b6009546104819063ffffffff1681565b60405163ffffffff90911681526020016102d1565b6102ed6104a436600461376a565b610b20565b60015460ff166102c5565b6102ed6104c23660046135cb565b610d45565b6104d061271081565b60405161ffff90911681526020016102d1565b6102ed6104f136600461343b565b610dff565b61058361050436600461376a565b600c602052600090815260409020805460018201546002830154600384015460048501546005909501549394929391926001600160a01b0380831693600160a01b80850463ffffffff1694600160c01b900461ffff169367ffffffffffffffff8116936801000000000000000090910481169290811691900460ff168a565b604080519a8b5260208b0199909952978901969096526001600160a01b03948516606089015263ffffffff909316608088015261ffff90911660a087015267ffffffffffffffff1660c0860152811660e0850152166101008301521515610120820152610140016102d1565b6102ed6105fd366004613508565b610efa565b6102ed610ff7565b6102c561061836600461343b565b6001600160a01b031660009081526007602052604090205460ff1690565b6102c56106443660046135fb565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b61039560045481565b61039561068436600461376a565b63ffffffff166000908152600c602052604090206001015490565b6006546104d09061ffff1681565b61039560055481565b6103957f2aeb38be3df14d720aeb10a2de6df09b0fb3cd5c5ec256283a22d4593110ca4081565b610395600081565b6102ed6106f3366004613750565b611029565b6102ed6107063660046135cb565b6110fd565b6102ed610719366004613652565b6111b2565b6102ed61072c3660046135cb565b61123d565b600f54610430906001600160a01b031681565b6102ed6107523660046135fb565b611300565b600b54610430906001600160a01b031681565b6102ed61077836600461376a565b611325565b6103957faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c81565b60006001600160e01b03198216630a85bd0160e11b14806107c957506107c9826115ff565b92915050565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c6107f981611666565b815183511461085b5760405162461bcd60e51b815260206004820152602360248201527f6164647265737320616e64207065726d697473206c656e677468206d69736d616044820152620e8c6d60eb1b60648201526084015b60405180910390fd5b60005b83518110156108d1576108bf84828151811061088a57634e487b7160e01b600052603260045260246000fd5b60200260200101518483815181106108b257634e487b7160e01b600052603260045260246000fd5b6020026020010151611670565b806108c981613be4565b91505061085e565b50505050565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c61090181611666565b6004548211156109535760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964206475726174696f6e000000000000000000000000000000006044820152606401610852565b81600554146109965760058290556040518281527fada00761622e18474ad9efbe0dfbbcfdad01ffb7c67e8d41edce1369f8e66f28906020015b60405180910390a15b5050565b6000828152602081905260409020600101546109b581611666565b6109bf8383611726565b505050565b6001600160a01b0381163314610a425760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610852565b61099682826117c4565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c610a7681611666565b610a7e611843565b50565b604080518082019091526000808252602082015263ffffffff82166000908152600a60209081526040918290208251808401909352805467ffffffffffffffff81168452909183019068010000000000000000900460ff166002811115610af857634e487b7160e01b600052602160045260246000fd5b6002811115610b1757634e487b7160e01b600052602160045260246000fd5b90525092915050565b600280541415610b725760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610852565b60028055806001610b8282610a81565b602001516002811115610ba557634e487b7160e01b600052602160045260246000fd5b14610bf25760405162461bcd60e51b815260206004820152601060248201527f4c6f616e206973206e6f74206f70656e000000000000000000000000000000006044820152606401610852565b6000806000610c0085611895565b9250925092506000610c1182611a4f565b9050804211610c625760405162461bcd60e51b815260206004820152601760248201527f4c6f616e206973206e6f74206f766572647565207965740000000000000000006044820152606401610852565b336001600160a01b03841614610cba5760405162461bcd60e51b815260206004820152601960248201527f4f6e6c79206c656e6465722063616e206c6971756964617465000000000000006044820152606401610852565b815160408084015160e0850151825193845260208401919091529082018390524260608301526001600160a01b039081166080830152808516919086169063ffffffff8916907f4fac0ff43299a330bce57d0579985305af580acf256a6d7977083ede81be13269060a00160405180910390a4610d38868484611a75565b5050600160025550505050565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c610d6f81611666565b600554821015610dc15760405162461bcd60e51b815260206004820152601060248201527f496e76616c6964206475726174696f6e000000000000000000000000000000006044820152606401610852565b81600454146109965760048290556040518281527f78e13060dd5049aaff2eee249c07301476e6e5b5a60c65116c3fd872c288e4539060200161098d565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c610e2981611666565b6001600160a01b038216610e7f5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207265636569766572206164647265737300000000000000006044820152606401610852565b6003546001600160a01b0383811691161461099657600380547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040519081527fb390a6eece33fc2616d0250e8cd5d72a2b7e0d6cb889791d36ec8892a045b0949060200161098d565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c610f2481611666565b8151835114610f815760405162461bcd60e51b815260206004820152602360248201527f6164647265737320616e64207065726d697473206c656e677468206d69736d616044820152620e8c6d60eb1b6064820152608401610852565b60005b83518110156108d157610fe5848281518110610fb057634e487b7160e01b600052603260045260246000fd5b6020026020010151848381518110610fd857634e487b7160e01b600052603260045260246000fd5b6020026020010151611b9b565b80610fef81613be4565b915050610f84565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c61102181611666565b610a7e611c49565b7faf290d8680820aad922855f39b306097b20e28774d6c1ad35a20325630c3a02c61105381611666565b61271061ffff831611156110a95760405162461bcd60e51b815260206004820152601460248201527f626173697320706f696e7473203e2031303030300000000000000000000000006044820152606401610852565b60065461ffff838116911614610996576006805461ffff191661ffff84169081179091556040519081527f03017365bbe16943b524030df07e7689168ab63e854d27417498e6f9dc584dab9060200161098d565b42811061114c5760405162461bcd60e51b815260206004820152601160248201527f496e76616c69642074696d657374616d700000000000000000000000000000006044820152606401610852565b336000908152600e6020526040902054811115610a7e57336000818152600e6020908152604091829020849055815192835282018390527fe7258d55b23f4902343add21f328e6d35c5d58bff7fe8bda6f1df7851f04d36a91015b60405180910390a150565b6111ba611c84565b60028054141561120c5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610852565b6002805561121985611cd9565b611231611227868686611f19565b8686868686612003565b50506001600255505050565b336000908152600d6020908152604080832084845290915290205460ff16156112a85760405162461bcd60e51b815260206004820152600d60248201527f496e76616c6964206e6f6e6365000000000000000000000000000000000000006044820152606401610852565b336000818152600d60209081526040808320858452825291829020805460ff19166001179055815192835282018390527f26ccf9904b9b2fb069d347553978928fd2fc65efb2638dcbeb8d142e974479f091016111a7565b60008281526020819052604090206001015461131b81611666565b6109bf83836117c4565b6002805414156113775760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610852565b6002805580600161138782610a81565b6020015160028111156113aa57634e487b7160e01b600052602160045260246000fd5b146113f75760405162461bcd60e51b815260206004820152601060248201527f4c6f616e206973206e6f74206f70656e000000000000000000000000000000006044820152606401610852565b600080600061140585611895565b92509250925061141481611a4f565b4211156114635760405162461bcd60e51b815260206004820152600f60248201527f4c6f616e206973206578706972656400000000000000000000000000000000006044820152606401610852565b60008061146f8361248d565b600f54606086015160405163df77783560e01b81523360048201526001600160a01b038981166024830152918216604482015260648101849052939550919350169063df77783590608401600060405180830381600087803b1580156114d457600080fd5b505af11580156114e8573d6000803e3d6000fd5b5050600f54600354606087015160405163df77783560e01b81523360048201526001600160a01b0392831660248201529082166044820152606481018790529116925063df7778359150608401600060405180830381600087803b15801561154f57600080fd5b505af1158015611563573d6000803e3d6000fd5b5050845160408087015160e08801516060808a0151845195865260208601939093529284018790529183018790526001600160a01b039182166080840152811660a083015280881693508816915063ffffffff8a16907f6ee3573bd905753c83bc1aaca3c15bfa36391db95b778bd825eb010645a7ee459060c00160405180910390a46115f1878685611a75565b505060016002555050505050565b60006001600160e01b031982167f7965db0b0000000000000000000000000000000000000000000000000000000014806107c957507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146107c9565b610a7e81336124e4565b6001600160a01b0382166116c65760405162461bcd60e51b815260206004820152601660248201527f657263373231206973207a65726f2061646472657373000000000000000000006044820152606401610852565b6001600160a01b038216600081815260086020908152604091829020805460ff191685151590811790915591519182527f3e0c443872dd01e15f6ca1f8ee12f284a44836f46012e421d74611bf80eda7c191015b60405180910390a25050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16610996576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556117803390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1615610996576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b61184b612562565b6001805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e0810182905261010081018290526101208101829052819060006118f285610a81565b5163ffffffff8681166000908152600c60209081526040918290208251610140810184528154815260018201549281019290925260028101548284015260038101546001600160a01b038082166060850152600160a01b8083049096166080850152600160c01b90910461ffff1660a084015260048083015467ffffffffffffffff80821660c087015268010000000000000000909104831660e0860152600590930154808316610100860181905296900460ff161515610120850152600b5494517f6352211e000000000000000000000000000000000000000000000000000000008152929096169582018690529398509095509293501690636352211e9060240160206040518083038186803b158015611a0d57600080fd5b505afa158015611a21573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a459190613457565b9250509193909250565b6000816080015163ffffffff168260c0015167ffffffffffffffff166107c99190613b0b565b611a7e836125b4565b60e081015160408083015190517f42842e0e0000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b03858116602483015260448201929092529116906342842e0e90606401600060405180830381600087803b158015611af257600080fd5b505af1158015611b06573d6000803e3d6000fd5b50505063ffffffff9093166000908152600c602052604081208181556001810182905560028101919091556003810180547fffffffffffff00000000000000000000000000000000000000000000000000001690556004810180546001600160e01b031916905560050180547fffffffffffffffffffffff000000000000000000000000000000000000000000169055505050565b6001600160a01b038216611bf15760405162461bcd60e51b815260206004820152601560248201527f6572633230206973207a65726f206164647265737300000000000000000000006044820152606401610852565b6001600160a01b038216600081815260076020908152604091829020805460ff191685151590811790915591519182527ff100355be652ecc881568750e6a98c0713e4316f75d5314ebc9039e0acb52f24910161171a565b611c51611c84565b6001805460ff1916811790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25833611878565b60015460ff1615611cd75760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401610852565b565b60a08101516001600160a01b031660009081526007602052604090205460ff16611d455760405162461bcd60e51b815260206004820152601060248201527f496e76616c69642063757272656e6379000000000000000000000000000000006044820152606401610852565b6040808201516001600160a01b031660009081526008602052205460ff16611daf5760405162461bcd60e51b815260206004820152601460248201527f496e76616c69642045524337323120746f6b656e0000000000000000000000006044820152606401610852565b600454816060015163ffffffff161115611e0b5760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206d6178696d756d206475726174696f6e00000000000000006044820152606401610852565b600554816060015163ffffffff161015611e675760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964206d696e696d756d206475726174696f6e00000000000000006044820152606401610852565b805160208201511015611ebc5760405162461bcd60e51b815260206004820152601560248201527f496e76616c696420696e746572657374207261746500000000000000000000006044820152606401610852565b600654608082015161ffff908116911614610a7e5760405162461bcd60e51b815260206004820152601160248201527f41646d696e20666565206368616e6765640000000000000000000000000000006044820152606401610852565b6040805161014081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081019190915260405180610140016040528085600001518152602001856020015181526020018481526020018560a001516001600160a01b03168152602001856060015163ffffffff168152602001856080015161ffff1681526020014267ffffffffffffffff16815260200185604001516001600160a01b03168152602001336001600160a01b0316815260200183151581525090505b9392505050565b6040808301516001600160a01b0381166000908152600d6020908152838220865183529052919091205460ff161561207d5760405162461bcd60e51b815260206004820152601460248201527f4c656e646572206e6f6e636520696e76616c69640000000000000000000000006044820152606401610852565b6040808301516001600160a01b031660009081527fdb8ccd0e71cbf52bceafef256d2658d12104739e125d9c49583283aa4b756454602052205460ff166121065760405162461bcd60e51b815260206004820152601560248201527f496e76616c69642062726f6b6572207369676e657200000000000000000000006044820152606401610852565b60c08601516001600160a01b0382166000908152600e6020526040902054106121715760405162461bcd60e51b815260206004820152600f60248201527f4f666665722063616e63656c6c656400000000000000000000000000000000006044820152606401610852565b61217e8686868686612737565b6001600160a01b038181166000908152600d602090815260408083208751845290915290819020805460ff19166001179055600f5460e08a01518a83015192517f42f1a25600000000000000000000000000000000000000000000000000000000815233600482015230602482015290841660448201526064810192909252909116906342f1a25690608401600060405180830381600087803b15801561222457600080fd5b505af1158015612238573d6000803e3d6000fd5b5050600f5460608a01518a5160405163df77783560e01b81526001600160a01b038781166004830152336024830152928316604482015260648101919091529116925063df7778359150608401600060405180830381600087803b15801561229f57600080fd5b505af11580156122b3573d6000803e3d6000fd5b5050505060006122c28261284d565b905087600c60008363ffffffff1663ffffffff16815260200190815260200160002060008201518160000155602082015181600101556040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160030160146101000a81548163ffffffff021916908363ffffffff16021790555060a08201518160030160186101000a81548161ffff021916908361ffff16021790555060c08201518160040160006101000a81548167ffffffffffffffff021916908367ffffffffffffffff16021790555060e08201518160040160086101000a8154816001600160a01b0302191690836001600160a01b031602179055506101008201518160050160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506101208201518160050160146101000a81548160ff02191690831515021790555090505083604001516001600160a01b0316336001600160a01b03168263ffffffff167f41405b00e0df471a285ab48e999085e2587e99e951ecd148b4c65d5c98735edc87600001518c60405161247b9291906139c5565b60405180910390a45050505050505050565b6000806000836000015184602001516124a69190613b8a565b60a0850151909150612710906124c09061ffff1683613b6b565b6124ca9190613b4b565b92508284602001516124dc9190613b8a565b915050915091565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661099657612520816001600160a01b03166014612a68565b61252b836020612a68565b60405160200161253c92919061389b565b60408051601f198184030181529082905262461bcd60e51b825261085291600401613986565b60015460ff16611cd75760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401610852565b63ffffffff81166000908152600a602052604090206001815468010000000000000000900460ff1660028111156125fb57634e487b7160e01b600052602160045260246000fd5b146126485760405162461bcd60e51b815260206004820152601560248201527f4c6f616e206973206e6f742061206e6577206f6e6500000000000000000000006044820152606401610852565b80546802000000000000000068ff0000000000000000198216178255600b546040517f42966c6800000000000000000000000000000000000000000000000000000000815267ffffffffffffffff90921660048301526001600160a01b0316906342966c6890602401600060405180830381600087803b1580156126cb57600080fd5b505af11580156126df573d6000803e3d6000fd5b5050825460405167ffffffffffffffff909116925063ffffffff851691507fa99afb24dca45e3cebef49cd6184255e4623c0bf6c5e87bb6738629ceefa2dac9061272b90600290613978565b60405180910390a35050565b8215612798576127478583612c8f565b6127935760405162461bcd60e51b815260206004820152601b60248201527f4c656e646572207369676e617475726520697320696e76616c696400000000006044820152606401610852565b6127ef565b6127a3858584612db1565b6127ef5760405162461bcd60e51b815260206004820152601b60248201527f4c656e646572207369676e617475726520697320696e76616c696400000000006044820152606401610852565b6127fa858583612db1565b6128465760405162461bcd60e51b815260206004820152601b60248201527f5369676e6572207369676e617475726520697320696e76616c696400000000006044820152606401610852565b5050505050565b60098054600091600191839061286a90849063ffffffff16613b23565b82546101009290920a63ffffffff818102199093169190921691909102179055506009546040513060601b6bffffffffffffffffffffffff1916602082015260e09190911b6001600160e01b031916603482015260009060380160408051808303601f190181528282528051602091820120838301835267ffffffffffffffff81168452600182850152600b54600954845163ffffffff909116938101939093529094506001600160a01b0316916394d008ef9187918691016040516020818303038152906040526040518463ffffffff1660e01b81526004016129509392919061391c565b600060405180830381600087803b15801561296a57600080fd5b505af115801561297e573d6000803e3d6000fd5b505060095463ffffffff166000908152600a602090815260409091208451815467ffffffffffffffff90911667ffffffffffffffff19821681178355928601518695509193509091839168ffffffffffffffffff191617680100000000000000008360028111156129ff57634e487b7160e01b600052602160045260246000fd5b02179055505060095460405167ffffffffffffffff8516925063ffffffff909116907fa99afb24dca45e3cebef49cd6184255e4623c0bf6c5e87bb6738629ceefa2dac90612a4f90600190613978565b60405180910390a3505060095463ffffffff1692915050565b60606000612a77836002613b6b565b612a82906002613b0b565b67ffffffffffffffff811115612aa857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612ad2576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110612b1757634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110612b7057634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000612b94846002613b6b565b612b9f906001613b0b565b90505b6001811115612c40577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110612bee57634e487b7160e01b600052603260045260246000fd5b1a60f81b828281518110612c1257634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c93612c3981613bcd565b9050612ba2565b508315611ffc5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610852565b60008160200151421115612ce55760405162461bcd60e51b815260206004820152601560248201527f5369676e617475726520686173206578706972656400000000000000000000006044820152606401610852565b60408201516001600160a01b0316612cff575060006107c9565b6000612d0a84612ecb565b612d1384612f98565b3046604051602001612d2894939291906137ee565b604051602081830303815290604052805190602001209050612da98360400151612d9f836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b8560600151612fe0565b9150506107c9565b60008160200151421115612e075760405162461bcd60e51b815260206004820152601160248201527f5369676e617475726520657870697265640000000000000000000000000000006044820152606401610852565b60408201516001600160a01b0316612e2157506000611ffc565b6000612e2c85612ecb565b84612e3685612f98565b3046604051602001612e4c95949392919061383e565b604051602081830303815290604052805190602001209050612ec38360400151612d9f836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b915050611ffc565b60608160a00151826000015183602001518460400151856060015186608001518760c00151604051602001612f829796959493929190606097881b6bffffffffffffffffffffffff199081168252601482019790975260348101959095529290951b909316605483015260e09290921b6001600160e01b031916606882015260f09290921b7fffff00000000000000000000000000000000000000000000000000000000000016606c830152606e820152608e0190565b6040516020818303038152906040529050919050565b6060816040015182600001518360200151604051602001612f829392919060609390931b6bffffffffffffffffffffffff191683526014830191909152603482015260540190565b6000806000612fef858561315e565b9092509050600081600481111561301657634e487b7160e01b600052602160045260246000fd5b1480156130345750856001600160a01b0316826001600160a01b0316145b1561304457600192505050611ffc565b600080876001600160a01b0316631626ba7e60e01b888860405160240161306c929190613957565b60408051601f198184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff166001600160e01b03199094169390931790925290516130bf91906137d2565b600060405180830381855afa9150503d80600081146130fa576040519150601f19603f3d011682016040523d82523d6000602084013e6130ff565b606091505b5091509150818015613112575080516020145b8015613152575080517f1626ba7e000000000000000000000000000000000000000000000000000000009061315090830160209081019084016135e3565b145b98975050505050505050565b6000808251604114156131955760208301516040840151606085015160001a613189878285856131a4565b9450945050505061319d565b506000905060025b9250929050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156131db5750600090506003613288565b8460ff16601b141580156131f357508460ff16601c14155b156132045750600090506004613288565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613258573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661328157600060019250925050613288565b9150600090505b94509492505050565b600082601f8301126132a1578081fd5b813560206132b66132b183613ae7565b613ab6565b80838252828201915082860187848660051b89010111156132d5578586fd5b855b858110156132fa576132e882613307565b845292840192908401906001016132d7565b5090979650505050505050565b8035801515811461331757600080fd5b919050565b600082601f83011261332c578081fd5b813567ffffffffffffffff81111561334657613346613c15565b613359601f8201601f1916602001613ab6565b81815284602083860101111561336d578283fd5b816020850160208301379081016020019190915292915050565b600060808284031215613398578081fd5b6040516080810167ffffffffffffffff82821081831117156133bc576133bc613c15565b816040528293508435835260208501356020840152604085013591506133e182613c2b565b81604084015260608501359150808211156133fb57600080fd5b506134088582860161331c565b6060830152505092915050565b803561ffff8116811461331757600080fd5b803563ffffffff8116811461331757600080fd5b60006020828403121561344c578081fd5b8135611ffc81613c2b565b600060208284031215613468578081fd5b8151611ffc81613c2b565b60008060008060808587031215613488578283fd5b843561349381613c2b565b935060208501356134a381613c2b565b925060408501359150606085013567ffffffffffffffff8111156134c5578182fd5b6134d18782880161331c565b91505092959194509250565b600080604083850312156134ef578182fd5b82356134fa81613c2b565b946020939093013593505050565b6000806040838503121561351a578182fd5b823567ffffffffffffffff80821115613531578384fd5b818501915085601f830112613544578384fd5b813560206135546132b183613ae7565b8083825282820191508286018a848660051b8901011115613573578889fd5b8896505b8487101561359e57803561358a81613c2b565b835260019690960195918301918301613577565b50965050860135925050808211156135b4578283fd5b506135c185828601613291565b9150509250929050565b6000602082840312156135dc578081fd5b5035919050565b6000602082840312156135f4578081fd5b5051919050565b6000806040838503121561360d578182fd5b82359150602083013561361f81613c2b565b809150509250929050565b60006020828403121561363b578081fd5b81356001600160e01b031981168114611ffc578182fd5b600080600080600085870361016081121561366b578384fd5b60e0811215613678578384fd5b50613681613a8d565b8635815260208701356020820152604087013561369d81613c2b565b60408201526136ae60608801613427565b60608201526136bf60808801613415565b608082015260a08701356136d281613c2b565b60a082015260c08781013590820152945060e086013593506136f76101008701613307565b925061012086013567ffffffffffffffff80821115613714578283fd5b61372089838a01613387565b9350610140880135915080821115613736578283fd5b5061374388828901613387565b9150509295509295909350565b600060208284031215613761578081fd5b611ffc82613415565b60006020828403121561377b578081fd5b611ffc82613427565b6000815180845261379c816020860160208601613ba1565b601f01601f19169290920160200192915050565b600381106137ce57634e487b7160e01b600052602160045260246000fd5b9052565b600082516137e4818460208701613ba1565b9190910192915050565b60008551613800818460208a01613ba1565b855190830190613814818360208a01613ba1565b60609590951b6bffffffffffffffffffffffff191694019384525050601482015260340192915050565b60008651613850818460208b01613ba1565b82018681528551613868816020808501908a01613ba1565b60609590951b6bffffffffffffffffffffffff191660209190950190810194909452505060348201526054019392505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516138d3816017850160208801613ba1565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351613910816028840160208801613ba1565b01602801949350505050565b6001600160a01b038416815267ffffffffffffffff8316602082015260606040820152600061394e6060830184613784565b95945050505050565b8281526040602082015260006139706040830184613784565b949350505050565b602081016107c982846137b0565b602081526000611ffc6020830184613784565b815167ffffffffffffffff16815260208083015160408301916139be908401826137b0565b5092915050565b6000610160820190508382528251602083015260208301516040830152604083015160608301526060830151613a0660808401826001600160a01b03169052565b50608083015163ffffffff811660a08401525060a083015161ffff811660c08401525060c083015167ffffffffffffffff811660e08401525060e0830151610100613a5b818501836001600160a01b03169052565b8401519050610120613a77848201836001600160a01b03169052565b8401518015156101408501529050509392505050565b60405160e0810167ffffffffffffffff81118282101715613ab057613ab0613c15565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715613adf57613adf613c15565b604052919050565b600067ffffffffffffffff821115613b0157613b01613c15565b5060051b60200190565b60008219821115613b1e57613b1e613bff565b500190565b600063ffffffff808316818516808303821115613b4257613b42613bff565b01949350505050565b600082613b6657634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613b8557613b85613bff565b500290565b600082821015613b9c57613b9c613bff565b500390565b60005b83811015613bbc578181015183820152602001613ba4565b838111156108d15750506000910152565b600081613bdc57613bdc613bff565b506000190190565b6000600019821415613bf857613bf8613bff565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610a7e57600080fdfea26469706673582212200940b68a61a9137d65c3629708006f45614eb9460825c7ae2742ada76b023f0e64736f6c63430008040033

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

0000000000000000000000001b4b3465b65fb87f869f8eb880ac28099ef43dee0000000000000000000000000e258c84df0f8728ae4a6426ea5fd163eb6b9d1b000000000000000000000000ef887e8b1c06209f59e8ae55d0e625c937344376

-----Decoded View---------------
Arg [0] : _admin (address): 0x1B4B3465B65Fb87f869f8eB880ac28099eF43dee
Arg [1] : _ticketToken (address): 0x0E258c84Df0f8728ae4A6426EA5FD163Eb6b9D1B
Arg [2] : _delegate (address): 0xeF887e8b1C06209F59E8Ae55D0e625C937344376

-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000001b4b3465b65fb87f869f8eb880ac28099ef43dee
Arg [1] : 0000000000000000000000000e258c84df0f8728ae4a6426ea5fd163eb6b9d1b
Arg [2] : 000000000000000000000000ef887e8b1c06209f59e8ae55d0e625c937344376


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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