Address Details
contract

0x06d2411213faDF2D46FA39609f40aa81529dc07d

Contract Name
VirtuousAuction
Creator
0x6d3f1b–09369f at 0x51e31a–2a0d9a
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
13418906
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-02-01T18:02:00.135621Z

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;
    IERC20Upgradeable private erc20Token;
    address private contractFactory;

    // static
    uint256 public floorPrice;
    uint256 public startTime;
    uint256 public endTime;
    address private beneficiary;
    address private salesPerson;
    uint256 private marketplaceRoyaltyFeePercent;
    uint256 private salesPersonRoyaltyFeePercent;

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

    // events
    event LogBid(address bidder, uint256 bid, address highestBidder, uint256 highestBid, uint256 highestBindingBid);
    event LogWithdrawal(address withdrawalAccount, uint256 amount);
    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) initializer public {
        __ReentrancyGuard_init();     
        __VirtuousTokenServices_init(_virtuousTokensIssued, _redeemQty);  
        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!');
        erc20Token = _erc20Token;
        beneficiary = _beneficiary;
        salesPerson = _salesPerson;
        floorPrice = _floorPrice;
        startTime = _startTime;
        endTime = _endTime;
        marketplaceRoyaltyFeePercent = _marketplaceRoyaltyFeePercent;
        salesPersonRoyaltyFeePercent = _salesPersonRoyaltyFeePercent;
        contractFactory = msg.sender;
    }

    // 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');

         // if the user isn't even willing to overbid the highest binding bid, there's nothing for us
        // to do except revert the transaction.
        if (newBid <= highestBindingBid) revert('overbid the highest binding bid!');

        // 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 the user has overbid the highestBindingBid but not the highestBid, we simply
            // increase the highestBindingBid and leave highestBidder alone.

            // note that this case is impossible if msg.sender == highestBidder because you can never
            // bid less ETH than you've already bid.

            highestBindingBid = min(newBid.add(etherToWei(1)), highestBid);
        } else {
            // if msg.sender is already the highest bidder, they must simply be wanting to raise
            // their maximum bid, in which case we shouldn't increase the highestBindingBid.

            // if the user is NOT highestBidder, and has overbid highestBid completely, we set them
            // as the new highestBidder and recalculate highestBindingBid.

            if (_bidder != highestBidder) {
                highestBidder = _bidder;
                highestBindingBid = min(newBid, highestBid.add(etherToWei(1)));
            }
            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)
    {
       address[] memory winners = _winnerList();
       return winners;
    }

    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], 1, winners, 1);
    }
    
    function _winnersListPrepare( uint256 _lastHighestBidPrice, uint256 _priceMargin, address[] memory _winners, uint256 _winnerIndex) internal 
        view 
        returns (address[] memory)
    {   
        uint256 priceFilter = fundsByBidder[highestBidder].sub(etherToWei(_priceMargin)); 
        for (uint256 j = bidders.length - 1; j >= 0; j--) {
           if( _winnerIndex == _winners.length ) break;
            address bidder = bidders[j];
            if( fundsByBidder[bidder] >= priceFilter && fundsByBidder[bidder] < _lastHighestBidPrice ){                        
                _winners[_winnerIndex] = bidder;
                _winnerIndex++;
            } 
        }
        if( _winnerIndex == _winners.length ) return _winners;
        return _winnersListPrepare(priceFilter, _priceMargin.add(1), _winners, _winnerIndex);
    }

    function etherToWei(uint valueEther) internal pure returns (uint)
    {
       return valueEther*(10**18);
    }


    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
    {
        _collectToken(_tokenId, _virtuousToken);
    }

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

    function collectFund() external
        nonReentrant
        onlyBeneficiaryOrOwner
    {   
        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;
        }
        address marketPlaceRoyaltyReceiver = IVirtuousContractFactory(contractFactory).getMarketPlaceRoyaltyReceiverWallet();
        _collectFund(erc20Token, beneficiary, salesPerson, marketPlaceRoyaltyReceiver, merchantFund, royalty, salesPersonRoyaltyFeePercent);
    }

    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 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 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.6.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 = _setInitializedVersion(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) {
        bool isTopLevelCall = _setInitializedVersion(version);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _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 {
        _setInitializedVersion(type(uint8).max);
    }

    function _setInitializedVersion(uint8 version) private returns (bool) {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
        // of initializers, because in other contexts the contract may have been reentered.
        if (_initializing) {
            require(
                version == 1 && !AddressUpgradeable.isContract(address(this)),
                "Initializable: contract is already initialized"
            );
            return false;
        } else {
            require(_initialized < version, "Initializable: contract is already initialized");
            _initialized = version;
            return true;
        }
    }
}
          

