Address Details
contract

0xD5E9Cd763ad38cB777C8eED2d0446e52c84406bc

Contract Name
VirtuousAuction
Creator
0x6d3f1b–09369f at 0xf87e18–c8d7a2
Balance
0 CELO ( )
Locked CELO Balance
0.00 CELO
Voting CELO Balance
0.00 CELO
Pending Unlocked Gold
0.00 CELO
Tokens
Fetching tokens...
Transactions
0 Transactions
Transfers
0 Transfers
Gas Used
Fetching gas used...
Last Balance Update
14524762
This contract has been verified via Sourcify. View contract in Sourcify repository
Contract name:
VirtuousAuction




Optimization enabled
true
Compiler version
v0.8.4+commit.c7e474f2




Optimization runs
200
EVM Version
istanbul




Verified at
2023-01-25T22:08:27.151785Z

project:/contracts/VirtuousAuction.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "./VirtuousTokenServices.sol";
import "./IVirtuousContractFactory.sol";

contract VirtuousAuction is Initializable, VirtuousTokenServices, ReentrancyGuardUpgradeable {

    using SafeMathUpgradeable for uint256;
    // static
    uint256 public floorPrice;
    uint256 public startTime;
    uint256 public endTime;
    address private salesPerson;
    uint256 private salesPersonRoyaltyFeePercent;

    // state
    bool private fundCollected;
    bool public canceled;
    uint256 public highestBindingBid;
    address public highestBidder;
    address[] private bidders;   
    mapping(address => uint256) public fundsByBidder;  
    mapping(address => bool) public rewardCollected;         

    // events
    event LogBid(address bidder, uint256 bid, address highestBidder, uint256 highestBid, uint256 highestBindingBid);
    event LogWithdrawal(address withdrawalAccount, uint256 amount);
    event FundCollected(uint256 merchantFee, uint256 marketplaceRoyalty, uint256 salesPersonRoyalty); 
    event VirtuousTokenCollected(address winner, uint256 tokenId);
    event LogCanceled(bool success);
    event LogRefund(address sender, uint256 amount);
    event Received(address sender, uint256 amount);

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

    function initialize(IERC20Upgradeable _erc20Token, address _beneficiary, uint256 _floorPrice, uint256 _startTime, uint256 _endTime, uint256 _virtuousTokensIssued, uint256 _redeemQty, address _salesPerson, uint256 _marketplaceRoyaltyFeePercent, uint256 _salesPersonRoyaltyFeePercent, uint256 _maintenanceFee, maintenanceFeeDueType _feeDueType) initializer public {
        __ReentrancyGuard_init();     
        __VirtuousTokenServices_init(_erc20Token, _beneficiary, _marketplaceRoyaltyFeePercent, _virtuousTokensIssued, _redeemQty, _maintenanceFee, _feeDueType); 
        require(_endTime > block.timestamp && _endTime > _startTime, 'Auction end timestamp can not be the past or invalid!');
        require(_beneficiary != address(0x0), 'Beneficiary address is not correct!');
        salesPerson = _salesPerson;
        floorPrice = _floorPrice;
        startTime = _startTime;
        endTime = _endTime;
        salesPersonRoyaltyFeePercent = _salesPersonRoyaltyFeePercent;
    }

    // bid on NFD
    function placeBid(uint256 amount) external
        nonReentrant
        onlyAfterStart
        onlyBeforeEnd
        onlyNotCanceled
        onlyNotBeneficiary
    {   
        address _bidder = msg.sender;
        require(erc20Token.balanceOf(_bidder) >= amount, 'Insufficiant ERC20 token balance!');       

        // calculate the user's total bid based on the current amount they've sent to the contract
        // plus whatever has been sent with this transaction
        uint newBid = fundsByBidder[_bidder].add(amount);

        // reject payments of less than floor price
        require(newBid >= floorPrice, 'Bid Token amount too low!, amount should be above floor price');

        // grab the previous highest bid (before updating fundsByBidder, in case msg.sender is the
        // highestBidder and is just increasing their maximum bid).
        uint highestBid = fundsByBidder[highestBidder];

        fundsByBidder[_bidder] = newBid;

        if (newBid > highestBid) {
            if (_bidder != highestBidder) {
                highestBidder = _bidder;
            }
            highestBid = newBid;
        }                 
               
        // ERC20 token transfer from bidder to current contract address
        bool sent = IVirtuousContractFactory(contractFactory).erc20TransferFrom(_bidder, address(this), amount);
        require(sent, "Fund transfer failed!");

        _checkBidder(_bidder);
        emit LogBid(_bidder, amount, highestBidder, highestBid, highestBindingBid);
    }

    function _checkBidder(address bidder) internal virtual
    {
        bool alreadyBidder; 
        for (uint256 i = 0; i < bidders.length; i++) {
            if(msg.sender == bidders[i]) {alreadyBidder = true; break;}
        }
        if(!alreadyBidder) bidders.push(bidder);
    }

    function min(uint a, uint b)
        private
        pure
        returns (uint)
    {
        if (a < b) return a;
        return b;
    }

    function withdraw() external
        nonReentrant
        onlyHasCanceled
        onlyNotBeneficiary
        onlyBidder
    {
        address withdrawalAccount;
        uint256 withdrawalAmount;        

        withdrawalAccount = msg.sender;
        withdrawalAmount = fundsByBidder[withdrawalAccount];

        require(withdrawalAmount > 0, 'You have already withdrawal your funds!');
        fundsByBidder[withdrawalAccount] -= withdrawalAmount;

        //withdraw the ERC20 tokens paid for bid
        erc20Token.transfer(withdrawalAccount, withdrawalAmount);
        emit LogWithdrawal(withdrawalAccount, withdrawalAmount);
    }

    function getHighestBid() public       
        view returns (uint256)
    {
        return fundsByBidder[highestBidder];
    }

    function getMyBid() public
        view returns (uint256)
    {
        return fundsByBidder[msg.sender];
    }

    function getAuctionStatus() public
        view returns (string memory )
    {
        if( canceled ) return 'canceled';
        if( block.timestamp > endTime ) return 'ended';
        if( block.timestamp < startTime ) return 'not-started';
        return 'running';
    }

    function getMarketPlaceRoyaltyFeePercent() external 
        onlyContractFactoryOwner      
        view returns (uint256)
    {
        return marketplaceRoyaltyFeePercent;
    }

    function getSalesPersonRoyaltyFeePercent() external 
        onlyContractFactoryOwner      
        view returns (uint256)
    {
        return salesPersonRoyaltyFeePercent;
    }

    function tokenList() external
        onlyContractFactoryOwner
        onlyCompleted
        view returns (uint256[] memory) 
    {
        return _tokenList();
    }

    function bidderList() external 
        onlyContractFactoryOwner
        onlyAfterStart
        view returns (address[] memory) 
    {
        return bidders;
    }

     function winnerList() public
        onlyContractFactoryOwner
        view 
        returns (address[] memory)
    {
       return _winnerList();
    }

    function _winnerList() internal
        view 
        returns (address[] memory)
    {
        require(bidders.length > 0, 'No bidder found, winner list can not be generate!');
        uint256 maxWinners = bidders.length < getVirtuousTokensIssued() ? bidders.length : getVirtuousTokensIssued();
        address[] memory winners = new address[](maxWinners); 
        winners[0] = highestBidder;
        if( maxWinners == 1 ) return winners;
        return _winnersListPrepare(fundsByBidder[highestBidder], winners, 1);
    }
    
    function _winnersListPrepare( uint256 _lastWinningPrice, address[] memory winners, uint winnerIndex) internal 
        view 
        returns (address[] memory)
    {   
        uint256 priceFilter = _lastWinningPrice.sub(10000000000000000); 
        for (uint j = bidders.length; j > 0; j--) {
            if( winnerIndex == winners.length ) break;
            address bidder = bidders[j-1];
            if( fundsByBidder[bidder] >= priceFilter && fundsByBidder[bidder] < _lastWinningPrice ){                        
                winners[winnerIndex] = bidder;
                winnerIndex = winnerIndex.add(1);
            } 
        }
        if( winnerIndex == winners.length ) return winners;
        return _winnersListPrepare(priceFilter, winners, winnerIndex);
    }

    function redeemNFD(uint256 _tokenId) external virtual
        onlyContractFactoryOwner
        onlyCompleted
    {
        _redeemNFD(_tokenId);
    }    

    function cancelAuction() external
        nonReentrant
        onlyContractFactoryOwner
        onlyBeforeEnd
        onlyNotCanceled
        returns (bool success)
    {
        canceled = true;
        emit LogCanceled(true);
        return true;
    }

    function refund() external
        nonReentrant
        onlyNotBeneficiary
        onlyCompleted
        onlyBidder
        onlyNonWinner
    {
        uint256 withdrawalAmount = fundsByBidder[msg.sender];
        require(withdrawalAmount > 0, 'You already have refund back!');
        fundsByBidder[msg.sender] -= withdrawalAmount;
        
        //refund the ERC20 tokens to bidder, paid for bid but not become winner
        erc20Token.transfer(msg.sender, withdrawalAmount);
        emit LogRefund(msg.sender, withdrawalAmount);
    }

    function collectToken(uint _tokenId, address _virtuousToken) external virtual
        nonReentrant
        onlyNotBeneficiary
        onlyCompleted
        onlyWinner
        onlyRewardNotCollected
    {
        rewardCollected[msg.sender] = true;
        IERC721Upgradeable virtuousToken = IERC721Upgradeable(_virtuousToken);
        require(virtuousToken.ownerOf(_tokenId) == address(this), "This contract is not owner of this NFD token!");
        virtuousToken.safeTransferFrom(address(this), msg.sender, _tokenId);
        emit VirtuousTokenCollected(msg.sender,  _tokenId);
    }

    function contractFactoryOwner() internal view returns(address){
        return IVirtuousContractFactory(contractFactory).getContractFactoryOwner();
    }

    function collectFund() external
        nonReentrant
        onlyBeneficiaryOrOwner
        onlyNotCollected
    {   
        address[] memory winners = _winnerList();
        uint256 merchantFund;
        uint256 royalty;
        for( uint256 i = 0; i < winners.length; i++ ) 
        {   
            address winner = winners[i];
            uint256 amount = fundsByBidder[winner];                   
            uint256 marketplaceFee = amount.div(100).mul(marketplaceRoyaltyFeePercent);
            royalty = royalty.add(marketplaceFee);
            uint256 merchantFee = amount.sub(marketplaceFee);
            merchantFund = merchantFund.add(merchantFee);            
            fundsByBidder[winner] -= amount;
        }
       
        fundCollected = true;
        //transfer to benefiaciary wallet
        erc20Token.transfer(beneficiary, merchantFund); 

        uint256 marketplaceRoyalty;
        uint256 salesPersonRoyalty;
        if( salesPerson != address(0x0) ){
            salesPersonRoyalty = royalty.div(100).mul(salesPersonRoyaltyFeePercent);
            marketplaceRoyalty = royalty.sub(salesPersonRoyalty);
            //Transfer sale royalty to sales person wallet address
            erc20Token.transfer(salesPerson, salesPersonRoyalty);
        }else{ marketplaceRoyalty = royalty; } 

        //Transfer marketplace royalty to royalty receiver wallet address
        address marketPlaceRoyaltyReceiver = IVirtuousContractFactory(contractFactory).getMarketPlaceRoyaltyReceiverWallet();
        erc20Token.transfer(marketPlaceRoyaltyReceiver, marketplaceRoyalty);  

        emit FundCollected(merchantFund, marketplaceRoyalty, salesPersonRoyalty);
    } 

    receive() external payable 
    {
        emit Received(msg.sender, msg.value);
    }

    fallback() external payable {
        emit Received(msg.sender, msg.value);
    }

    modifier onlyNotBeneficiary {
        if (msg.sender == beneficiary) revert('Beneficiary can not perform the action!');
        _;
    }

    modifier onlyBeneficiaryOrOwner {
        require( msg.sender == beneficiary || msg.sender == contractFactoryOwner(), 'Beneficiary / Owner can only perform the action!');
        _;
    }

    modifier onlyAfterStart {
        if (block.timestamp < startTime) revert('Auction yet not start!');
        _;
    }

    modifier onlyBeforeEnd {
        if (block.timestamp > endTime) revert('Auction already ended!');
        _;
    }

    modifier onlyNotCanceled {
        if (canceled) revert('Auction already canceled!');
        _;
    }

    modifier onlyRewardNotCollected {
        require(!rewardCollected[msg.sender], 'You have already collected your token!');
        _;
    }

    modifier onlyHasCanceled {
        if (!canceled) revert('Auction is not canceled!');
        _;
    }

    modifier onlyCompleted {
        require(block.timestamp > endTime && !canceled, "Auction is not ended yet!");
        _;
    }

    modifier onlyBidder {
        require(fundsByBidder[msg.sender] > 0, 'You are not a valid bidder!');
        _;
    }

    modifier onlyContractFactoryOwner {        
        require(contractFactoryOwner() == msg.sender, "You are not an owner");
        _;
    }

    modifier onlyNotCollected {
        require(!fundCollected, "Funds already collected!");
        _;
    }

    modifier onlyNonWinner {
        address[] memory winners = _winnerList();
        for( uint256 i = 0; i < winners.length; i++ ) {
            if( msg.sender == winners[i] ) revert('You are winner, you can not perform this action!');
        }
        _;
    }

    modifier onlyWinner {
        address[] memory winners = _winnerList();
        bool winner;
        for( uint256 i = 0; i < winners.length; i++ ) {
            if( msg.sender == winners[i] ){ winner = true; break; }
        }
        require(winner, 'You are not a winner!');
        _;
    }
}
        

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

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

