Contract 0x611dFbc0c35AE0f9c345Fb685A5f0C17f5aA24Fd

 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0x6a569ff0d1396ba1768e19c30f11f249daf3dcca0a10562163b94be3fedd096cAccept Bid For T...579796122023-03-20 11:50:503 days 8 hrs ago0x20a175efc332dbd9fa7f5a75a40d10083d917893 IN  0x611dfbc0c35ae0f9c345fb685a5f0c17f5aa24fd0 FTM0.0118468
0x94538b2c58870942485e6cc0774e118299ce612d86b0bc13209e460b3a0f4a4dEnter Bid For To...579771612023-03-20 10:37:563 days 10 hrs ago0xf55f91f4b5b9ae377c90e6dea3eaeeac18bd6bb8 IN  0x611dfbc0c35ae0f9c345fb685a5f0c17f5aa24fd0 FTM0.012547788
0xe51388ec58dc953edc9c71b66ec715d17ac2e3dcf0701bafaac02bf9ba2cdc330x60806040578963062023-03-19 6:11:084 days 14 hrs ago0x1d28577186e6c3fa278b844b578d420d97b9b1f9 IN  Create: ERC721Bids0 FTM0.293382125381
[ Download CSV Export 
Latest 1 internal transaction
Parent Txn Hash Block From To Value
0xe51388ec58dc953edc9c71b66ec715d17ac2e3dcf0701bafaac02bf9ba2cdc33578963062023-03-19 6:11:084 days 14 hrs ago 0x1d28577186e6c3fa278b844b578d420d97b9b1f9  Contract Creation0 FTM
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC721Bids

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 99999999 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 19 : ERC721Bids.sol
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;
pragma abicoder v2;

import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../library/CollectionReader.sol";
import "../royalty/ICollectionRoyaltyReader.sol";
import "../payment-token/IPaymentTokenCheck.sol";
import "../market-settings/IMarketSettings.sol";
import "./IERC721Bids.sol";
import "./OperatorDelegation.sol";

contract ERC721Bids is IERC721Bids, OperatorDelegation, ReentrancyGuard {
    using EnumerableSet for EnumerableSet.UintSet;
    using EnumerableSet for EnumerableSet.AddressSet;
    using SafeERC20 for IERC20;

    constructor(address marketSettings_) {
        _marketSettings = IMarketSettings(marketSettings_);
    }

    IMarketSettings private _marketSettings;

    mapping(address => ERC721Bids) private _erc721Bids;

    /**
     * @dev See {IERC721Bids-enterBidForToken}.
     */
    function enterBidForToken(
        address erc721Address,
        uint256 tokenId,
        uint256 value,
        uint256 expireTimestamp,
        address paymentToken,
        address bidder
    ) external {
        require(
            bidder == _msgSender() || isApprovedOperator(bidder, _msgSender()),
            "sender not bidder or approved operator"
        );

        (bool isValid, string memory message) = _checkEnterBidAction(
            erc721Address,
            tokenId,
            value,
            expireTimestamp,
            paymentToken,
            bidder
        );

        require(isValid, message);

        _enterBidForToken(
            erc721Address,
            tokenId,
            value,
            expireTimestamp,
            paymentToken,
            bidder
        );
    }

    /**
     * @dev See {IERC721Bids-enterBidForTokens}.
     */
    function enterBidForTokens(EnterBidInput[] calldata newBids, address bidder)
        external
    {
        require(
            bidder == _msgSender() || isApprovedOperator(bidder, _msgSender()),
            "sender not bidder or approved operator"
        );

        for (uint256 i = 0; i < newBids.length; i++) {
            address erc721Address = newBids[i].erc721Address;
            uint256 tokenId = newBids[i].tokenId;
            uint256 value = newBids[i].value;
            uint256 expireTimestamp = newBids[i].expireTimestamp;
            address paymentToken = newBids[i].paymentToken;

            (bool isValid, string memory message) = _checkEnterBidAction(
                erc721Address,
                tokenId,
                value,
                expireTimestamp,
                paymentToken,
                bidder
            );

            if (isValid) {
                _enterBidForToken(
                    erc721Address,
                    tokenId,
                    value,
                    expireTimestamp,
                    paymentToken,
                    bidder
                );
            } else {
                emit EnterBidFailed(
                    erc721Address,
                    tokenId,
                    message,
                    _msgSender()
                );
            }
        }
    }

    /**
     * @dev See {IERC721Bids-withdrawBidForToken}.
     */
    function withdrawBidForToken(
        address erc721Address,
        uint256 tokenId,
        address bidder
    ) external {
        Bid memory bid = _erc721Bids[erc721Address].bids[tokenId].bids[bidder];

        (bool isValid, string memory message) = _checkWithdrawBidAction(bid);

        require(isValid, message);

        _withdrawBidForToken(erc721Address, bid);
    }

    /**
     * @dev See {IERC721Bids-withdrawBidForTokens}.
     */
    function withdrawBidForTokens(WithdrawBidInput[] calldata bids) external {
        for (uint256 i = 0; i < bids.length; i++) {
            address erc721Address = bids[i].erc721Address;
            uint256 tokenId = bids[i].tokenId;
            address bidder = bids[i].bidder;
            Bid memory bid = _erc721Bids[erc721Address].bids[tokenId].bids[
                bidder
            ];

            (bool isValid, string memory message) = _checkWithdrawBidAction(
                bid
            );

            if (isValid) {
                _withdrawBidForToken(erc721Address, bid);
            } else {
                emit WithdrawBidFailed(
                    erc721Address,
                    tokenId,
                    message,
                    _msgSender()
                );
            }
        }
    }

    /**
     * @dev See {IERC721Bids-acceptBidForToken}.
     */
    function acceptBidForToken(
        address erc721Address,
        uint256 tokenId,
        address bidder,
        uint256 value
    ) external {
        Bid memory bid = _erc721Bids[erc721Address].bids[tokenId].bids[bidder];
        address tokenOwner = CollectionReader.tokenOwner(
            erc721Address,
            tokenId
        );

        (bool isValid, string memory message) = _checkAcceptBidAction(
            erc721Address,
            bid,
            value,
            tokenOwner
        );

        require(isValid, message);

        _acceptBidForToken(erc721Address, bid, tokenOwner);
    }

    /**
     * @dev See {IERC721Bids-acceptBidForTokens}.
     */
    function acceptBidForTokens(AcceptBidInput[] calldata bids) external {
        for (uint256 i = 0; i < bids.length; i++) {
            address erc721Address = bids[i].erc721Address;
            uint256 tokenId = bids[i].tokenId;
            address bidder = bids[i].bidder;
            uint256 value = bids[i].value;
            Bid memory bid = _erc721Bids[erc721Address].bids[tokenId].bids[
                bidder
            ];
            address tokenOwner = CollectionReader.tokenOwner(
                erc721Address,
                tokenId
            );

            (bool isValid, string memory message) = _checkAcceptBidAction(
                erc721Address,
                bid,
                value,
                tokenOwner
            );

            if (isValid) {
                _acceptBidForToken(erc721Address, bid, tokenOwner);
            } else {
                emit AcceptBidFailed(
                    erc721Address,
                    tokenId,
                    message,
                    _msgSender()
                );
            }
        }
    }

    /**
     * @dev See {IERC721Bids-removeExpiredBids}.
     */
    function removeExpiredBids(RemoveExpiredBidInput[] calldata bids) external {
        for (uint256 i = 0; i < bids.length; i++) {
            address erc721Address = bids[i].erc721Address;
            uint256 tokenId = bids[i].tokenId;
            address bidder = bids[i].bidder;
            Bid memory bid = _erc721Bids[erc721Address].bids[tokenId].bids[
                bidder
            ];

            if (
                bid.expireTimestamp != 0 &&
                bid.expireTimestamp <= block.timestamp
            ) {
                _removeBid(erc721Address, tokenId, bidder);
            }
        }
    }

    /**
     * @dev check if enter bid action is valid
     * if not valid, return the reason
     */
    function _checkEnterBidAction(
        address erc721Address,
        uint256 tokenId,
        uint256 value,
        uint256 expireTimestamp,
        address paymentToken,
        address bidder
    ) private view returns (bool isValid, string memory message) {
        isValid = false;

        if (!_marketSettings.isCollectionTradingEnabled(erc721Address)) {
            message = "trading is not open";
            return (isValid, message);
        }
        if (value == 0) {
            message = "value cannot be 0";
            return (isValid, message);
        }
        if (
            expireTimestamp - block.timestamp <
            _marketSettings.actionTimeOutRangeMin()
        ) {
            message = "expire time below minimum";
            return (isValid, message);
        }
        if (
            expireTimestamp - block.timestamp >
            _marketSettings.actionTimeOutRangeMax()
        ) {
            message = "expire time above maximum";
            return (isValid, message);
        }
        if (!_isAllowedPaymentToken(erc721Address, paymentToken)) {
            message = "payment token not enabled";
            return (isValid, message);
        }
        address _paymentToken = _getPaymentTokenAddress(paymentToken);
        if (IERC20(_paymentToken).balanceOf(bidder) < value) {
            message = "insufficient balance";
            return (isValid, message);
        }
        if (IERC20(_paymentToken).allowance(bidder, address(this)) < value) {
            message = "insufficient allowance";
            return (isValid, message);
        }
        address tokenOwner = CollectionReader.tokenOwner(
            erc721Address,
            tokenId
        );
        if (tokenOwner == bidder) {
            message = "token owner cannot bid";
            return (isValid, message);
        }

        isValid = true;
    }

    /**
     * @dev enter a bid
     */
    function _enterBidForToken(
        address erc721Address,
        uint256 tokenId,
        uint256 value,
        uint256 expireTimestamp,
        address paymentToken,
        address bidder
    ) private {
        Bid memory bid = Bid(
            tokenId,
            value,
            bidder,
            expireTimestamp,
            paymentToken
        );

        _erc721Bids[erc721Address].tokenIds.add(tokenId);
        _erc721Bids[erc721Address].bids[tokenId].bidders.add(bidder);
        _erc721Bids[erc721Address].bids[tokenId].bids[bidder] = bid;

        emit TokenBidEntered(erc721Address, bidder, tokenId, bid, _msgSender());
    }

    /**
     * @dev check if withdraw bid action is valid
     * if not valid, return the reason
     */
    function _checkWithdrawBidAction(Bid memory bid)
        private
        view
        returns (bool isValid, string memory message)
    {
        isValid = false;

        if (bid.bidder == address(0)) {
            message = "bid does not exist";
            return (isValid, message);
        }

        if (
            bid.bidder != _msgSender() &&
            !isApprovedOperator(bid.bidder, _msgSender())
        ) {
            message = "sender not bidder or approved operator";
            return (isValid, message);
        }

        isValid = true;
    }

    /**
     * @dev withdraw a bid
     */
    function _withdrawBidForToken(address erc721Address, Bid memory bid)
        private
    {
        _removeBid(erc721Address, bid.tokenId, bid.bidder);

        emit TokenBidWithdrawn(
            erc721Address,
            bid.bidder,
            bid.tokenId,
            bid,
            _msgSender()
        );
    }

    /**
     * @dev check if accept bid action is valid
     * if not valid, return the reason
     */
    function _checkAcceptBidAction(
        address erc721Address,
        Bid memory bid,
        uint256 value,
        address tokenOwner
    ) private view returns (bool isValid, string memory message) {
        isValid = false;

        Status status = _getBidStatus(erc721Address, bid);
        if (status != Status.ACTIVE) {
            message = "bid is not valid";
            return (isValid, message);
        }
        if (value != bid.value) {
            message = "accepting value differ from bid";
            return (isValid, message);
        }
        if (
            tokenOwner != _msgSender() &&
            !isApprovedOperator(tokenOwner, _msgSender())
        ) {
            message = "sender not owner or approved operator";
            return (isValid, message);
        }
        if (
            !_isApprovedToTransferToken(erc721Address, bid.tokenId, tokenOwner)
        ) {
            message = "transferred not approved";
            return (isValid, message);
        }
        isValid = true;
    }

    /**
     * @dev accept a bid
     */
    function _acceptBidForToken(
        address erc721Address,
        Bid memory bid,
        address tokenOwner
    ) private nonReentrant {
        (
            FundReceiver[] memory fundReceivers,
            ICollectionRoyaltyReader.RoyaltyAmount[] memory royaltyInfo,
            uint256 serviceFee
        ) = _getFundReceiversOfBid(erc721Address, bid, tokenOwner);

        _sendFundToReceivers(bid.bidder, fundReceivers);

        // Send token to bidder
        IERC721(erc721Address).safeTransferFrom(
            tokenOwner,
            bid.bidder,
            bid.tokenId
        );

        _removeBid(erc721Address, bid.tokenId, bid.bidder);

        emit TokenBidAccepted({
            erc721Address: erc721Address,
            seller: tokenOwner,
            tokenId: bid.tokenId,
            bid: bid,
            serviceFee: serviceFee,
            royaltyInfo: royaltyInfo,
            sender: _msgSender()
        });
    }

    /**
     * @dev remove bid from storage
     */
    function _removeBid(
        address erc721Address,
        uint256 tokenId,
        address bidder
    ) private {
        if (_erc721Bids[erc721Address].bids[tokenId].bidders.contains(bidder)) {
            // Step 1: delete the bid and the address
            delete _erc721Bids[erc721Address].bids[tokenId].bids[bidder];
            _erc721Bids[erc721Address].bids[tokenId].bidders.remove(bidder);

            // Step 2: if no bid left
            if (
                _erc721Bids[erc721Address].bids[tokenId].bidders.length() == 0
            ) {
                _erc721Bids[erc721Address].tokenIds.remove(tokenId);
            }
        }
    }

    /**
     * @dev get list of fund receivers, amount, and payment token
     * Note:
     * List of receivers
     * - Seller of token
     * - Service fee receiver
     * - royalty receivers
     */
    function _getFundReceiversOfBid(
        address erc721Address,
        Bid memory bid,
        address tokenOwner
    )
        private
        view
        returns (
            FundReceiver[] memory fundReceivers,
            ICollectionRoyaltyReader.RoyaltyAmount[] memory royaltyInfo,
            uint256 serviceFee
        )
    {
        address paymentToken = _getPaymentTokenAddress(bid.paymentToken);

        royaltyInfo = ICollectionRoyaltyReader(
            _marketSettings.royaltyRegsitry()
        ).royaltyInfo(erc721Address, bid.tokenId, bid.value);

        fundReceivers = new FundReceiver[](royaltyInfo.length + 2);

        uint256 amountToSeller = bid.value;
        for (uint256 i = 0; i < royaltyInfo.length; i++) {
            address royaltyReceiver = royaltyInfo[i].receiver;
            uint256 royaltyAmount = royaltyInfo[i].royaltyAmount;

            fundReceivers[i + 2] = FundReceiver({
                account: royaltyReceiver,
                amount: royaltyAmount,
                paymentToken: paymentToken
            });

            amountToSeller -= royaltyAmount;
        }

        (address feeReceiver, uint256 feeAmount) = _marketSettings
            .serviceFeeInfo(bid.value);
        serviceFee = feeAmount;

        fundReceivers[1] = FundReceiver({
            account: feeReceiver,
            amount: serviceFee,
            paymentToken: paymentToken
        });

        amountToSeller -= serviceFee;

        fundReceivers[0] = FundReceiver({
            account: tokenOwner,
            amount: amountToSeller,
            paymentToken: paymentToken
        });
    }

    /**
     * @dev map payment token address
     * Address 0 is mapped to wrapped ether address.
     * For a given chain, wrapped ether represent it's
     * corresponding wrapped coin. e.g. WBNB for BSC, WFTM for FTM
     */
    function _getPaymentTokenAddress(address _paymentToken)
        private
        view
        returns (address paymentToken)
    {
        paymentToken = _paymentToken;

        if (_paymentToken == address(0)) {
            paymentToken = _marketSettings.wrappedEther();
        }
    }

    /**
     * @dev send payment token
     */
    function _sendFund(
        address paymentToken,
        address from,
        address to,
        uint256 value
    ) private {
        require(paymentToken != address(0), "payment token can't be 0 address");
        IERC20(paymentToken).safeTransferFrom(from, to, value);
    }

    /**
     * @dev send funds to a list of receivers
     */
    function _sendFundToReceivers(
        address from,
        FundReceiver[] memory fundReceivers
    ) private {
        for (uint256 i; i < fundReceivers.length; i++) {
            _sendFund(
                fundReceivers[i].paymentToken,
                from,
                fundReceivers[i].account,
                fundReceivers[i].amount
            );
        }
    }

    /**
     * @dev See {IERC721Bids-getBidderTokenBid}.
     */
    function getBidderTokenBid(
        address erc721Address,
        uint256 tokenId,
        address bidder
    ) public view returns (BidStatus memory) {
        Bid memory bid = _erc721Bids[erc721Address].bids[tokenId].bids[bidder];
        Status status = _getBidStatus(erc721Address, bid);

        return
            BidStatus({
                tokenId: bid.tokenId,
                value: bid.value,
                bidder: bid.bidder,
                expireTimestamp: bid.expireTimestamp,
                paymentToken: bid.paymentToken,
                status: status
            });
    }

    /**
     * @dev See {IERC721Bids-getTokenBids}.
     */
    function getTokenBids(address erc721Address, uint256 tokenId)
        public
        view
        returns (BidStatus[] memory bids)
    {
        uint256 bidderCount = _erc721Bids[erc721Address]
            .bids[tokenId]
            .bidders
            .length();

        bids = new BidStatus[](bidderCount);
        for (uint256 i; i < bidderCount; i++) {
            address bidder = _erc721Bids[erc721Address]
                .bids[tokenId]
                .bidders
                .at(i);
            bids[i] = getBidderTokenBid(erc721Address, tokenId, bidder);
        }
    }

    /**
     * @dev See {IERC721Bids-getTokenHighestBid}.
     */
    function getTokenHighestBid(address erc721Address, uint256 tokenId)
        public
        view
        returns (BidStatus memory highestBid)
    {
        uint256 bidderCount = _erc721Bids[erc721Address]
            .bids[tokenId]
            .bidders
            .length();
        for (uint256 i; i < bidderCount; i++) {
            address bidder = _erc721Bids[erc721Address]
                .bids[tokenId]
                .bidders
                .at(i);
            BidStatus memory bid = getBidderTokenBid(
                erc721Address,
                tokenId,
                bidder
            );
            if (bid.status == Status.ACTIVE && bid.value > highestBid.value) {
                highestBid = bid;
            }
        }
    }

    /**
     * @dev See {IERC721Bids-numTokenWithBidsOfCollection}.
     */
    function numTokenWithBidsOfCollection(address erc721Address)
        public
        view
        returns (uint256)
    {
        return _erc721Bids[erc721Address].tokenIds.length();
    }

    /**
     * @dev See {IERC721Bids-getHighestBidsOfCollection}.
     */
    function getHighestBidsOfCollection(
        address erc721Address,
        uint256 from,
        uint256 size
    ) external view returns (BidStatus[] memory highestBids) {
        uint256 tokenCount = numTokenWithBidsOfCollection(erc721Address);

        if (from < tokenCount && size > 0) {
            uint256 querySize = size;
            if ((from + size) > tokenCount) {
                querySize = tokenCount - from;
            }
            highestBids = new BidStatus[](querySize);
            for (uint256 i = 0; i < querySize; i++) {
                highestBids[i] = getTokenHighestBid({
                    erc721Address: erc721Address,
                    tokenId: _erc721Bids[erc721Address].tokenIds.at(i + from)
                });
            }
        }
    }

    /**
     * @dev See {IERC721Bids-getBidderBidsOfCollection}.
     */
    function getBidderBidsOfCollection(
        address erc721Address,
        address bidder,
        uint256 from,
        uint256 size
    ) external view returns (BidStatus[] memory bidderBids) {
        uint256 tokenCount = numTokenWithBidsOfCollection(erc721Address);

        if (from < tokenCount && size > 0) {
            uint256 querySize = size;
            if ((from + size) > tokenCount) {
                querySize = tokenCount - from;
            }
            bidderBids = new BidStatus[](querySize);
            for (uint256 i = 0; i < querySize; i++) {
                bidderBids[i] = getBidderTokenBid({
                    erc721Address: erc721Address,
                    tokenId: _erc721Bids[erc721Address].tokenIds.at(i + from),
                    bidder: bidder
                });
            }
        }
    }

    /**
     * @dev address of market settings contract
     */
    function marketSettingsContract() external view returns (address) {
        return address(_marketSettings);
    }

    /**
     * @dev update market settings contract
     */
    function updateMarketSettingsContract(address newMarketSettingsContract)
        external
        onlyOwner
    {
        address oldMarketSettingsContract = address(_marketSettings);
        _marketSettings = IMarketSettings(newMarketSettingsContract);

        emit MarketSettingsContractUpdated(
            oldMarketSettingsContract,
            newMarketSettingsContract
        );
    }

    /**
     * @dev check if payment token is allowed for a collection
     */
    function _isAllowedPaymentToken(address erc721Address, address paymentToken)
        private
        view
        returns (bool)
    {
        return
            paymentToken == address(0) ||
            IPaymentTokenCheck(_marketSettings.paymentTokenRegistry())
                .isAllowedPaymentToken(erc721Address, paymentToken);
    }

    /**
     * @dev check if a token or a collection if approved
     *  to be transferred by this contract
     */
    function _isApprovedToTransferToken(
        address erc721Address,
        uint256 tokenId,
        address account
    ) private view returns (bool) {
        return
            CollectionReader.isTokenApproved(erc721Address, tokenId) ||
            CollectionReader.isAllTokenApproved(
                erc721Address,
                account,
                address(this)
            );
    }

    /**
     * @dev get current status of a bid
     */
    function _getBidStatus(address erc721Address, Bid memory bid)
        private
        view
        returns (Status)
    {
        if (bid.bidder == address(0)) {
            return Status.NOT_EXIST;
        }
        if (!_marketSettings.isCollectionTradingEnabled(erc721Address)) {
            return Status.TRADE_NOT_OPEN;
        }
        if (bid.expireTimestamp < block.timestamp) {
            return Status.EXPIRED;
        }
        if (
            CollectionReader.tokenOwner(erc721Address, bid.tokenId) ==
            bid.bidder
        ) {
            return Status.ALREADY_TOKEN_OWNER;
        }
        if (!_isAllowedPaymentToken(erc721Address, bid.paymentToken)) {
            return Status.INVALID_PAYMENT_TOKEN;
        }

        address paymentToken = _getPaymentTokenAddress(bid.paymentToken);
        if (IERC20(paymentToken).balanceOf(bid.bidder) < bid.value) {
            return Status.INSUFFICIENT_BALANCE;
        }
        if (
            IERC20(paymentToken).allowance(bid.bidder, address(this)) <
            bid.value
        ) {
            return Status.INSUFFICIENT_ALLOWANCE;
        }

        return Status.ACTIVE;
    }
}

File 2 of 19 : ICollectionRoyaltyReader.sol
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;
pragma abicoder v2;

interface ICollectionRoyaltyReader {
    struct RoyaltyAmount {
        address receiver;
        uint256 royaltyAmount;
    }

    /**
     * @dev Get collection royalty receiver list
     * @param collectionAddress to read royalty receiver
     * @return list of royalty receivers and their shares
     */
    function royaltyInfo(
        address collectionAddress,
        uint256 tokenId,
        uint256 salePrice
    ) external view returns (RoyaltyAmount[] memory);
}

File 3 of 19 : IPaymentTokenCheck.sol
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;
pragma abicoder v2;

interface IPaymentTokenCheck {
    /**
     * @dev Check if a payment token is allowed for a collection
     */
    function isAllowedPaymentToken(address collectionAddress, address token)
        external
        view
        returns (bool);
}

File 4 of 19 : OperatorDelegation.sol
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;
pragma abicoder v2;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "./IOperatorDelegation.sol";

contract OperatorDelegation is IOperatorDelegation, Ownable {
    using EnumerableSet for EnumerableSet.AddressSet;

    // Allowed operator contracts will be reviewed
    // to make sure the original caller is the owner.
    // And the operator contract is a just a delegator contract
    // that does what the owner intended
    EnumerableSet.AddressSet private _allowedOperators;
    mapping(address => string) private _operatorName;
    mapping(address => EnumerableSet.AddressSet) private _operatorApprovals;

    /**
     * @dev See {IOperatorDelegation-setApprovalToOperator}.
     */
    function setApprovalToOperator(address operator, bool approved) public {
        _setApprovalToOperator(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IOperatorDelegation-isOperatorAllowed}.
     */
    function isOperatorAllowed(address operator) public view returns (bool) {
        return _allowedOperators.contains(operator);
    }

    /**
     * @dev See {IOperatorDelegation-isApprovedOperator}.
     */
    function isApprovedOperator(address owner, address operator)
        public
        view
        returns (bool)
    {
        return
            isOperatorAllowed(operator) &&
            _operatorApprovals[owner].contains(operator);
    }

    /**
     * @dev See {IOperatorDelegation-getOperator}.
     */
    function getOperator(address operator)
        external
        view
        returns (OperatorInfo memory operatorInfo)
    {
        if (isOperatorAllowed(operator)) {
            operatorInfo = OperatorInfo({
                operator: operator,
                name: _operatorName[operator]
            });
        }
    }

    /**
     * @dev See {IOperatorDelegation-getAllowedOperators}.
     */
    function getAllowedOperators()
        external
        view
        returns (OperatorInfo[] memory operators)
    {
        operators = new OperatorInfo[](_allowedOperators.length());

        for (uint256 i; i < _allowedOperators.length(); i++) {
            operators[i] = OperatorInfo({
                operator: _allowedOperators.at(i),
                name: _operatorName[_allowedOperators.at(i)]
            });
        }
    }

    /**
     * @dev See {IOperatorDelegation-getOwnerApprovedOperators}.
     */
    function getOwnerApprovedOperators(address owner)
        external
        view
        returns (OwnerOperatorInfo[] memory operators)
    {
        uint256 ownerOperatorCount = _operatorApprovals[owner].length();
        operators = new OwnerOperatorInfo[](ownerOperatorCount);

        for (uint256 i; i < ownerOperatorCount; i++) {
            address operator = _operatorApprovals[owner].at(i);
            operators[i] = OwnerOperatorInfo({
                operator: operator,
                name: _operatorName[operator],
                allowed: _allowedOperators.contains(operator)
            });
        }
    }

    /**
     * @dev See {IOperatorDelegation-addAllowedOperator}.
     */
    function addAllowedOperator(address newOperator, string memory operatorName)
        external
        onlyOwner
    {
        require(
            !_allowedOperators.contains(newOperator),
            "operator already in allowed list"
        );

        _allowedOperators.add(newOperator);
        _operatorName[newOperator] = operatorName;

        emit AllowedOperatorAdded(newOperator, operatorName, _msgSender());
    }

    /**
     * @dev See {IOperatorDelegation-removeAllowedOperator}.
     */
    function removeAllowedOperator(address operator) external onlyOwner {
        require(
            _allowedOperators.contains(operator),
            "operator not in allowed list"
        );

        string memory operatorName = _operatorName[operator];

        _allowedOperators.remove(operator);
        delete _operatorName[operator];

        emit AllowedOperatorRemoved(operator, operatorName, _msgSender());
    }

    /**
     * @dev See {IOperatorDelegation-updateOperatorName}.
     */
    function updateOperatorName(address operator, string memory newName)
        external
        onlyOwner
    {
        require(
            _allowedOperators.contains(operator),
            "operator not in allowed list"
        );

        string memory oldName = _operatorName[operator];

        require(
            keccak256(abi.encodePacked((newName))) ==
                keccak256(abi.encodePacked((oldName))),
            "operator name unchanged"
        );

        _operatorName[operator] = newName;

        emit OperatorNameUpdated(operator, oldName, newName, _msgSender());
    }

    /**
     * @dev Approve `operator` to operate on behalf of `owner`
     */
    function _setApprovalToOperator(
        address owner,
        address operator,
        bool approved
    ) private {
        require(
            _allowedOperators.contains(operator),
            "operator not in allowed list"
        );
        require(owner != operator, "approve to sender");

        if (approved) {
            _operatorApprovals[owner].add(operator);
        } else {
            _operatorApprovals[owner].remove(operator);
        }

        string memory operatorName = _operatorName[operator];
        emit OperatorApproved(owner, operator, approved, operatorName);
    }
}

File 5 of 19 : IOperatorDelegation.sol
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;
pragma abicoder v2;

interface IOperatorDelegation {
    struct OperatorInfo {
        address operator;
        string name;
    }

    struct OwnerOperatorInfo {
        address operator;
        string name;
        bool allowed;
    }

    event OperatorApproved(
        address indexed owner,
        address indexed operator,
        bool approved,
        string operatorName
    );

    event AllowedOperatorAdded(
        address indexed operator,
        string operatorName,
        address sender
    );

    event AllowedOperatorRemoved(
        address indexed operator,
        string operatorName,
        address sender
    );

    event OperatorNameUpdated(
        address indexed operator,
        string previousName,
        string newName,
        address sender
    );

    /**
     * @dev Approve or remove `operator` as an operator for the sender.
     */
    function setApprovalToOperator(address operator, bool _approved) external;

    /**
     * @dev check if operator is in the allowed list
     */
    function isOperatorAllowed(address operator) external view returns (bool);

    /**
     * @dev check if the `operator` is allowed to manage on behalf of `owner`.
     */
    function isApprovedOperator(address owner, address operator)
        external
        view
        returns (bool);

    /**
     * @dev check details of operator by address
     */
    function getOperator(address operator)
        external
        view
        returns (OperatorInfo memory);

    /**
     * @dev get the allowed list of operators
     */
    function getAllowedOperators()
        external
        view
        returns (OperatorInfo[] memory);

    /**
     * @dev get approved operators of a given address
     */
    function getOwnerApprovedOperators(address owner)
        external
        view
        returns (OwnerOperatorInfo[] memory);

    /**
     * @dev add allowed operator to allowed list
     */
    function addAllowedOperator(address newOperator, string memory operatorName)
        external;

    /**
     * @dev remove allowed operator from allowed list
     */
    function removeAllowedOperator(address operator) external;

    /**
     * @dev update name of an operator
     */
    function updateOperatorName(address operator, string memory newName)
        external;
}

File 6 of 19 : IERC721Bids.sol
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;
pragma abicoder v2;

import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "../royalty/ICollectionRoyaltyReader.sol";

interface IERC721Bids {
    struct EnterBidInput {
        address erc721Address;
        uint256 tokenId;
        uint256 value;
        uint256 expireTimestamp;
        address paymentToken;
    }

    struct WithdrawBidInput {
        address erc721Address;
        uint256 tokenId;
        address bidder;
    }

    struct AcceptBidInput {
        address erc721Address;
        uint256 tokenId;
        address bidder;
        uint256 value;
    }

    struct RemoveExpiredBidInput {
        address erc721Address;
        uint256 tokenId;
        address bidder;
    }

    struct Bid {
        uint256 tokenId;
        uint256 value;
        address bidder;
        uint256 expireTimestamp;
        address paymentToken;
    }

    struct TokenBids {
        EnumerableSet.AddressSet bidders;
        mapping(address => Bid) bids;
    }

    struct ERC721Bids {
        EnumerableSet.UintSet tokenIds;
        mapping(uint256 => TokenBids) bids;
    }

    struct FundReceiver {
        address account;
        uint256 amount;
        address paymentToken;
    }

    enum Status {
        NOT_EXIST, // 0: bid doesn't exist
        ACTIVE, // 1: bid is active and valid
        TRADE_NOT_OPEN, // 2: trade not open
        EXPIRED, // 3: bid has expired
        ALREADY_TOKEN_OWNER, // 4: bidder is token owner
        INVALID_PAYMENT_TOKEN, // 5: payment token is not allowed
        INSUFFICIENT_BALANCE, // 6: insufficient payment token balance
        INSUFFICIENT_ALLOWANCE // 7: insufficient payment token allowance
    }

    struct BidStatus {
        uint256 tokenId;
        uint256 value;
        address bidder;
        uint256 expireTimestamp;
        address paymentToken;
        Status status;
    }

    event TokenBidEntered(
        address indexed erc721Address,
        address indexed bidder,
        uint256 tokenId,
        Bid bid,
        address sender
    );
    event TokenBidWithdrawn(
        address indexed erc721Address,
        address indexed bidder,
        uint256 tokenId,
        Bid bid,
        address sender
    );
    event TokenBidAccepted(
        address indexed erc721Address,
        address indexed seller,
        uint256 tokenId,
        Bid bid,
        uint256 serviceFee,
        ICollectionRoyaltyReader.RoyaltyAmount[] royaltyInfo,
        address sender
    );

    event EnterBidFailed(
        address indexed erc721Address,
        uint256 tokenId,
        string message,
        address sender
    );
    event WithdrawBidFailed(
        address indexed erc721Address,
        uint256 tokenId,
        string message,
        address sender
    );
    event AcceptBidFailed(
        address indexed erc721Address,
        uint256 tokenId,
        string message,
        address sender
    );

    event MarketSettingsContractUpdated(
        address previousMarketSettingsContract,
        address newMarketSettingsContract
    );

    /**
     * @dev enter bid for token
     * @param erc721Address collection address
     * @param tokenId token ID to bid on
     * @param value bid price
     * @param expireTimestamp bid expire time
     * @param paymentToken erc20 token for payment
     * @param bidder address of bidder
     * Note:
     * paymentToken: When using address 0 as payment token,
     * it refers to wrapped coin of the chain, e.g. WBNB, WFTM, etc.
     * bidder: bidder is a required field because
     * sender can be a delegated operator, therefore bidder
     * address needs to be included
     */
    function enterBidForToken(
        address erc721Address,
        uint256 tokenId,
        uint256 value,
        uint256 expireTimestamp,
        address paymentToken,
        address bidder
    ) external;

    /**
     * @dev batch enter bids
     * @param newBids details of new bid
     * @param bidder address of bidder
     * Note:
     * Refer to enterBidForToken comments for input params def
     */
    function enterBidForTokens(EnterBidInput[] calldata newBids, address bidder)
        external;

    /**
     * @dev withdraw bid for token
     * @param erc721Address collection address
     * @param tokenId token ID of the bid
     * @param bidder address of bidder
     */
    function withdrawBidForToken(
        address erc721Address,
        uint256 tokenId,
        address bidder
    ) external;

    /**
     * @dev batch withdraw bids
     * @param bids details of bid to withdraw
     * Note:
     * Refer to withdrawBidForToken comments for input params def
     */
    function withdrawBidForTokens(WithdrawBidInput[] calldata bids) external;

    /**
     * @dev accept bid for token
     * @param erc721Address collection address
     * @param tokenId token ID to accept bid of
     * @param value bid price
     * @param bidder address of bidder
     * Note:
     * value is required to avoid bidder frontrun
     */
    function acceptBidForToken(
        address erc721Address,
        uint256 tokenId,
        address bidder,
        uint256 value
    ) external;

    /**
     * @dev batch accept bids
     * @param bids details of bid to accept
     * Note:
     * Refer to acceptBidForToken comments for input params def
     */
    function acceptBidForTokens(AcceptBidInput[] calldata bids) external;

    /**
     * @dev Remove expired bids
     * @param bids list bids to remove
     * anyone can removed expired bids
     */
    function removeExpiredBids(RemoveExpiredBidInput[] calldata bids) external;

    /**
     * @dev get bid details of a bid
     * @param erc721Address collection address
     * @param tokenId token ID to read
     * @param bidder address of bidder
     */
    function getBidderTokenBid(
        address erc721Address,
        uint256 tokenId,
        address bidder
    ) external view returns (BidStatus memory);

    /**
     * @dev get bids details of a token
     * @param erc721Address collection address
     * @param tokenId token ID to read
     */
    function getTokenBids(address erc721Address, uint256 tokenId)
        external
        view
        returns (BidStatus[] memory bids);

    /**
     * @dev get highest bid of a token
     * @param erc721Address collection address
     * @param tokenId token ID to read
     */
    function getTokenHighestBid(address erc721Address, uint256 tokenId)
        external
        view
        returns (BidStatus memory highestBid);

    /**
     * @dev get number of token with bids of a collection
     * @param erc721Address collection address
     */
    function numTokenWithBidsOfCollection(address erc721Address)
        external
        view
        returns (uint256);

    /**
     * @dev get batch of highest bids of a collection
     * @param erc721Address collection address
     * @param from index of token to read
     * @param size amount of tokens to read
     */
    function getHighestBidsOfCollection(
        address erc721Address,
        uint256 from,
        uint256 size
    ) external view returns (BidStatus[] memory highestBids);

    /**
     * @dev get batch of bids from a bidder of a collection
     * @param erc721Address collection address
     * @param bidder address of bidder
     * @param from index of token to read
     * @param size amount of tokens to read
     */
    function getBidderBidsOfCollection(
        address erc721Address,
        address bidder,
        uint256 from,
        uint256 size
    ) external view returns (BidStatus[] memory bidderBids);
}

File 7 of 19 : IMarketSettings.sol
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;
pragma abicoder v2;

interface IMarketSettings {
    event RoyaltyRegistryChanged(
        address previousRoyaltyRegistry,
        address newRoyaltyRegistry
    );

    event PaymentTokenRegistryChanged(
        address previousPaymentTokenRegistry,
        address newPaymentTokenRegistry
    );

    /**
     * @dev fee denominator for service fee
     */
    function FEE_DENOMINATOR() external view returns (uint256);

    /**
     * @dev address to wrapped coin of the chain
     * e.g.: WETH, WBNB, WFTM, WAVAX, etc.
     */
    function wrappedEther() external view returns (address);

    /**
     * @dev address of royalty registry contract
     */
    function royaltyRegsitry() external view returns (address);

    /**
     * @dev address of payment token registry
     */
    function paymentTokenRegistry() external view returns (address);

    /**
     * @dev Show if trading is enabled
     */
    function isTradingEnabled() external view returns (bool);

    /**
     * @dev Show if trading is enabled
     */
    function isCollectionTradingEnabled(address collectionAddress)
        external
        view
        returns (bool);

    /**
     * @dev Surface minimum trading time range
     */
    function actionTimeOutRangeMin() external view returns (uint256);

    /**
     * @dev Surface maximum trading time range
     */
    function actionTimeOutRangeMax() external view returns (uint256);

    /**
     * @dev Service fee receiver
     */
    function serviceFeeReceiver() external view returns (address);

    /**
     * @dev Service fee fraction
     * @return fee fraction based on denominator
     */
    function serviceFeeFraction() external view returns (uint256);

    /**
     * @dev Service fee receiver and amount
     * @param salePrice price of token
     */
    function serviceFeeInfo(uint256 salePrice)
        external
        view
        returns (address, uint256);
}

File 8 of 19 : CollectionReader.sol
// SPDX-License-Identifier: AGPL-3.0-or-later

pragma solidity ^0.8.0;

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

library CollectionReader {
    function collectionOwner(address collectionAddress)
        internal
        view
        returns (address owner)
    {
        try Ownable(collectionAddress).owner() returns (address _owner) {
            owner = _owner;
        } catch {}
    }

    function tokenOwner(address erc721Address, uint256 tokenId)
        internal
        view
        returns (address owner)
    {
        IERC721 _erc721 = IERC721(erc721Address);
        try _erc721.ownerOf(tokenId) returns (address _owner) {
            owner = _owner;
        } catch {}
    }

    /**
     * @dev check if this contract has approved to transfer this erc721 token
     */
    function isTokenApproved(address erc721Address, uint256 tokenId)
        internal
        view
        returns (bool isApproved)
    {
        IERC721 _erc721 = IERC721(erc721Address);
        try _erc721.getApproved(tokenId) returns (address tokenOperator) {
            if (tokenOperator == address(this)) {
                isApproved = true;
            }
        } catch {}
    }

    /**
     * @dev check if this contract has approved to all of this owner's erc721 tokens
     */
    function isAllTokenApproved(
        address erc721Address,
        address owner,
        address operator
    ) internal view returns (bool isApproved) {
        IERC721 _erc721 = IERC721(erc721Address);

        try _erc721.isApprovedForAll(owner, operator) returns (
            bool _isApproved
        ) {
            isApproved = _isApproved;
        } catch {}
    }
}

File 9 of 19 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;
        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping(bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) {
            // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            if (lastIndex != toDeleteIndex) {
                bytes32 lastValue = set._values[lastIndex];

                // Move the last value to the index where the value to delete is
                set._values[toDeleteIndex] = lastValue;
                // Update the index for the moved value
                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
            }

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

    /**
     * @dev Returns the value stored at position `index` in the set. O(1).
     *
     * Note that there are no guarantees on the ordering of values inside the
     * array, and it may change when more values are added or removed.
     *
     * Requirements:
     *
     * - `index` must be strictly less than {length}.
     */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

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

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

File 18 of 19 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol)

pragma solidity ^0.8.0;

import "../token/ERC721/IERC721.sol";

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"marketSettings_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Address","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"AcceptBidFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"string","name":"operatorName","type":"string"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"AllowedOperatorAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"string","name":"operatorName","type":"string"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"AllowedOperatorRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Address","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"EnterBidFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousMarketSettingsContract","type":"address"},{"indexed":false,"internalType":"address","name":"newMarketSettingsContract","type":"address"}],"name":"MarketSettingsContractUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"},{"indexed":false,"internalType":"string","name":"operatorName","type":"string"}],"name":"OperatorApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"string","name":"previousName","type":"string"},{"indexed":false,"internalType":"string","name":"newName","type":"string"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"OperatorNameUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Address","type":"address"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"}],"indexed":false,"internalType":"struct IERC721Bids.Bid","name":"bid","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"serviceFee","type":"uint256"},{"components":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"indexed":false,"internalType":"struct ICollectionRoyaltyReader.RoyaltyAmount[]","name":"royaltyInfo","type":"tuple[]"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"TokenBidAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Address","type":"address"},{"indexed":true,"internalType":"address","name":"bidder","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"}],"indexed":false,"internalType":"struct IERC721Bids.Bid","name":"bid","type":"tuple"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"TokenBidEntered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Address","type":"address"},{"indexed":true,"internalType":"address","name":"bidder","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"}],"indexed":false,"internalType":"struct IERC721Bids.Bid","name":"bid","type":"tuple"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"TokenBidWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"erc721Address","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"message","type":"string"},{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"WithdrawBidFailed","type":"event"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"acceptBidForToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"internalType":"struct IERC721Bids.AcceptBidInput[]","name":"bids","type":"tuple[]"}],"name":"acceptBidForTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOperator","type":"address"},{"internalType":"string","name":"operatorName","type":"string"}],"name":"addAllowedOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"address","name":"bidder","type":"address"}],"name":"enterBidForToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"}],"internalType":"struct IERC721Bids.EnterBidInput[]","name":"newBids","type":"tuple[]"},{"internalType":"address","name":"bidder","type":"address"}],"name":"enterBidForTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getAllowedOperators","outputs":[{"components":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"string","name":"name","type":"string"}],"internalType":"struct IOperatorDelegation.OperatorInfo[]","name":"operators","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"from","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"}],"name":"getBidderBidsOfCollection","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"enum IERC721Bids.Status","name":"status","type":"uint8"}],"internalType":"struct IERC721Bids.BidStatus[]","name":"bidderBids","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"}],"name":"getBidderTokenBid","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"enum IERC721Bids.Status","name":"status","type":"uint8"}],"internalType":"struct IERC721Bids.BidStatus","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"from","type":"uint256"},{"internalType":"uint256","name":"size","type":"uint256"}],"name":"getHighestBidsOfCollection","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"enum IERC721Bids.Status","name":"status","type":"uint8"}],"internalType":"struct IERC721Bids.BidStatus[]","name":"highestBids","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"getOperator","outputs":[{"components":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"string","name":"name","type":"string"}],"internalType":"struct IOperatorDelegation.OperatorInfo","name":"operatorInfo","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"getOwnerApprovedOperators","outputs":[{"components":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"string","name":"name","type":"string"},{"internalType":"bool","name":"allowed","type":"bool"}],"internalType":"struct IOperatorDelegation.OwnerOperatorInfo[]","name":"operators","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenBids","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"enum IERC721Bids.Status","name":"status","type":"uint8"}],"internalType":"struct IERC721Bids.BidStatus[]","name":"bids","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTokenHighestBid","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"expireTimestamp","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"enum IERC721Bids.Status","name":"status","type":"uint8"}],"internalType":"struct IERC721Bids.BidStatus","name":"highestBid","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedOperator","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"isOperatorAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketSettingsContract","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"}],"name":"numTokenWithBidsOfCollection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"removeAllowedOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"}],"internalType":"struct IERC721Bids.RemoveExpiredBidInput[]","name":"bids","type":"tuple[]"}],"name":"removeExpiredBids","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalToOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newMarketSettingsContract","type":"address"}],"name":"updateMarketSettingsContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"string","name":"newName","type":"string"}],"name":"updateOperatorName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"}],"name":"withdrawBidForToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"erc721Address","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"bidder","type":"address"}],"internalType":"struct IERC721Bids.WithdrawBidInput[]","name":"bids","type":"tuple[]"}],"name":"withdrawBidForTokens","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60806040523480156200001157600080fd5b5060405162005262380380620052628339810160408190526200003491620000ba565b6200003f336200006a565b6001600555600680546001600160a01b0319166001600160a01b0392909216919091179055620000ec565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215620000cd57600080fd5b81516001600160a01b0381168114620000e557600080fd5b9392505050565b61516680620000fc6000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80637610a92b116100f9578063b1e6212211610097578063eb3e87b911610071578063eb3e87b9146103ed578063efdbbe7e14610400578063f0ada82114610413578063f2fde38b1461043357600080fd5b8063b1e62122146103b2578063bef1b625146103c5578063d8d33958146103d857600080fd5b80638da7a378116100d35780638da7a3781461036657806390bc4e37146103795780639316a6c01461038c5780639f5db69c1461039f57600080fd5b80637610a92b146103225780638765ac87146103355780638da5cb5b1461034857600080fd5b8063569d84211161016657806366c1e8bf1161014057806366c1e8bf146102d3578063715018a6146102e657806374a3b593146102ee57806375ccc1321461030f57600080fd5b8063569d8421146102615780635865c60c146102a057806364d786ee146102c057600080fd5b80632b724834116101975780632b7248341461021b578063400c6a2d1461022e578063447f9fba1461024157600080fd5b80631a179451146101be5780631f77a820146101e65780632765b15f14610206575b600080fd5b6101d16101cc36600461425e565b610446565b60405190151581526020015b60405180910390f35b6101f96101f4366004614297565b610490565b6040516101dd9190614381565b6102196102143660046143db565b6105af565b005b61021961022936600461441d565b6106f3565b61021961023c36600461452b565b610815565b61025461024f3660046145f1565b610920565b6040516101dd9190614626565b60065473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101dd565b6102b36102ae366004614674565b610a67565b6040516101dd919061473b565b6102196102ce36600461474e565b610b55565b6102546102e1366004614297565b610d26565b610219610e71565b6103016102fc366004614674565b610e85565b6040519081526020016101dd565b6101d161031d366004614674565b610eb3565b6102196103303660046147c3565b610ec0565b610219610343366004614849565b6110db565b60005473ffffffffffffffffffffffffffffffffffffffff1661027b565b610219610374366004614674565b6111b3565b6101f9610387366004614849565b61135e565b61021961039a3660046143db565b6114a4565b6102196103ad36600461452b565b611637565b6102196103c0366004614674565b61189c565b6102196103d336600461488e565b61192a565b6103e0611939565b6040516101dd91906148bc565b6102196103fb36600461493c565b611af4565b61025461040e366004614984565b611bd6565b610426610421366004614674565b611d24565b6040516101dd91906149ca565b610219610441366004614674565b611f5a565b600061045182610eb3565b8015610487575073ffffffffffffffffffffffffffffffffffffffff831660009081526004602052604090206104879083612011565b90505b92915050565b6104c66040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b73ffffffffffffffffffffffffffffffffffffffff83166000908152600760209081526040808320858452600201909152812061050290612040565b905060005b818110156105a75773ffffffffffffffffffffffffffffffffffffffff85166000908152600760209081526040808320878452600201909152812061054c908361204a565b9050600061055b87878461135e565b905060018160a001516007811115610575576105756142c3565b148015610589575084602001518160200151115b15610592578094505b5050808061059f90614ab0565b915050610507565b505092915050565b60005b818110156106ee5760008383838181106105ce576105ce614ae8565b6105e49260206060909202019081019150614674565b905060008484848181106105fa576105fa614ae8565b905060600201602001359050600085858581811061061a5761061a614ae8565b90506060020160400160208101906106329190614674565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526007602090815260408083208784526002908101835281842085871685528101835292819020815160a0810183528154815260018201549381019390935292830154841690820152600382015460608201819052600490920154909216608083015291925090158015906106c7575042816060015111155b156106d7576106d7848484612056565b5050505080806106e690614ab0565b9150506105b2565b505050565b73ffffffffffffffffffffffffffffffffffffffff811633148061071c575061071c8133610446565b6107ad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f73656e646572206e6f7420626964646572206f7220617070726f766564206f7060448201527f657261746f72000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b6000806107be8888888888886121a7565b915091508181906107fc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a49190614b17565b5061080b88888888888861270b565b5050505050505050565b61081d612893565b610828600183612011565b1561088f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f6f70657261746f7220616c726561647920696e20616c6c6f776564206c69737460448201526064016107a4565b61089a600183612914565b5073ffffffffffffffffffffffffffffffffffffffff821660009081526003602052604090206108ca8282614bc3565b5073ffffffffffffffffffffffffffffffffffffffff82167fcf217b6ae435029d09f195cbca49d35ea68829af8ad20064a1a498679e8ed06182335b604051610914929190614cdd565b60405180910390a25050565b6060600061092d85610e85565b9050808410801561093e5750600083115b15610a5f57828161094f8287614d15565b11156109625761095f8583614d28565b90505b8067ffffffffffffffff81111561097b5761097b614484565b6040519080825280602002602001820160405280156109e257816020015b6109cf6040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b8152602001906001900390816109995790505b50925060005b81811015610a5c57610a2c876101f4610a018985614d15565b73ffffffffffffffffffffffffffffffffffffffff8b1660009081526007602052604090209061204a565b848281518110610a3e57610a3e614ae8565b60200260200101819052508080610a5490614ab0565b9150506109e8565b50505b509392505050565b604080518082019091526000815260606020820152610a8582610eb3565b15610b505760408051808201825273ffffffffffffffffffffffffffffffffffffffff841680825260009081526003602090815292902080549192830191610acc90614b2a565b80601f0160208091040260200160405190810160405280929190818152602001828054610af890614b2a565b8015610b455780601f10610b1a57610100808354040283529160200191610b45565b820191906000526020600020905b815481529060010190602001808311610b2857829003601f168201915b505050505081525090505b919050565b60005b818110156106ee576000838383818110610b7457610b74614ae8565b610b8a9260206080909202019081019150614674565b90506000848484818110610ba057610ba0614ae8565b9050608002016020013590506000858585818110610bc057610bc0614ae8565b9050608002016040016020810190610bd89190614674565b90506000868686818110610bee57610bee614ae8565b73ffffffffffffffffffffffffffffffffffffffff80881660009081526007602090815260408083208a8452600290810183528184208a8616855281018352818420825160a081018452815481526001820154948101949094529081015485169183019190915260038101546060838101919091526004909101549093166080828101919091529093029490940101359350919050610c8d8686612936565b9050600080610c9e888587866129ef565b915091508115610cb857610cb3888585612b4a565b610d0b565b73ffffffffffffffffffffffffffffffffffffffff88167fc3a95abb66083b9379d6b616e13c00ae3df000e9d37d59677cef970d263e52d8888333604051610d0293929190614d3b565b60405180910390a25b50505050505050508080610d1e90614ab0565b915050610b58565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600760209081526040808320848452600201909152812060609190610d6690612040565b90508067ffffffffffffffff811115610d8157610d81614484565b604051908082528060200260200182016040528015610de857816020015b610dd56040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b815260200190600190039081610d9f5790505b50915060005b818110156105a75773ffffffffffffffffffffffffffffffffffffffff851660009081526007602090815260408083208784526002019091528120610e33908361204a565b9050610e4086868361135e565b848381518110610e5257610e52614ae8565b6020026020010181905250508080610e6990614ab0565b915050610dee565b610e79612893565b610e836000612ca5565b565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260076020526040812061048a90612040565b600061048a600183612011565b73ffffffffffffffffffffffffffffffffffffffff8116331480610ee95750610ee98133610446565b610f75576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f73656e646572206e6f7420626964646572206f7220617070726f766564206f7060448201527f657261746f72000000000000000000000000000000000000000000000000000060648201526084016107a4565b60005b828110156110d5576000848483818110610f9457610f94614ae8565b610faa92602060a0909202019081019150614674565b90506000858584818110610fc057610fc0614ae8565b905060a002016020013590506000868685818110610fe057610fe0614ae8565b905060a00201604001359050600087878681811061100057611000614ae8565b905060a00201606001359050600088888781811061102057611020614ae8565b905060a0020160800160208101906110389190614674565b905060008061104b87878787878e6121a7565b9150915081156110685761106387878787878e61270b565b6110bb565b73ffffffffffffffffffffffffffffffffffffffff87167fa7128b7849657e1d57dee55cbd7ed6b24650a1e9b51226803dc19efc13e98b788783336040516110b293929190614d3b565b60405180910390a25b5050505050505080806110cd90614ab0565b915050610f78565b50505050565b73ffffffffffffffffffffffffffffffffffffffff808416600090815260076020908152604080832086845260029081018352818420868616855281018352818420825160a0810184528154815260018201549481019490945290810154851691830191909152600381015460608301526004015490921660808301528061116283612d1a565b915091508181906111a0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a49190614b17565b506111ab8684612de0565b505050505050565b6111bb612893565b6111c6600182612011565b61122c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f6f70657261746f72206e6f7420696e20616c6c6f776564206c6973740000000060448201526064016107a4565b73ffffffffffffffffffffffffffffffffffffffff81166000908152600360205260408120805461125c90614b2a565b80601f016020809104026020016040519081016040528092919081815260200182805461128890614b2a565b80156112d55780601f106112aa576101008083540402835291602001916112d5565b820191906000526020600020905b8154815290600101906020018083116112b857829003601f168201915b505050505090506112f0826001612e6e90919063ffffffff16565b5073ffffffffffffffffffffffffffffffffffffffff8216600090815260036020526040812061131f916141f2565b73ffffffffffffffffffffffffffffffffffffffff82167f51874fe75b2df8a99c14442d29c63641f3bbc214b2f0eb57598f08b8453e99368233610906565b6113946040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260076020908152604080832087845260029081018352818420878616855281018352818420825160a08101845281548152600182015494810194909452908101548516918301919091526003810154606083015260040154909216608083015261141b8683612e90565b90506040518060c001604052808360000151815260200183602001518152602001836040015173ffffffffffffffffffffffffffffffffffffffff16815260200183606001518152602001836080015173ffffffffffffffffffffffffffffffffffffffff168152602001826007811115611498576114986142c3565b90529695505050505050565b60005b818110156106ee5760008383838181106114c3576114c3614ae8565b6114d99260206060909202019081019150614674565b905060008484848181106114ef576114ef614ae8565b905060600201602001359050600085858581811061150f5761150f614ae8565b90506060020160400160208101906115279190614674565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260076020908152604080832087845260029081018352818420858716855281018352818420825160a08101845281548152600182015494810194909452908101548516918301919091526003810154606083015260040154909216608083015291925090806115b283612d1a565b9150915081156115cb576115c68684612de0565b61161e565b73ffffffffffffffffffffffffffffffffffffffff86167f19540170862aafe4cae7d2f0b5cd9c027c2c0bcb63bed5b4a8c414d887981f8086833360405161161593929190614d3b565b60405180910390a25b505050505050808061162f90614ab0565b9150506114a7565b61163f612893565b61164a600183612011565b6116b0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f6f70657261746f72206e6f7420696e20616c6c6f776564206c6973740000000060448201526064016107a4565b73ffffffffffffffffffffffffffffffffffffffff8216600090815260036020526040812080546116e090614b2a565b80601f016020809104026020016040519081016040528092919081815260200182805461170c90614b2a565b80156117595780601f1061172e57610100808354040283529160200191611759565b820191906000526020600020905b81548152906001019060200180831161173c57829003601f168201915b50505050509050806040516020016117719190614d7a565b60405160208183030381529060405280519060200120826040516020016117989190614d7a565b6040516020818303038152906040528051906020012014611815576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f6f70657261746f72206e616d6520756e6368616e67656400000000000000000060448201526064016107a4565b73ffffffffffffffffffffffffffffffffffffffff831660009081526003602052604090206118448382614bc3565b5073ffffffffffffffffffffffffffffffffffffffff83167f98002064ad243222107bb6b9757d92aff0d9f52d99fa6f1947ac7896bcfaa24a82843360405161188f93929190614d96565b60405180910390a2505050565b6118a4612893565b6006805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f96f51d1326d0860d784344c105c865c611beea4863865803eaab17b56f5b5d7d910160405180910390a15050565b61193533838361314e565b5050565b60606119456001612040565b67ffffffffffffffff81111561195d5761195d614484565b6040519080825280602002602001820160405280156119a357816020015b60408051808201909152600081526060602082015281526020019060019003908161197b5790505b50905060005b6119b36001612040565b811015611af05760408051808201909152806119d060018461204a565b73ffffffffffffffffffffffffffffffffffffffff168152602001600360006119fa60018661204a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054611a3f90614b2a565b80601f0160208091040260200160405190810160405280929190818152602001828054611a6b90614b2a565b8015611ab85780601f10611a8d57610100808354040283529160200191611ab8565b820191906000526020600020905b815481529060010190602001808311611a9b57829003601f168201915b5050505050815250828281518110611ad257611ad2614ae8565b60200260200101819052508080611ae890614ab0565b9150506119a9565b5090565b73ffffffffffffffffffffffffffffffffffffffff808516600090815260076020908152604080832087845260029081018352818420878616855281018352818420825160a081018452815481526001820154948101949094529081015485169183019190915260038101546060830152600401549092166080830152611b7b8686612936565b9050600080611b8c888587866129ef565b91509150818190611bca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a49190614b17565b5061080b888585612b4a565b60606000611be386610e85565b90508084108015611bf45750600083115b15611d1b578281611c058287614d15565b1115611c1857611c158583614d28565b90505b8067ffffffffffffffff811115611c3157611c31614484565b604051908082528060200260200182016040528015611c9857816020015b611c856040805160c08101825260008082526020820181905291810182905260608101829052608081018290529060a082015290565b815260200190600190039081611c4f5790505b50925060005b81811015611d1857611ce888611ce2611cb78985614d15565b73ffffffffffffffffffffffffffffffffffffffff8c1660009081526007602052604090209061204a565b8961135e565b848281518110611cfa57611cfa614ae8565b60200260200101819052508080611d1090614ab0565b915050611c9e565b50505b50949350505050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260046020526040812060609190611d5690612040565b90508067ffffffffffffffff811115611d7157611d71614484565b604051908082528060200260200182016040528015611dde57816020015b611dcb6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001606081526020016000151581525090565b815260200190600190039081611d8f5790505b50915060005b81811015611f535773ffffffffffffffffffffffffffffffffffffffff84166000908152600460205260408120611e1b908361204a565b905060405180606001604052808273ffffffffffffffffffffffffffffffffffffffff168152602001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208054611e8e90614b2a565b80601f0160208091040260200160405190810160405280929190818152602001828054611eba90614b2a565b8015611f075780601f10611edc57610100808354040283529160200191611f07565b820191906000526020600020905b815481529060010190602001808311611eea57829003601f168201915b5050509183525050602001611f1d600184612011565b1515815250848381518110611f3457611f34614ae8565b6020026020010181905250508080611f4b90614ab0565b915050611de4565b5050919050565b611f62612893565b73ffffffffffffffffffffffffffffffffffffffff8116612005576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016107a4565b61200e81612ca5565b50565b73ffffffffffffffffffffffffffffffffffffffff811660009081526001830160205260408120541515610487565b600061048a825490565b600061048783836133dd565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260076020908152604080832085845260020190915290206120939082612011565b156106ee5773ffffffffffffffffffffffffffffffffffffffff80841660009081526007602090815260408083208684526002908101808452828520958716855285820184529184208481556001810185905590810180547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169091556003820185905560049091018054909116905591859052526121349082612e6e565b5073ffffffffffffffffffffffffffffffffffffffff83166000908152600760209081526040808320858452600201909152902061217190612040565b6000036106ee5773ffffffffffffffffffffffffffffffffffffffff831660009081526007602052604090206110d59083613407565b6006546040517fd9cb168500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff888116600483015260009260609291169063d9cb168590602401602060405180830381865afa15801561221c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122409190614de2565b61227e575060408051808201909152601381527f74726164696e67206973206e6f74206f70656e000000000000000000000000006020820152612700565b856000036122c0575060408051808201909152601181527f76616c75652063616e6e6f7420626520300000000000000000000000000000006020820152612700565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166333549d3d6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561232d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123519190614dff565b61235b4287614d28565b101561239b575060408051808201909152601981527f6578706972652074696d652062656c6f77206d696e696d756d000000000000006020820152612700565b600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663453dfc506040518163ffffffff1660e01b8152600401602060405180830381865afa158015612408573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061242c9190614dff565b6124364287614d28565b1115612476575060408051808201909152601981527f6578706972652074696d652061626f7665206d6178696d756d000000000000006020820152612700565b6124808885613413565b6124be575060408051808201909152601981527f7061796d656e7420746f6b656e206e6f7420656e61626c6564000000000000006020820152612700565b60006124c98561355e565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff868116600483015291925088918316906370a0823190602401602060405180830381865afa15801561253a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061255e9190614dff565b101561259f57505060408051808201909152601481527f696e73756666696369656e742062616c616e63650000000000000000000000006020820152612700565b6040517fdd62ed3e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015230602483015288919083169063dd62ed3e90604401602060405180830381865afa158015612614573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126389190614dff565b101561267957505060408051808201909152601681527f696e73756666696369656e7420616c6c6f77616e6365000000000000000000006020820152612700565b60006126858a8a612936565b90508473ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036126f9576040518060400160405280601681526020017f746f6b656e206f776e65722063616e6e6f74206269640000000000000000000081525092505050612700565b6001935050505b965096945050505050565b6040805160a081018252868152602080820187905273ffffffffffffffffffffffffffffffffffffffff8085168385015260608301879052858116608084015289166000908152600790915291909120612765908761360b565b5073ffffffffffffffffffffffffffffffffffffffff8716600090815260076020908152604080832089845260020190915290206127a39083612914565b5073ffffffffffffffffffffffffffffffffffffffff80881660008181526007602090815260408083208b845260029081018352818420888716808652908201845293829020875181559287015160018401559086015190820180549186167fffffffffffffffffffffffff000000000000000000000000000000000000000092831617905560608601516003830155608086015160049092018054929095169116179092557f9ab041be940411778f93ed5b6591c04e8b2455adb6002ac5fa7ae6cfa0d3236b88846128733390565b60405161288293929190614e18565b60405180910390a350505050505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e83576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016107a4565b60006104878373ffffffffffffffffffffffffffffffffffffffff8416613613565b6040517f6352211e00000000000000000000000000000000000000000000000000000000815260048101829052600090839073ffffffffffffffffffffffffffffffffffffffff821690636352211e90602401602060405180830381865afa9250505080156129e0575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682019092526129dd91810190614e97565b60015b156129e85791505b5092915050565b60006060816129fe8787612e90565b90506001816007811115612a1457612a146142c3565b14612a5457505060408051808201909152601081527f626964206973206e6f742076616c6964000000000000000000000000000000006020820152612b41565b85602001518514612a9a57505060408051808201909152601f81527f616363657074696e672076616c7565206469666665722066726f6d20626964006020820152612b41565b73ffffffffffffffffffffffffffffffffffffffff84163314801590612ac75750612ac58433610446565b155b15612aed5760405180606001604052806025815260200161510c60259139915050612b41565b612afc87876000015186613662565b612b3b57505060408051808201909152601881527f7472616e73666572726564206e6f7420617070726f76656400000000000000006020820152612b41565b60019250505b94509492505050565b612b52613687565b6000806000612b628686866136fa565b925092509250612b76856040015184613b71565b604085810151865191517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8781166004830152918216602482015260448101929092528716906342842e0e90606401600060405180830381600087803b158015612bf657600080fd5b505af1158015612c0a573d6000803e3d6000fd5b50505050612c218686600001518760400151612056565b8373ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff167f5d994bc290fbe0101b1dca3c1cedb54138460d3e4258c493b0a2f8053056a9568760000151888587612c7f3390565b604051612c90959493929190614eb4565b60405180910390a35050506106ee6001600555565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604081015160009060609073ffffffffffffffffffffffffffffffffffffffff16612d7c576040518060400160405280601281526020017f62696420646f6573206e6f7420657869737400000000000000000000000000008152509050915091565b604083015173ffffffffffffffffffffffffffffffffffffffff163314801590612db25750612db083604001516101cc3390565b155b15612dd7576040518060600160405280602681526020016150e6602691399050915091565b60019150915091565b612df38282600001518360400151612056565b806040015173ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fbb03ab73112a085ef57b0ce58b2203b62392753d54b5a1eca6ce0ff518ae040b836000015184612e533390565b604051612e6293929190614e18565b60405180910390a35050565b60006104878373ffffffffffffffffffffffffffffffffffffffff8416613bf2565b604081015160009073ffffffffffffffffffffffffffffffffffffffff16612eba5750600061048a565b6006546040517fd9cb168500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301529091169063d9cb168590602401602060405180830381865afa158015612f2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f4e9190614de2565b612f5a5750600261048a565b4282606001511015612f6e5750600361048a565b816040015173ffffffffffffffffffffffffffffffffffffffff16612f97848460000151612936565b73ffffffffffffffffffffffffffffffffffffffff1603612fba5750600461048a565b612fc8838360800151613413565b612fd45750600561048a565b6000612fe3836080015161355e565b602084015160408086015190517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201529293509091908316906370a0823190602401602060405180830381865afa15801561305f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130839190614dff565b101561309357600691505061048a565b602083015160408085015190517fdd62ed3e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff91821660048201523060248201529083169063dd62ed3e90604401602060405180830381865afa158015613110573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131349190614dff565b101561314457600791505061048a565b5060019392505050565b613159600183612011565b6131bf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f6f70657261746f72206e6f7420696e20616c6c6f776564206c6973740000000060448201526064016107a4565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603613254576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f617070726f766520746f2073656e64657200000000000000000000000000000060448201526064016107a4565b801561328f5773ffffffffffffffffffffffffffffffffffffffff831660009081526004602052604090206132899083612914565b506132c0565b73ffffffffffffffffffffffffffffffffffffffff831660009081526004602052604090206132be9083612e6e565b505b73ffffffffffffffffffffffffffffffffffffffff8216600090815260036020526040812080546132f090614b2a565b80601f016020809104026020016040519081016040528092919081815260200182805461331c90614b2a565b80156133695780601f1061333e57610100808354040283529160200191613369565b820191906000526020600020905b81548152906001019060200180831161334c57829003601f168201915b505050505090508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fd8ea97265d3bf61e3dd9ca96da2d68f5d72337bf8f50ce89b5723b27b0dea7ed84846040516133cf929190614fa2565b60405180910390a350505050565b60008260000182815481106133f4576133f4614ae8565b9060005260206000200154905092915050565b60006104878383613bf2565b600073ffffffffffffffffffffffffffffffffffffffff821615806104875750600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639e4d3c126040518163ffffffff1660e01b8152600401602060405180830381865afa1580156134a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134c49190614e97565b6040517fd885d4d800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301528481166024830152919091169063d885d4d890604401602060405180830381865afa15801561353a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104879190614de2565b8073ffffffffffffffffffffffffffffffffffffffff8116610b5057600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166314671a296040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061048a9190614e97565b600061048783835b600081815260018301602052604081205461365a5750815460018181018455600084815260208082209093018490558454848252828601909352604090209190915561048a565b50600061048a565b600061366e8484613ce5565b8061367f575061367f848330613dbc565b949350505050565b6002600554036136f3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107a4565b6002600555565b60608060008061370d866080015161355e565b9050600660009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663ae8265976040518163ffffffff1660e01b8152600401602060405180830381865afa15801561377c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137a09190614e97565b865160208801516040517f538bd5ea00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8b811660048301526024820193909352604481019190915291169063538bd5ea90606401600060405180830381865afa158015613823573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526138699190810190614fbd565b9250825160026138799190614d15565b67ffffffffffffffff81111561389157613891614484565b6040519080825280602002602001820160405280156138fa57816020015b60408051606081018252600080825260208083018290529282015282527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9092019101816138af5790505b50602087015190945060005b84518110156139e457600085828151811061392357613923614ae8565b6020026020010151600001519050600086838151811061394557613945614ae8565b602002602001015160200151905060405180606001604052808373ffffffffffffffffffffffffffffffffffffffff1681526020018281526020018673ffffffffffffffffffffffffffffffffffffffff16815250888460026139a89190614d15565b815181106139b8576139b8614ae8565b60209081029190910101526139cd8185614d28565b9350505080806139dc90614ab0565b915050613906565b5060065460208801516040517f1441ad1c000000000000000000000000000000000000000000000000000000008152600092839273ffffffffffffffffffffffffffffffffffffffff90911691631441ad1c91613a479160040190815260200190565b6040805180830381865afa158015613a63573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a879190615088565b9150915080945060405180606001604052808373ffffffffffffffffffffffffffffffffffffffff1681526020018681526020018573ffffffffffffffffffffffffffffffffffffffff1681525087600181518110613ae857613ae8614ae8565b6020908102919091010152613afd8584614d28565b925060405180606001604052808973ffffffffffffffffffffffffffffffffffffffff1681526020018481526020018573ffffffffffffffffffffffffffffffffffffffff1681525087600081518110613b5957613b59614ae8565b60200260200101819052505050505093509350939050565b60005b81518110156106ee57613be0828281518110613b9257613b92614ae8565b60200260200101516040015184848481518110613bb157613bb1614ae8565b602002602001015160000151858581518110613bcf57613bcf614ae8565b602002602001015160200151613e7d565b80613bea81614ab0565b915050613b74565b60008181526001830160205260408120548015613cdb576000613c16600183614d28565b8554909150600090613c2a90600190614d28565b9050818114613c8f576000866000018281548110613c4a57613c4a614ae8565b9060005260206000200154905080876000018481548110613c6d57613c6d614ae8565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613ca057613ca06150b6565b60019003818190600052602060002001600090559055856001016000868152602001908152602001600020600090556001935050505061048a565b600091505061048a565b6040517f081812fc00000000000000000000000000000000000000000000000000000000815260048101829052600090839073ffffffffffffffffffffffffffffffffffffffff82169063081812fc90602401602060405180830381865afa925050508015613d8f575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252613d8c91810190614e97565b60015b156129e8573073ffffffffffffffffffffffffffffffffffffffff8216036105a757506001949350505050565b6040517fe985e9c500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301528281166024830152600091859182169063e985e9c590604401602060405180830381865afa925050508015613e6f575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252613e6c91810190614de2565b60015b15610a5f5795945050505050565b73ffffffffffffffffffffffffffffffffffffffff8416613efa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f7061796d656e7420746f6b656e2063616e27742062652030206164647265737360448201526064016107a4565b6040805173ffffffffffffffffffffffffffffffffffffffff8581166024830152848116604483015260648083018590528351808403909101815260849092018352602080830180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905283518085019094528084527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564908401526110d5929087169186918691869186918691600090613fd79084908490614081565b8051909150156106ee5780806020019051810190613ff59190614de2565b6106ee576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016107a4565b606061367f8484600085856000808673ffffffffffffffffffffffffffffffffffffffff1685876040516140b59190614d7a565b60006040518083038185875af1925050503d80600081146140f2576040519150601f19603f3d011682016040523d82523d6000602084013e6140f7565b606091505b509150915061410887838387614113565b979650505050505050565b606083156141a95782516000036141a25773ffffffffffffffffffffffffffffffffffffffff85163b6141a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016107a4565b508161367f565b61367f83838151156141be5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107a49190614b17565b5080546141fe90614b2a565b6000825580601f1061420e575050565b601f01602090049060005260206000209081019061200e91905b80821115611af05760008155600101614228565b73ffffffffffffffffffffffffffffffffffffffff8116811461200e57600080fd5b6000806040838503121561427157600080fd5b823561427c8161423c565b9150602083013561428c8161423c565b809150509250929050565b600080604083850312156142aa57600080fd5b82356142b58161423c565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8051825260208101516020830152604081015173ffffffffffffffffffffffffffffffffffffffff808216604085015260608301516060850152806080840151166080850152505060a081015160088110614376577f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b8060a0840152505050565b60c0810161048a82846142f2565b60008083601f8401126143a157600080fd5b50813567ffffffffffffffff8111156143b957600080fd5b6020830191508360206060830285010111156143d457600080fd5b9250929050565b600080602083850312156143ee57600080fd5b823567ffffffffffffffff81111561440557600080fd5b6144118582860161438f565b90969095509350505050565b60008060008060008060c0878903121561443657600080fd5b86356144418161423c565b955060208701359450604087013593506060870135925060808701356144668161423c565b915060a08701356144768161423c565b809150509295509295509295565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040805190810167ffffffffffffffff811182821017156144d6576144d6614484565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561452357614523614484565b604052919050565b6000806040838503121561453e57600080fd5b82356145498161423c565b915060208381013567ffffffffffffffff8082111561456757600080fd5b818601915086601f83011261457b57600080fd5b81358181111561458d5761458d614484565b6145bd847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016144dc565b915080825287848285010111156145d357600080fd5b80848401858401376000848284010152508093505050509250929050565b60008060006060848603121561460657600080fd5b83356146118161423c565b95602085013595506040909401359392505050565b6020808252825182820181905260009190848201906040850190845b81811015614668576146558385516142f2565b9284019260c09290920191600101614642565b50909695505050505050565b60006020828403121561468657600080fd5b81356146918161423c565b9392505050565b60005b838110156146b357818101518382015260200161469b565b50506000910152565b600081518084526146d4816020860160208601614698565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b73ffffffffffffffffffffffffffffffffffffffff8151168252600060208201516040602085015261367f60408501826146bc565b6020815260006104876020830184614706565b6000806020838503121561476157600080fd5b823567ffffffffffffffff8082111561477957600080fd5b818501915085601f83011261478d57600080fd5b81358181111561479c57600080fd5b8660208260071b85010111156147b157600080fd5b60209290920196919550909350505050565b6000806000604084860312156147d857600080fd5b833567ffffffffffffffff808211156147f057600080fd5b818601915086601f83011261480457600080fd5b81358181111561481357600080fd5b87602060a08302850101111561482857600080fd5b6020928301955093505084013561483e8161423c565b809150509250925092565b60008060006060848603121561485e57600080fd5b83356148698161423c565b925060208401359150604084013561483e8161423c565b801515811461200e57600080fd5b600080604083850312156148a157600080fd5b82356148ac8161423c565b9150602083013561428c81614880565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b8281101561492f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc088860301845261491d858351614706565b945092850192908501906001016148e3565b5092979650505050505050565b6000806000806080858703121561495257600080fd5b843561495d8161423c565b93506020850135925060408501356149748161423c565b9396929550929360600135925050565b6000806000806080858703121561499a57600080fd5b84356149a58161423c565b935060208501356149b58161423c565b93969395505050506040820135916060013590565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015614a73577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08984030185528151606073ffffffffffffffffffffffffffffffffffffffff825116855288820151818a870152614a53828701826146bc565b9289015115159589019590955250948701949250908601906001016149f1565b509098975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203614ae157614ae1614a81565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60208152600061048760208301846146bc565b600181811c90821680614b3e57607f821691505b602082108103614b77577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b601f8211156106ee57600081815260208120601f850160051c81016020861015614ba45750805b601f850160051c820191505b818110156111ab57828155600101614bb0565b815167ffffffffffffffff811115614bdd57614bdd614484565b614bf181614beb8454614b2a565b84614b7d565b602080601f831160018114614c445760008415614c0e5750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b1785556111ab565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b82811015614c9157888601518255948401946001909101908401614c72565b5085821015614ccd57878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b604081526000614cf060408301856146bc565b905073ffffffffffffffffffffffffffffffffffffffff831660208301529392505050565b8082018082111561048a5761048a614a81565b8181038181111561048a5761048a614a81565b838152606060208201526000614d5460608301856146bc565b905073ffffffffffffffffffffffffffffffffffffffff83166040830152949350505050565b60008251614d8c818460208701614698565b9190910192915050565b606081526000614da960608301866146bc565b8281036020840152614dbb81866146bc565b91505073ffffffffffffffffffffffffffffffffffffffff83166040830152949350505050565b600060208284031215614df457600080fd5b815161469181614880565b600060208284031215614e1157600080fd5b5051919050565b83815260e08101614e7360208301858051825260208101516020830152604081015173ffffffffffffffffffffffffffffffffffffffff80821660408501526060830151606085015280608084015116608085015250505050565b73ffffffffffffffffffffffffffffffffffffffff831660c0830152949350505050565b600060208284031215614ea957600080fd5b81516146918161423c565b60006101208083018884526020614f148186018a8051825260208101516020830152604081015173ffffffffffffffffffffffffffffffffffffffff80821660408501526060830151606085015280608084015116608085015250505050565b60c0850188905260e08501929092528551908190526101408401918087019160005b81811015614f73578351805173ffffffffffffffffffffffffffffffffffffffff1686528301518386015260409094019392820192600101614f36565b505050508091505073ffffffffffffffffffffffffffffffffffffffff83166101008301529695505050505050565b821515815260406020820152600061367f60408301846146bc565b60006020808385031215614fd057600080fd5b825167ffffffffffffffff80821115614fe857600080fd5b818501915085601f830112614ffc57600080fd5b81518181111561500e5761500e614484565b61501c848260051b016144dc565b818152848101925060069190911b83018401908782111561503c57600080fd5b928401925b81841015614108576040848903121561505a5760008081fd5b6150626144b3565b845161506d8161423c565b81528486015186820152835260409093019291840191615041565b6000806040838503121561509b57600080fd5b82516150a68161423c565b6020939093015192949293505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fdfe73656e646572206e6f7420626964646572206f7220617070726f766564206f70657261746f7273656e646572206e6f74206f776e6572206f7220617070726f766564206f70657261746f72a26469706673582212206656d086c4ee81525eca947740b5196f73c0a0158d16b495ef895a010ef86e5564736f6c6343000811003300000000000000000000000009372a34017d1588658c06a7ed94a284fdb72ab9

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

00000000000000000000000009372a34017d1588658c06a7ed94a284fdb72ab9

-----Decoded View---------------
Arg [0] : marketSettings_ (address): 0x09372a34017d1588658c06a7ed94a284fdb72ab9

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 00000000000000000000000009372a34017d1588658c06a7ed94a284fdb72ab9


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Validator ID :
0 FTM

Amount Staked
0

Amount Delegated
0

Staking Total
0

Staking Start Epoch
0

Staking Start Time
0

Proof of Importance
0

Origination Score
0

Validation Score
0

Active
0

Online
0

Downtime
0 s
Address Amount claimed Rewards Created On Epoch Created On
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.