/_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.6.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 be have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

    /**
     * @dev 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.5.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

                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";

abstract contract VirtuousTokenServices is Initializable, ERC721HolderUpgradeable {

    using SafeMathUpgradeable for uint256;
    bool private fundCollected;
    uint256 private redeemQty;
    uint256 private virtuousTokensIssued;
    uint256[] private allowedVirtuousTokens;

    mapping(uint256 => uint256) public redeemed;
    mapping(address => bool) public rewardCollected;     

    event VirtuousTokenCollected(address winner, uint256 tokenId);
    event VirtuousTokenRedeemed(uint tokenId, uint256 redeemedTotal); 
    event FundCollected(uint256 merchantFee, uint256 marketplaceRoyalty, uint256 salesPersonRoyalty); 

    function __VirtuousTokenServices_init(uint256 _virtuousTokensIssued, uint256 _redeemQty) 
        internal 
        onlyInitializing 
    {
        virtuousTokensIssued = _virtuousTokensIssued;
        redeemQty = _redeemQty; 
    }

    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)
    {   
        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 _collectToken(uint _tokenId, address _virtuousToken) 
        internal
        virtual
        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 _collectFund(IERC20Upgradeable erc20Token, address beneficiary, address salesPerson, address marketPlaceRoyaltyReceiver, uint256 merchantFund, uint256 royalty, uint256 salesPersonRoyaltyFeePercent) internal virtual
        onlyNotCollected
    {   
        uint256 marketplaceRoyalty;
        uint256 salesPersonRoyalty;
        fundCollected = true;
        //transfer to benefiaciary wallet
        erc20Token.transfer(beneficiary, merchantFund); 
        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
        erc20Token.transfer(marketPlaceRoyaltyReceiver, marketplaceRoyalty);      
        emit FundCollected(merchantFund, marketplaceRoyalty, salesPersonRoyalty);
    }

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

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

    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":"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":"bool","name":"","internalType":"bool"}],"name":"ended","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":"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":"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

0x60806040523480156200001157600080fd5b506200001c62000022565b62000152565b6200002e60ff62000031565b50565b60008054610100900460ff1615620000ca578160ff1660011480156200006a575062000068306200014360201b62001a811760201c565b155b620000c25760405162461bcd60e51b815260206004820152602e602482015260008051602062002da183398151915260448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b506000919050565b60005460ff808416911610620001295760405162461bcd60e51b815260206004820152602e602482015260008051602062002da183398151915260448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401620000b9565b506000805460ff191660ff92909216919091179055600190565b6001600160a01b03163b151590565b612c3f80620001626000396000f3fe6080604052600436106101bb5760003560e01c8063704416b4116100ec5780639363c8121161008a5780639e2c58ca116100645780639e2c58ca14610540578063ce10cf8014610562578063f28c40401461058f578063f5b56c56146105bc576101fb565b80639363c812146104ea5780639912a835146105005780639979ef4514610520576101fb565b80637ed0f1c1116100c65780637ed0f1c11461044e57806384ddc67f1461047b5780638fa8b7901461049d57806391f90157146104b2576101fb565b8063704416b4146103f357806378e97925146104085780637b0e08201461041e576101fb565b80633197cbb6116101595780633f9942ff116101335780633f9942ff146103775780634979440a14610391578063590e1ae3146103be57806369de8347146103d3576101fb565b80633197cbb6146103375780633711ef041461034d5780633ccfd60b14610362576101fb565b8063150b7a0211610195578063150b7a02146102a557806315d6af8f146102de57806324d507fd146103005780632e93be3014610315576101fb565b8063026670c51461022c5780631257e2791461025457806312fa6feb14610276576101fb565b366101fb577f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516101f19291906128bb565b60405180910390a1005b7f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516101f19291906128bb565b34801561023857600080fd5b506102416105d2565b6040519081526020015b60405180910390f35b34801561026057600080fd5b5061027461026f36600461288c565b610613565b005b34801561028257600080fd5b5060745461029590610100900460ff1681565b604051901515815260200161024b565b3480156102b157600080fd5b506102c56102c03660046126d3565b610766565b6040516001600160e01b0319909116815260200161024b565b3480156102ea57600080fd5b506102f3610819565b60405161024b91906128d4565b34801561030c57600080fd5b5061027461085a565b34801561032157600080fd5b5061032a610ab8565b60405161024b9190612959565b34801561034357600080fd5b50610241606f5481565b34801561035957600080fd5b50610241610b65565b34801561036e57600080fd5b50610274610b9d565b34801561038357600080fd5b506074546102959060ff1681565b34801561039d57600080fd5b506076546001600160a01b0316600090815260786020526040902054610241565b3480156103ca57600080fd5b50610274610dff565b3480156103df57600080fd5b506102746103ee36600461285c565b6110e2565b3480156103ff57600080fd5b506102f361114d565b34801561041457600080fd5b50610241606e5481565b34801561042a57600080fd5b50610295610439366004612694565b60386020526000908152604090205460ff1681565b34801561045a57600080fd5b5061024161046936600461285c565b60376020526000908152604090205481565b34801561048757600080fd5b5033600090815260786020526040902054610241565b3480156104a957600080fd5b50610295611229565b3480156104be57600080fd5b506076546104d2906001600160a01b031681565b6040516001600160a01b03909116815260200161024b565b3480156104f657600080fd5b50610241606d5481565b34801561050c57600080fd5b5061027461051b3660046127cc565b611369565b34801561052c57600080fd5b5061027461053b36600461285c565b61152d565b34801561054c57600080fd5b50610555611a13565b60405161024b9190612921565b34801561056e57600080fd5b5061024161057d366004612694565b60786020526000908152604090205481565b34801561059b57600080fd5b506102416105aa36600461285c565b60009081526037602052604090205490565b3480156105c857600080fd5b5061024160755481565b6000336105dd611a90565b6001600160a01b03161461060c5760405162461bcd60e51b815260040161060390612a78565b60405180910390fd5b5060725490565b600260395414156106365760405162461bcd60e51b815260040161060390612af1565b60026039556070546001600160a01b03163314156106665760405162461bcd60e51b815260040161060390612a31565b606f544211801561067a575060745460ff16155b6106965760405162461bcd60e51b8152600401610603906129ac565b60006106a0611b0d565b90506000805b825181101561070b578281815181106106cf57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316336001600160a01b031614156106f9576001915061070b565b8061070381612bad565b9150506106a6565b50806107515760405162461bcd60e51b8152602060048201526015602482015274596f7520617265206e6f7420612077696e6e65722160581b6044820152606401610603565b61075b8484611c7c565b505060016039555050565b6000610770611e91565b51603554116107d25760405162461bcd60e51b815260206004820152602860248201527f546f6b656e20616c6c6f77616e636520686173207265616368656420746865206044820152676d6178696d756d2160c01b6064820152608401610603565b50603680546001810182556000919091527f4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b801829055630a85bd0160e11b5b949350505050565b606033610824611a90565b6001600160a01b03161461084a5760405162461bcd60e51b815260040161060390612a78565b6000610854611b0d565b91505090565b6002603954141561087d5760405162461bcd60e51b815260040161060390612af1565b60026039556070546001600160a01b03163314806108b3575061089e611a90565b6001600160a01b0316336001600160a01b0316145b6109185760405162461bcd60e51b815260206004820152603060248201527f42656e6566696369617279202f204f776e65722063616e206f6e6c792070657260448201526f666f726d2074686520616374696f6e2160801b6064820152608401610603565b6000610922611b0d565b905060008060005b8351811015610a0857600084828151811061095557634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b038116600090815260789092526040822054607254919350919061099790610991846064611ee8565b90611efd565b90506109a38582611f09565b945060006109b18383611f15565b90506109bd8782611f09565b6001600160a01b0385166000908152607860205260408120805492995085929091906109ea908490612b7f565b92505081905550505050508080610a0090612bad565b91505061092a565b50606c54604080516340f06db760e01b815290516000926001600160a01b0316916340f06db7916004808301926020929190829003018186803b158015610a4e57600080fd5b505afa158015610a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8691906126b7565b606b5460705460715460735493945061075b936001600160a01b03938416939283169290911690859088908890611f21565b60745460609060ff1615610ae9575060408051808201909152600881526718d85b98d95b195960c21b602082015290565b606f54421115610b135750604080518082019091526005815264195b99195960da1b602082015290565b606e54421015610b43575060408051808201909152600b81526a1b9bdd0b5cdd185c9d195960aa1b602082015290565b5060408051808201909152600781526672756e6e696e6760c81b602082015290565b600033610b70611a90565b6001600160a01b031614610b965760405162461bcd60e51b815260040161060390612a78565b5060735490565b60026039541415610bc05760405162461bcd60e51b815260040161060390612af1565b600260395560745460ff16610c175760405162461bcd60e51b815260206004820152601860248201527f41756374696f6e206973206e6f742063616e63656c65642100000000000000006044820152606401610603565b6070546001600160a01b0316331415610c425760405162461bcd60e51b815260040161060390612a31565b33600090815260786020526040902054610c9e5760405162461bcd60e51b815260206004820152601b60248201527f596f7520617265206e6f7420612076616c6964206269646465722100000000006044820152606401610603565b3360008181526078602052604090205480610d0b5760405162461bcd60e51b815260206004820152602760248201527f596f75206861766520616c7265616479207769746864726177616c20796f75726044820152662066756e64732160c81b6064820152608401610603565b6001600160a01b03821660009081526078602052604081208054839290610d33908490612b7f565b9091555050606b5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610d6a90859085906004016128bb565b602060405180830381600087803b158015610d8457600080fd5b505af1158015610d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbc91906127ac565b507fb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e918282604051610dee9291906128bb565b60405180910390a150506001603955565b60026039541415610e225760405162461bcd60e51b815260040161060390612af1565b60026039556070546001600160a01b0316331415610e525760405162461bcd60e51b815260040161060390612a31565b606f5442118015610e66575060745460ff16155b610e825760405162461bcd60e51b8152600401610603906129ac565b33600090815260786020526040902054610ede5760405162461bcd60e51b815260206004820152601b60248201527f596f7520617265206e6f7420612076616c6964206269646465722100000000006044820152606401610603565b6000610ee8611b0d565b905060005b8151811015610faa57818181518110610f1657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316336001600160a01b03161415610f985760405162461bcd60e51b815260206004820152603060248201527f596f75206172652077696e6e65722c20796f752063616e206e6f74207065726660448201526f6f726d207468697320616374696f6e2160801b6064820152608401610603565b80610fa281612bad565b915050610eed565b5033600090815260786020526040902054806110085760405162461bcd60e51b815260206004820152601d60248201527f596f7520616c7265616479206861766520726566756e64206261636b210000006044820152606401610603565b3360009081526078602052604081208054839290611027908490612b7f565b9091555050606b5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb9061105e90339085906004016128bb565b602060405180830381600087803b15801561107857600080fd5b505af115801561108c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b091906127ac565b507fb6c0eca8138e097d71e2dd31e19a1266487f0553f170b7260ffe68bcbe9ff8a73382604051610dee9291906128bb565b336110eb611a90565b6001600160a01b0316146111115760405162461bcd60e51b815260040161060390612a78565b606f5442118015611125575060745460ff16155b6111415760405162461bcd60e51b8152600401610603906129ac565b61114a8161218b565b50565b606033611158611a90565b6001600160a01b03161461117e5760405162461bcd60e51b815260040161060390612a78565b606e544210156111c95760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20796574206e6f742073746172742160501b6044820152606401610603565b607780548060200260200160405190810160405280929190818152602001828054801561121f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611201575b5050505050905090565b60006002603954141561124e5760405162461bcd60e51b815260040161060390612af1565b60026039553361125c611a90565b6001600160a01b0316146112825760405162461bcd60e51b815260040161060390612a78565b606f544211156112cd5760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20616c726561647920656e6465642160501b6044820152606401610603565b60745460ff161561131c5760405162461bcd60e51b815260206004820152601960248201527841756374696f6e20616c72656164792063616e63656c65642160381b6044820152606401610603565b6074805460ff191660019081179091556040519081527f1fd636bc86322e474244a9366e9b72f9e75d3ba45b442352c7f950c92a9808a59060200160405180910390a15060018060395590565b60006113756001612330565b9050801561138d576000805461ff0019166101001790555b6113956123b8565b61139f86866123e9565b42871180156113ad57508787115b6114175760405162461bcd60e51b815260206004820152603560248201527f41756374696f6e20656e642074696d657374616d702063616e206e6f74206265604482015274207468652070617374206f7220696e76616c69642160581b6064820152608401610603565b6001600160a01b038a166114795760405162461bcd60e51b815260206004820152602360248201527f42656e65666963696172792061646472657373206973206e6f7420636f72726560448201526263742160e81b6064820152608401610603565b606b80546001600160a01b03808e166001600160a01b031992831617909255607080548d84169083161790556071805492871692821692909217909155606d8a9055606e899055606f88905560728490556073839055606c8054909116331790558015611520576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b600260395414156115505760405162461bcd60e51b815260040161060390612af1565b6002603955606e544210156115a05760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20796574206e6f742073746172742160501b6044820152606401610603565b606f544211156115eb5760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20616c726561647920656e6465642160501b6044820152606401610603565b60745460ff161561163a5760405162461bcd60e51b815260206004820152601960248201527841756374696f6e20616c72656164792063616e63656c65642160381b6044820152606401610603565b6070546001600160a01b03163314156116655760405162461bcd60e51b815260040161060390612a31565b606b546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b1580156116ad57600080fd5b505afa1580156116c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e59190612874565b101561173d5760405162461bcd60e51b815260206004820152602160248201527f496e73756666696369616e7420455243323020746f6b656e2062616c616e63656044820152602160f81b6064820152608401610603565b6001600160a01b0381166000908152607860205260408120546117609084611f09565b9050606d548110156117da5760405162461bcd60e51b815260206004820152603d60248201527f42696420546f6b656e20616d6f756e7420746f6f206c6f77212c20616d6f756e60448201527f742073686f756c642062652061626f766520666c6f6f722070726963650000006064820152608401610603565b607554811161182b5760405162461bcd60e51b815260206004820181905260248201527f6f7665726269642074686520686967686573742062696e64696e6720626964216044820152606401610603565b6076546001600160a01b03908116600090815260786020526040808220549285168252902082905580821161187f5761187761187161186a600161241b565b8490611f09565b8261242f565b6075556118cc565b6076546001600160a01b038481169116146118c957607680546001600160a01b0319166001600160a01b0385161790556118c5826118c061186a600161241b565b61242f565b6075555b50805b606c5460405163d96ca0b960e01b81526001600160a01b03858116600483015230602483015260448201879052600092169063d96ca0b990606401602060405180830381600087803b15801561192157600080fd5b505af1158015611935573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195991906127ac565b9050806119a05760405162461bcd60e51b815260206004820152601560248201527446756e64207472616e73666572206661696c65642160581b6044820152606401610603565b6119a984612446565b607654607554604080516001600160a01b038089168252602082018a9052909316908301526060820184905260808201527ff152f4ff5e488c55370a2d53925a55055228ebd8ec95bd0251bbb299e48786b09060a00160405180910390a150506001603955505050565b606033611a1e611a90565b6001600160a01b031614611a445760405162461bcd60e51b815260040161060390612a78565b606f5442118015611a58575060745460ff16155b611a745760405162461bcd60e51b8152600401610603906129ac565b611a7c612502565b905090565b6001600160a01b03163b151590565b606c546040805163544e486d60e11b815290516000926001600160a01b03169163a89c90da916004808301926020929190829003018186803b158015611ad557600080fd5b505afa158015611ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7c91906126b7565b607754606090611b795760405162461bcd60e51b815260206004820152603160248201527f4e6f2062696464657220666f756e642c2077696e6e6572206c6973742063616e604482015270206e6f742062652067656e65726174652160781b6064820152608401610603565b6000611b8460355490565b60775410611b9457603554611b98565b6077545b905060008167ffffffffffffffff811115611bc357634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611bec578160200160208202803683370190505b5060765481519192506001600160a01b0316908290600090611c1e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508160011415611c4d5792915050565b6076546001600160a01b0316600090815260786020526040902054611c75906001838161250c565b9250505090565b3360009081526038602052604090205460ff1615611ceb5760405162461bcd60e51b815260206004820152602660248201527f596f75206861766520616c726561647920636f6c6c656374656420796f757220604482015265746f6b656e2160d01b6064820152608401610603565b3360009081526038602052604090819020805460ff19166001179055516331a9108f60e11b815260048101839052819030906001600160a01b03831690636352211e9060240160206040518083038186803b158015611d4957600080fd5b505afa158015611d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8191906126b7565b6001600160a01b031614611ded5760405162461bcd60e51b815260206004820152602d60248201527f5468697320636f6e7472616374206973206e6f74206f776e6572206f6620746860448201526c6973204e464420746f6b656e2160981b6064820152608401610603565b604051632142170760e11b8152306004820152336024820152604481018490526001600160a01b038216906342842e0e90606401600060405180830381600087803b158015611e3b57600080fd5b505af1158015611e4f573d6000803e3d6000fd5b505050507fe1d87fa11bbc18b46a63a92a5548e27ac8c4c7bedd39a610616afdb467828dca3384604051611e849291906128bb565b60405180910390a1505050565b6060603680548060200260200160405190810160405280929190818152602001828054801561121f57602002820191906000526020600020905b815481526020019060010190808311611ecb575050505050905090565b6000611ef48284612b40565b90505b92915050565b6000611ef48284612b60565b6000611ef48284612b28565b6000611ef48284612b7f565b60335460ff1615611f745760405162461bcd60e51b815260206004820152601860248201527f46756e647320616c726561647920636f6c6c65637465642100000000000000006044820152606401610603565b6033805460ff1916600117905560405163a9059cbb60e01b815260009081906001600160a01b038a169063a9059cbb90611fb4908b9089906004016128bb565b602060405180830381600087803b158015611fce57600080fd5b505af1158015611fe2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200691906127ac565b506001600160a01b038716156120ba5761202583610991866064611ee8565b90506120318482611f15565b60405163a9059cbb60e01b81529092506001600160a01b038a169063a9059cbb90612062908a9085906004016128bb565b602060405180830381600087803b15801561207c57600080fd5b505af1158015612090573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b491906127ac565b506120be565b8391505b60405163a9059cbb60e01b81526001600160a01b038a169063a9059cbb906120ec90899086906004016128bb565b602060405180830381600087803b15801561210657600080fd5b505af115801561211a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061213e91906127ac565b5060408051868152602081018490529081018290527f6ea5c59900d2287e197ce26928208769c75c08f14c9d14b894eb8afde1185ee69060600160405180910390a1505050505050505050565b806000805b612198611e91565b518110156121ee5782603682815481106121c257634e487b7160e01b600052603260045260246000fd5b906000526020600020015414156121dc57600191506121ee565b806121e681612bad565b915050612190565b508061224c5760405162461bcd60e51b815260206004820152602760248201527f5468697320546f6b656e206973206e6f7420616c6c6f77656420666f722074686044820152666973204e46442160c81b6064820152608401610603565b600060345411801561226d5750600083815260376020526040902054603454115b156122cb5760405162461bcd60e51b815260206004820152602860248201527f557365722068617665207265616368656420746865206d6178696d756d20616c6044820152676c6f77616e63652160c01b6064820152608401610603565b6000838152603760205260409020546122e5906001611f09565b60008481526037602052604090819020829055517f564d4309aa774c1f02ae91e99cd84f81af757524feafb7bcd96612a07e6c523391611e8491869190918252602082015260400190565b60008054610100900460ff1615612377578160ff1660011480156123535750303b155b61236f5760405162461bcd60e51b8152600401610603906129e3565b506000919050565b60005460ff80841691161061239e5760405162461bcd60e51b8152600401610603906129e3565b506000805460ff191660ff92909216919091179055600190565b600054610100900460ff166123df5760405162461bcd60e51b815260040161060390612aa6565b6123e7612666565b565b600054610100900460ff166124105760405162461bcd60e51b815260040161060390612aa6565b603591909155603455565b6000611ef782670de0b6b3a7640000612b60565b600081831015612440575081611ef7565b50919050565b6000805b6077548110156124ac576077818154811061247557634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031633141561249a57600191506124ac565b806124a481612bad565b91505061244a565b50806124fe57607780546001810182556000919091527f7901cb5addcae2d210a531c604a76a660d77039093bac314de0816a16392aff10180546001600160a01b0319166001600160a01b0384161790555b5050565b6060611a7c611e91565b6060600061253d61251c8661241b565b6076546001600160a01b031660009081526078602052604090205490611f15565b60775490915060009061255290600190612b7f565b90505b845184141561256357612633565b60006077828154811061258657634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b0316808352607890915260409091205490915083118015906125d457506001600160a01b03811660009081526078602052604090205488115b1561262057808686815181106125fa57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101528461261c81612bad565b9550505b508061262b81612b96565b915050612555565b5083518314156126465783915050610811565b61265c81612655876001611f09565b868661250c565b9695505050505050565b600054610100900460ff1661268d5760405162461bcd60e51b815260040161060390612aa6565b6001603955565b6000602082840312156126a5578081fd5b81356126b081612bf4565b9392505050565b6000602082840312156126c8578081fd5b81516126b081612bf4565b600080600080608085870312156126e8578283fd5b84356126f381612bf4565b9350602085013561270381612bf4565b925060408501359150606085013567ffffffffffffffff80821115612726578283fd5b818701915087601f830112612739578283fd5b81358181111561274b5761274b612bde565b604051601f8201601f19908116603f0116810190838211818310171561277357612773612bde565b816040528281528a602084870101111561278b578586fd5b82602086016020830137918201602001949094529598949750929550505050565b6000602082840312156127bd578081fd5b815180151581146126b0578182fd5b6000806000806000806000806000806101408b8d0312156127eb578586fd5b8a356127f681612bf4565b995060208b013561280681612bf4565b985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b0135935060e08b013561283981612bf4565b809350506101008b013591506101208b013590509295989b9194979a5092959850565b60006020828403121561286d578081fd5b5035919050565b600060208284031215612885578081fd5b5051919050565b6000806040838503121561289e578182fd5b8235915060208301356128b081612bf4565b809150509250929050565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156129155783516001600160a01b0316835292840192918401916001016128f0565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156129155783518352928401929184019160010161293d565b6000602080835283518082850152825b8181101561298557858101830151858201604001528201612969565b818111156129965783604083870101525b50601f01601f1916929092016040019392505050565b60208082526019908201527f41756374696f6e206973206e6f7420656e646564207965742100000000000000604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526027908201527f42656e65666963696172792063616e206e6f7420706572666f726d2074686520604082015266616374696f6e2160c81b606082015260800190565b6020808252601490820152732cb7ba9030b932903737ba1030b71037bbb732b960611b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612b3b57612b3b612bc8565b500190565b600082612b5b57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612b7a57612b7a612bc8565b500290565b600082821015612b9157612b91612bc8565b500390565b600081612ba557612ba5612bc8565b506000190190565b6000600019821415612bc157612bc1612bc8565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461114a57600080fdfea264697066735822122086b37de2a6ea1d72f22118e22b98e9c7f6b27664947bf7d7ae940f1d1b24fbe964736f6c63430008040033496e697469616c697a61626c653a20636f6e747261637420697320616c726561

Deployed ByteCode

0x6080604052600436106101bb5760003560e01c8063704416b4116100ec5780639363c8121161008a5780639e2c58ca116100645780639e2c58ca14610540578063ce10cf8014610562578063f28c40401461058f578063f5b56c56146105bc576101fb565b80639363c812146104ea5780639912a835146105005780639979ef4514610520576101fb565b80637ed0f1c1116100c65780637ed0f1c11461044e57806384ddc67f1461047b5780638fa8b7901461049d57806391f90157146104b2576101fb565b8063704416b4146103f357806378e97925146104085780637b0e08201461041e576101fb565b80633197cbb6116101595780633f9942ff116101335780633f9942ff146103775780634979440a14610391578063590e1ae3146103be57806369de8347146103d3576101fb565b80633197cbb6146103375780633711ef041461034d5780633ccfd60b14610362576101fb565b8063150b7a0211610195578063150b7a02146102a557806315d6af8f146102de57806324d507fd146103005780632e93be3014610315576101fb565b8063026670c51461022c5780631257e2791461025457806312fa6feb14610276576101fb565b366101fb577f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516101f19291906128bb565b60405180910390a1005b7f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f8852587433346040516101f19291906128bb565b34801561023857600080fd5b506102416105d2565b6040519081526020015b60405180910390f35b34801561026057600080fd5b5061027461026f36600461288c565b610613565b005b34801561028257600080fd5b5060745461029590610100900460ff1681565b604051901515815260200161024b565b3480156102b157600080fd5b506102c56102c03660046126d3565b610766565b6040516001600160e01b0319909116815260200161024b565b3480156102ea57600080fd5b506102f3610819565b60405161024b91906128d4565b34801561030c57600080fd5b5061027461085a565b34801561032157600080fd5b5061032a610ab8565b60405161024b9190612959565b34801561034357600080fd5b50610241606f5481565b34801561035957600080fd5b50610241610b65565b34801561036e57600080fd5b50610274610b9d565b34801561038357600080fd5b506074546102959060ff1681565b34801561039d57600080fd5b506076546001600160a01b0316600090815260786020526040902054610241565b3480156103ca57600080fd5b50610274610dff565b3480156103df57600080fd5b506102746103ee36600461285c565b6110e2565b3480156103ff57600080fd5b506102f361114d565b34801561041457600080fd5b50610241606e5481565b34801561042a57600080fd5b50610295610439366004612694565b60386020526000908152604090205460ff1681565b34801561045a57600080fd5b5061024161046936600461285c565b60376020526000908152604090205481565b34801561048757600080fd5b5033600090815260786020526040902054610241565b3480156104a957600080fd5b50610295611229565b3480156104be57600080fd5b506076546104d2906001600160a01b031681565b6040516001600160a01b03909116815260200161024b565b3480156104f657600080fd5b50610241606d5481565b34801561050c57600080fd5b5061027461051b3660046127cc565b611369565b34801561052c57600080fd5b5061027461053b36600461285c565b61152d565b34801561054c57600080fd5b50610555611a13565b60405161024b9190612921565b34801561056e57600080fd5b5061024161057d366004612694565b60786020526000908152604090205481565b34801561059b57600080fd5b506102416105aa36600461285c565b60009081526037602052604090205490565b3480156105c857600080fd5b5061024160755481565b6000336105dd611a90565b6001600160a01b03161461060c5760405162461bcd60e51b815260040161060390612a78565b60405180910390fd5b5060725490565b600260395414156106365760405162461bcd60e51b815260040161060390612af1565b60026039556070546001600160a01b03163314156106665760405162461bcd60e51b815260040161060390612a31565b606f544211801561067a575060745460ff16155b6106965760405162461bcd60e51b8152600401610603906129ac565b60006106a0611b0d565b90506000805b825181101561070b578281815181106106cf57634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316336001600160a01b031614156106f9576001915061070b565b8061070381612bad565b9150506106a6565b50806107515760405162461bcd60e51b8152602060048201526015602482015274596f7520617265206e6f7420612077696e6e65722160581b6044820152606401610603565b61075b8484611c7c565b505060016039555050565b6000610770611e91565b51603554116107d25760405162461bcd60e51b815260206004820152602860248201527f546f6b656e20616c6c6f77616e636520686173207265616368656420746865206044820152676d6178696d756d2160c01b6064820152608401610603565b50603680546001810182556000919091527f4a11f94e20a93c79f6ec743a1954ec4fc2c08429ae2122118bf234b2185c81b801829055630a85bd0160e11b5b949350505050565b606033610824611a90565b6001600160a01b03161461084a5760405162461bcd60e51b815260040161060390612a78565b6000610854611b0d565b91505090565b6002603954141561087d5760405162461bcd60e51b815260040161060390612af1565b60026039556070546001600160a01b03163314806108b3575061089e611a90565b6001600160a01b0316336001600160a01b0316145b6109185760405162461bcd60e51b815260206004820152603060248201527f42656e6566696369617279202f204f776e65722063616e206f6e6c792070657260448201526f666f726d2074686520616374696f6e2160801b6064820152608401610603565b6000610922611b0d565b905060008060005b8351811015610a0857600084828151811061095557634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b038116600090815260789092526040822054607254919350919061099790610991846064611ee8565b90611efd565b90506109a38582611f09565b945060006109b18383611f15565b90506109bd8782611f09565b6001600160a01b0385166000908152607860205260408120805492995085929091906109ea908490612b7f565b92505081905550505050508080610a0090612bad565b91505061092a565b50606c54604080516340f06db760e01b815290516000926001600160a01b0316916340f06db7916004808301926020929190829003018186803b158015610a4e57600080fd5b505afa158015610a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8691906126b7565b606b5460705460715460735493945061075b936001600160a01b03938416939283169290911690859088908890611f21565b60745460609060ff1615610ae9575060408051808201909152600881526718d85b98d95b195960c21b602082015290565b606f54421115610b135750604080518082019091526005815264195b99195960da1b602082015290565b606e54421015610b43575060408051808201909152600b81526a1b9bdd0b5cdd185c9d195960aa1b602082015290565b5060408051808201909152600781526672756e6e696e6760c81b602082015290565b600033610b70611a90565b6001600160a01b031614610b965760405162461bcd60e51b815260040161060390612a78565b5060735490565b60026039541415610bc05760405162461bcd60e51b815260040161060390612af1565b600260395560745460ff16610c175760405162461bcd60e51b815260206004820152601860248201527f41756374696f6e206973206e6f742063616e63656c65642100000000000000006044820152606401610603565b6070546001600160a01b0316331415610c425760405162461bcd60e51b815260040161060390612a31565b33600090815260786020526040902054610c9e5760405162461bcd60e51b815260206004820152601b60248201527f596f7520617265206e6f7420612076616c6964206269646465722100000000006044820152606401610603565b3360008181526078602052604090205480610d0b5760405162461bcd60e51b815260206004820152602760248201527f596f75206861766520616c7265616479207769746864726177616c20796f75726044820152662066756e64732160c81b6064820152608401610603565b6001600160a01b03821660009081526078602052604081208054839290610d33908490612b7f565b9091555050606b5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb90610d6a90859085906004016128bb565b602060405180830381600087803b158015610d8457600080fd5b505af1158015610d98573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbc91906127ac565b507fb4214c8c54fc7442f36d3682f59aebaf09358a4431835b30efb29d52cf9e1e918282604051610dee9291906128bb565b60405180910390a150506001603955565b60026039541415610e225760405162461bcd60e51b815260040161060390612af1565b60026039556070546001600160a01b0316331415610e525760405162461bcd60e51b815260040161060390612a31565b606f5442118015610e66575060745460ff16155b610e825760405162461bcd60e51b8152600401610603906129ac565b33600090815260786020526040902054610ede5760405162461bcd60e51b815260206004820152601b60248201527f596f7520617265206e6f7420612076616c6964206269646465722100000000006044820152606401610603565b6000610ee8611b0d565b905060005b8151811015610faa57818181518110610f1657634e487b7160e01b600052603260045260246000fd5b60200260200101516001600160a01b0316336001600160a01b03161415610f985760405162461bcd60e51b815260206004820152603060248201527f596f75206172652077696e6e65722c20796f752063616e206e6f74207065726660448201526f6f726d207468697320616374696f6e2160801b6064820152608401610603565b80610fa281612bad565b915050610eed565b5033600090815260786020526040902054806110085760405162461bcd60e51b815260206004820152601d60248201527f596f7520616c7265616479206861766520726566756e64206261636b210000006044820152606401610603565b3360009081526078602052604081208054839290611027908490612b7f565b9091555050606b5460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb9061105e90339085906004016128bb565b602060405180830381600087803b15801561107857600080fd5b505af115801561108c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b091906127ac565b507fb6c0eca8138e097d71e2dd31e19a1266487f0553f170b7260ffe68bcbe9ff8a73382604051610dee9291906128bb565b336110eb611a90565b6001600160a01b0316146111115760405162461bcd60e51b815260040161060390612a78565b606f5442118015611125575060745460ff16155b6111415760405162461bcd60e51b8152600401610603906129ac565b61114a8161218b565b50565b606033611158611a90565b6001600160a01b03161461117e5760405162461bcd60e51b815260040161060390612a78565b606e544210156111c95760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20796574206e6f742073746172742160501b6044820152606401610603565b607780548060200260200160405190810160405280929190818152602001828054801561121f57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611201575b5050505050905090565b60006002603954141561124e5760405162461bcd60e51b815260040161060390612af1565b60026039553361125c611a90565b6001600160a01b0316146112825760405162461bcd60e51b815260040161060390612a78565b606f544211156112cd5760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20616c726561647920656e6465642160501b6044820152606401610603565b60745460ff161561131c5760405162461bcd60e51b815260206004820152601960248201527841756374696f6e20616c72656164792063616e63656c65642160381b6044820152606401610603565b6074805460ff191660019081179091556040519081527f1fd636bc86322e474244a9366e9b72f9e75d3ba45b442352c7f950c92a9808a59060200160405180910390a15060018060395590565b60006113756001612330565b9050801561138d576000805461ff0019166101001790555b6113956123b8565b61139f86866123e9565b42871180156113ad57508787115b6114175760405162461bcd60e51b815260206004820152603560248201527f41756374696f6e20656e642074696d657374616d702063616e206e6f74206265604482015274207468652070617374206f7220696e76616c69642160581b6064820152608401610603565b6001600160a01b038a166114795760405162461bcd60e51b815260206004820152602360248201527f42656e65666963696172792061646472657373206973206e6f7420636f72726560448201526263742160e81b6064820152608401610603565b606b80546001600160a01b03808e166001600160a01b031992831617909255607080548d84169083161790556071805492871692821692909217909155606d8a9055606e899055606f88905560728490556073839055606c8054909116331790558015611520576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050505050565b600260395414156115505760405162461bcd60e51b815260040161060390612af1565b6002603955606e544210156115a05760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20796574206e6f742073746172742160501b6044820152606401610603565b606f544211156115eb5760405162461bcd60e51b815260206004820152601660248201527541756374696f6e20616c726561647920656e6465642160501b6044820152606401610603565b60745460ff161561163a5760405162461bcd60e51b815260206004820152601960248201527841756374696f6e20616c72656164792063616e63656c65642160381b6044820152606401610603565b6070546001600160a01b03163314156116655760405162461bcd60e51b815260040161060390612a31565b606b546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b1580156116ad57600080fd5b505afa1580156116c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e59190612874565b101561173d5760405162461bcd60e51b815260206004820152602160248201527f496e73756666696369616e7420455243323020746f6b656e2062616c616e63656044820152602160f81b6064820152608401610603565b6001600160a01b0381166000908152607860205260408120546117609084611f09565b9050606d548110156117da5760405162461bcd60e51b815260206004820152603d60248201527f42696420546f6b656e20616d6f756e7420746f6f206c6f77212c20616d6f756e60448201527f742073686f756c642062652061626f766520666c6f6f722070726963650000006064820152608401610603565b607554811161182b5760405162461bcd60e51b815260206004820181905260248201527f6f7665726269642074686520686967686573742062696e64696e6720626964216044820152606401610603565b6076546001600160a01b03908116600090815260786020526040808220549285168252902082905580821161187f5761187761187161186a600161241b565b8490611f09565b8261242f565b6075556118cc565b6076546001600160a01b038481169116146118c957607680546001600160a01b0319166001600160a01b0385161790556118c5826118c061186a600161241b565b61242f565b6075555b50805b606c5460405163d96ca0b960e01b81526001600160a01b03858116600483015230602483015260448201879052600092169063d96ca0b990606401602060405180830381600087803b15801561192157600080fd5b505af1158015611935573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061195991906127ac565b9050806119a05760405162461bcd60e51b815260206004820152601560248201527446756e64207472616e73666572206661696c65642160581b6044820152606401610603565b6119a984612446565b607654607554604080516001600160a01b038089168252602082018a9052909316908301526060820184905260808201527ff152f4ff5e488c55370a2d53925a55055228ebd8ec95bd0251bbb299e48786b09060a00160405180910390a150506001603955505050565b606033611a1e611a90565b6001600160a01b031614611a445760405162461bcd60e51b815260040161060390612a78565b606f5442118015611a58575060745460ff16155b611a745760405162461bcd60e51b8152600401610603906129ac565b611a7c612502565b905090565b6001600160a01b03163b151590565b606c546040805163544e486d60e11b815290516000926001600160a01b03169163a89c90da916004808301926020929190829003018186803b158015611ad557600080fd5b505afa158015611ae9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a7c91906126b7565b607754606090611b795760405162461bcd60e51b815260206004820152603160248201527f4e6f2062696464657220666f756e642c2077696e6e6572206c6973742063616e604482015270206e6f742062652067656e65726174652160781b6064820152608401610603565b6000611b8460355490565b60775410611b9457603554611b98565b6077545b905060008167ffffffffffffffff811115611bc357634e487b7160e01b600052604160045260246000fd5b604051908082528060200260200182016040528015611bec578160200160208202803683370190505b5060765481519192506001600160a01b0316908290600090611c1e57634e487b7160e01b600052603260045260246000fd5b60200260200101906001600160a01b031690816001600160a01b0316815250508160011415611c4d5792915050565b6076546001600160a01b0316600090815260786020526040902054611c75906001838161250c565b9250505090565b3360009081526038602052604090205460ff1615611ceb5760405162461bcd60e51b815260206004820152602660248201527f596f75206861766520616c726561647920636f6c6c656374656420796f757220604482015265746f6b656e2160d01b6064820152608401610603565b3360009081526038602052604090819020805460ff19166001179055516331a9108f60e11b815260048101839052819030906001600160a01b03831690636352211e9060240160206040518083038186803b158015611d4957600080fd5b505afa158015611d5d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8191906126b7565b6001600160a01b031614611ded5760405162461bcd60e51b815260206004820152602d60248201527f5468697320636f6e7472616374206973206e6f74206f776e6572206f6620746860448201526c6973204e464420746f6b656e2160981b6064820152608401610603565b604051632142170760e11b8152306004820152336024820152604481018490526001600160a01b038216906342842e0e90606401600060405180830381600087803b158015611e3b57600080fd5b505af1158015611e4f573d6000803e3d6000fd5b505050507fe1d87fa11bbc18b46a63a92a5548e27ac8c4c7bedd39a610616afdb467828dca3384604051611e849291906128bb565b60405180910390a1505050565b6060603680548060200260200160405190810160405280929190818152602001828054801561121f57602002820191906000526020600020905b815481526020019060010190808311611ecb575050505050905090565b6000611ef48284612b40565b90505b92915050565b6000611ef48284612b60565b6000611ef48284612b28565b6000611ef48284612b7f565b60335460ff1615611f745760405162461bcd60e51b815260206004820152601860248201527f46756e647320616c726561647920636f6c6c65637465642100000000000000006044820152606401610603565b6033805460ff1916600117905560405163a9059cbb60e01b815260009081906001600160a01b038a169063a9059cbb90611fb4908b9089906004016128bb565b602060405180830381600087803b158015611fce57600080fd5b505af1158015611fe2573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061200691906127ac565b506001600160a01b038716156120ba5761202583610991866064611ee8565b90506120318482611f15565b60405163a9059cbb60e01b81529092506001600160a01b038a169063a9059cbb90612062908a9085906004016128bb565b602060405180830381600087803b15801561207c57600080fd5b505af1158015612090573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120b491906127ac565b506120be565b8391505b60405163a9059cbb60e01b81526001600160a01b038a169063a9059cbb906120ec90899086906004016128bb565b602060405180830381600087803b15801561210657600080fd5b505af115801561211a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061213e91906127ac565b5060408051868152602081018490529081018290527f6ea5c59900d2287e197ce26928208769c75c08f14c9d14b894eb8afde1185ee69060600160405180910390a1505050505050505050565b806000805b612198611e91565b518110156121ee5782603682815481106121c257634e487b7160e01b600052603260045260246000fd5b906000526020600020015414156121dc57600191506121ee565b806121e681612bad565b915050612190565b508061224c5760405162461bcd60e51b815260206004820152602760248201527f5468697320546f6b656e206973206e6f7420616c6c6f77656420666f722074686044820152666973204e46442160c81b6064820152608401610603565b600060345411801561226d5750600083815260376020526040902054603454115b156122cb5760405162461bcd60e51b815260206004820152602860248201527f557365722068617665207265616368656420746865206d6178696d756d20616c6044820152676c6f77616e63652160c01b6064820152608401610603565b6000838152603760205260409020546122e5906001611f09565b60008481526037602052604090819020829055517f564d4309aa774c1f02ae91e99cd84f81af757524feafb7bcd96612a07e6c523391611e8491869190918252602082015260400190565b60008054610100900460ff1615612377578160ff1660011480156123535750303b155b61236f5760405162461bcd60e51b8152600401610603906129e3565b506000919050565b60005460ff80841691161061239e5760405162461bcd60e51b8152600401610603906129e3565b506000805460ff191660ff92909216919091179055600190565b600054610100900460ff166123df5760405162461bcd60e51b815260040161060390612aa6565b6123e7612666565b565b600054610100900460ff166124105760405162461bcd60e51b815260040161060390612aa6565b603591909155603455565b6000611ef782670de0b6b3a7640000612b60565b600081831015612440575081611ef7565b50919050565b6000805b6077548110156124ac576077818154811061247557634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031633141561249a57600191506124ac565b806124a481612bad565b91505061244a565b50806124fe57607780546001810182556000919091527f7901cb5addcae2d210a531c604a76a660d77039093bac314de0816a16392aff10180546001600160a01b0319166001600160a01b0384161790555b5050565b6060611a7c611e91565b6060600061253d61251c8661241b565b6076546001600160a01b031660009081526078602052604090205490611f15565b60775490915060009061255290600190612b7f565b90505b845184141561256357612633565b60006077828154811061258657634e487b7160e01b600052603260045260246000fd5b60009182526020808320909101546001600160a01b0316808352607890915260409091205490915083118015906125d457506001600160a01b03811660009081526078602052604090205488115b1561262057808686815181106125fa57634e487b7160e01b600052603260045260246000fd5b6001600160a01b03909216602092830291909101909101528461261c81612bad565b9550505b508061262b81612b96565b915050612555565b5083518314156126465783915050610811565b61265c81612655876001611f09565b868661250c565b9695505050505050565b600054610100900460ff1661268d5760405162461bcd60e51b815260040161060390612aa6565b6001603955565b6000602082840312156126a5578081fd5b81356126b081612bf4565b9392505050565b6000602082840312156126c8578081fd5b81516126b081612bf4565b600080600080608085870312156126e8578283fd5b84356126f381612bf4565b9350602085013561270381612bf4565b925060408501359150606085013567ffffffffffffffff80821115612726578283fd5b818701915087601f830112612739578283fd5b81358181111561274b5761274b612bde565b604051601f8201601f19908116603f0116810190838211818310171561277357612773612bde565b816040528281528a602084870101111561278b578586fd5b82602086016020830137918201602001949094529598949750929550505050565b6000602082840312156127bd578081fd5b815180151581146126b0578182fd5b6000806000806000806000806000806101408b8d0312156127eb578586fd5b8a356127f681612bf4565b995060208b013561280681612bf4565b985060408b0135975060608b0135965060808b0135955060a08b0135945060c08b0135935060e08b013561283981612bf4565b809350506101008b013591506101208b013590509295989b9194979a5092959850565b60006020828403121561286d578081fd5b5035919050565b600060208284031215612885578081fd5b5051919050565b6000806040838503121561289e578182fd5b8235915060208301356128b081612bf4565b809150509250929050565b6001600160a01b03929092168252602082015260400190565b6020808252825182820181905260009190848201906040850190845b818110156129155783516001600160a01b0316835292840192918401916001016128f0565b50909695505050505050565b6020808252825182820181905260009190848201906040850190845b818110156129155783518352928401929184019160010161293d565b6000602080835283518082850152825b8181101561298557858101830151858201604001528201612969565b818111156129965783604083870101525b50601f01601f1916929092016040019392505050565b60208082526019908201527f41756374696f6e206973206e6f7420656e646564207965742100000000000000604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526027908201527f42656e65666963696172792063616e206e6f7420706572666f726d2074686520604082015266616374696f6e2160c81b606082015260800190565b6020808252601490820152732cb7ba9030b932903737ba1030b71037bbb732b960611b604082015260600190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60008219821115612b3b57612b3b612bc8565b500190565b600082612b5b57634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615612b7a57612b7a612bc8565b500290565b600082821015612b9157612b91612bc8565b500390565b600081612ba557612ba5612bc8565b506000190190565b6000600019821415612bc157612bc1612bc8565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461114a57600080fdfea264697066735822122086b37de2a6ea1d72f22118e22b98e9c7f6b27664947bf7d7ae940f1d1b24fbe964736f6c63430008040033