pragma solidity ^0.8.2;

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

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

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

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

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

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

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

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

/_openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

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

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _status = _NOT_ENTERED;
    }

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

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

/_openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

/_openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol

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

pragma solidity ^0.8.0;

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

/_openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

/project_/contracts/IVirtuousContractFactory.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface IVirtuousContractFactory {
    function erc20TransferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    function getMarketPlaceRoyaltyReceiverWallet() external view returns (address);
    function getContractFactoryOwner() external view returns (address);
}
          

/project_/contracts/VirtuousTokenServices.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "./IVirtuousContractFactory.sol";

abstract contract VirtuousTokenServices is Initializable, ERC721HolderUpgradeable {

    using SafeMathUpgradeable for uint256;      
    IERC20Upgradeable internal erc20Token;
    address internal contractFactory;  
    address internal beneficiary;
    uint256 internal marketplaceRoyaltyFeePercent;    
    uint256 internal virtuousTokensIssued;
    uint256[] private allowedVirtuousTokens;
    uint256 private redeemQty;
    mapping(uint256 => uint256) public redeemed;  
    uint256 public maintenanceFee;
    mapping(uint256 => uint256) private maintenanceFeeExpiredOn;
    enum maintenanceFeeDueType{ monthly, quarterly, annual, none }
    maintenanceFeeDueType private maintenanceDueType;

    event MaintenanceFeePaid(uint256 tokenId, address from, uint validityTill);
    event VirtuousTokenRedeemed(uint tokenId, uint256 redeemedTotal);     

    function __VirtuousTokenServices_init(IERC20Upgradeable _erc20Token, address _beneficiary, uint256 _marketplaceRoyaltyFeePercent, uint256 _virtuousTokensIssued, uint256 _redeemQty, uint256 _maintenanceFee, maintenanceFeeDueType _feeDueType ) 
        internal 
        onlyInitializing 
    {   
        erc20Token = _erc20Token;
        beneficiary = _beneficiary;
        marketplaceRoyaltyFeePercent = _marketplaceRoyaltyFeePercent;
        contractFactory = msg.sender;
        virtuousTokensIssued = _virtuousTokensIssued;
        redeemQty = _redeemQty; 
        maintenanceFee = _maintenanceFee;
        maintenanceDueType = _feeDueType;
    }

    function getVirtuousTokensIssued() internal view returns(uint256)
    {
        return virtuousTokensIssued;
    }

    function getVirtuousTokensAllowed() internal view returns(uint256[] memory)
    {
        return allowedVirtuousTokens;
    }

    function getTokenReddemCount(uint256 _tokenId) 
        public
        view returns (uint256)
    {
        return redeemed[_tokenId];
    }

    function _tokenList() 
        internal
        view returns (uint256[] memory) 
    {
        return getVirtuousTokensAllowed();
    }

    function onERC721Received(
        address,
        address,
        uint256 _tokenId,   
        bytes memory
    ) public virtual override returns (bytes4) 
    {
        require(getVirtuousTokensIssued() > getVirtuousTokensAllowed().length, 'Token allowance has reached the maximum!');
        allowedVirtuousTokens.push(_tokenId);
        return this.onERC721Received.selector;
    }

    function _redeemNFD(uint256 _tokenId) 
        internal 
        isTokenAllowed(_tokenId)
        isMaintenanceFeeApplicable(_tokenId)
    {   
        if(redeemQty > 0 && redeemQty > redeemed[_tokenId])
        { 
            revert("User have reached the maximum allowance!"); 
        }
        redeemed[_tokenId] = redeemed[_tokenId].add(1);
        emit VirtuousTokenRedeemed( _tokenId,  redeemed[_tokenId]);        
    }

    function payMaintenanceFee(uint256 tokenId) public isTokenAllowed(tokenId){
        
        require(maintenanceFee > 0, 'This NFD does not support maintenance fee');
        uint256 marketplaceFee = maintenanceFee.div(100).mul(marketplaceRoyaltyFeePercent);
        uint256 merchantFee = maintenanceFee.sub(marketplaceFee);
        address marketPlaceRoyaltyReceiver = IVirtuousContractFactory(contractFactory).getMarketPlaceRoyaltyReceiverWallet();

        //transfer to benefiaciary wallet
        bool sentToBeneficiary = IVirtuousContractFactory(contractFactory).erc20TransferFrom(msg.sender, beneficiary, merchantFee);
        require(sentToBeneficiary, "Fund transfer to beneficiary failed!");
        //Transfer marketplace fee to royalty receiver wallet address
        bool sentToMarketPlace = IVirtuousContractFactory(contractFactory).erc20TransferFrom(msg.sender, marketPlaceRoyaltyReceiver, marketplaceFee);
        require(sentToMarketPlace, "Fund transfer to marketplace failed!");    
        
        uint today = block.timestamp;
        uint validityTill;
  
        if(maintenanceDueType == maintenanceFeeDueType.monthly){
            validityTill = today + 30 days;
        }else if(maintenanceDueType == maintenanceFeeDueType.quarterly){
            validityTill = today + 90 days;
        }else if(maintenanceDueType == maintenanceFeeDueType.annual){
            validityTill = today + 365 days;
        }
        maintenanceFeeExpiredOn[tokenId] = validityTill;
        emit MaintenanceFeePaid(tokenId, msg.sender, validityTill); 
    }

    modifier isMaintenanceFeeApplicable(uint256 tokenId){
        uint256 expireOn = maintenanceFeeExpiredOn[tokenId];
        if(maintenanceFee > 0) require(block.timestamp <= expireOn, 'Maintenance validity expired please pay maintenance fee!');
        _;        
    }

    modifier isTokenAllowed(uint256 _tokenId)
    {
        bool tokenAllowed;
        for( uint256 i = 0; i < getVirtuousTokensAllowed().length; i++ ) 
        {
            if(allowedVirtuousTokens[i] == _tokenId) {
                tokenAllowed = true;
                break;
            }
        }
        require(tokenAllowed, 'This Token is not allowed for this NFD!');
        _;
    }
}
          

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"event","name":"FundCollected","inputs":[{"type":"uint256","name":"merchantFee","internalType":"uint256","indexed":false},{"type":"uint256","name":"marketplaceRoyalty","internalType":"uint256","indexed":false},{"type":"uint256","name":"salesPersonRoyalty","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"LogBid","inputs":[{"type":"address","name":"bidder","internalType":"address","indexed":false},{"type":"uint256","name":"bid","internalType":"uint256","indexed":false},{"type":"address","name":"highestBidder","internalType":"address","indexed":false},{"type":"uint256","name":"highestBid","internalType":"uint256","indexed":false},{"type":"uint256","name":"highestBindingBid","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LogCanceled","inputs":[{"type":"bool","name":"success","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"LogRefund","inputs":[{"type":"address","name":"sender","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"LogWithdrawal","inputs":[{"type":"address","name":"withdrawalAccount","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MaintenanceFeePaid","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"address","name":"from","internalType":"address","indexed":false},{"type":"uint256","name":"validityTill","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Received","inputs":[{"type":"address","name":"sender","internalType":"address","indexed":false},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"VirtuousTokenCollected","inputs":[{"type":"address","name":"winner","internalType":"address","indexed":false},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"VirtuousTokenRedeemed","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"redeemedTotal","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"fallback","stateMutability":"payable"},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"bidderList","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"success","internalType":"bool"}],"name":"cancelAuction","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"canceled","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"collectFund","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"collectToken","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"address","name":"_virtuousToken","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"endTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"floorPrice","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"fundsByBidder","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"string","name":"","internalType":"string"}],"name":"getAuctionStatus","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getHighestBid","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getMarketPlaceRoyaltyFeePercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getMyBid","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getSalesPersonRoyaltyFeePercent","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTokenReddemCount","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"highestBidder","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"highestBindingBid","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_erc20Token","internalType":"contract IERC20Upgradeable"},{"type":"address","name":"_beneficiary","internalType":"address"},{"type":"uint256","name":"_floorPrice","internalType":"uint256"},{"type":"uint256","name":"_startTime","internalType":"uint256"},{"type":"uint256","name":"_endTime","internalType":"uint256"},{"type":"uint256","name":"_virtuousTokensIssued","internalType":"uint256"},{"type":"uint256","name":"_redeemQty","internalType":"uint256"},{"type":"address","name":"_salesPerson","internalType":"address"},{"type":"uint256","name":"_marketplaceRoyaltyFeePercent","internalType":"uint256"},{"type":"uint256","name":"_salesPersonRoyaltyFeePercent","internalType":"uint256"},{"type":"uint256","name":"_maintenanceFee","internalType":"uint256"},{"type":"uint8","name":"_feeDueType","internalType":"enum VirtuousTokenServices.maintenanceFeeDueType"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"maintenanceFee","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"payMaintenanceFee","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"placeBid","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"redeemNFD","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"redeemed","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"refund","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"rewardCollected","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"startTime","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"tokenList","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"winnerList","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"withdraw","inputs":[]},{"type":"receive","stateMutability":"payable"}]
              

Contract Creation Code

0x60806040523480156200001157600080fd5b506200001c62000022565b620000e4565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6130dd80620000f46000396000f3fe6080604052600436106101c65760003560e01c80636853fbe6116100f75780638fa8b790116100955780639e2c58ca116100645780639e2c58ca14610567578063ce10cf8014610589578063f28c4040146105b6578063f5b56c56146105e357610206565b80638fa8b790146104e457806391f90157146104f95780639363c812146105315780639979ef451461054757610206565b806378e97925116100d157806378e979251461044f5780637b0e0820146104655780637ed0f1c11461049557806384ddc67f146104c257610206565b80636853fbe6146103fa57806369de83471461041a578063704416b41461043a57610206565b80633197cbb6116101645780633f9942ff1161013e5780633f9942ff146103695780634979440a146103985780634d2e0198146103c5578063590e1ae3146103e557610206565b80633197cbb6146103295780633711ef041461033f5780633ccfd60b1461035457610206565b8063150b7a02116101a0578063150b7a021461029757806315d6af8f146102d057806324d507fd146102f25780632e93be301461030757610206565b8063026670c514610237578063046604491461025f5780631257e2791461027557610206565b36610206577f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516101fc929190612d60565b60405180910390a1005b7f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516101fc929190612d60565b34801561024357600080fd5b5061024c6105f9565b6040519081526020015b60405180910390f35b34801561026b57600080fd5b5061024c603b5481565b34801561028157600080fd5b50610295610290366004612d0d565b61063a565b005b3480156102a357600080fd5b506102b76102b2366004612b34565b610995565b6040516001600160e01b03199091168152602001610256565b3480156102dc57600080fd5b506102e5610a44565b6040516102569190612d79565b3480156102fe57600080fd5b50610295610a82565b34801561031357600080fd5b5061031c610f33565b6040516102569190612dfe565b34801561033557600080fd5b5061024c60725481565b34801561034b57600080fd5b5061024c610fe5565b34801561036057600080fd5b5061029561101d565b34801561037557600080fd5b5060755461038890610100900460ff1681565b6040519015158152602001610256565b3480156103a457600080fd5b506077546001600160a01b031660009081526079602052604090205461024c565b3480156103d157600080fd5b506102956103e0366004612cdd565b611284565b3480156103f157600080fd5b50610295611714565b34801561040657600080fd5b50610295610415366004612c2d565b6119fc565b34801561042657600080fd5b50610295610435366004612cdd565b611c31565b34801561044657600080fd5b506102e5611ca1565b34801561045b57600080fd5b5061024c60715481565b34801561047157600080fd5b50610388610480366004612afc565b607a6020526000908152604090205460ff1681565b3480156104a157600080fd5b5061024c6104b0366004612cdd565b603a6020526000908152604090205481565b3480156104ce57600080fd5b503360009081526079602052604090205461024c565b3480156104f057600080fd5b50610388611d7d565b34801561050557600080fd5b50607754610519906001600160a01b031681565b6040516001600160a01b039091168152602001610256565b34801561053d57600080fd5b5061024c60705481565b34801561055357600080fd5b50610295610562366004612cdd565b611ec2565b34801561057357600080fd5b5061057c61230a565b6040516102569190612dc6565b34801561059557600080fd5b5061024c6105a4366004612afc565b60796020526000908152604090205481565b3480156105c257600080fd5b5061024c6105d1366004612cdd565b6000908152603a602052604090205490565b3480156105ef57600080fd5b5061024c60765481565b600033610604612378565b6001600160a01b0316146106335760405162461bcd60e51b815260040161062a90612f16565b60405180910390fd5b5060365490565b6002603e54141561065d5760405162461bcd60e51b815260040161062a90612f8f565b6002603e556035546001600160a01b031633141561068d5760405162461bcd60e51b815260040161062a90612ecf565b607254421180156106a65750607554610100900460ff16155b6106c25760405162461bcd60e51b815260040161062a90612e98565b60006106cc6123f5565b90506000805b8251811015610737578281815181106106fb57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316336001600160a01b031614156107255760019150610737565b8061072f8161304b565b9150506106d2565b508061077d5760405162461bcd60e51b8152602060048201526015602482015274596f7520617265206e6f7420612077696e6e65722160581b604482015260640161062a565b336000908152607a602052604090205460ff16156107ec5760405162461bcd60e51b815260206004820152602660248201527f596f75206861766520616c726561647920636f6c6c656374656420796f757220604482015265746f6b656e2160d01b606482015260840161062a565b336000908152607a602052604090819020805460ff19166001179055516331a9108f60e11b815260048101859052839030906001600160a01b03831690636352211e9060240160206040518083038186803b15801561084a57600080fd5b505afa15801561085e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108829190612b18565b6001600160a01b0316146108ee5760405162461bcd60e51b815260206004820152602d60248201527f5468697320636f6e7472616374206973206e6f74206f776e6572206f6620746860448201526c6973204e464420746f6b656e2160981b606482015260840161062a565b604051632142170760e11b81526001600160a01b038216906342842e0e9061091e90309033908a90600401612d3c565b600060405180830381600087803b15801561093857600080fd5b505af115801561094c573d6000803e3d6000fd5b505050507fe1d87fa11bbc18b46a63a92a5548e27ac8c4c7bedd39a610616afdb467828dca3386604051610981929190612d60565b60405180910390a150506001603e55505050565b600061099f612563565b5160375411610a015760405162461bcd60e51b815260206004820152602860248201527f546f6b656e20616c6c6f77616e636520686173207265616368656420746865206044820152676d6178696d756d2160c01b606482015260840161062a565b5050603880546001810182556000919091527f38395c5dceade9603479b177b68959049485df8aa97b39f3533039af5f456199015550630a85bd0160e11b919050565b606033610a4f612378565b6001600160a01b031614610a755760405162461bcd60e51b815260040161062a90612f16565b610a7d6123f5565b905090565b6002603e541415610aa55760405162461bcd60e51b815260040161062a90612f8f565b6002603e556035546001600160a01b0316331480610adb5750610ac6612378565b6001600160a01b0316336001600160a01b0316145b610b405760405162461bcd60e51b815260206004820152603060248201527f42656e6566696369617279202f204f776e65722063616e206f6e6c792070657260448201526f666f726d2074686520616374696f6e2160801b606482015260840161062a565b60755460ff1615610b935760405162461bcd60e51b815260206004820152601860248201527f46756e647320616c726561647920636f6c6c6563746564210000000000000000604482015260640161062a565b6000610b9d6123f5565b905060008060005b8351811015610c83576000848281518110610bd057634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b0381166000908152607990925260408220546036549193509190610c1290610c0c8460646125ba565b906125cd565b9050610c1e85826125d9565b94506000610c2c83836125e5565b9050610c3887826125d9565b6001600160a01b038516600090815260796020526040812080549299508592909190610c6590849061301d565b92505081905550505050508080610c7b9061304b565b915050610ba5565b506075805460ff1916600117905560335460355460405163a9059cbb60e01b81526001600160a01b039283169263a9059cbb92610cc7929116908690600401612d60565b602060405180830381600087803b158015610ce157600080fd5b505af1158015610cf5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d199190612c0d565b5060735460009081906001600160a01b031615610dde57607454610d4290610c0c8560646125ba565b9050610d4e83826125e5565b60335460735460405163a9059cbb60e01b81529294506001600160a01b039182169263a9059cbb92610d869216908590600401612d60565b602060405180830381600087803b158015610da057600080fd5b505af1158015610db4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd89190612c0d565b50610de2565b8291505b603454604080516340f06db760e01b815290516000926001600160a01b0316916340f06db7916004808301926020929190829003018186803b158015610e2757600080fd5b505afa158015610e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5f9190612b18565b60335460405163a9059cbb60e01b81529192506001600160a01b03169063a9059cbb90610e929084908790600401612d60565b602060405180830381600087803b158015610eac57600080fd5b505af1158015610ec0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee49190612c0d565b5060408051868152602081018590529081018390527f6ea5c59900d2287e197ce26928208769c75c08f14c9d14b894eb8afde1185ee69060600160405180910390a150506001603e5550505050565b607554606090610100900460ff1615610f69575060408051808201909152600881526718d85b98d95b195960c21b602082015290565b607254421115610f935750604080518082019091526005815264195b99195960da1b602082015290565b607154421015610fc3575060408051808201909152600b81526a1b9bdd0b5cdd185c9d195960aa1b602082015290565b5060408051808201909152600781526672756e6e696e6760c81b602082015290565b600033610ff0612378565b6001600160a01b0316146110165760405162461bcd60e51b815260040161062a90612f16565b5060745490565b6002603e5414156110405760405162461bcd60e51b815260040161062a90612f8f565b6002603e55607554610100900460ff1661109c5760405162461bcd60e51b815260206004820152601860248201527f41756374696f6e206973206e6f742063616e63656c6564210000000000000000604482015260640161062a565b6035546001600160a01b03163314156110c75760405162461bcd60e51b815260040161062a90612ecf565b336000908152607960205260409020546111235760405162461bcd60e51b815260206004820152601b60248201527f596f7520617265206e6f7420612076616c696420626964646572210000000000604482015260640161062a565b33600081815260796020526040902054806111905760405162461bcd60e51b815260206004820152602760248201527f596f75206861766520616c7265616479207769746864726177616c20796f75726044820152662066756e64732160c81b606482015260840161062a565b6001600160a01b038216600090815260796020526040812080548392906111b890849061301d565b909155505060335460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906111ef9085908590600401612d60565b602060405180830381600087803b15801561120957600080fd5b505af115801561121d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112419190612c0d565b507fb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e918282604051611273929190612d60565b60405180910390a150506001603e55565b806000805b611291612563565b518110156112e75782603882815481106112bb57634e487b7160e01b600052603260045260246000fd5b906000526020600020015414156112d557600191506112e7565b806112df8161304b565b915050611289565b50806113055760405162461bcd60e51b815260040161062a90612e51565b6000603b54116113695760405162461bcd60e51b815260206004820152602960248201527f54686973204e464420646f6573206e6f7420737570706f7274206d61696e74656044820152686e616e63652066656560b81b606482015260840161062a565b6000611387603654610c0c6064603b546125ba90919063ffffffff16565b905060006113a082603b546125e590919063ffffffff16565b90506000603460009054906101000a90046001600160a01b03166001600160a01b03166340f06db76040518163ffffffff1660e01b815260040160206040518083038186803b1580156113f257600080fd5b505afa158015611406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142a9190612b18565b60345460355460405163d96ca0b960e01b81529293506000926001600160a01b039283169263d96ca0b992611469923392909116908890600401612d3c565b602060405180830381600087803b15801561148357600080fd5b505af1158015611497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114bb9190612c0d565b9050806115165760405162461bcd60e51b8152602060048201526024808201527f46756e64207472616e7366657220746f2062656e6566696369617279206661696044820152636c65642160e01b606482015260840161062a565b60345460405163d96ca0b960e01b81526000916001600160a01b03169063d96ca0b99061154b90339087908a90600401612d3c565b602060405180830381600087803b15801561156557600080fd5b505af1158015611579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159d9190612c0d565b9050806115f85760405162461bcd60e51b8152602060048201526024808201527f46756e64207472616e7366657220746f206d61726b6574706c616365206661696044820152636c65642160e01b606482015260840161062a565b42600080603d5460ff16600381111561162157634e487b7160e01b600052602160045260246000fd5b141561163b576116348262278d00612fc6565b90506116b3565b6001603d5460ff16600381111561166257634e487b7160e01b600052602160045260246000fd5b141561167557611634826276a700612fc6565b6002603d5460ff16600381111561169c57634e487b7160e01b600052602160045260246000fd5b14156116b3576116b0826301e13380612fc6565b90505b60008a8152603c602090815260409182902083905581518c815233918101919091529081018290527f592920b5aeb6e87ef6b387867afe0714aeb9c2fe2d7033ea40c2b88b5e3863089060600160405180910390a150505050505050505050565b6002603e5414156117375760405162461bcd60e51b815260040161062a90612f8f565b6002603e556035546001600160a01b03163314156117675760405162461bcd60e51b815260040161062a90612ecf565b607254421180156117805750607554610100900460ff16155b61179c5760405162461bcd60e51b815260040161062a90612e98565b336000908152607960205260409020546117f85760405162461bcd60e51b815260206004820152601b60248201527f596f7520617265206e6f7420612076616c696420626964646572210000000000604482015260640161062a565b60006118026123f5565b905060005b81518110156118c45781818151811061183057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316336001600160a01b031614156118b25760405162461bcd60e51b815260206004820152603060248201527f596f75206172652077696e6e65722c20796f752063616e206e6f74207065726660448201526f6f726d207468697320616374696f6e2160801b606482015260840161062a565b806118bc8161304b565b915050611807565b5033600090815260796020526040902054806119225760405162461bcd60e51b815260206004820152601d60248201527f596f7520616c7265616479206861766520726566756e64206261636b21000000604482015260640161062a565b336000908152607960205260408120805483929061194190849061301d565b909155505060335460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906119789033908590600401612d60565b602060405180830381600087803b15801561199257600080fd5b505af11580156119a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ca9190612c0d565b507fb6c0eca8138e097d71e2dd31e19a1266487f0553f170b7260ffe68bcbe9ff8a73382604051611273929190612d60565b600054610100900460ff1615808015611a1c5750600054600160ff909116105b80611a365750303b158015611a36575060005460ff166001145b611a995760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161062a565b6000805460ff191660011790558015611abc576000805461ff0019166101001790555b611ac46125f1565b611ad38d8d878b8b8888612622565b4289118015611ae157508989115b611b4b5760405162461bcd60e51b815260206004820152603560248201527f41756374696f6e20656e642074696d657374616d702063616e206e6f74206265604482015274207468652070617374206f7220696e76616c69642160581b606482015260840161062a565b6001600160a01b038c16611bad5760405162461bcd60e51b815260206004820152602360248201527f42656e65666963696172792061646472657373206973206e6f7420636f72726560448201526263742160e81b606482015260840161062a565b607380546001600160a01b0319166001600160a01b03881617905560708b905560718a9055607289905560748490558015611c22576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050505050565b33611c3a612378565b6001600160a01b031614611c605760405162461bcd60e51b815260040161062a90612f16565b60725442118015611c795750607554610100900460ff16155b611c955760405162461bcd60e51b815260040161062a90612e98565b611c9e816126d3565b50565b606033611cac612378565b6001600160a01b031614611cd25760405162461bcd60e51b815260040161062a90612f16565b607154421015611d1d5760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20796574206e6f742073746172742160501b604482015260640161062a565b6078805480602002602001604051908101604052809291908181526020018280548015611d7357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d55575b5050505050905090565b60006002603e541415611da25760405162461bcd60e51b815260040161062a90612f8f565b6002603e5533611db0612378565b6001600160a01b031614611dd65760405162461bcd60e51b815260040161062a90612f16565b607254421115611e215760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20616c726561647920656e6465642160501b604482015260640161062a565b607554610100900460ff1615611e755760405162461bcd60e51b815260206004820152601960248201527841756374696f6e20616c72656164792063616e63656c65642160381b604482015260640161062a565b6075805461ff001916610100179055604051600181527f1fd636bc86322e474244a9366e9b72f9e75d3ba45b442352c7f950c92a9808a59060200160405180910390a150600180603e5590565b6002603e541415611ee55760405162461bcd60e51b815260040161062a90612f8f565b6002603e55607154421015611f355760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20796574206e6f742073746172742160501b604482015260640161062a565b607254421115611f805760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20616c726561647920656e6465642160501b604482015260640161062a565b607554610100900460ff1615611fd45760405162461bcd60e51b815260206004820152601960248201527841756374696f6e20616c72656164792063616e63656c65642160381b604482015260640161062a565b6035546001600160a01b0316331415611fff5760405162461bcd60e51b815260040161062a90612ecf565b6033546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561204757600080fd5b505afa15801561205b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207f9190612cf5565b10156120d75760405162461bcd60e51b815260206004820152602160248201527f496e73756666696369616e7420455243323020746f6b656e2062616c616e63656044820152602160f81b606482015260840161062a565b6001600160a01b0381166000908152607960205260408120546120fa90846125d9565b90506070548110156121745760405162461bcd60e51b815260206004820152603d60248201527f42696420546f6b656e20616d6f756e7420746f6f206c6f77212c20616d6f756e60448201527f742073686f756c642062652061626f766520666c6f6f72207072696365000000606482015260840161062a565b6077546001600160a01b039081166000908152607960205260408082205492851682529020829055808211156121d8576077546001600160a01b038481169116146121d557607780546001600160a01b0319166001600160a01b0385161790555b50805b60345460405163d96ca0b960e01b81526000916001600160a01b03169063d96ca0b99061220d90879030908a90600401612d3c565b602060405180830381600087803b15801561222757600080fd5b505af115801561223b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225f9190612c0d565b9050806122a65760405162461bcd60e51b815260206004820152601560248201527446756e64207472616e73666572206661696c65642160581b604482015260640161062a565b6122af846128d7565b607754607654604080516001600160a01b038089168252602082018a9052909316908301526060820184905260808201527ff152f4ff5e488c55370a2d53925a55055228ebd8ec95bd0251bbb299e48786b09060a001610981565b606033612315612378565b6001600160a01b03161461233b5760405162461bcd60e51b815260040161062a90612f16565b607254421180156123545750607554610100900460ff16155b6123705760405162461bcd60e51b815260040161062a90612e98565b610a7d612993565b6034546040805163544e486d60e11b815290516000926001600160a01b03169163a89c90da916004808301926020929190829003018186803b1580156123bd57600080fd5b505afa1580156123d1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7d9190612b18565b6078546060906124615760405162461bcd60e51b815260206004820152603160248201527f4e6f2062696464657220666f756e642c2077696e6e6572206c6973742063616e604482015270206e6f742062652067656e65726174652160781b606482015260840161062a565b600061246c60375490565b6078541061247c57603754612480565b6078545b905060008167ffffffffffffffff8111156124ab57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156124d4578160200160208202803683370190505b5060775481519192506001600160a01b031690829060009061250657634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505081600114156125355792915050565b6077546001600160a01b031660009081526079602052604090205461255c9082600161299d565b9250505090565b60606038805480602002602001604051908101604052809291908181526020018280548015611d7357602002820191906000526020600020905b81548152602001906001019080831161259d575050505050905090565b60006125c68284612fde565b9392505050565b60006125c68284612ffe565b60006125c68284612fc6565b60006125c6828461301d565b600054610100900460ff166126185760405162461bcd60e51b815260040161062a90612f44565b612620612ace565b565b600054610100900460ff166126495760405162461bcd60e51b815260040161062a90612f44565b603380546001600160a01b03808a166001600160a01b03199283161790925560358054928916928216929092179091556036869055603480549091163317905560378490556039839055603b829055603d805482919060ff191660018360038111156126c557634e487b7160e01b600052602160045260246000fd5b021790555050505050505050565b806000805b6126e0612563565b5181101561273657826038828154811061270a57634e487b7160e01b600052603260045260246000fd5b906000526020600020015414156127245760019150612736565b8061272e8161304b565b9150506126d8565b50806127545760405162461bcd60e51b815260040161062a90612e51565b6000838152603c6020526040902054603b54849190156127e457804211156127e45760405162461bcd60e51b815260206004820152603860248201527f4d61696e74656e616e63652076616c6964697479206578706972656420706c6560448201527f61736520706179206d61696e74656e616e636520666565210000000000000000606482015260840161062a565b600060395411801561280557506000858152603a6020526040902054603954115b156128635760405162461bcd60e51b815260206004820152602860248201527f557365722068617665207265616368656420746865206d6178696d756d20616c6044820152676c6f77616e63652160c01b606482015260840161062a565b6000858152603a602052604090205461287d9060016125d9565b6000868152603a602052604090819020829055517f564d4309aa774c1f02ae91e99cd84f81af757524feafb7bcd96612a07e6c5233916128c891889190918252602082015260400190565b60405180910390a15050505050565b6000805b60785481101561293d576078818154811061290657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031633141561292b576001915061293d565b806129358161304b565b9150506128db565b508061298f57607880546001810182556000919091527f8dc6fb69531d98d70dc0420e638d2dfd04e09e1ec783ede9aac77da9c5a0dac40180546001600160a01b0319166001600160a01b0384161790555b5050565b6060610a7d612563565b606060006129b285662386f26fc100006125e5565b6078549091505b8015612aa75784518414156129cd57612aa7565b600060786129dc60018461301d565b815481106129fa57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031680835260799091526040909120549091508311801590612a4857506001600160a01b03811660009081526079602052604090205487115b15612a945780868681518110612a6e57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152612a918560016125d9565b94505b5080612a9f81613034565b9150506129b9565b508351831415612aba57839150506125c6565b612ac581858561299d565b95945050505050565b600054610100900460ff16612af55760405162461bcd60e51b815260040161062a90612f44565b6001603e55565b600060208284031215612b0d578081fd5b81356125c681613092565b600060208284031215612b29578081fd5b81516125c681613092565b60008060008060808587031215612b49578283fd5b8435612b5481613092565b93506020850135612b6481613092565b925060408501359150606085013567ffffffffffffffff80821115612b87578283fd5b818701915087601f830112612b9a578283fd5b813581811115612bac57612bac61307c565b604051601f8201601f19908116603f01168101908382118183101715612bd457612bd461307c565b816040528281528a6020848701011115612bec578586fd5b82602086016020830137918201602001949094529598949750929550505050565b600060208284031215612c1e578081fd5b815180151581146125c6578182fd5b6000806000806000806000806000806000806101808d8f031215612c4f578788fd5b8c35612c5a81613092565b9b5060208d0135612c6a81613092565b9a5060408d0135995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d0135612c9d81613092565b94506101008d013593506101208d013592506101408d013591506101608d013560048110612cc9578182fd5b809150509295989b509295989b509295989b565b600060208284031215612cee578081fd5b5035919050565b600060208284031215612d06578081fd5b5051919050565b60008060408385031215612d1f578182fd5b823591506020830135612d3181613092565b809150509250929050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015612dba5783516001600160a01b031683529284019291840191600101612d95565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612dba57835183529284019291840191600101612de2565b6000602080835283518082850152825b81811015612e2a57858101830151858201604001528201612e0e565b81811115612e3b5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526027908201527f5468697320546f6b656e206973206e6f7420616c6c6f77656420666f722074686040820152666973204e46442160c81b606082015260800190565b60208082526019908201527f41756374696f6e206973206e6f7420656e646564207965742100000000000000604082015260600190565b60208082526027908201527f42656e65666963696172792063616e206e6f7420706572666f726d2074686520604082015266616374696f6e2160c81b606082015260800190565b6020808252601490820152732cb7ba9030b932903737ba1030b71037bbb732b960611b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612fd957612fd9613066565b500190565b600082612ff957634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561301857613018613066565b500290565b60008282101561302f5761302f613066565b500390565b60008161304357613043613066565b506000190190565b600060001982141561305f5761305f613066565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611c9e57600080fdfea264697066735822122039c2759de2804fb5c795075dd0e71688a36d6376183661ffcedcde8dbe04bb8d64736f6c63430008040033

Deployed ByteCode

0x6080604052600436106101c65760003560e01c80636853fbe6116100f75780638fa8b790116100955780639e2c58ca116100645780639e2c58ca14610567578063ce10cf8014610589578063f28c4040146105b6578063f5b56c56146105e357610206565b80638fa8b790146104e457806391f90157146104f95780639363c812146105315780639979ef451461054757610206565b806378e97925116100d157806378e979251461044f5780637b0e0820146104655780637ed0f1c11461049557806384ddc67f146104c257610206565b80636853fbe6146103fa57806369de83471461041a578063704416b41461043a57610206565b80633197cbb6116101645780633f9942ff1161013e5780633f9942ff146103695780634979440a146103985780634d2e0198146103c5578063590e1ae3146103e557610206565b80633197cbb6146103295780633711ef041461033f5780633ccfd60b1461035457610206565b8063150b7a02116101a0578063150b7a021461029757806315d6af8f146102d057806324d507fd146102f25780632e93be301461030757610206565b8063026670c514610237578063046604491461025f5780631257e2791461027557610206565b36610206577f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516101fc929190612d60565b60405180910390a1005b7f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516101fc929190612d60565b34801561024357600080fd5b5061024c6105f9565b6040519081526020015b60405180910390f35b34801561026b57600080fd5b5061024c603b5481565b34801561028157600080fd5b50610295610290366004612d0d565b61063a565b005b3480156102a357600080fd5b506102b76102b2366004612b34565b610995565b6040516001600160e01b03199091168152602001610256565b3480156102dc57600080fd5b506102e5610a44565b6040516102569190612d79565b3480156102fe57600080fd5b50610295610a82565b34801561031357600080fd5b5061031c610f33565b6040516102569190612dfe565b34801561033557600080fd5b5061024c60725481565b34801561034b57600080fd5b5061024c610fe5565b34801561036057600080fd5b5061029561101d565b34801561037557600080fd5b5060755461038890610100900460ff1681565b6040519015158152602001610256565b3480156103a457600080fd5b506077546001600160a01b031660009081526079602052604090205461024c565b3480156103d157600080fd5b506102956103e0366004612cdd565b611284565b3480156103f157600080fd5b50610295611714565b34801561040657600080fd5b50610295610415366004612c2d565b6119fc565b34801561042657600080fd5b50610295610435366004612cdd565b611c31565b34801561044657600080fd5b506102e5611ca1565b34801561045b57600080fd5b5061024c60715481565b34801561047157600080fd5b50610388610480366004612afc565b607a6020526000908152604090205460ff1681565b3480156104a157600080fd5b5061024c6104b0366004612cdd565b603a6020526000908152604090205481565b3480156104ce57600080fd5b503360009081526079602052604090205461024c565b3480156104f057600080fd5b50610388611d7d565b34801561050557600080fd5b50607754610519906001600160a01b031681565b6040516001600160a01b039091168152602001610256565b34801561053d57600080fd5b5061024c60705481565b34801561055357600080fd5b50610295610562366004612cdd565b611ec2565b34801561057357600080fd5b5061057c61230a565b6040516102569190612dc6565b34801561059557600080fd5b5061024c6105a4366004612afc565b60796020526000908152604090205481565b3480156105c257600080fd5b5061024c6105d1366004612cdd565b6000908152603a602052604090205490565b3480156105ef57600080fd5b5061024c60765481565b600033610604612378565b6001600160a01b0316146106335760405162461bcd60e51b815260040161062a90612f16565b60405180910390fd5b5060365490565b6002603e54141561065d5760405162461bcd60e51b815260040161062a90612f8f565b6002603e556035546001600160a01b031633141561068d5760405162461bcd60e51b815260040161062a90612ecf565b607254421180156106a65750607554610100900460ff16155b6106c25760405162461bcd60e51b815260040161062a90612e98565b60006106cc6123f5565b90506000805b8251811015610737578281815181106106fb57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316336001600160a01b031614156107255760019150610737565b8061072f8161304b565b9150506106d2565b508061077d5760405162461bcd60e51b8152602060048201526015602482015274596f7520617265206e6f7420612077696e6e65722160581b604482015260640161062a565b336000908152607a602052604090205460ff16156107ec5760405162461bcd60e51b815260206004820152602660248201527f596f75206861766520616c726561647920636f6c6c656374656420796f757220604482015265746f6b656e2160d01b606482015260840161062a565b336000908152607a602052604090819020805460ff19166001179055516331a9108f60e11b815260048101859052839030906001600160a01b03831690636352211e9060240160206040518083038186803b15801561084a57600080fd5b505afa15801561085e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108829190612b18565b6001600160a01b0316146108ee5760405162461bcd60e51b815260206004820152602d60248201527f5468697320636f6e7472616374206973206e6f74206f776e6572206f6620746860448201526c6973204e464420746f6b656e2160981b606482015260840161062a565b604051632142170760e11b81526001600160a01b038216906342842e0e9061091e90309033908a90600401612d3c565b600060405180830381600087803b15801561093857600080fd5b505af115801561094c573d6000803e3d6000fd5b505050507fe1d87fa11bbc18b46a63a92a5548e27ac8c4c7bedd39a610616afdb467828dca3386604051610981929190612d60565b60405180910390a150506001603e55505050565b600061099f612563565b5160375411610a015760405162461bcd60e51b815260206004820152602860248201527f546f6b656e20616c6c6f77616e636520686173207265616368656420746865206044820152676d6178696d756d2160c01b606482015260840161062a565b5050603880546001810182556000919091527f38395c5dceade9603479b177b68959049485df8aa97b39f3533039af5f456199015550630a85bd0160e11b919050565b606033610a4f612378565b6001600160a01b031614610a755760405162461bcd60e51b815260040161062a90612f16565b610a7d6123f5565b905090565b6002603e541415610aa55760405162461bcd60e51b815260040161062a90612f8f565b6002603e556035546001600160a01b0316331480610adb5750610ac6612378565b6001600160a01b0316336001600160a01b0316145b610b405760405162461bcd60e51b815260206004820152603060248201527f42656e6566696369617279202f204f776e65722063616e206f6e6c792070657260448201526f666f726d2074686520616374696f6e2160801b606482015260840161062a565b60755460ff1615610b935760405162461bcd60e51b815260206004820152601860248201527f46756e647320616c726561647920636f6c6c6563746564210000000000000000604482015260640161062a565b6000610b9d6123f5565b905060008060005b8351811015610c83576000848281518110610bd057634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b0381166000908152607990925260408220546036549193509190610c1290610c0c8460646125ba565b906125cd565b9050610c1e85826125d9565b94506000610c2c83836125e5565b9050610c3887826125d9565b6001600160a01b038516600090815260796020526040812080549299508592909190610c6590849061301d565b92505081905550505050508080610c7b9061304b565b915050610ba5565b506075805460ff1916600117905560335460355460405163a9059cbb60e01b81526001600160a01b039283169263a9059cbb92610cc7929116908690600401612d60565b602060405180830381600087803b158015610ce157600080fd5b505af1158015610cf5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d199190612c0d565b5060735460009081906001600160a01b031615610dde57607454610d4290610c0c8560646125ba565b9050610d4e83826125e5565b60335460735460405163a9059cbb60e01b81529294506001600160a01b039182169263a9059cbb92610d869216908590600401612d60565b602060405180830381600087803b158015610da057600080fd5b505af1158015610db4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd89190612c0d565b50610de2565b8291505b603454604080516340f06db760e01b815290516000926001600160a01b0316916340f06db7916004808301926020929190829003018186803b158015610e2757600080fd5b505afa158015610e3b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5f9190612b18565b60335460405163a9059cbb60e01b81529192506001600160a01b03169063a9059cbb90610e929084908790600401612d60565b602060405180830381600087803b158015610eac57600080fd5b505af1158015610ec0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee49190612c0d565b5060408051868152602081018590529081018390527f6ea5c59900d2287e197ce26928208769c75c08f14c9d14b894eb8afde1185ee69060600160405180910390a150506001603e5550505050565b607554606090610100900460ff1615610f69575060408051808201909152600881526718d85b98d95b195960c21b602082015290565b607254421115610f935750604080518082019091526005815264195b99195960da1b602082015290565b607154421015610fc3575060408051808201909152600b81526a1b9bdd0b5cdd185c9d195960aa1b602082015290565b5060408051808201909152600781526672756e6e696e6760c81b602082015290565b600033610ff0612378565b6001600160a01b0316146110165760405162461bcd60e51b815260040161062a90612f16565b5060745490565b6002603e5414156110405760405162461bcd60e51b815260040161062a90612f8f565b6002603e55607554610100900460ff1661109c5760405162461bcd60e51b815260206004820152601860248201527f41756374696f6e206973206e6f742063616e63656c6564210000000000000000604482015260640161062a565b6035546001600160a01b03163314156110c75760405162461bcd60e51b815260040161062a90612ecf565b336000908152607960205260409020546111235760405162461bcd60e51b815260206004820152601b60248201527f596f7520617265206e6f7420612076616c696420626964646572210000000000604482015260640161062a565b33600081815260796020526040902054806111905760405162461bcd60e51b815260206004820152602760248201527f596f75206861766520616c7265616479207769746864726177616c20796f75726044820152662066756e64732160c81b606482015260840161062a565b6001600160a01b038216600090815260796020526040812080548392906111b890849061301d565b909155505060335460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906111ef9085908590600401612d60565b602060405180830381600087803b15801561120957600080fd5b505af115801561121d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112419190612c0d565b507fb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e918282604051611273929190612d60565b60405180910390a150506001603e55565b806000805b611291612563565b518110156112e75782603882815481106112bb57634e487b7160e01b600052603260045260246000fd5b906000526020600020015414156112d557600191506112e7565b806112df8161304b565b915050611289565b50806113055760405162461bcd60e51b815260040161062a90612e51565b6000603b54116113695760405162461bcd60e51b815260206004820152602960248201527f54686973204e464420646f6573206e6f7420737570706f7274206d61696e74656044820152686e616e63652066656560b81b606482015260840161062a565b6000611387603654610c0c6064603b546125ba90919063ffffffff16565b905060006113a082603b546125e590919063ffffffff16565b90506000603460009054906101000a90046001600160a01b03166001600160a01b03166340f06db76040518163ffffffff1660e01b815260040160206040518083038186803b1580156113f257600080fd5b505afa158015611406573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061142a9190612b18565b60345460355460405163d96ca0b960e01b81529293506000926001600160a01b039283169263d96ca0b992611469923392909116908890600401612d3c565b602060405180830381600087803b15801561148357600080fd5b505af1158015611497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114bb9190612c0d565b9050806115165760405162461bcd60e51b8152602060048201526024808201527f46756e64207472616e7366657220746f2062656e6566696369617279206661696044820152636c65642160e01b606482015260840161062a565b60345460405163d96ca0b960e01b81526000916001600160a01b03169063d96ca0b99061154b90339087908a90600401612d3c565b602060405180830381600087803b15801561156557600080fd5b505af1158015611579573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061159d9190612c0d565b9050806115f85760405162461bcd60e51b8152602060048201526024808201527f46756e64207472616e7366657220746f206d61726b6574706c616365206661696044820152636c65642160e01b606482015260840161062a565b42600080603d5460ff16600381111561162157634e487b7160e01b600052602160045260246000fd5b141561163b576116348262278d00612fc6565b90506116b3565b6001603d5460ff16600381111561166257634e487b7160e01b600052602160045260246000fd5b141561167557611634826276a700612fc6565b6002603d5460ff16600381111561169c57634e487b7160e01b600052602160045260246000fd5b14156116b3576116b0826301e13380612fc6565b90505b60008a8152603c602090815260409182902083905581518c815233918101919091529081018290527f592920b5aeb6e87ef6b387867afe0714aeb9c2fe2d7033ea40c2b88b5e3863089060600160405180910390a150505050505050505050565b6002603e5414156117375760405162461bcd60e51b815260040161062a90612f8f565b6002603e556035546001600160a01b03163314156117675760405162461bcd60e51b815260040161062a90612ecf565b607254421180156117805750607554610100900460ff16155b61179c5760405162461bcd60e51b815260040161062a90612e98565b336000908152607960205260409020546117f85760405162461bcd60e51b815260206004820152601b60248201527f596f7520617265206e6f7420612076616c696420626964646572210000000000604482015260640161062a565b60006118026123f5565b905060005b81518110156118c45781818151811061183057634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316336001600160a01b031614156118b25760405162461bcd60e51b815260206004820152603060248201527f596f75206172652077696e6e65722c20796f752063616e206e6f74207065726660448201526f6f726d207468697320616374696f6e2160801b606482015260840161062a565b806118bc8161304b565b915050611807565b5033600090815260796020526040902054806119225760405162461bcd60e51b815260206004820152601d60248201527f596f7520616c7265616479206861766520726566756e64206261636b21000000604482015260640161062a565b336000908152607960205260408120805483929061194190849061301d565b909155505060335460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906119789033908590600401612d60565b602060405180830381600087803b15801561199257600080fd5b505af11580156119a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119ca9190612c0d565b507fb6c0eca8138e097d71e2dd31e19a1266487f0553f170b7260ffe68bcbe9ff8a73382604051611273929190612d60565b600054610100900460ff1615808015611a1c5750600054600160ff909116105b80611a365750303b158015611a36575060005460ff166001145b611a995760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b606482015260840161062a565b6000805460ff191660011790558015611abc576000805461ff0019166101001790555b611ac46125f1565b611ad38d8d878b8b8888612622565b4289118015611ae157508989115b611b4b5760405162461bcd60e51b815260206004820152603560248201527f41756374696f6e20656e642074696d657374616d702063616e206e6f74206265604482015274207468652070617374206f7220696e76616c69642160581b606482015260840161062a565b6001600160a01b038c16611bad5760405162461bcd60e51b815260206004820152602360248201527f42656e65666963696172792061646472657373206973206e6f7420636f72726560448201526263742160e81b606482015260840161062a565b607380546001600160a01b0319166001600160a01b03881617905560708b905560718a9055607289905560748490558015611c22576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050505050565b33611c3a612378565b6001600160a01b031614611c605760405162461bcd60e51b815260040161062a90612f16565b60725442118015611c795750607554610100900460ff16155b611c955760405162461bcd60e51b815260040161062a90612e98565b611c9e816126d3565b50565b606033611cac612378565b6001600160a01b031614611cd25760405162461bcd60e51b815260040161062a90612f16565b607154421015611d1d5760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20796574206e6f742073746172742160501b604482015260640161062a565b6078805480602002602001604051908101604052809291908181526020018280548015611d7357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611d55575b5050505050905090565b60006002603e541415611da25760405162461bcd60e51b815260040161062a90612f8f565b6002603e5533611db0612378565b6001600160a01b031614611dd65760405162461bcd60e51b815260040161062a90612f16565b607254421115611e215760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20616c726561647920656e6465642160501b604482015260640161062a565b607554610100900460ff1615611e755760405162461bcd60e51b815260206004820152601960248201527841756374696f6e20616c72656164792063616e63656c65642160381b604482015260640161062a565b6075805461ff001916610100179055604051600181527f1fd636bc86322e474244a9366e9b72f9e75d3ba45b442352c7f950c92a9808a59060200160405180910390a150600180603e5590565b6002603e541415611ee55760405162461bcd60e51b815260040161062a90612f8f565b6002603e55607154421015611f355760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20796574206e6f742073746172742160501b604482015260640161062a565b607254421115611f805760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20616c726561647920656e6465642160501b604482015260640161062a565b607554610100900460ff1615611fd45760405162461bcd60e51b815260206004820152601960248201527841756374696f6e20616c72656164792063616e63656c65642160381b604482015260640161062a565b6035546001600160a01b0316331415611fff5760405162461bcd60e51b815260040161062a90612ecf565b6033546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b15801561204757600080fd5b505afa15801561205b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061207f9190612cf5565b10156120d75760405162461bcd60e51b815260206004820152602160248201527f496e73756666696369616e7420455243323020746f6b656e2062616c616e63656044820152602160f81b606482015260840161062a565b6001600160a01b0381166000908152607960205260408120546120fa90846125d9565b90506070548110156121745760405162461bcd60e51b815260206004820152603d60248201527f42696420546f6b656e20616d6f756e7420746f6f206c6f77212c20616d6f756e60448201527f742073686f756c642062652061626f766520666c6f6f72207072696365000000606482015260840161062a565b6077546001600160a01b039081166000908152607960205260408082205492851682529020829055808211156121d8576077546001600160a01b038481169116146121d557607780546001600160a01b0319166001600160a01b0385161790555b50805b60345460405163d96ca0b960e01b81526000916001600160a01b03169063d96ca0b99061220d90879030908a90600401612d3c565b602060405180830381600087803b15801561222757600080fd5b505af115801561223b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225f9190612c0d565b9050806122a65760405162461bcd60e51b815260206004820152601560248201527446756e64207472616e73666572206661696c65642160581b604482015260640161062a565b6122af846128d7565b607754607654604080516001600160a01b038089168252602082018a9052909316908301526060820184905260808201527ff152f4ff5e488c55370a2d53925a55055228ebd8ec95bd0251bbb299e48786b09060a001610981565b606033612315612378565b6001600160a01b03161461233b5760405162461bcd60e51b815260040161062a90612f16565b607254421180156123545750607554610100900460ff16155b6123705760405162461bcd60e51b815260040161062a90612e98565b610a7d612993565b6034546040805163544e486d60e11b815290516000926001600160a01b03169163a89c90da916004808301926020929190829003018186803b1580156123bd57600080fd5b505afa1580156123d1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7d9190612b18565b6078546060906124615760405162461bcd60e51b815260206004820152603160248201527f4e6f2062696464657220666f756e642c2077696e6e6572206c6973742063616e604482015270206e6f742062652067656e65726174652160781b606482015260840161062a565b600061246c60375490565b6078541061247c57603754612480565b6078545b905060008167ffffffffffffffff8111156124ab57634e487b7160e01b600052604160045260246000fd5b6040519080825280602002602001820160405280156124d4578160200160208202803683370190505b5060775481519192506001600160a01b031690829060009061250657634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b03168152505081600114156125355792915050565b6077546001600160a01b031660009081526079602052604090205461255c9082600161299d565b9250505090565b60606038805480602002602001604051908101604052809291908181526020018280548015611d7357602002820191906000526020600020905b81548152602001906001019080831161259d575050505050905090565b60006125c68284612fde565b9392505050565b60006125c68284612ffe565b60006125c68284612fc6565b60006125c6828461301d565b600054610100900460ff166126185760405162461bcd60e51b815260040161062a90612f44565b612620612ace565b565b600054610100900460ff166126495760405162461bcd60e51b815260040161062a90612f44565b603380546001600160a01b03808a166001600160a01b03199283161790925560358054928916928216929092179091556036869055603480549091163317905560378490556039839055603b829055603d805482919060ff191660018360038111156126c557634e487b7160e01b600052602160045260246000fd5b021790555050505050505050565b806000805b6126e0612563565b5181101561273657826038828154811061270a57634e487b7160e01b600052603260045260246000fd5b906000526020600020015414156127245760019150612736565b8061272e8161304b565b9150506126d8565b50806127545760405162461bcd60e51b815260040161062a90612e51565b6000838152603c6020526040902054603b54849190156127e457804211156127e45760405162461bcd60e51b815260206004820152603860248201527f4d61696e74656e616e63652076616c6964697479206578706972656420706c6560448201527f61736520706179206d61696e74656e616e636520666565210000000000000000606482015260840161062a565b600060395411801561280557506000858152603a6020526040902054603954115b156128635760405162461bcd60e51b815260206004820152602860248201527f557365722068617665207265616368656420746865206d6178696d756d20616c6044820152676c6f77616e63652160c01b606482015260840161062a565b6000858152603a602052604090205461287d9060016125d9565b6000868152603a602052604090819020829055517f564d4309aa774c1f02ae91e99cd84f81af757524feafb7bcd96612a07e6c5233916128c891889190918252602082015260400190565b60405180910390a15050505050565b6000805b60785481101561293d576078818154811061290657634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031633141561292b576001915061293d565b806129358161304b565b9150506128db565b508061298f57607880546001810182556000919091527f8dc6fb69531d98d70dc0420e638d2dfd04e09e1ec783ede9aac77da9c5a0dac40180546001600160a01b0319166001600160a01b0384161790555b5050565b6060610a7d612563565b606060006129b285662386f26fc100006125e5565b6078549091505b8015612aa75784518414156129cd57612aa7565b600060786129dc60018461301d565b815481106129fa57634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b031680835260799091526040909120549091508311801590612a4857506001600160a01b03811660009081526079602052604090205487115b15612a945780868681518110612a6e57634e487b7160e01b600052603260045260246000fd5b6001600160a01b0390921660209283029190910190910152612a918560016125d9565b94505b5080612a9f81613034565b9150506129b9565b508351831415612aba57839150506125c6565b612ac581858561299d565b95945050505050565b600054610100900460ff16612af55760405162461bcd60e51b815260040161062a90612f44565b6001603e55565b600060208284031215612b0d578081fd5b81356125c681613092565b600060208284031215612b29578081fd5b81516125c681613092565b60008060008060808587031215612b49578283fd5b8435612b5481613092565b93506020850135612b6481613092565b925060408501359150606085013567ffffffffffffffff80821115612b87578283fd5b818701915087601f830112612b9a578283fd5b813581811115612bac57612bac61307c565b604051601f8201601f19908116603f01168101908382118183101715612bd457612bd461307c565b816040528281528a6020848701011115612bec578586fd5b82602086016020830137918201602001949094529598949750929550505050565b600060208284031215612c1e578081fd5b815180151581146125c6578182fd5b6000806000806000806000806000806000806101808d8f031215612c4f578788fd5b8c35612c5a81613092565b9b5060208d0135612c6a81613092565b9a5060408d0135995060608d0135985060808d0135975060a08d0135965060c08d0135955060e08d0135612c9d81613092565b94506101008d013593506101208d013592506101408d013591506101608d013560048110612cc9578182fd5b809150509295989b509295989b509295989b565b600060208284031215612cee578081fd5b5035919050565b600060208284031215612d06578081fd5b5051919050565b60008060408385031215612d1f578182fd5b823591506020830135612d3181613092565b809150509250929050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b81811015612dba5783516001600160a01b031683529284019291840191600101612d95565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b81811015612dba57835183529284019291840191600101612de2565b6000602080835283518082850152825b81811015612e2a57858101830151858201604001528201612e0e565b81811115612e3b5783604083870101525b50601f01601f1916929092016040019392505050565b60208082526027908201527f5468697320546f6b656e206973206e6f7420616c6c6f77656420666f722074686040820152666973204e46442160c81b606082015260800190565b60208082526019908201527f41756374696f6e206973206e6f7420656e646564207965742100000000000000604082015260600190565b60208082526027908201527f42656e65666963696172792063616e206e6f7420706572666f726d2074686520604082015266616374696f6e2160c81b606082015260800190565b6020808252601490820152732cb7ba9030b932903737ba1030b71037bbb732b960611b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612fd957612fd9613066565b500190565b600082612ff957634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561301857613018613066565b500290565b60008282101561302f5761302f613066565b500390565b60008161304357613043613066565b506000190190565b600060001982141561305f5761305f613066565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611c9e57600080fdfea264697066735822122039c2759de2804fb5c795075dd0e71688a36d6376183661ffcedcde8dbe04bb8d64736f6c63430008040033