ETH Price: $2,972.16 (+3.87%)
Gas: 1 Gwei

Contract

0xDd867a8Eb1720185B3fdAD7F81Caed4E8132Be19
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
0x60806040141666822022-02-08 17:09:34878 days ago1644340174IN
 Create: SuperRareAuctionHouse
0 ETH0.426151185.87439853

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SuperRareAuctionHouse

Compiler Version
v0.7.3+commit.9bfce1f6

Optimization Enabled:
Yes with 999 runs

Other Settings:
default evmVersion
File 1 of 22 : SuperRareAuctionHouse.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

import "@openzeppelin/contracts-upgradeable-0.7.2/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-0.7.2/utils/ReentrancyGuardUpgradeable.sol";
import "./ISuperRareAuctionHouse.sol";
import "../SuperRareBazaarBase.sol";

/// @author koloz
/// @title SuperRareAuctionHouse
/// @notice The logic for all functions related to the SuperRareAuctionHouse.
contract SuperRareAuctionHouse is
    ISuperRareAuctionHouse,
    OwnableUpgradeable,
    ReentrancyGuardUpgradeable,
    SuperRareBazaarBase
{
    using SafeMath for uint256;
    using SafeERC20 for IERC20;

    /////////////////////////////////////////////////////////////////////////
    // Initializer
    /////////////////////////////////////////////////////////////////////////
    function initialize(
        address _marketplaceSettings,
        address _royaltyRegistry,
        address _royaltyEngine,
        address _spaceOperatorRegistry,
        address _approvedTokenRegistry,
        address _payments,
        address _stakingRegistry,
        address _networkBeneficiary
    ) public initializer {
        require(_marketplaceSettings != address(0));
        require(_royaltyRegistry != address(0));
        require(_royaltyEngine != address(0));
        require(_spaceOperatorRegistry != address(0));
        require(_approvedTokenRegistry != address(0));
        require(_payments != address(0));
        require(_networkBeneficiary != address(0));

        marketplaceSettings = IMarketplaceSettings(_marketplaceSettings);
        royaltyRegistry = IERC721CreatorRoyalty(_royaltyRegistry);
        royaltyEngine = IRoyaltyEngineV1(_royaltyEngine);
        spaceOperatorRegistry = ISpaceOperatorRegistry(_spaceOperatorRegistry);
        approvedTokenRegistry = IApprovedTokenRegistry(_approvedTokenRegistry);
        payments = IPayments(_payments);
        stakingRegistry = _stakingRegistry;
        networkBeneficiary = _networkBeneficiary;

        minimumBidIncreasePercentage = 10;
        maxAuctionLength = 7 days;
        auctionLengthExtension = 15 minutes;
        offerCancelationDelay = 5 minutes;

        __Ownable_init();
        __ReentrancyGuard_init();
    }

    /// @notice Configures an Auction for a given asset.
    /// @dev If auction type is coldie (reserve) then _startingAmount cant be 0.
    /// @dev _currencyAddress equal to the zero address denotes eth.
    /// @dev All time related params are unix epoch timestamps.
    /// @param _auctionType The type of auction being configured.
    /// @param _originContract Contract address of the asset being put up for auction.
    /// @param _tokenId Token Id of the asset.
    /// @param _startingAmount The reserve price or min bid of an auction.
    /// @param _currencyAddress The currency the auction is being conducted in.
    /// @param _lengthOfAuction The amount of time in seconds that the auction is configured for.
    /// @param _splitAddresses Addresses to split the sellers commission with.
    /// @param _splitRatios The ratio for the split corresponding to each of the addresses being split with.
    function configureAuction(
        bytes32 _auctionType,
        address _originContract,
        uint256 _tokenId,
        uint256 _startingAmount,
        address _currencyAddress,
        uint256 _lengthOfAuction,
        uint256 _startTime,
        address payable[] calldata _splitAddresses,
        uint8[] calldata _splitRatios
    ) external override {
        _checkIfCurrencyIsApproved(_currencyAddress);
        _senderMustBeTokenOwner(_originContract, _tokenId);
        _ownerMustHaveMarketplaceApprovedForNFT(_originContract, _tokenId);
        _checkSplits(_splitAddresses, _splitRatios);
        _checkValidAuctionType(_auctionType);

        require(
            _lengthOfAuction <= maxAuctionLength,
            "configureAuction::Auction too long."
        );

        Auction memory auction = tokenAuctions[_originContract][_tokenId];

        require(
            auction.auctionType == NO_AUCTION ||
                auction.auctionCreator != msg.sender,
            "configureAuction::Cannot have a current auction."
        );

        require(_lengthOfAuction > 0, "configureAuction::Length must be > 0");

        if (_auctionType == COLDIE_AUCTION) {
            require(
                _startingAmount > 0,
                "configureAuction::Coldie starting price must be > 0"
            );
        } else if (_auctionType == SCHEDULED_AUCTION) {
            require(
                _startTime > block.timestamp,
                "configureAuction::Scheduled auction cannot start in past."
            );
        }

        require(
            _startingAmount <= marketplaceSettings.getMarketplaceMaxValue(),
            "configureAuction::Cannot set starting price higher than max value."
        );

        tokenAuctions[_originContract][_tokenId] = Auction(
            msg.sender,
            block.number,
            _auctionType == COLDIE_AUCTION ? 0 : _startTime,
            _lengthOfAuction,
            _currencyAddress,
            _startingAmount,
            _auctionType,
            _splitAddresses,
            _splitRatios
        );

        if (_auctionType == SCHEDULED_AUCTION) {
            IERC721 erc721 = IERC721(_originContract);
            erc721.transferFrom(msg.sender, address(this), _tokenId);
        }

        emit NewAuction(
            _originContract,
            _tokenId,
            msg.sender,
            _currencyAddress,
            _startTime,
            _startingAmount,
            _lengthOfAuction
        );
    }

    /// @notice Converts an offer into a coldie auction.
    /// @param _originContract Contract address of the asset.
    /// @dev Covers use of any currency (0 address is eth).
    /// @dev Only covers converting an offer to a coldie auction.
    /// @dev Cant convert offer if an auction currently exists.
    /// @param _tokenId Token Id of the asset.
    /// @param _currencyAddress Address of the currency being converted.
    /// @param _amount Amount being converted into an auction.
    /// @param _lengthOfAuction Number of seconds the auction will last.
    /// @param _splitAddresses Addresses that the sellers take in will be split amongst.
    /// @param _splitRatios Ratios that the take in will be split by.
    function convertOfferToAuction(
        address _originContract,
        uint256 _tokenId,
        address _currencyAddress,
        uint256 _amount,
        uint256 _lengthOfAuction,
        address payable[] calldata _splitAddresses,
        uint8[] calldata _splitRatios
    ) external override {
        _senderMustBeTokenOwner(_originContract, _tokenId);
        _ownerMustHaveMarketplaceApprovedForNFT(_originContract, _tokenId);
        _checkSplits(_splitAddresses, _splitRatios);

        Auction memory auction = tokenAuctions[_originContract][_tokenId];

        require(
            auction.auctionType == NO_AUCTION ||
                auction.auctionCreator != msg.sender,
            "convertOfferToAuction::Cannot have a current auction."
        );

        require(
            _lengthOfAuction <= maxAuctionLength,
            "convertOfferToAuction::Auction too long."
        );

        Offer memory currOffer = tokenCurrentOffers[_originContract][_tokenId][
            _currencyAddress
        ];

        require(currOffer.buyer != msg.sender, "convert::own offer");

        require(
            currOffer.convertible,
            "convertOfferToAuction::Offer is not convertible"
        );

        require(
            currOffer.amount == _amount,
            "convertOfferToAuction::Converting offer with different amount."
        );

        tokenAuctions[_originContract][_tokenId] = Auction(
            msg.sender,
            block.number,
            block.timestamp,
            _lengthOfAuction,
            _currencyAddress,
            currOffer.amount,
            COLDIE_AUCTION,
            _splitAddresses,
            _splitRatios
        );

        delete tokenCurrentOffers[_originContract][_tokenId][_currencyAddress];

        auctionBids[_originContract][_tokenId] = Bid(
            currOffer.buyer,
            _currencyAddress,
            _amount,
            marketplaceSettings.getMarketplaceFeePercentage()
        );

        IERC721 erc721 = IERC721(_originContract);
        erc721.transferFrom(msg.sender, address(this), _tokenId);

        emit NewAuction(
            _originContract,
            _tokenId,
            msg.sender,
            _currencyAddress,
            block.timestamp,
            _amount,
            _lengthOfAuction
        );

        emit AuctionBid(
            _originContract,
            currOffer.buyer,
            _tokenId,
            _currencyAddress,
            _amount,
            true,
            0,
            address(0)
        );
    }

    /// @notice Cancels a configured Auction that has not started.
    /// @dev Requires the person sending the message to be the auction creator or token owner.
    /// @param _originContract Contract address of the asset pending auction.
    /// @param _tokenId Token Id of the asset.
    function cancelAuction(address _originContract, uint256 _tokenId)
        external
        override
    {
        Auction memory auction = tokenAuctions[_originContract][_tokenId];

        IERC721 erc721 = IERC721(_originContract);

        require(
            auction.auctionType != NO_AUCTION,
            "cancelAuction::Must have an auction configured."
        );

        require(
            auction.startingTime == 0 || block.timestamp < auction.startingTime,
            "cancelAuction::Auction must not have started."
        );

        require(
            auction.auctionCreator == msg.sender ||
                erc721.ownerOf(_tokenId) == msg.sender,
            "cancelAuction::Must be creator or owner."
        );

        delete tokenAuctions[_originContract][_tokenId];

        if (erc721.ownerOf(_tokenId) == address(this)) {
            erc721.transferFrom(address(this), msg.sender, _tokenId);
        }

        emit CancelAuction(_originContract, _tokenId, auction.auctionCreator);
    }

    /// @notice Places a bid on a valid auction.
    /// @dev Only the configured currency can be used (Zero address for eth)
    /// @param _originContract Contract address of asset being bid on.
    /// @param _tokenId Token Id of the asset.
    /// @param _currencyAddress Address of currency being used to bid.
    /// @param _amount Amount of the currency being used for the bid.
    function bid(
        address _originContract,
        uint256 _tokenId,
        address _currencyAddress,
        uint256 _amount
    ) external payable override nonReentrant {
        uint256 requiredAmount = _amount.add(
            marketplaceSettings.calculateMarketplaceFee(_amount)
        );

        _senderMustHaveMarketplaceApproved(_currencyAddress, requiredAmount);

        Auction memory auction = tokenAuctions[_originContract][_tokenId];

        require(
            auction.auctionType != NO_AUCTION,
            "bid::Must have a current auction."
        );

        require(
            auction.auctionCreator != msg.sender,
            "bid::Cannot bid on your own auction."
        );

        require(
            block.timestamp >= auction.startingTime,
            "bid::Auction not active."
        );

        require(
            _currencyAddress == auction.currencyAddress,
            "bid::Currency must be in configured denomination"
        );

        require(_amount > 0, "bid::Cannot be 0");

        require(
            _amount <= marketplaceSettings.getMarketplaceMaxValue(),
            "bid::Must be less than max value."
        );

        require(
            _amount >= auction.minimumBid,
            "bid::Cannot be lower than minimum bid."
        );

        require(
            auction.startingTime == 0 ||
                block.timestamp <
                auction.startingTime.add(auction.lengthOfAuction),
            "bid::Must be active."
        );

        Bid memory currBid = auctionBids[_originContract][_tokenId];

        require(
            _amount >=
                currBid.amount.add(
                    currBid.amount.mul(minimumBidIncreasePercentage).div(100)
                ),
            "bid::Must be higher than prev bid + min increase."
        );

        IERC721 erc721 = IERC721(_originContract);
        address tokenOwner = erc721.ownerOf(_tokenId);

        require(
            auction.auctionCreator == tokenOwner || tokenOwner == address(this),
            "bid::Auction creator must be owner."
        );

        if (auction.auctionCreator == tokenOwner) {
            _ownerMustHaveMarketplaceApprovedForNFT(_originContract, _tokenId);
        }

        _checkAmountAndTransfer(_currencyAddress, requiredAmount);

        _refund(
            _currencyAddress,
            currBid.amount,
            currBid.marketplaceFee,
            currBid.bidder
        );

        auctionBids[_originContract][_tokenId] = Bid(
            msg.sender,
            _currencyAddress,
            _amount,
            marketplaceSettings.getMarketplaceFeePercentage()
        );

        bool startedAuction = false;
        uint256 newAuctionLength = 0;

        if (auction.startingTime == 0) {
            tokenAuctions[_originContract][_tokenId].startingTime = block
                .timestamp;

            erc721.transferFrom(
                auction.auctionCreator,
                address(this),
                _tokenId
            );

            startedAuction = true;
        } else if (
            auction.startingTime.add(auction.lengthOfAuction).sub(
                block.timestamp
            ) < auctionLengthExtension
        ) {
            newAuctionLength = block.timestamp.add(auctionLengthExtension).sub(
                auction.startingTime
            );

            tokenAuctions[_originContract][_tokenId]
                .lengthOfAuction = newAuctionLength;
        }

        emit AuctionBid(
            _originContract,
            msg.sender,
            _tokenId,
            _currencyAddress,
            _amount,
            startedAuction,
            newAuctionLength,
            currBid.bidder
        );
    }

    /// @notice Settles an auction that has ended.
    /// @dev Anyone is able to settle an auction since non-input params are used.
    /// @param _originContract Contract address of asset.
    /// @param _tokenId Token Id of the asset.
    function settleAuction(address _originContract, uint256 _tokenId)
        external
        override
    {
        Auction memory auction = tokenAuctions[_originContract][_tokenId];

        require(
            auction.auctionType != NO_AUCTION && auction.startingTime != 0,
            "settleAuction::Must have a current valid auction."
        );

        require(
            block.timestamp >=
                auction.startingTime.add(auction.lengthOfAuction),
            "settleAuction::Can only settle ended auctions."
        );

        Bid memory currBid = auctionBids[_originContract][_tokenId];

        delete tokenAuctions[_originContract][_tokenId];
        delete auctionBids[_originContract][_tokenId];

        IERC721 erc721 = IERC721(_originContract);

        if (currBid.bidder == address(0)) {
            erc721.transferFrom(
                address(this),
                auction.auctionCreator,
                _tokenId
            );
        } else {
            erc721.transferFrom(address(this), currBid.bidder, _tokenId);

            _payout(
                _originContract,
                _tokenId,
                auction.currencyAddress,
                currBid.amount,
                auction.auctionCreator,
                auction.splitRecipients,
                auction.splitRatios
            );

            marketplaceSettings.markERC721Token(
                _originContract,
                _tokenId,
                true
            );
        }

        emit AuctionSettled(
            _originContract,
            currBid.bidder,
            auction.auctionCreator,
            _tokenId,
            auction.currencyAddress,
            currBid.amount
        );
    }

    /// @notice Grabs the current auction details for a token.
    /// @param _originContract Contract address of asset.
    /// @param _tokenId Token Id of the asset.
    /** @return Auction Struct: creatorAddress, creationTime, startingTime, lengthOfAuction,
                currencyAddress, minimumBid, auctionType, splitRecipients array, and splitRatios array.
    */
    function getAuctionDetails(address _originContract, uint256 _tokenId)
        external
        view
        override
        returns (
            address,
            uint256,
            uint256,
            uint256,
            address,
            uint256,
            bytes32,
            address payable[] memory,
            uint8[] memory
        )
    {
        Auction memory auction = tokenAuctions[_originContract][_tokenId];

        return (
            auction.auctionCreator,
            auction.creationBlock,
            auction.startingTime,
            auction.lengthOfAuction,
            auction.currencyAddress,
            auction.minimumBid,
            auction.auctionType,
            auction.splitRecipients,
            auction.splitRatios
        );
    }

    function _checkValidAuctionType(bytes32 _auctionType) internal pure {
        if (
            _auctionType != COLDIE_AUCTION && _auctionType != SCHEDULED_AUCTION
        ) {
            revert("Invalid Auction Type");
        }
    }
}

File 2 of 22 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    function __Ownable_init() internal initializer {
        __Context_init_unchained();
        __Ownable_init_unchained();
    }

    function __Ownable_init_unchained() internal initializer {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
    uint256[49] private __gap;
}

File 3 of 22 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;
import "../proxy/Initializable.sol";

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

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

    uint256 private _status;

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

    function __ReentrancyGuard_init_unchained() internal initializer {
        _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 make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 4 of 22 : ISuperRareAuctionHouse.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

/// @author koloz
/// @title ISuperRareAuctionHouse
/// @notice The interface for the SuperRareAuctionHouse Functions.
interface ISuperRareAuctionHouse {
    /// @notice Configures an Auction for a given asset.
    /// @param _auctionType The type of auction being configured.
    /// @param _originContract Contract address of the asset being put up for auction.
    /// @param _tokenId Token Id of the asset.
    /// @param _startingAmount The reserve price or min bid of an auction.
    /// @param _currencyAddress The currency the auction is being conducted in.
    /// @param _lengthOfAuction The amount of time in seconds that the auction is configured for.
    /// @param _splitAddresses Addresses to split the sellers commission with.
    /// @param _splitRatios The ratio for the split corresponding to each of the addresses being split with.
    function configureAuction(
        bytes32 _auctionType,
        address _originContract,
        uint256 _tokenId,
        uint256 _startingAmount,
        address _currencyAddress,
        uint256 _lengthOfAuction,
        uint256 _startTime,
        address payable[] calldata _splitAddresses,
        uint8[] calldata _splitRatios
    ) external;

    /// @notice Converts an offer into a coldie auction.
    /// @param _originContract Contract address of the asset.
    /// @param _tokenId Token Id of the asset.
    /// @param _currencyAddress Address of the currency being converted.
    /// @param _amount Amount being converted into an auction.
    /// @param _lengthOfAuction Number of seconds the auction will last.
    /// @param _splitAddresses Addresses that the sellers take in will be split amongst.
    /// @param _splitRatios Ratios that the take in will be split by.
    function convertOfferToAuction(
        address _originContract,
        uint256 _tokenId,
        address _currencyAddress,
        uint256 _amount,
        uint256 _lengthOfAuction,
        address payable[] calldata _splitAddresses,
        uint8[] calldata _splitRatios
    ) external;

    /// @notice Cancels a configured Auction that has not started.
    /// @param _originContract Contract address of the asset pending auction.
    /// @param _tokenId Token Id of the asset.
    function cancelAuction(address _originContract, uint256 _tokenId) external;

    /// @notice Places a bid on a valid auction.
    /// @param _originContract Contract address of asset being bid on.
    /// @param _tokenId Token Id of the asset.
    /// @param _currencyAddress Address of currency being used to bid.
    /// @param _amount Amount of the currency being used for the bid.
    function bid(
        address _originContract,
        uint256 _tokenId,
        address _currencyAddress,
        uint256 _amount
    ) external payable;

    /// @notice Settles an auction that has ended.
    /// @param _originContract Contract address of asset.
    /// @param _tokenId Token Id of the asset.
    function settleAuction(address _originContract, uint256 _tokenId) external;

    /// @notice Grabs the current auction details for a token.
    /// @param _originContract Contract address of asset.
    /// @param _tokenId Token Id of the asset.
    /** @return Auction Struct: creatorAddress, creationTime, startingTime, lengthOfAuction,
                currencyAddress, minimumBid, auctionType, splitRecipients array, and splitRatios array.
    */
    function getAuctionDetails(address _originContract, uint256 _tokenId)
        external
        view
        returns (
            address,
            uint256,
            uint256,
            uint256,
            address,
            uint256,
            bytes32,
            address payable[] memory,
            uint8[] memory
        );
}

File 5 of 22 : SuperRareBazaarBase.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

import "@openzeppelin/contracts-0.7.2/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts-0.7.2/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-0.7.2/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts-0.7.2/math/SafeMath.sol";
import "./storage/SuperRareBazaarStorage.sol";

/// @author koloz
/// @title SuperRareBazaarBase
/// @notice Base contract containing the internal functions for the SuperRareBazaar.
abstract contract SuperRareBazaarBase is SuperRareBazaarStorage {
    using SafeMath for uint256;
    using SafeMath for uint8;
    using SafeERC20 for IERC20;

    /////////////////////////////////////////////////////////////////////////
    // Internal Functions
    /////////////////////////////////////////////////////////////////////////

    /// @notice Checks to see if the currenccy address is eth or an approved erc20 token.
    /// @param _currencyAddress Address of currency (Zero address if eth).
    function _checkIfCurrencyIsApproved(address _currencyAddress)
        internal
        view
    {
        require(
            _currencyAddress == address(0) ||
                approvedTokenRegistry.isApprovedToken(_currencyAddress),
            "Not approved currency"
        );
    }

    /// @notice Checks to see if the owner of the token has the marketplace approved.
    /// @param _originContract Contract address of the token being checked.
    /// @param _tokenId Token Id of the asset.
    function _ownerMustHaveMarketplaceApprovedForNFT(
        address _originContract,
        uint256 _tokenId
    ) internal view {
        IERC721 erc721 = IERC721(_originContract);
        address owner = erc721.ownerOf(_tokenId);
        require(
            erc721.isApprovedForAll(owner, address(this)),
            "owner must have approved contract"
        );
    }

    /// @notice Checks to see if the msg sender owns the token.
    /// @param _originContract Contract address of the token being checked.
    /// @param _tokenId Token Id of the asset.
    function _senderMustBeTokenOwner(address _originContract, uint256 _tokenId)
        internal
        view
    {
        IERC721 erc721 = IERC721(_originContract);
        require(
            erc721.ownerOf(_tokenId) == msg.sender,
            "sender must be the token owner"
        );
    }

    /// @notice Verifies that the splits supplied are valid.
    /// @dev A valid split has the same number of splits and ratios.
    /// @dev There can only be a max of 5 parties split with.
    /// @dev Total of the ratios should be 100 which is relative.
    /// @param _splits The addresses the amount is being split with.
    /// @param _ratios The ratios each address in _splits is getting.
    function _checkSplits(
        address payable[] calldata _splits,
        uint8[] calldata _ratios
    ) internal pure {
        require(_splits.length > 0, "checkSplits::Must have at least 1 split");
        require(_splits.length <= 5, "checkSplits::Split exceeded max size");
        require(
            _splits.length == _ratios.length,
            "checkSplits::Splits and ratios must be equal"
        );
        uint256 totalRatio = 0;

        for (uint256 i = 0; i < _ratios.length; i++) {
            totalRatio += _ratios[i];
        }

        require(totalRatio == 100, "checkSplits::Total must be equal to 100");
    }

    /// @notice Checks to see if the sender has approved the marketplace to move tokens.
    /// @dev This is for offers/buys/bids and the allowance of erc20 tokens.
    /// @dev Returns on zero address because no allowance is needed for eth.
    /// @param _contract The address of the currency being checked.
    /// @param _amount The total amount being checked.
    function _senderMustHaveMarketplaceApproved(
        address _contract,
        uint256 _amount
    ) internal view {
        if (_contract == address(0)) {
            return;
        }

        IERC20 erc20 = IERC20(_contract);

        require(
            erc20.allowance(msg.sender, address(this)) >= _amount,
            "sender needs to approve marketplace for currency"
        );
    }

    /// @notice Checks the user has the correct amount and transfers to the marketplace.
    /// @dev If the currency used is eth (zero address) the msg value is checked.
    /// @dev If eth isnt used and eth is sent we revert the txn.
    /// @dev We need to check this contracts balance before and after the transfer to ensure no fee.
    /// @param _currencyAddress Currency address being checked and transfered.
    /// @param _amount Total amount of currency.
    function _checkAmountAndTransfer(address _currencyAddress, uint256 _amount)
        internal
    {
        if (_currencyAddress == address(0)) {
            require(msg.value == _amount, "not enough eth sent");
            return;
        }

        require(msg.value == 0, "msg.value should be 0 when not using eth");

        IERC20 erc20 = IERC20(_currencyAddress);
        uint256 balanceBefore = erc20.balanceOf(address(this));

        erc20.safeTransferFrom(msg.sender, address(this), _amount);

        uint256 balanceAfter = erc20.balanceOf(address(this));

        require(
            balanceAfter.sub(balanceBefore) == _amount,
            "not enough tokens transfered"
        );
    }

    /// @notice Refunds an address the designated amount.
    /// @dev Return if amount being refunded is zero.
    /// @dev Forwards to payment contract if eth is being refunded.
    /// @param _currencyAddress Address of currency being refunded.
    /// @param _amount Amount being refunded.
    /// @param _marketplaceFee Marketplace Fee (percentage) paid by _recipient.
    /// @param _recipient Address amount is being refunded to.
    function _refund(
        address _currencyAddress,
        uint256 _amount,
        uint256 _marketplaceFee,
        address _recipient
    ) internal {
        if (_amount == 0) {
            return;
        }

        uint256 requiredAmount = _amount.add(
            _amount.mul(_marketplaceFee).div(100)
        );

        if (_currencyAddress == address(0)) {
            (bool success, bytes memory data) = address(payments).call{
                value: requiredAmount
            }(
                abi.encodeWithSignature(
                    "refund(address,uint256)",
                    _recipient,
                    requiredAmount
                )
            );

            require(success, string(data));
            return;
        }

        IERC20 erc20 = IERC20(_currencyAddress);
        erc20.safeTransfer(_recipient, requiredAmount);
    }

    /// @notice Sends a payout to all the necessary parties.
    /// @dev Sends payments to the network, royalty if applicable, and splits for the rest.
    /// @dev Forwards payments to the payment contract if payout is happening in eth.
    /// @dev Total amount of ratios should be 100 and is relative to the total ratio left.
    /// @param _originContract Contract address of asset triggering a payout.
    /// @param _tokenId Token Id of the asset.
    /// @param _currencyAddress Address of currency being paid out.
    /// @param _amount Total amount to be paid out.
    /// @param _seller Address of the person selling the asset.
    /// @param _splitAddrs Addresses that funds need to be split against.
    /// @param _splitRatios Ratios for split pertaining to each address.
    function _payout(
        address _originContract,
        uint256 _tokenId,
        address _currencyAddress,
        uint256 _amount,
        address _seller,
        address payable[] memory _splitAddrs,
        uint8[] memory _splitRatios
    ) internal {
        require(
            _splitAddrs.length == _splitRatios.length,
            "Number of split addresses and ratios must be equal."
        );

        /*
        The overall flow for payouts is:
            1. Payout marketplace fee
            2. Primary/Secondary Payouts
                a. Primary -> If space sale, query space operator registry for platform comission and payout
                              Else query marketplace setting for primary sale comission and payout
                b. Secondary -> Query global royalty registry for recipients and amounts and payout
            3. Calculate the amount for each _splitAddr based on remaining amount and payout
         */

        uint256 remainingAmount = _amount;

        // Marketplace fee
        uint256 marketplaceFee = marketplaceSettings.calculateMarketplaceFee(
            _amount
        );

        address payable[] memory mktFeeRecip = new address payable[](1);
        mktFeeRecip[0] = payable(networkBeneficiary);
        uint256[] memory mktFee = new uint256[](1);
        mktFee[0] = marketplaceFee;

        _performPayouts(_currencyAddress, marketplaceFee, mktFeeRecip, mktFee);

        if (
            !marketplaceSettings.hasERC721TokenSold(_originContract, _tokenId)
        ) {
            uint256[] memory platformFee = new uint256[](1);

            if (spaceOperatorRegistry.isApprovedSpaceOperator(_seller)) {
                uint256 platformCommission = spaceOperatorRegistry
                    .getPlatformCommission(_seller);

                remainingAmount = remainingAmount.sub(
                    _amount.mul(platformCommission).div(100)
                );

                platformFee[0] = _amount.mul(platformCommission).div(100);

                _performPayouts(
                    _currencyAddress,
                    platformFee[0],
                    mktFeeRecip,
                    platformFee
                );
            } else {
                uint256 platformCommission = marketplaceSettings
                    .getERC721ContractPrimarySaleFeePercentage(_originContract);

                remainingAmount = remainingAmount.sub(
                    _amount.mul(platformCommission).div(100)
                );

                platformFee[0] = _amount.mul(platformCommission).div(100);

                _performPayouts(
                    _currencyAddress,
                    platformFee[0],
                    mktFeeRecip,
                    platformFee
                );
            }
        } else {
            (
                address payable[] memory receivers,
                uint256[] memory royalties
            ) = royaltyEngine.getRoyalty(_originContract, _tokenId, _amount);

            uint256 totalRoyalties = 0;

            for (uint256 i = 0; i < royalties.length; i++) {
                totalRoyalties = totalRoyalties.add(royalties[i]);
            }

            remainingAmount = remainingAmount.sub(totalRoyalties);
            _performPayouts(
                _currencyAddress,
                totalRoyalties,
                receivers,
                royalties
            );
        }

        uint256[] memory remainingAmts = new uint256[](_splitAddrs.length);

        uint256 totalSplit = 0;

        for (uint256 i = 0; i < _splitAddrs.length; i++) {
            remainingAmts[i] = remainingAmount.mul(_splitRatios[i]).div(100);
            totalSplit = totalSplit.add(
                remainingAmount.mul(_splitRatios[i]).div(100)
            );
        }
        _performPayouts(
            _currencyAddress,
            totalSplit,
            _splitAddrs,
            remainingAmts
        );
    }

    function _performPayouts(
        address _currencyAddress,
        uint256 _amount,
        address payable[] memory _recipients,
        uint256[] memory _amounts
    ) internal {
        if (_currencyAddress == address(0)) {
            (bool success, bytes memory data) = address(payments).call{
                value: _amount
            }(
                abi.encodeWithSelector(
                    IPayments.payout.selector,
                    _recipients,
                    _amounts
                )
            );

            require(success, string(data));
        } else {
            IERC20 erc20 = IERC20(_currencyAddress);

            for (uint256 i = 0; i < _recipients.length; i++) {
                erc20.safeTransfer(_recipients[i], _amounts[i]);
            }
        }
    }
}

File 6 of 22 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";

/*
 * @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 GSN 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 ContextUpgradeable is Initializable {
    function __Context_init() internal initializer {
        __Context_init_unchained();
    }

    function __Context_init_unchained() internal initializer {
    }
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
    uint256[50] private __gap;
}

File 7 of 22 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;

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

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /// @dev Returns true if and only if the function is running in the constructor
    function _isConstructor() private view returns (bool) {
        return !AddressUpgradeable.isContract(address(this));
    }
}

File 8 of 22 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 9 of 22 : IERC721.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 10 of 22 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 11 of 22 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20.sol";
import "../../math/SafeMath.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 SafeMath for uint256;
    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'
        // solhint-disable-next-line max-line-length
        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).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

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

    /**
     * @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
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 12 of 22 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

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

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

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

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

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

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

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

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

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

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

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

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

File 13 of 22 : SuperRareBazaarStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

import "../../marketplace/IMarketplaceSettings.sol";
import "../../royalty/creator/IERC721CreatorRoyalty.sol";
import "../../payments/IPayments.sol";
import "../../registry/spaces/ISpaceOperatorRegistry.sol";
import "../../registry/token/IApprovedTokenRegistry.sol";
import "../../royalty/creator/IRoyaltyEngine.sol";

/// @author koloz
/// @title SuperRareBazaar Storage Contract
/// @dev STORAGE CAN ONLY BE APPENDED NOT INSERTED OR MODIFIED
contract SuperRareBazaarStorage {
    /////////////////////////////////////////////////////////////////////////
    // Constants
    /////////////////////////////////////////////////////////////////////////

    // Auction Types
    bytes32 public constant COLDIE_AUCTION = "COLDIE_AUCTION";
    bytes32 public constant SCHEDULED_AUCTION = "SCHEDULED_AUCTION";
    bytes32 public constant NO_AUCTION = bytes32(0);

    /////////////////////////////////////////////////////////////////////////
    // Structs
    /////////////////////////////////////////////////////////////////////////

    // The Offer truct for a given token:
    // buyer - address of person making the offer
    // currencyAddress - address of the erc20 token used for an offer
    //                   or the zero address for eth
    // amount - offer in wei/full erc20 value
    // marketplaceFee - the amount that is taken by the network on offer acceptance.
    struct Offer {
        address payable buyer;
        uint256 amount;
        uint256 timestamp;
        uint8 marketplaceFee;
        bool convertible;
    }

    // The Sale Price struct for a given token:
    // seller - address of the person selling the token
    // currencyAddress - address of the erc20 token used for an offer
    //                   or the zero address for eth
    // amount - offer in wei/full erc20 value
    struct SalePrice {
        address payable seller;
        address currencyAddress;
        uint256 amount;
        address payable[] splitRecipients;
        uint8[] splitRatios;
    }

    // Structure of an Auction:
    // auctionCreator - creator of the auction
    // creationBlock - time that the auction was created/configured
    // startingBlock - time that the auction starts on
    // lengthOfAuction - how long the auction is
    // currencyAddress - address of the erc20 token used for an offer
    //                   or the zero address for eth
    // minimumBid - min amount a bidder can bid at the start of an auction.
    // auctionType - type of auction, represented as the formatted bytes 32 string
    struct Auction {
        address payable auctionCreator;
        uint256 creationBlock;
        uint256 startingTime;
        uint256 lengthOfAuction;
        address currencyAddress;
        uint256 minimumBid;
        bytes32 auctionType;
        address payable[] splitRecipients;
        uint8[] splitRatios;
    }

    struct Bid {
        address payable bidder;
        address currencyAddress;
        uint256 amount;
        uint8 marketplaceFee;
    }

    /////////////////////////////////////////////////////////////////////////
    // Events
    /////////////////////////////////////////////////////////////////////////
    event Sold(
        address indexed _originContract,
        address indexed _buyer,
        address indexed _seller,
        address _currencyAddress,
        uint256 _amount,
        uint256 _tokenId
    );

    event SetSalePrice(
        address indexed _originContract,
        address indexed _currencyAddress,
        address _target,
        uint256 _amount,
        uint256 _tokenId,
        address payable[] _splitRecipients,
        uint8[] _splitRatios
    );

    event OfferPlaced(
        address indexed _originContract,
        address indexed _bidder,
        address indexed _currencyAddress,
        uint256 _amount,
        uint256 _tokenId,
        bool _convertible
    );

    event AcceptOffer(
        address indexed _originContract,
        address indexed _bidder,
        address indexed _seller,
        address _currencyAddress,
        uint256 _amount,
        uint256 _tokenId,
        address payable[] _splitAddresses,
        uint8[] _splitRatios
    );

    event CancelOffer(
        address indexed _originContract,
        address indexed _bidder,
        address indexed _currencyAddress,
        uint256 _amount,
        uint256 _tokenId
    );

    event NewAuction(
        address indexed _contractAddress,
        uint256 indexed _tokenId,
        address indexed _auctionCreator,
        address _currencyAddress,
        uint256 _startingTime,
        uint256 _minimumBid,
        uint256 _lengthOfAuction
    );

    event CancelAuction(
        address indexed _contractAddress,
        uint256 indexed _tokenId,
        address indexed _auctionCreator
    );

    event AuctionBid(
        address indexed _contractAddress,
        address indexed _bidder,
        uint256 indexed _tokenId,
        address _currencyAddress,
        uint256 _amount,
        bool _startedAuction,
        uint256 _newAuctionLength,
        address _previousBidder
    );

    event AuctionSettled(
        address indexed _contractAddress,
        address indexed _bidder,
        address _seller,
        uint256 indexed _tokenId,
        address _currencyAddress,
        uint256 _amount
    );

    /////////////////////////////////////////////////////////////////////////
    // State Variables
    /////////////////////////////////////////////////////////////////////////

    // Current marketplace settings implementation to be used
    IMarketplaceSettings public marketplaceSettings;

    // Current creator royalty implementation to be used
    IERC721CreatorRoyalty public royaltyRegistry;

    // Address of the global royalty engine being used.
    IRoyaltyEngineV1 public royaltyEngine;

    // Current SuperRareMarketplace implementation to be used
    address public superRareMarketplace;

    // Current SuperRareAuctionHouse implementation to be used
    address public superRareAuctionHouse;

    // Current SpaceOperatorRegistry implementation to be used.
    ISpaceOperatorRegistry public spaceOperatorRegistry;

    // Current ApprovedTokenRegistry implementation being used for currencies.
    IApprovedTokenRegistry public approvedTokenRegistry;

    // Current payments contract to use
    IPayments public payments;

    // Address to be used for staking registry.
    address public stakingRegistry;

    // Address of the network beneficiary
    address public networkBeneficiary;

    // A minimum increase in bid amount when out bidding someone.
    uint8 public minimumBidIncreasePercentage; // 10 = 10%

    // Maximum length that an auction can be.
    uint256 public maxAuctionLength;

    // Extension length for an auction
    uint256 public auctionLengthExtension;

    // Offer cancellation delay
    uint256 public offerCancelationDelay;

    // Mapping from contract to mapping of tokenId to mapping of target to sale price.
    mapping(address => mapping(uint256 => mapping(address => SalePrice)))
        public tokenSalePrices;

    // Mapping from contract to mapping of tokenId to mapping of currency address to Current Offer.
    mapping(address => mapping(uint256 => mapping(address => Offer)))
        public tokenCurrentOffers;

    // Mapping from contract to mapping of tokenId to Auction.
    mapping(address => mapping(uint256 => Auction)) public tokenAuctions;

    // Mapping from contract to mapping of tokenId to Bid.
    mapping(address => mapping(uint256 => Bid)) public auctionBids;

    uint256[50] private __gap;
    /// ALL NEW STORAGE MUST COME AFTER THIS
}

File 14 of 22 : IERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <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 15 of 22 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 16 of 22 : IMarketplaceSettings.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

/**
 * @title IMarketplaceSettings Settings governing a marketplace.
 */
interface IMarketplaceSettings {
    /////////////////////////////////////////////////////////////////////////
    // Marketplace Min and Max Values
    /////////////////////////////////////////////////////////////////////////
    /**
     * @dev Get the max value to be used with the marketplace.
     * @return uint256 wei value.
     */
    function getMarketplaceMaxValue() external view returns (uint256);

    /**
     * @dev Get the max value to be used with the marketplace.
     * @return uint256 wei value.
     */
    function getMarketplaceMinValue() external view returns (uint256);

    /////////////////////////////////////////////////////////////////////////
    // Marketplace Fee
    /////////////////////////////////////////////////////////////////////////
    /**
     * @dev Get the marketplace fee percentage.
     * @return uint8 wei fee.
     */
    function getMarketplaceFeePercentage() external view returns (uint8);

    /**
     * @dev Utility function for calculating the marketplace fee for given amount of wei.
     * @param _amount uint256 wei amount.
     * @return uint256 wei fee.
     */
    function calculateMarketplaceFee(uint256 _amount)
        external
        view
        returns (uint256);

    /////////////////////////////////////////////////////////////////////////
    // Primary Sale Fee
    /////////////////////////////////////////////////////////////////////////
    /**
     * @dev Get the primary sale fee percentage for a specific ERC721 contract.
     * @param _contractAddress address ERC721Contract address.
     * @return uint8 wei primary sale fee.
     */
    function getERC721ContractPrimarySaleFeePercentage(address _contractAddress)
        external
        view
        returns (uint8);

    /**
     * @dev Utility function for calculating the primary sale fee for given amount of wei
     * @param _contractAddress address ERC721Contract address.
     * @param _amount uint256 wei amount.
     * @return uint256 wei fee.
     */
    function calculatePrimarySaleFee(address _contractAddress, uint256 _amount)
        external
        view
        returns (uint256);

    /**
     * @dev Check whether the ERC721 token has sold at least once.
     * @param _contractAddress address ERC721Contract address.
     * @param _tokenId uint256 token ID.
     * @return bool of whether the token has sold.
     */
    function hasERC721TokenSold(address _contractAddress, uint256 _tokenId)
        external
        view
        returns (bool);

    /**
     * @dev Mark a token as sold.
     * Requirements:
     *
     * - `_contractAddress` cannot be the zero address.
     * @param _contractAddress address ERC721Contract address.
     * @param _tokenId uint256 token ID.
     * @param _hasSold bool of whether the token should be marked sold or not.
     */
    function markERC721Token(
        address _contractAddress,
        uint256 _tokenId,
        bool _hasSold
    ) external;

    function setERC721ContractPrimarySaleFeePercentage(
        address _contractAddress,
        uint8 _percentage
    ) external;
}

File 17 of 22 : IERC721CreatorRoyalty.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

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

/**
 * @title IERC721CreatorRoyalty Token level royalty interface.
 */
interface IERC721CreatorRoyalty is IERC721TokenCreator {
    /**
     * @dev Get the royalty fee percentage for a specific ERC721 contract.
     * @param _contractAddress address ERC721Contract address.
     * @param _tokenId uint256 token ID.
     * @return uint8 wei royalty fee.
     */
    function getERC721TokenRoyaltyPercentage(
        address _contractAddress,
        uint256 _tokenId
    ) external view returns (uint8);

    /**
     * @dev Utililty function to calculate the royalty fee for a token.
     * @param _contractAddress address ERC721Contract address.
     * @param _tokenId uint256 token ID.
     * @param _amount uint256 wei amount.
     * @return uint256 wei fee.
     */
    function calculateRoyaltyFee(
        address _contractAddress,
        uint256 _tokenId,
        uint256 _amount
    ) external view returns (uint256);

    /**
     * @dev Utililty function to set the royalty percentage for a specific ERC721 contract.
     * @param _contractAddress address ERC721Contract address.
     * @param _percentage percentage for royalty
     */
    function setPercentageForSetERC721ContractRoyalty(
        address _contractAddress,
        uint8 _percentage
    ) external;
}

File 18 of 22 : IPayments.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

/// @author koloz
/// @title IPayments
/// @notice Interface for the Payments contract used.
interface IPayments {
    function refund(address _payee, uint256 _amount) external payable;

    function payout(address[] calldata _splits, uint256[] calldata _amounts)
        external
        payable;
}

File 19 of 22 : ISpaceOperatorRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

/// @author koloz
/// @title ISpaceOperatorRegistry
/// @notice The interface for the SpaceOperatorRegistry
interface ISpaceOperatorRegistry {
    function getPlatformCommission(address _operator)
        external
        view
        returns (uint8);

    function setPlatformCommission(address _operator, uint8 _commission)
        external;

    function isApprovedSpaceOperator(address _operator)
        external
        view
        returns (bool);

    function setSpaceOperatorApproved(address _operator, bool _approved)
        external;
}

File 20 of 22 : IApprovedTokenRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

interface IApprovedTokenRegistry {
    /// @notice Returns if a token has been approved or not.
    /// @param _tokenContract Contract of token being checked.
    /// @return True if the token is allowed, false otherwise.
    function isApprovedToken(address _tokenContract)
        external
        view
        returns (bool);

    /// @notice Adds a token to the list of approved tokens.
    /// @param _tokenContract Contract of token being approved.
    function addApprovedToken(address _tokenContract) external;

    /// @notice Removes a token from the approved tokens list.
    /// @param _tokenContract Contract of token being approved.
    function removeApprovedToken(address _tokenContract) external;

    /// @notice Sets whether all token contracts should be approved.
    /// @param _allTokensApproved Bool denoting if all tokens should be approved.
    function setAllTokensApproved(bool _allTokensApproved) external;
}

File 21 of 22 : IRoyaltyEngine.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

/// @author: manifold.xyz

/**
 * @dev Lookup engine interface
 */
interface IRoyaltyEngineV1 {
    /**
     * Get the royalty for a given token (address, id) and value amount.  Does not cache the bps/amounts.  Caches the spec for a given token address
     *
     * @param tokenAddress - The address of the token
     * @param tokenId      - The id of the token
     * @param value        - The value you wish to get the royalty of
     *
     * returns Two arrays of equal length, royalty recipients and the corresponding amount each recipient should get
     */
    function getRoyalty(
        address tokenAddress,
        uint256 tokenId,
        uint256 value
    )
        external
        returns (address payable[] memory recipients, uint256[] memory amounts);

    /**
     * View only version of getRoyalty
     *
     * @param tokenAddress - The address of the token
     * @param tokenId      - The id of the token
     * @param value        - The value you wish to get the royalty of
     *
     * returns Two arrays of equal length, royalty recipients and the corresponding amount each recipient should get
     */
    function getRoyaltyView(
        address tokenAddress,
        uint256 tokenId,
        uint256 value
    )
        external
        view
        returns (address payable[] memory recipients, uint256[] memory amounts);
}

File 22 of 22 : IERC721TokenCreator.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;

interface IERC721TokenCreator {
    function tokenCreator(address _contractAddress, uint256 _tokenId)
        external
        view
        returns (address payable);
}

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

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":true,"internalType":"address","name":"_seller","type":"address"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address payable[]","name":"_splitAddresses","type":"address[]"},{"indexed":false,"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"AcceptOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"_startedAuction","type":"bool"},{"indexed":false,"internalType":"uint256","name":"_newAuctionLength","type":"uint256"},{"indexed":false,"internalType":"address","name":"_previousBidder","type":"address"}],"name":"AuctionBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":false,"internalType":"address","name":"_seller","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"AuctionSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_auctionCreator","type":"address"}],"name":"CancelAuction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":true,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"CancelOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_auctionCreator","type":"address"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_startingTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minimumBid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lengthOfAuction","type":"uint256"}],"name":"NewAuction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":true,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"_convertible","type":"bool"}],"name":"OfferPlaced","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":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_target","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address payable[]","name":"_splitRecipients","type":"address[]"},{"indexed":false,"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"SetSalePrice","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_buyer","type":"address"},{"indexed":true,"internalType":"address","name":"_seller","type":"address"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Sold","type":"event"},{"inputs":[],"name":"COLDIE_AUCTION","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NO_AUCTION","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SCHEDULED_AUCTION","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"approvedTokenRegistry","outputs":[{"internalType":"contract IApprovedTokenRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"auctionBids","outputs":[{"internalType":"address payable","name":"bidder","type":"address"},{"internalType":"address","name":"currencyAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint8","name":"marketplaceFee","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionLengthExtension","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_auctionType","type":"bytes32"},{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_startingAmount","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_lengthOfAuction","type":"uint256"},{"internalType":"uint256","name":"_startTime","type":"uint256"},{"internalType":"address payable[]","name":"_splitAddresses","type":"address[]"},{"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"configureAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lengthOfAuction","type":"uint256"},{"internalType":"address payable[]","name":"_splitAddresses","type":"address[]"},{"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"convertOfferToAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getAuctionDetails","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address payable[]","name":"","type":"address[]"},{"internalType":"uint8[]","name":"","type":"uint8[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_marketplaceSettings","type":"address"},{"internalType":"address","name":"_royaltyRegistry","type":"address"},{"internalType":"address","name":"_royaltyEngine","type":"address"},{"internalType":"address","name":"_spaceOperatorRegistry","type":"address"},{"internalType":"address","name":"_approvedTokenRegistry","type":"address"},{"internalType":"address","name":"_payments","type":"address"},{"internalType":"address","name":"_stakingRegistry","type":"address"},{"internalType":"address","name":"_networkBeneficiary","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"marketplaceSettings","outputs":[{"internalType":"contract IMarketplaceSettings","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAuctionLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumBidIncreasePercentage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"networkBeneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"offerCancelationDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"payments","outputs":[{"internalType":"contract IPayments","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"royaltyEngine","outputs":[{"internalType":"contract IRoyaltyEngineV1","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltyRegistry","outputs":[{"internalType":"contract IERC721CreatorRoyalty","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"settleAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"spaceOperatorRegistry","outputs":[{"internalType":"contract ISpaceOperatorRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"superRareAuctionHouse","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"superRareMarketplace","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenAuctions","outputs":[{"internalType":"address payable","name":"auctionCreator","type":"address"},{"internalType":"uint256","name":"creationBlock","type":"uint256"},{"internalType":"uint256","name":"startingTime","type":"uint256"},{"internalType":"uint256","name":"lengthOfAuction","type":"uint256"},{"internalType":"address","name":"currencyAddress","type":"address"},{"internalType":"uint256","name":"minimumBid","type":"uint256"},{"internalType":"bytes32","name":"auctionType","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"tokenCurrentOffers","outputs":[{"internalType":"address payable","name":"buyer","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint8","name":"marketplaceFee","type":"uint8"},{"internalType":"bool","name":"convertible","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"tokenSalePrices","outputs":[{"internalType":"address payable","name":"seller","type":"address"},{"internalType":"address","name":"currencyAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506158e9806100206000396000f3fe6080604052600436106101d75760003560e01c80636b534ed011610102578063a6d23e1011610095578063c47c35c111610064578063c47c35c11461090c578063c90b871414610997578063daa26499146109ac578063f2fde38b146109c1576101d7565b8063a6d23e1014610893578063b23afc26146108a8578063b5678588146108bd578063ba50b632146108f7576101d7565b80638a29e2de116100d15780638a29e2de146106f75780638da5cb5b146107635780639041a0ec14610778578063a11b07121461087e576101d7565b80636b534ed0146106695780636fe9f44c1461067e578063715018a6146106a9578063859b97fe146106be576101d7565b8063155a56b11161017a5780633bc3d9be116101495780633bc3d9be146105f15780634c94c90c146106065780635138b08c1461061b5780636240cd1c14610654576101d7565b8063155a56b1146104845780631a2ac30f14610499578063299a0e1e146105065780632c41905314610574576101d7565b80630a5c4ed5116101b65780630a5c4ed51461031e5780630bcba09d146103455780630cd87c681461035a5780630e519ef91461046f576101d7565b80629d9aa9146101dc5780630141c5901461020d578063060d9eeb14610222575b600080fd5b3480156101e857600080fd5b506101f16109f4565b604080516001600160a01b039092168252519081900360200190f35b34801561021957600080fd5b506101f1610a03565b34801561022e57600080fd5b5061031c600480360360e081101561024557600080fd5b6001600160a01b03823581169260208101359260408201359092169160608201359160808101359181019060c0810160a082013564010000000081111561028b57600080fd5b82018360208201111561029d57600080fd5b803590602001918460208302840111640100000000831117156102bf57600080fd5b9193909290916020810190356401000000008111156102dd57600080fd5b8201836020820111156102ef57600080fd5b8035906020019184602083028401116401000000008311171561031157600080fd5b509092509050610a12565b005b34801561032a57600080fd5b50610333611299565b60408051918252519081900360200190f35b34801561035157600080fd5b506101f161129f565b34801561036657600080fd5b506103936004803603604081101561037d57600080fd5b506001600160a01b0381351690602001356112ae565b604051808a6001600160a01b03168152602001898152602001888152602001878152602001866001600160a01b031681526020018581526020018481526020018060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156104135781810151838201526020016103fb565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561045257818101518382015260200161043a565b505050509050019b50505050505050505050505060405180910390f35b34801561047b57600080fd5b5061033361145c565b34801561049057600080fd5b50610333611462565b3480156104a557600080fd5b506104dc600480360360608110156104bc57600080fd5b506001600160a01b03813581169160208101359160409091013516611467565b604080516001600160a01b0394851681529290931660208301528183015290519081900360600190f35b34801561051257600080fd5b5061053f6004803603604081101561052957600080fd5b506001600160a01b0381351690602001356114a6565b604080516001600160a01b0395861681529390941660208401528284019190915260ff16606082015290519081900360800190f35b34801561058057600080fd5b506105b76004803603606081101561059757600080fd5b506001600160a01b038135811691602081013591604090910135166114e8565b604080516001600160a01b03909616865260208601949094528484019290925260ff16606084015215156080830152519081900360a00190f35b3480156105fd57600080fd5b506101f1611536565b34801561061257600080fd5b506101f1611545565b34801561062757600080fd5b5061031c6004803603604081101561063e57600080fd5b506001600160a01b038135169060200135611554565b34801561066057600080fd5b506101f1611a70565b34801561067557600080fd5b506101f1611a7f565b34801561068a57600080fd5b50610693611a8e565b6040805160ff9092168252519081900360200190f35b3480156106b557600080fd5b5061031c611a9e565b3480156106ca57600080fd5b5061031c600480360360408110156106e157600080fd5b506001600160a01b038135169060200135611b5c565b34801561070357600080fd5b5061031c600480360361010081101561071b57600080fd5b506001600160a01b038135811691602081013582169160408201358116916060810135821691608082013581169160a081013582169160c082013581169160e0013516611fd4565b34801561076f57600080fd5b506101f16121d9565b34801561078457600080fd5b5061031c600480360361012081101561079c57600080fd5b8135916001600160a01b0360208201358116926040830135926060810135926080820135169160a08201359160c081013591810190610100810160e08201356401000000008111156107ed57600080fd5b8201836020820111156107ff57600080fd5b8035906020019184602083028401116401000000008311171561082157600080fd5b91939092909160208101903564010000000081111561083f57600080fd5b82018360208201111561085157600080fd5b8035906020019184602083028401116401000000008311171561087357600080fd5b5090925090506121e8565b34801561088a57600080fd5b506101f1612880565b34801561089f57600080fd5b506101f161288f565b3480156108b457600080fd5b5061033361289e565b61031c600480360360808110156108d357600080fd5b506001600160a01b03813581169160208101359160408201351690606001356128b6565b34801561090357600080fd5b506101f16132a4565b34801561091857600080fd5b506109456004803603604081101561092f57600080fd5b506001600160a01b0381351690602001356132b3565b60405180886001600160a01b03168152602001878152602001868152602001858152602001846001600160a01b0316815260200183815260200182815260200197505050505050505060405180910390f35b3480156109a357600080fd5b50610333613307565b3480156109b857600080fd5b5061033361331c565b3480156109cd57600080fd5b5061031c600480360360208110156109e457600080fd5b50356001600160a01b0316613322565b609f546001600160a01b031681565b609a546001600160a01b031681565b610a1c8989613437565b610a268989613527565b610a3284848484613677565b610a3a6150b2565b6001600160a01b03808b16600090815260a6602090815260408083208d84528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e0860193909290830182828015610b0357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ae5575b5050505050815260200160088201805480602002602001604051908101604052809291908181526020018280548015610b7957602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411610b4a5790505b5050509190925250505060c08101519091501580610ba1575080516001600160a01b03163314155b610bdc5760405162461bcd60e51b81526004018080602001828103825260358152602001806156df6035913960400191505060405180910390fd5b60a154861115610c1d5760405162461bcd60e51b81526004018080602001828103825260288152602001806157cc6028913960400191505060405180910390fd5b610c25615113565b506001600160a01b03808b16600090815260a5602090815260408083208d845282528083208c85168452825291829020825160a081018452815490941680855260018201549285019290925260028101549284019290925260039091015460ff80821660608501526101009091041615156080830152331415610cef576040805162461bcd60e51b815260206004820152601260248201527f636f6e766572743a3a6f776e206f666665720000000000000000000000000000604482015290519081900360640190fd5b8060800151610d2f5760405162461bcd60e51b815260040180806020018281038252602f8152602001806154bb602f913960400191505060405180910390fd5b87816020015114610d715760405162461bcd60e51b815260040180806020018281038252603e8152602001806153de603e913960400191505060405180910390fd5b604051806101200160405280336001600160a01b031681526020014381526020014281526020018881526020018a6001600160a01b03168152602001826020015181526020016d21a7a62224a2afa0aaa1aa24a7a760911b81526020018787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040805160208781028281018201909352878252928301929091889188918291850190849080828437600081840152601f19601f8201169050808301925050505050505081525060a660008d6001600160a01b03166001600160a01b0316815260200190815260200160002060008c815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c0820151816006015560e0820151816007019080519060200190610f29929190615141565b506101008201518051610f469160088401916020909101906151a6565b5050506001600160a01b03808c16600090815260a5602090815260408083208e845282528083208d851680855290835281842080546001600160a01b03191681556001810185905560028101949094556003909301805461ffff191690558051608081018252855185168152808301939093528281018c905260975481517f8347592100000000000000000000000000000000000000000000000000000000815291519394606086019491169263834759219260048082019391829003018186803b15801561101457600080fd5b505afa158015611028573d6000803e3d6000fd5b505050506040513d602081101561103e57600080fd5b810190808051906020019092919050505060ff1681525060a760008d6001600160a01b03166001600160a01b0316815260200190815260200160002060008c815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030160006101000a81548160ff021916908360ff16021790555090505060008b9050806001600160a01b03166323b872dd33308e6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561118057600080fd5b505af1158015611194573d6000803e3d6000fd5b50505050336001600160a01b03168b8d6001600160a01b03167fdb89081d9a5399380ffbcc376a961ed023027fca462e08b3d23146e4c6ac62f28d428e8e60405180856001600160a01b0316815260200184815260200183815260200182815260200194505050505060405180910390a48a82600001516001600160a01b03168d6001600160a01b03167f189a468e632a450afd491f84aa9ae94addc6813c7e309a7b1b1223f88802a77d8d8d600160008060405180866001600160a01b031681526020018581526020018415158152602001838152602001826001600160a01b031681526020019550505050505060405180910390a4505050505050505050505050565b60a35481565b609c546001600160a01b031681565b60008060008060008060006060806112c46150b2565b6001600160a01b03808d16600090815260a6602090815260408083208f84528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e086019390929083018282801561138d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161136f575b505050505081526020016008820180548060200260200160405190810160405280929190818152602001828054801561140357602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116113d45790505b5050505050815250509050806000015181602001518260400151836060015184608001518560a001518660c001518760e00151886101000151995099509950995099509950995099509950509295985092959850929598565b60a15481565b600081565b60a46020908152600093845260408085208252928452828420905282529020805460018201546002909201546001600160a01b03918216929091169083565b60a760209081526000928352604080842090915290825290208054600182015460028301546003909301546001600160a01b0392831693919092169160ff1684565b60a560209081526000938452604080852082529284528284209052825290208054600182015460028301546003909301546001600160a01b0390921692909160ff8082169161010090041685565b609b546001600160a01b031681565b6099546001600160a01b031681565b61155c6150b2565b6001600160a01b03808416600090815260a6602090815260408083208684528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e086019390929083018282801561162557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611607575b505050505081526020016008820180548060200260200160405190810160405280929190818152602001828054801561169b57602002820191906000526020600020906000905b825461010083900a900460ff1681526020600192830181810494850194909303909202910180841161166c5790505b5050509190925250505060c0810151909150158015906116be5750604081015115155b6116f95760405162461bcd60e51b815260040180806020018281038252603181526020018061535f6031913960400191505060405180910390fd5b6060810151604082015161170c916137ae565b42101561174a5760405162461bcd60e51b815260040180806020018281038252602e815260200180615714602e913960400191505060405180910390fd5b611752615247565b506001600160a01b03808416600081815260a76020908152604080832087845282528083208151608081018352815487168152600180830154909716818501526002808301548285015260039283015460ff16606083015295855260a6845282852089865290935290832080546001600160a01b0319908116825595810184905593840183905583018290556004830180549094169093556005820181905560068201819055611805600783018261526e565b61181360088301600061528c565b50506001600160a01b03808516600090815260a760209081526040808320878452909152812080546001600160a01b0319908116825560018201805490911690556002810191909155600301805460ff1916905581518591166118e7578251604080516323b872dd60e01b81523060048201526001600160a01b039283166024820152604481018790529051918316916323b872dd9160648082019260009290919082900301818387803b1580156118ca57600080fd5b505af11580156118de573d6000803e3d6000fd5b50505050611a0b565b8151604080516323b872dd60e01b81523060048201526001600160a01b039283166024820152604481018790529051918316916323b872dd9160648082019260009290919082900301818387803b15801561194157600080fd5b505af1158015611955573d6000803e3d6000fd5b5050505061197d85858560800151856040015187600001518860e00151896101000151613811565b609754604080517f5a3c652d0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018890526001604483015291519190921691635a3c652d91606480830192600092919082900301818387803b1580156119f257600080fd5b505af1158015611a06573d6000803e3d6000fd5b505050505b81518351608085015160408086015181516001600160a01b0394851681529284166020840152828201525187938316928916917fef4e2262a841641690bb931801dc0d1923e6b417cd217f91f8049d8aa9f5f086919081900360600190a45050505050565b609d546001600160a01b031681565b60a0546001600160a01b031681565b60a054600160a01b900460ff1681565b611aa6613fd7565b6001600160a01b0316611ab76121d9565b6001600160a01b031614611b12576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b611b646150b2565b6001600160a01b03808416600090815260a6602090815260408083208684528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e0860193909290830182828015611c2d57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c0f575b5050505050815260200160088201805480602002602001604051908101604052809291908181526020018280548015611ca357602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411611c745790505b5050509190925250505060c08101519091508390611cf25760405162461bcd60e51b815260040180806020018281038252602f81526020018061541c602f913960400191505060405180910390fd5b60408201511580611d065750816040015142105b611d415760405162461bcd60e51b815260040180806020018281038252602d815260200180615390602d913960400191505060405180910390fd5b81516001600160a01b0316331480611dd95750336001600160a01b0316816001600160a01b0316636352211e856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611da257600080fd5b505afa158015611db6573d6000803e3d6000fd5b505050506040513d6020811015611dcc57600080fd5b50516001600160a01b0316145b611e145760405162461bcd60e51b81526004018080602001828103825260288152602001806155186028913960400191505060405180910390fd5b6001600160a01b038416600090815260a660209081526040808320868452909152812080546001600160a01b031990811682556001820183905560028201839055600382018390556004820180549091169055600581018290556006810182905590611e83600783018261526e565b611e9160088301600061528c565b5050306001600160a01b0316816001600160a01b0316636352211e856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611ee157600080fd5b505afa158015611ef5573d6000803e3d6000fd5b505050506040513d6020811015611f0b57600080fd5b50516001600160a01b03161415611f8957604080516323b872dd60e01b81523060048201523360248201526044810185905290516001600160a01b038316916323b872dd91606480830192600092919082900301818387803b158015611f7057600080fd5b505af1158015611f84573d6000803e3d6000fd5b505050505b81600001516001600160a01b031683856001600160a01b03167f26d4510b556e779d6507640413e013206e44c8f5d018c7c74ed8926f3f024a9c60405160405180910390a450505050565b600054610100900460ff1680611fed5750611fed613fdb565b80611ffb575060005460ff16155b6120365760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015612061576000805460ff1961ff0019909116610100171660011790555b6001600160a01b03891661207457600080fd5b6001600160a01b03881661208757600080fd5b6001600160a01b03871661209a57600080fd5b6001600160a01b0386166120ad57600080fd5b6001600160a01b0385166120c057600080fd5b6001600160a01b0384166120d357600080fd5b6001600160a01b0382166120e657600080fd5b609780546001600160a01b03199081166001600160a01b038c8116919091179092556098805482168b84161790556099805482168a8416179055609c80548216898416179055609d80548216888416179055609e80548216878416179055609f8054821686841617905560a08054909116918416919091177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740a000000000000000000000000000000000000000017905562093a8060a15561038460a25561012c60a3556121b4613fec565b6121bc61409e565b80156121ce576000805461ff00191690555b505050505050505050565b6033546001600160a01b031690565b6121f187614133565b6121fb8a8a613437565b6122058a8a613527565b61221184848484613677565b61221a8b614228565b60a15486111561225b5760405162461bcd60e51b81526004018080602001828103825260238152602001806155ff6023913960400191505060405180910390fd5b6122636150b2565b6001600160a01b03808c16600090815260a6602090815260408083208e84528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e086019390929083018282801561232c57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161230e575b50505050508152602001600882018054806020026020016040519081016040528092919081815260200182805480156123a257602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116123735790505b5050509190925250505060c081015190915015806123ca575080516001600160a01b03163314155b6124055760405162461bcd60e51b81526004018080602001828103825260308152602001806156646030913960400191505060405180910390fd5b600087116124445760405162461bcd60e51b81526004018080602001828103825260248152602001806156bb6024913960400191505060405180910390fd5b6d21a7a62224a2afa0aaa1aa24a7a760911b8c14156124a1576000891161249c5760405162461bcd60e51b815260040180806020018281038252603381526020018061581e6033913960400191505060405180910390fd5b6124fb565b7029a1a422a22aa622a22fa0aaa1aa24a7a760791b8c14156124fb574286116124fb5760405162461bcd60e51b81526004018080602001828103825260398152602001806157936039913960400191505060405180910390fd5b609760009054906101000a90046001600160a01b03166001600160a01b031663f9a23e866040518163ffffffff1660e01b815260040160206040518083038186803b15801561254957600080fd5b505afa15801561255d573d6000803e3d6000fd5b505050506040513d602081101561257357600080fd5b50518911156125b35760405162461bcd60e51b81526004018080602001828103825260428152602001806156226042913960600191505060405180910390fd5b60408051610120810182523381524360208201529081016d21a7a62224a2afa0aaa1aa24a7a760911b8e146125e857876125eb565b60005b8152602001888152602001896001600160a01b031681526020018a81526020018d81526020018686808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040805160208681028281018201909352868252928301929091879187918291850190849080828437600081840152601f19601f8201169050808301925050505050505081525060a660008d6001600160a01b03166001600160a01b0316815260200190815260200160002060008c815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c0820151816006015560e082015181600701908051906020019061276c929190615141565b5061010082015180516127899160088401916020909101906151a6565b5050507029a1a422a22aa622a22fa0aaa1aa24a7a760791b8c141561281957604080516323b872dd60e01b8152336004820152306024820152604481018c905290518c916001600160a01b038316916323b872dd9160648082019260009290919082900301818387803b1580156127ff57600080fd5b505af1158015612813573d6000803e3d6000fd5b50505050505b604080516001600160a01b038a81168252602082018990528183018c9052606082018a9052915133928d92908f16917fdb89081d9a5399380ffbcc376a961ed023027fca462e08b3d23146e4c6ac62f29181900360800190a4505050505050505050505050565b6098546001600160a01b031681565b609e546001600160a01b031681565b7029a1a422a22aa622a22fa0aaa1aa24a7a760791b81565b6002606554141561290e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002606555609754604080516361fe24a960e11b8152600481018490529051600092612999926001600160a01b039091169163c3fc495291602480820192602092909190829003018186803b15801561296657600080fd5b505afa15801561297a573d6000803e3d6000fd5b505050506040513d602081101561299057600080fd5b505183906137ae565b90506129a583826142af565b6129ad6150b2565b6001600160a01b03808716600090815260a6602090815260408083208984528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e0860193909290830182828015612a7657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612a58575b5050505050815260200160088201805480602002602001604051908101604052809291908181526020018280548015612aec57602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411612abd5790505b5050509190925250505060c0810151909150612b395760405162461bcd60e51b81526004018080602001828103825260218152602001806153bd6021913960400191505060405180910390fd5b80516001600160a01b0316331415612b825760405162461bcd60e51b815260040180806020018281038252602481526020018061533b6024913960400191505060405180910390fd5b8060400151421015612bdb576040805162461bcd60e51b815260206004820152601860248201527f6269643a3a41756374696f6e206e6f74206163746976652e0000000000000000604482015290519081900360640190fd5b80608001516001600160a01b0316846001600160a01b031614612c2f5760405162461bcd60e51b81526004018080602001828103825260308152602001806158516030913960400191505060405180910390fd5b60008311612c84576040805162461bcd60e51b815260206004820152601060248201527f6269643a3a43616e6e6f74206265203000000000000000000000000000000000604482015290519081900360640190fd5b609760009054906101000a90046001600160a01b03166001600160a01b031663f9a23e866040518163ffffffff1660e01b815260040160206040518083038186803b158015612cd257600080fd5b505afa158015612ce6573d6000803e3d6000fd5b505050506040513d6020811015612cfc57600080fd5b5051831115612d3c5760405162461bcd60e51b81526004018080602001828103825260218152602001806157426021913960400191505060405180910390fd5b8060a00151831015612d7f5760405162461bcd60e51b81526004018080602001828103825260268152602001806152c36026913960400191505060405180910390fd5b60408101511580612da1575060608101516040820151612d9e916137ae565b42105b612df2576040805162461bcd60e51b815260206004820152601460248201527f6269643a3a4d757374206265206163746976652e000000000000000000000000604482015290519081900360640190fd5b612dfa615247565b506001600160a01b03808716600090815260a760209081526040808320898452825291829020825160808101845281548516815260018201549094169184019190915260028101549183018290526003015460ff908116606084015260a054612e8892612e7d92606492612e779291600160a01b90910416614398565b906143f1565b6040830151906137ae565b841015612ec65760405162461bcd60e51b81526004018080602001828103825260318152602001806155406031913960400191505060405180910390fd5b60008790506000816001600160a01b0316636352211e896040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015612f1157600080fd5b505afa158015612f25573d6000803e3d6000fd5b505050506040513d6020811015612f3b57600080fd5b505184519091506001600160a01b0380831691161480612f6357506001600160a01b03811630145b612f9e5760405162461bcd60e51b815260040180806020018281038252602381526020018061544b6023913960400191505060405180910390fd5b806001600160a01b031684600001516001600160a01b03161415612fc657612fc68989613527565b612fd08786614458565b612feb878460400151856060015160ff16866000015161467d565b6040518060800160405280336001600160a01b03168152602001886001600160a01b03168152602001878152602001609760009054906101000a90046001600160a01b03166001600160a01b031663834759216040518163ffffffff1660e01b815260040160206040518083038186803b15801561306857600080fd5b505afa15801561307c573d6000803e3d6000fd5b505050506040513d602081101561309257600080fd5b505160ff9081169091526001600160a01b03808c16600090815260a7602090815260408083208e84528252808320865181549086166001600160a01b03199182161782559287015160018201805491909616931692909217909355848301516002820155606090940151600390940180549490931660ff199094169390931790915585015181906131b7576001600160a01b03808c16600090815260a6602090815260408083208e845290915280822042600290910155885181516323b872dd60e01b81529084166004820152306024820152604481018e90529051928716926323b872dd9260648084019391929182900301818387803b15801561319657600080fd5b505af11580156131aa573d6000803e3d6000fd5b505050506001915061322e565b60a2546131df426131d989606001518a604001516137ae90919063ffffffff16565b9061486a565b101561322e5761320286604001516131d960a254426137ae90919063ffffffff16565b6001600160a01b038c16600090815260a6602090815260408083208e8452909152902060030181905590505b8451604080516001600160a01b038c81168252602082018c90528515158284015260608201859052928316608082015290518c923392908f16917f189a468e632a450afd491f84aa9ae94addc6813c7e309a7b1b1223f88802a77d9181900360a00190a450506001606555505050505050505050565b6097546001600160a01b031681565b60a660209081526000928352604080842090915290825290208054600182015460028301546003840154600485015460058601546006909601546001600160a01b0395861696949593949293909116919087565b6d21a7a62224a2afa0aaa1aa24a7a760911b81565b60a25481565b61332a613fd7565b6001600160a01b031661333b6121d9565b6001600160a01b031614613396576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166133db5760405162461bcd60e51b81526004018080602001828103825260268152602001806153156026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b604080517f6352211e000000000000000000000000000000000000000000000000000000008152600481018390529051839133916001600160a01b03841691636352211e916024808301926020929190829003018186803b15801561349b57600080fd5b505afa1580156134af573d6000803e3d6000fd5b505050506040513d60208110156134c557600080fd5b50516001600160a01b031614613522576040805162461bcd60e51b815260206004820152601e60248201527f73656e646572206d7573742062652074686520746f6b656e206f776e65720000604482015290519081900360640190fd5b505050565b60008290506000816001600160a01b0316636352211e846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561357257600080fd5b505afa158015613586573d6000803e3d6000fd5b505050506040513d602081101561359c57600080fd5b5051604080517fe985e9c50000000000000000000000000000000000000000000000000000000081526001600160a01b03808416600483015230602483015291519293509084169163e985e9c591604480820192602092909190829003018186803b15801561360a57600080fd5b505afa15801561361e573d6000803e3d6000fd5b505050506040513d602081101561363457600080fd5b50516136715760405162461bcd60e51b81526004018080602001828103825260218152602001806155ba6021913960400191505060405180910390fd5b50505050565b826136b35760405162461bcd60e51b81526004018080602001828103825260278152602001806156946027913960400191505060405180910390fd5b60058311156136f35760405162461bcd60e51b81526004018080602001828103825260248152602001806155db6024913960400191505060405180910390fd5b8281146137315760405162461bcd60e51b815260040180806020018281038252602c8152602001806152e9602c913960400191505060405180910390fd5b6000805b828110156137675783838281811061374957fe5b9050602002013560ff1660ff16820191508080600101915050613735565b50806064146137a75760405162461bcd60e51b815260040180806020018281038252602781526020018061546e6027913960400191505060405180910390fd5b5050505050565b600082820183811015613808576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b80518251146138515760405162461bcd60e51b81526004018080602001828103825260338152602001806158816033913960400191505060405180910390fd5b609754604080516361fe24a960e11b815260048101879052905186926000926001600160a01b039091169163c3fc495291602480820192602092909190829003018186803b1580156138a257600080fd5b505afa1580156138b6573d6000803e3d6000fd5b505050506040513d60208110156138cc57600080fd5b50516040805160018082528183019092529192506060919060208083019080368337505060a05482519293506001600160a01b03169183915060009061390e57fe5b6001600160a01b039290921660209283029190910190910152604080516001808252818301909252606091816020016020820280368337019050509050828160008151811061395957fe5b602002602001018181525050613971898484846148c7565b609754604080517f511bc84c0000000000000000000000000000000000000000000000000000000081526001600160a01b038e81166004830152602482018e90529151919092169163511bc84c916044808301926020929190829003018186803b1580156139de57600080fd5b505afa1580156139f2573d6000803e3d6000fd5b505050506040513d6020811015613a0857600080fd5b5051613cb957604080516001808252818301909252606091602080830190803683375050609c54604080517f5dc22eff0000000000000000000000000000000000000000000000000000000081526001600160a01b038d811660048301529151949550911692635dc22eff92506024808301926020929190829003018186803b158015613a9457600080fd5b505afa158015613aa8573d6000803e3d6000fd5b505050506040513d6020811015613abe57600080fd5b505115613bc957609c54604080517f2260494f0000000000000000000000000000000000000000000000000000000081526001600160a01b038b8116600483015291516000939290921691632260494f91602480820192602092909190829003018186803b158015613b2f57600080fd5b505afa158015613b43573d6000803e3d6000fd5b505050506040513d6020811015613b5957600080fd5b505160ff169050613b79613b726064612e778d85614398565b879061486a565b9550613b8a6064612e778c84614398565b82600081518110613b9757fe5b602002602001018181525050613bc38b83600081518110613bb457fe5b602002602001015186856148c7565b50613cb3565b609754604080517fb28a7bad0000000000000000000000000000000000000000000000000000000081526001600160a01b038f811660048301529151600093929092169163b28a7bad91602480820192602092909190829003018186803b158015613c3357600080fd5b505afa158015613c47573d6000803e3d6000fd5b505050506040513d6020811015613c5d57600080fd5b505160ff169050613c76613b726064612e778d85614398565b9550613c876064612e778c84614398565b82600081518110613c9457fe5b602002602001018181525050613cb18b83600081518110613bb457fe5b505b50613edf565b609954604080517ff533b8020000000000000000000000000000000000000000000000000000000081526001600160a01b038e81166004830152602482018e9052604482018c905291516060938493169163f533b80291606480830192600092919082900301818387803b158015613d3057600080fd5b505af1158015613d44573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040908152811015613d6d57600080fd5b8101908080516040519392919084640100000000821115613d8d57600080fd5b908301906020820185811115613da257600080fd5b8251866020820283011164010000000082111715613dbf57600080fd5b82525081516020918201928201910280838360005b83811015613dec578181015183820152602001613dd4565b5050505090500160405260200180516040519392919084640100000000821115613e1557600080fd5b908301906020820185811115613e2a57600080fd5b8251866020820283011164010000000082111715613e4757600080fd5b82525081516020918201928201910280838360005b83811015613e74578181015183820152602001613e5c565b50505050905001604052505050915091506000805b8251811015613ec257613eb8838281518110613ea157fe5b6020026020010151836137ae90919063ffffffff16565b9150600101613e89565b50613ecd878261486a565b9650613edb8c8285856148c7565b5050505b6060865167ffffffffffffffff81118015613ef957600080fd5b50604051908082528060200260200182016040528015613f23578160200160208202803683370190505b5090506000805b8851811015613fbb57613f616064612e778a8481518110613f4757fe5b602002602001015160ff168a61439890919063ffffffff16565b838281518110613f6d57fe5b602002602001018181525050613fb1613faa6064612e778b8581518110613f9057fe5b602002602001015160ff168b61439890919063ffffffff16565b83906137ae565b9150600101613f2a565b50613fc88b828a856148c7565b50505050505050505050505050565b3390565b6000613fe630614b20565b15905090565b600054610100900460ff16806140055750614005613fdb565b80614013575060005460ff16155b61404e5760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015614079576000805460ff1961ff0019909116610100171660011790555b614081614b26565b614089614bc6565b801561409b576000805461ff00191690555b50565b600054610100900460ff16806140b757506140b7613fdb565b806140c5575060005460ff16155b6141005760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff1615801561412b576000805460ff1961ff0019909116610100171660011790555b614089614cbf565b6001600160a01b03811615806141d75750609d54604080517f2d5ad3d50000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015291519190921691632d5ad3d5916024808301926020929190829003018186803b1580156141aa57600080fd5b505afa1580156141be573d6000803e3d6000fd5b505050506040513d60208110156141d457600080fd5b50515b61409b576040805162461bcd60e51b815260206004820152601560248201527f4e6f7420617070726f7665642063757272656e63790000000000000000000000604482015290519081900360640190fd5b6d21a7a62224a2afa0aaa1aa24a7a760911b811415801561425d57507029a1a422a22aa622a22fa0aaa1aa24a7a760791b8114155b1561409b576040805162461bcd60e51b815260206004820152601460248201527f496e76616c69642041756374696f6e2054797065000000000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166142c257614394565b604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523360048201523060248201529051839183916001600160a01b0384169163dd62ed3e916044808301926020929190829003018186803b15801561432b57600080fd5b505afa15801561433f573d6000803e3d6000fd5b505050506040513d602081101561435557600080fd5b505110156135225760405162461bcd60e51b81526004018080602001828103825260308152602001806157636030913960400191505060405180910390fd5b5050565b6000826143a75750600061380b565b828202828482816143b457fe5b04146138085760405162461bcd60e51b81526004018080602001828103825260218152602001806155996021913960400191505060405180910390fd5b6000808211614447576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161445057fe5b049392505050565b6001600160a01b0382166144bf578034146144ba576040805162461bcd60e51b815260206004820152601360248201527f6e6f7420656e6f756768206574682073656e7400000000000000000000000000604482015290519081900360640190fd5b614394565b34156144fc5760405162461bcd60e51b81526004018080602001828103825260288152602001806155716028913960400191505060405180910390fd5b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905183916000916001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561456057600080fd5b505afa158015614574573d6000803e3d6000fd5b505050506040513d602081101561458a57600080fd5b505190506145a36001600160a01b038316333086614d65565b6000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156145f257600080fd5b505afa158015614606573d6000803e3d6000fd5b505050506040513d602081101561461c57600080fd5b505190508361462b828461486a565b146137a7576040805162461bcd60e51b815260206004820152601c60248201527f6e6f7420656e6f75676820746f6b656e73207472616e73666572656400000000604482015290519081900360640190fd5b8261468757613671565b60006146a261469b6064612e778787614398565b85906137ae565b90506001600160a01b03851661484d57609e54604080516001600160a01b038581166024830152604480830186905283518084039091018152606490920183526020820180516001600160e01b03167f410085df000000000000000000000000000000000000000000000000000000001781529251825160009560609593169387939092918291908083835b6020831061474d5780518252601f19909201916020918201910161472e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146147af576040519150601f19603f3d011682016040523d82523d6000602084013e6147b4565b606091505b50915091508181906148445760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156148095781810151838201526020016147f1565b50505050905090810190601f1680156148365780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50505050613671565b846148626001600160a01b0382168484614dbf565b505050505050565b6000828211156148c1576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6001600160a01b038416614ac757609e5460408051602481019182528451606482015284516000936060936001600160a01b039091169288927fc176e63900000000000000000000000000000000000000000000000000000000928992899282916044810191608490910190602080880191028083838f5b8381101561495757818101518382015260200161493f565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561499657818101518382015260200161497e565b50505050905001945050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518082805190602001908083835b60208310614a055780518252601f1990920191602091820191016149e6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614a67576040519150601f19603f3d011682016040523d82523d6000602084013e614a6c565b606091505b5091509150818190614abf5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156148095781810151838201526020016147f1565b505050613671565b8360005b835181101561486257614b18848281518110614ae357fe5b6020026020010151848381518110614af757fe5b6020026020010151846001600160a01b0316614dbf9092919063ffffffff16565b600101614acb565b3b151590565b600054610100900460ff1680614b3f5750614b3f613fdb565b80614b4d575060005460ff16155b614b885760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015614089576000805460ff1961ff001990911661010017166001179055801561409b576000805461ff001916905550565b600054610100900460ff1680614bdf5750614bdf613fdb565b80614bed575060005460ff16155b614c285760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015614c53576000805460ff1961ff0019909116610100171660011790555b6000614c5d613fd7565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350801561409b576000805461ff001916905550565b600054610100900460ff1680614cd85750614cd8613fdb565b80614ce6575060005460ff16155b614d215760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015614d4c576000805460ff1961ff0019909116610100171660011790555b6001606555801561409b576000805461ff001916905550565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052613671908590614e26565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b03167fa9059cbb000000000000000000000000000000000000000000000000000000001790526135229084905b6060614e7b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ed79092919063ffffffff16565b80519091501561352257808060200190516020811015614e9a57600080fd5b50516135225760405162461bcd60e51b815260040180806020018281038252602a8152602001806157f4602a913960400191505060405180910390fd5b6060614ee68484600085614ef0565b90505b9392505050565b606082471015614f315760405162461bcd60e51b81526004018080602001828103825260268152602001806154956026913960400191505060405180910390fd5b614f3a85614b20565b614f8b576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310614fca5780518252601f199092019160209182019101614fab565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461502c576040519150601f19603f3d011682016040523d82523d6000602084013e615031565b606091505b509150915061504182828661504c565b979650505050505050565b6060831561505b575081614ee9565b82511561506b5782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156148095781810151838201526020016147f1565b60405180610120016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081526020016000801916815260200160608152602001606081525090565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b828054828255906000526020600020908101928215615196579160200282015b8281111561519657825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190615161565b506151a29291506152ad565b5090565b82805482825590600052602060002090601f016020900481019282156151965791602002820160005b8382111561520d57835183826101000a81548160ff021916908360ff16021790555092602001926001016020816000010492830192600103026151cf565b801561523a5782816101000a81549060ff021916905560010160208160000104928301926001030261520d565b50506151a29291506152ad565b60408051608081018252600080825260208201819052918101829052606081019190915290565b508054600082559060005260206000209081019061409b91906152ad565b50805460008255601f01602090049060005260206000209081019061409b91905b5b808211156151a257600081556001016152ae56fe6269643a3a43616e6e6f74206265206c6f776572207468616e206d696e696d756d206269642e636865636b53706c6974733a3a53706c69747320616e6420726174696f73206d75737420626520657175616c4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573736269643a3a43616e6e6f7420626964206f6e20796f7572206f776e2061756374696f6e2e736574746c6541756374696f6e3a3a4d757374206861766520612063757272656e742076616c69642061756374696f6e2e63616e63656c41756374696f6e3a3a41756374696f6e206d757374206e6f74206861766520737461727465642e6269643a3a4d757374206861766520612063757272656e742061756374696f6e2e636f6e766572744f66666572546f41756374696f6e3a3a436f6e76657274696e67206f66666572207769746820646966666572656e7420616d6f756e742e63616e63656c41756374696f6e3a3a4d757374206861766520616e2061756374696f6e20636f6e666967757265642e6269643a3a41756374696f6e2063726561746f72206d757374206265206f776e65722e636865636b53706c6974733a3a546f74616c206d75737420626520657175616c20746f20313030416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c636f6e766572744f66666572546f41756374696f6e3a3a4f66666572206973206e6f7420636f6e7665727469626c65496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a656463616e63656c41756374696f6e3a3a4d7573742062652063726561746f72206f72206f776e65722e6269643a3a4d75737420626520686967686572207468616e207072657620626964202b206d696e20696e6372656173652e6d73672e76616c75652073686f756c642062652030207768656e206e6f74207573696e6720657468536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776f776e6572206d757374206861766520617070726f76656420636f6e7472616374636865636b53706c6974733a3a53706c6974206578636565646564206d61782073697a65636f6e66696775726541756374696f6e3a3a41756374696f6e20746f6f206c6f6e672e636f6e66696775726541756374696f6e3a3a43616e6e6f7420736574207374617274696e6720707269636520686967686572207468616e206d61782076616c75652e636f6e66696775726541756374696f6e3a3a43616e6e6f74206861766520612063757272656e742061756374696f6e2e636865636b53706c6974733a3a4d7573742068617665206174206c6561737420312073706c6974636f6e66696775726541756374696f6e3a3a4c656e677468206d757374206265203e2030636f6e766572744f66666572546f41756374696f6e3a3a43616e6e6f74206861766520612063757272656e742061756374696f6e2e736574746c6541756374696f6e3a3a43616e206f6e6c7920736574746c6520656e6465642061756374696f6e732e6269643a3a4d757374206265206c657373207468616e206d61782076616c75652e73656e646572206e6565647320746f20617070726f7665206d61726b6574706c61636520666f722063757272656e6379636f6e66696775726541756374696f6e3a3a5363686564756c65642061756374696f6e2063616e6e6f7420737461727420696e20706173742e636f6e766572744f66666572546f41756374696f6e3a3a41756374696f6e20746f6f206c6f6e672e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564636f6e66696775726541756374696f6e3a3a436f6c646965207374617274696e67207072696365206d757374206265203e20306269643a3a43757272656e6379206d75737420626520696e20636f6e666967757265642064656e6f6d696e6174696f6e4e756d626572206f662073706c69742061646472657373657320616e6420726174696f73206d75737420626520657175616c2ea2646970667358221220bab2ad1dbb352e7d3bc0ecd2526d514f19aab8451578a601bb190165663d4f7864736f6c63430007030033

Deployed Bytecode

0x6080604052600436106101d75760003560e01c80636b534ed011610102578063a6d23e1011610095578063c47c35c111610064578063c47c35c11461090c578063c90b871414610997578063daa26499146109ac578063f2fde38b146109c1576101d7565b8063a6d23e1014610893578063b23afc26146108a8578063b5678588146108bd578063ba50b632146108f7576101d7565b80638a29e2de116100d15780638a29e2de146106f75780638da5cb5b146107635780639041a0ec14610778578063a11b07121461087e576101d7565b80636b534ed0146106695780636fe9f44c1461067e578063715018a6146106a9578063859b97fe146106be576101d7565b8063155a56b11161017a5780633bc3d9be116101495780633bc3d9be146105f15780634c94c90c146106065780635138b08c1461061b5780636240cd1c14610654576101d7565b8063155a56b1146104845780631a2ac30f14610499578063299a0e1e146105065780632c41905314610574576101d7565b80630a5c4ed5116101b65780630a5c4ed51461031e5780630bcba09d146103455780630cd87c681461035a5780630e519ef91461046f576101d7565b80629d9aa9146101dc5780630141c5901461020d578063060d9eeb14610222575b600080fd5b3480156101e857600080fd5b506101f16109f4565b604080516001600160a01b039092168252519081900360200190f35b34801561021957600080fd5b506101f1610a03565b34801561022e57600080fd5b5061031c600480360360e081101561024557600080fd5b6001600160a01b03823581169260208101359260408201359092169160608201359160808101359181019060c0810160a082013564010000000081111561028b57600080fd5b82018360208201111561029d57600080fd5b803590602001918460208302840111640100000000831117156102bf57600080fd5b9193909290916020810190356401000000008111156102dd57600080fd5b8201836020820111156102ef57600080fd5b8035906020019184602083028401116401000000008311171561031157600080fd5b509092509050610a12565b005b34801561032a57600080fd5b50610333611299565b60408051918252519081900360200190f35b34801561035157600080fd5b506101f161129f565b34801561036657600080fd5b506103936004803603604081101561037d57600080fd5b506001600160a01b0381351690602001356112ae565b604051808a6001600160a01b03168152602001898152602001888152602001878152602001866001600160a01b031681526020018581526020018481526020018060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156104135781810151838201526020016103fb565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561045257818101518382015260200161043a565b505050509050019b50505050505050505050505060405180910390f35b34801561047b57600080fd5b5061033361145c565b34801561049057600080fd5b50610333611462565b3480156104a557600080fd5b506104dc600480360360608110156104bc57600080fd5b506001600160a01b03813581169160208101359160409091013516611467565b604080516001600160a01b0394851681529290931660208301528183015290519081900360600190f35b34801561051257600080fd5b5061053f6004803603604081101561052957600080fd5b506001600160a01b0381351690602001356114a6565b604080516001600160a01b0395861681529390941660208401528284019190915260ff16606082015290519081900360800190f35b34801561058057600080fd5b506105b76004803603606081101561059757600080fd5b506001600160a01b038135811691602081013591604090910135166114e8565b604080516001600160a01b03909616865260208601949094528484019290925260ff16606084015215156080830152519081900360a00190f35b3480156105fd57600080fd5b506101f1611536565b34801561061257600080fd5b506101f1611545565b34801561062757600080fd5b5061031c6004803603604081101561063e57600080fd5b506001600160a01b038135169060200135611554565b34801561066057600080fd5b506101f1611a70565b34801561067557600080fd5b506101f1611a7f565b34801561068a57600080fd5b50610693611a8e565b6040805160ff9092168252519081900360200190f35b3480156106b557600080fd5b5061031c611a9e565b3480156106ca57600080fd5b5061031c600480360360408110156106e157600080fd5b506001600160a01b038135169060200135611b5c565b34801561070357600080fd5b5061031c600480360361010081101561071b57600080fd5b506001600160a01b038135811691602081013582169160408201358116916060810135821691608082013581169160a081013582169160c082013581169160e0013516611fd4565b34801561076f57600080fd5b506101f16121d9565b34801561078457600080fd5b5061031c600480360361012081101561079c57600080fd5b8135916001600160a01b0360208201358116926040830135926060810135926080820135169160a08201359160c081013591810190610100810160e08201356401000000008111156107ed57600080fd5b8201836020820111156107ff57600080fd5b8035906020019184602083028401116401000000008311171561082157600080fd5b91939092909160208101903564010000000081111561083f57600080fd5b82018360208201111561085157600080fd5b8035906020019184602083028401116401000000008311171561087357600080fd5b5090925090506121e8565b34801561088a57600080fd5b506101f1612880565b34801561089f57600080fd5b506101f161288f565b3480156108b457600080fd5b5061033361289e565b61031c600480360360808110156108d357600080fd5b506001600160a01b03813581169160208101359160408201351690606001356128b6565b34801561090357600080fd5b506101f16132a4565b34801561091857600080fd5b506109456004803603604081101561092f57600080fd5b506001600160a01b0381351690602001356132b3565b60405180886001600160a01b03168152602001878152602001868152602001858152602001846001600160a01b0316815260200183815260200182815260200197505050505050505060405180910390f35b3480156109a357600080fd5b50610333613307565b3480156109b857600080fd5b5061033361331c565b3480156109cd57600080fd5b5061031c600480360360208110156109e457600080fd5b50356001600160a01b0316613322565b609f546001600160a01b031681565b609a546001600160a01b031681565b610a1c8989613437565b610a268989613527565b610a3284848484613677565b610a3a6150b2565b6001600160a01b03808b16600090815260a6602090815260408083208d84528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e0860193909290830182828015610b0357602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610ae5575b5050505050815260200160088201805480602002602001604051908101604052809291908181526020018280548015610b7957602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411610b4a5790505b5050509190925250505060c08101519091501580610ba1575080516001600160a01b03163314155b610bdc5760405162461bcd60e51b81526004018080602001828103825260358152602001806156df6035913960400191505060405180910390fd5b60a154861115610c1d5760405162461bcd60e51b81526004018080602001828103825260288152602001806157cc6028913960400191505060405180910390fd5b610c25615113565b506001600160a01b03808b16600090815260a5602090815260408083208d845282528083208c85168452825291829020825160a081018452815490941680855260018201549285019290925260028101549284019290925260039091015460ff80821660608501526101009091041615156080830152331415610cef576040805162461bcd60e51b815260206004820152601260248201527f636f6e766572743a3a6f776e206f666665720000000000000000000000000000604482015290519081900360640190fd5b8060800151610d2f5760405162461bcd60e51b815260040180806020018281038252602f8152602001806154bb602f913960400191505060405180910390fd5b87816020015114610d715760405162461bcd60e51b815260040180806020018281038252603e8152602001806153de603e913960400191505060405180910390fd5b604051806101200160405280336001600160a01b031681526020014381526020014281526020018881526020018a6001600160a01b03168152602001826020015181526020016d21a7a62224a2afa0aaa1aa24a7a760911b81526020018787808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040805160208781028281018201909352878252928301929091889188918291850190849080828437600081840152601f19601f8201169050808301925050505050505081525060a660008d6001600160a01b03166001600160a01b0316815260200190815260200160002060008c815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c0820151816006015560e0820151816007019080519060200190610f29929190615141565b506101008201518051610f469160088401916020909101906151a6565b5050506001600160a01b03808c16600090815260a5602090815260408083208e845282528083208d851680855290835281842080546001600160a01b03191681556001810185905560028101949094556003909301805461ffff191690558051608081018252855185168152808301939093528281018c905260975481517f8347592100000000000000000000000000000000000000000000000000000000815291519394606086019491169263834759219260048082019391829003018186803b15801561101457600080fd5b505afa158015611028573d6000803e3d6000fd5b505050506040513d602081101561103e57600080fd5b810190808051906020019092919050505060ff1681525060a760008d6001600160a01b03166001600160a01b0316815260200190815260200160002060008c815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030160006101000a81548160ff021916908360ff16021790555090505060008b9050806001600160a01b03166323b872dd33308e6040518463ffffffff1660e01b815260040180846001600160a01b03168152602001836001600160a01b031681526020018281526020019350505050600060405180830381600087803b15801561118057600080fd5b505af1158015611194573d6000803e3d6000fd5b50505050336001600160a01b03168b8d6001600160a01b03167fdb89081d9a5399380ffbcc376a961ed023027fca462e08b3d23146e4c6ac62f28d428e8e60405180856001600160a01b0316815260200184815260200183815260200182815260200194505050505060405180910390a48a82600001516001600160a01b03168d6001600160a01b03167f189a468e632a450afd491f84aa9ae94addc6813c7e309a7b1b1223f88802a77d8d8d600160008060405180866001600160a01b031681526020018581526020018415158152602001838152602001826001600160a01b031681526020019550505050505060405180910390a4505050505050505050505050565b60a35481565b609c546001600160a01b031681565b60008060008060008060006060806112c46150b2565b6001600160a01b03808d16600090815260a6602090815260408083208f84528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e086019390929083018282801561138d57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161136f575b505050505081526020016008820180548060200260200160405190810160405280929190818152602001828054801561140357602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116113d45790505b5050505050815250509050806000015181602001518260400151836060015184608001518560a001518660c001518760e00151886101000151995099509950995099509950995099509950509295985092959850929598565b60a15481565b600081565b60a46020908152600093845260408085208252928452828420905282529020805460018201546002909201546001600160a01b03918216929091169083565b60a760209081526000928352604080842090915290825290208054600182015460028301546003909301546001600160a01b0392831693919092169160ff1684565b60a560209081526000938452604080852082529284528284209052825290208054600182015460028301546003909301546001600160a01b0390921692909160ff8082169161010090041685565b609b546001600160a01b031681565b6099546001600160a01b031681565b61155c6150b2565b6001600160a01b03808416600090815260a6602090815260408083208684528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e086019390929083018282801561162557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611607575b505050505081526020016008820180548060200260200160405190810160405280929190818152602001828054801561169b57602002820191906000526020600020906000905b825461010083900a900460ff1681526020600192830181810494850194909303909202910180841161166c5790505b5050509190925250505060c0810151909150158015906116be5750604081015115155b6116f95760405162461bcd60e51b815260040180806020018281038252603181526020018061535f6031913960400191505060405180910390fd5b6060810151604082015161170c916137ae565b42101561174a5760405162461bcd60e51b815260040180806020018281038252602e815260200180615714602e913960400191505060405180910390fd5b611752615247565b506001600160a01b03808416600081815260a76020908152604080832087845282528083208151608081018352815487168152600180830154909716818501526002808301548285015260039283015460ff16606083015295855260a6845282852089865290935290832080546001600160a01b0319908116825595810184905593840183905583018290556004830180549094169093556005820181905560068201819055611805600783018261526e565b61181360088301600061528c565b50506001600160a01b03808516600090815260a760209081526040808320878452909152812080546001600160a01b0319908116825560018201805490911690556002810191909155600301805460ff1916905581518591166118e7578251604080516323b872dd60e01b81523060048201526001600160a01b039283166024820152604481018790529051918316916323b872dd9160648082019260009290919082900301818387803b1580156118ca57600080fd5b505af11580156118de573d6000803e3d6000fd5b50505050611a0b565b8151604080516323b872dd60e01b81523060048201526001600160a01b039283166024820152604481018790529051918316916323b872dd9160648082019260009290919082900301818387803b15801561194157600080fd5b505af1158015611955573d6000803e3d6000fd5b5050505061197d85858560800151856040015187600001518860e00151896101000151613811565b609754604080517f5a3c652d0000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018890526001604483015291519190921691635a3c652d91606480830192600092919082900301818387803b1580156119f257600080fd5b505af1158015611a06573d6000803e3d6000fd5b505050505b81518351608085015160408086015181516001600160a01b0394851681529284166020840152828201525187938316928916917fef4e2262a841641690bb931801dc0d1923e6b417cd217f91f8049d8aa9f5f086919081900360600190a45050505050565b609d546001600160a01b031681565b60a0546001600160a01b031681565b60a054600160a01b900460ff1681565b611aa6613fd7565b6001600160a01b0316611ab76121d9565b6001600160a01b031614611b12576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6033546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3603380546001600160a01b0319169055565b611b646150b2565b6001600160a01b03808416600090815260a6602090815260408083208684528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e0860193909290830182828015611c2d57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611c0f575b5050505050815260200160088201805480602002602001604051908101604052809291908181526020018280548015611ca357602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411611c745790505b5050509190925250505060c08101519091508390611cf25760405162461bcd60e51b815260040180806020018281038252602f81526020018061541c602f913960400191505060405180910390fd5b60408201511580611d065750816040015142105b611d415760405162461bcd60e51b815260040180806020018281038252602d815260200180615390602d913960400191505060405180910390fd5b81516001600160a01b0316331480611dd95750336001600160a01b0316816001600160a01b0316636352211e856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611da257600080fd5b505afa158015611db6573d6000803e3d6000fd5b505050506040513d6020811015611dcc57600080fd5b50516001600160a01b0316145b611e145760405162461bcd60e51b81526004018080602001828103825260288152602001806155186028913960400191505060405180910390fd5b6001600160a01b038416600090815260a660209081526040808320868452909152812080546001600160a01b031990811682556001820183905560028201839055600382018390556004820180549091169055600581018290556006810182905590611e83600783018261526e565b611e9160088301600061528c565b5050306001600160a01b0316816001600160a01b0316636352211e856040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015611ee157600080fd5b505afa158015611ef5573d6000803e3d6000fd5b505050506040513d6020811015611f0b57600080fd5b50516001600160a01b03161415611f8957604080516323b872dd60e01b81523060048201523360248201526044810185905290516001600160a01b038316916323b872dd91606480830192600092919082900301818387803b158015611f7057600080fd5b505af1158015611f84573d6000803e3d6000fd5b505050505b81600001516001600160a01b031683856001600160a01b03167f26d4510b556e779d6507640413e013206e44c8f5d018c7c74ed8926f3f024a9c60405160405180910390a450505050565b600054610100900460ff1680611fed5750611fed613fdb565b80611ffb575060005460ff16155b6120365760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015612061576000805460ff1961ff0019909116610100171660011790555b6001600160a01b03891661207457600080fd5b6001600160a01b03881661208757600080fd5b6001600160a01b03871661209a57600080fd5b6001600160a01b0386166120ad57600080fd5b6001600160a01b0385166120c057600080fd5b6001600160a01b0384166120d357600080fd5b6001600160a01b0382166120e657600080fd5b609780546001600160a01b03199081166001600160a01b038c8116919091179092556098805482168b84161790556099805482168a8416179055609c80548216898416179055609d80548216888416179055609e80548216878416179055609f8054821686841617905560a08054909116918416919091177fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740a000000000000000000000000000000000000000017905562093a8060a15561038460a25561012c60a3556121b4613fec565b6121bc61409e565b80156121ce576000805461ff00191690555b505050505050505050565b6033546001600160a01b031690565b6121f187614133565b6121fb8a8a613437565b6122058a8a613527565b61221184848484613677565b61221a8b614228565b60a15486111561225b5760405162461bcd60e51b81526004018080602001828103825260238152602001806155ff6023913960400191505060405180910390fd5b6122636150b2565b6001600160a01b03808c16600090815260a6602090815260408083208e84528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e086019390929083018282801561232c57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161230e575b50505050508152602001600882018054806020026020016040519081016040528092919081815260200182805480156123a257602002820191906000526020600020906000905b825461010083900a900460ff168152602060019283018181049485019490930390920291018084116123735790505b5050509190925250505060c081015190915015806123ca575080516001600160a01b03163314155b6124055760405162461bcd60e51b81526004018080602001828103825260308152602001806156646030913960400191505060405180910390fd5b600087116124445760405162461bcd60e51b81526004018080602001828103825260248152602001806156bb6024913960400191505060405180910390fd5b6d21a7a62224a2afa0aaa1aa24a7a760911b8c14156124a1576000891161249c5760405162461bcd60e51b815260040180806020018281038252603381526020018061581e6033913960400191505060405180910390fd5b6124fb565b7029a1a422a22aa622a22fa0aaa1aa24a7a760791b8c14156124fb574286116124fb5760405162461bcd60e51b81526004018080602001828103825260398152602001806157936039913960400191505060405180910390fd5b609760009054906101000a90046001600160a01b03166001600160a01b031663f9a23e866040518163ffffffff1660e01b815260040160206040518083038186803b15801561254957600080fd5b505afa15801561255d573d6000803e3d6000fd5b505050506040513d602081101561257357600080fd5b50518911156125b35760405162461bcd60e51b81526004018080602001828103825260428152602001806156226042913960600191505060405180910390fd5b60408051610120810182523381524360208201529081016d21a7a62224a2afa0aaa1aa24a7a760911b8e146125e857876125eb565b60005b8152602001888152602001896001600160a01b031681526020018a81526020018d81526020018686808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506040805160208681028281018201909352868252928301929091879187918291850190849080828437600081840152601f19601f8201169050808301925050505050505081525060a660008d6001600160a01b03166001600160a01b0316815260200190815260200160002060008c815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010155604082015181600201556060820151816003015560808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c0820151816006015560e082015181600701908051906020019061276c929190615141565b5061010082015180516127899160088401916020909101906151a6565b5050507029a1a422a22aa622a22fa0aaa1aa24a7a760791b8c141561281957604080516323b872dd60e01b8152336004820152306024820152604481018c905290518c916001600160a01b038316916323b872dd9160648082019260009290919082900301818387803b1580156127ff57600080fd5b505af1158015612813573d6000803e3d6000fd5b50505050505b604080516001600160a01b038a81168252602082018990528183018c9052606082018a9052915133928d92908f16917fdb89081d9a5399380ffbcc376a961ed023027fca462e08b3d23146e4c6ac62f29181900360800190a4505050505050505050505050565b6098546001600160a01b031681565b609e546001600160a01b031681565b7029a1a422a22aa622a22fa0aaa1aa24a7a760791b81565b6002606554141561290e576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002606555609754604080516361fe24a960e11b8152600481018490529051600092612999926001600160a01b039091169163c3fc495291602480820192602092909190829003018186803b15801561296657600080fd5b505afa15801561297a573d6000803e3d6000fd5b505050506040513d602081101561299057600080fd5b505183906137ae565b90506129a583826142af565b6129ad6150b2565b6001600160a01b03808716600090815260a6602090815260408083208984528252918290208251610120810184528154851681526001820154818401526002820154818501526003820154606082015260048201549094166080850152600581015460a0850152600681015460c0850152600781018054845181850281018501909552808552919360e0860193909290830182828015612a7657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612a58575b5050505050815260200160088201805480602002602001604051908101604052809291908181526020018280548015612aec57602002820191906000526020600020906000905b825461010083900a900460ff16815260206001928301818104948501949093039092029101808411612abd5790505b5050509190925250505060c0810151909150612b395760405162461bcd60e51b81526004018080602001828103825260218152602001806153bd6021913960400191505060405180910390fd5b80516001600160a01b0316331415612b825760405162461bcd60e51b815260040180806020018281038252602481526020018061533b6024913960400191505060405180910390fd5b8060400151421015612bdb576040805162461bcd60e51b815260206004820152601860248201527f6269643a3a41756374696f6e206e6f74206163746976652e0000000000000000604482015290519081900360640190fd5b80608001516001600160a01b0316846001600160a01b031614612c2f5760405162461bcd60e51b81526004018080602001828103825260308152602001806158516030913960400191505060405180910390fd5b60008311612c84576040805162461bcd60e51b815260206004820152601060248201527f6269643a3a43616e6e6f74206265203000000000000000000000000000000000604482015290519081900360640190fd5b609760009054906101000a90046001600160a01b03166001600160a01b031663f9a23e866040518163ffffffff1660e01b815260040160206040518083038186803b158015612cd257600080fd5b505afa158015612ce6573d6000803e3d6000fd5b505050506040513d6020811015612cfc57600080fd5b5051831115612d3c5760405162461bcd60e51b81526004018080602001828103825260218152602001806157426021913960400191505060405180910390fd5b8060a00151831015612d7f5760405162461bcd60e51b81526004018080602001828103825260268152602001806152c36026913960400191505060405180910390fd5b60408101511580612da1575060608101516040820151612d9e916137ae565b42105b612df2576040805162461bcd60e51b815260206004820152601460248201527f6269643a3a4d757374206265206163746976652e000000000000000000000000604482015290519081900360640190fd5b612dfa615247565b506001600160a01b03808716600090815260a760209081526040808320898452825291829020825160808101845281548516815260018201549094169184019190915260028101549183018290526003015460ff908116606084015260a054612e8892612e7d92606492612e779291600160a01b90910416614398565b906143f1565b6040830151906137ae565b841015612ec65760405162461bcd60e51b81526004018080602001828103825260318152602001806155406031913960400191505060405180910390fd5b60008790506000816001600160a01b0316636352211e896040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b158015612f1157600080fd5b505afa158015612f25573d6000803e3d6000fd5b505050506040513d6020811015612f3b57600080fd5b505184519091506001600160a01b0380831691161480612f6357506001600160a01b03811630145b612f9e5760405162461bcd60e51b815260040180806020018281038252602381526020018061544b6023913960400191505060405180910390fd5b806001600160a01b031684600001516001600160a01b03161415612fc657612fc68989613527565b612fd08786614458565b612feb878460400151856060015160ff16866000015161467d565b6040518060800160405280336001600160a01b03168152602001886001600160a01b03168152602001878152602001609760009054906101000a90046001600160a01b03166001600160a01b031663834759216040518163ffffffff1660e01b815260040160206040518083038186803b15801561306857600080fd5b505afa15801561307c573d6000803e3d6000fd5b505050506040513d602081101561309257600080fd5b505160ff9081169091526001600160a01b03808c16600090815260a7602090815260408083208e84528252808320865181549086166001600160a01b03199182161782559287015160018201805491909616931692909217909355848301516002820155606090940151600390940180549490931660ff199094169390931790915585015181906131b7576001600160a01b03808c16600090815260a6602090815260408083208e845290915280822042600290910155885181516323b872dd60e01b81529084166004820152306024820152604481018e90529051928716926323b872dd9260648084019391929182900301818387803b15801561319657600080fd5b505af11580156131aa573d6000803e3d6000fd5b505050506001915061322e565b60a2546131df426131d989606001518a604001516137ae90919063ffffffff16565b9061486a565b101561322e5761320286604001516131d960a254426137ae90919063ffffffff16565b6001600160a01b038c16600090815260a6602090815260408083208e8452909152902060030181905590505b8451604080516001600160a01b038c81168252602082018c90528515158284015260608201859052928316608082015290518c923392908f16917f189a468e632a450afd491f84aa9ae94addc6813c7e309a7b1b1223f88802a77d9181900360a00190a450506001606555505050505050505050565b6097546001600160a01b031681565b60a660209081526000928352604080842090915290825290208054600182015460028301546003840154600485015460058601546006909601546001600160a01b0395861696949593949293909116919087565b6d21a7a62224a2afa0aaa1aa24a7a760911b81565b60a25481565b61332a613fd7565b6001600160a01b031661333b6121d9565b6001600160a01b031614613396576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166133db5760405162461bcd60e51b81526004018080602001828103825260268152602001806153156026913960400191505060405180910390fd5b6033546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3603380546001600160a01b0319166001600160a01b0392909216919091179055565b604080517f6352211e000000000000000000000000000000000000000000000000000000008152600481018390529051839133916001600160a01b03841691636352211e916024808301926020929190829003018186803b15801561349b57600080fd5b505afa1580156134af573d6000803e3d6000fd5b505050506040513d60208110156134c557600080fd5b50516001600160a01b031614613522576040805162461bcd60e51b815260206004820152601e60248201527f73656e646572206d7573742062652074686520746f6b656e206f776e65720000604482015290519081900360640190fd5b505050565b60008290506000816001600160a01b0316636352211e846040518263ffffffff1660e01b81526004018082815260200191505060206040518083038186803b15801561357257600080fd5b505afa158015613586573d6000803e3d6000fd5b505050506040513d602081101561359c57600080fd5b5051604080517fe985e9c50000000000000000000000000000000000000000000000000000000081526001600160a01b03808416600483015230602483015291519293509084169163e985e9c591604480820192602092909190829003018186803b15801561360a57600080fd5b505afa15801561361e573d6000803e3d6000fd5b505050506040513d602081101561363457600080fd5b50516136715760405162461bcd60e51b81526004018080602001828103825260218152602001806155ba6021913960400191505060405180910390fd5b50505050565b826136b35760405162461bcd60e51b81526004018080602001828103825260278152602001806156946027913960400191505060405180910390fd5b60058311156136f35760405162461bcd60e51b81526004018080602001828103825260248152602001806155db6024913960400191505060405180910390fd5b8281146137315760405162461bcd60e51b815260040180806020018281038252602c8152602001806152e9602c913960400191505060405180910390fd5b6000805b828110156137675783838281811061374957fe5b9050602002013560ff1660ff16820191508080600101915050613735565b50806064146137a75760405162461bcd60e51b815260040180806020018281038252602781526020018061546e6027913960400191505060405180910390fd5b5050505050565b600082820183811015613808576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b90505b92915050565b80518251146138515760405162461bcd60e51b81526004018080602001828103825260338152602001806158816033913960400191505060405180910390fd5b609754604080516361fe24a960e11b815260048101879052905186926000926001600160a01b039091169163c3fc495291602480820192602092909190829003018186803b1580156138a257600080fd5b505afa1580156138b6573d6000803e3d6000fd5b505050506040513d60208110156138cc57600080fd5b50516040805160018082528183019092529192506060919060208083019080368337505060a05482519293506001600160a01b03169183915060009061390e57fe5b6001600160a01b039290921660209283029190910190910152604080516001808252818301909252606091816020016020820280368337019050509050828160008151811061395957fe5b602002602001018181525050613971898484846148c7565b609754604080517f511bc84c0000000000000000000000000000000000000000000000000000000081526001600160a01b038e81166004830152602482018e90529151919092169163511bc84c916044808301926020929190829003018186803b1580156139de57600080fd5b505afa1580156139f2573d6000803e3d6000fd5b505050506040513d6020811015613a0857600080fd5b5051613cb957604080516001808252818301909252606091602080830190803683375050609c54604080517f5dc22eff0000000000000000000000000000000000000000000000000000000081526001600160a01b038d811660048301529151949550911692635dc22eff92506024808301926020929190829003018186803b158015613a9457600080fd5b505afa158015613aa8573d6000803e3d6000fd5b505050506040513d6020811015613abe57600080fd5b505115613bc957609c54604080517f2260494f0000000000000000000000000000000000000000000000000000000081526001600160a01b038b8116600483015291516000939290921691632260494f91602480820192602092909190829003018186803b158015613b2f57600080fd5b505afa158015613b43573d6000803e3d6000fd5b505050506040513d6020811015613b5957600080fd5b505160ff169050613b79613b726064612e778d85614398565b879061486a565b9550613b8a6064612e778c84614398565b82600081518110613b9757fe5b602002602001018181525050613bc38b83600081518110613bb457fe5b602002602001015186856148c7565b50613cb3565b609754604080517fb28a7bad0000000000000000000000000000000000000000000000000000000081526001600160a01b038f811660048301529151600093929092169163b28a7bad91602480820192602092909190829003018186803b158015613c3357600080fd5b505afa158015613c47573d6000803e3d6000fd5b505050506040513d6020811015613c5d57600080fd5b505160ff169050613c76613b726064612e778d85614398565b9550613c876064612e778c84614398565b82600081518110613c9457fe5b602002602001018181525050613cb18b83600081518110613bb457fe5b505b50613edf565b609954604080517ff533b8020000000000000000000000000000000000000000000000000000000081526001600160a01b038e81166004830152602482018e9052604482018c905291516060938493169163f533b80291606480830192600092919082900301818387803b158015613d3057600080fd5b505af1158015613d44573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040908152811015613d6d57600080fd5b8101908080516040519392919084640100000000821115613d8d57600080fd5b908301906020820185811115613da257600080fd5b8251866020820283011164010000000082111715613dbf57600080fd5b82525081516020918201928201910280838360005b83811015613dec578181015183820152602001613dd4565b5050505090500160405260200180516040519392919084640100000000821115613e1557600080fd5b908301906020820185811115613e2a57600080fd5b8251866020820283011164010000000082111715613e4757600080fd5b82525081516020918201928201910280838360005b83811015613e74578181015183820152602001613e5c565b50505050905001604052505050915091506000805b8251811015613ec257613eb8838281518110613ea157fe5b6020026020010151836137ae90919063ffffffff16565b9150600101613e89565b50613ecd878261486a565b9650613edb8c8285856148c7565b5050505b6060865167ffffffffffffffff81118015613ef957600080fd5b50604051908082528060200260200182016040528015613f23578160200160208202803683370190505b5090506000805b8851811015613fbb57613f616064612e778a8481518110613f4757fe5b602002602001015160ff168a61439890919063ffffffff16565b838281518110613f6d57fe5b602002602001018181525050613fb1613faa6064612e778b8581518110613f9057fe5b602002602001015160ff168b61439890919063ffffffff16565b83906137ae565b9150600101613f2a565b50613fc88b828a856148c7565b50505050505050505050505050565b3390565b6000613fe630614b20565b15905090565b600054610100900460ff16806140055750614005613fdb565b80614013575060005460ff16155b61404e5760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015614079576000805460ff1961ff0019909116610100171660011790555b614081614b26565b614089614bc6565b801561409b576000805461ff00191690555b50565b600054610100900460ff16806140b757506140b7613fdb565b806140c5575060005460ff16155b6141005760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff1615801561412b576000805460ff1961ff0019909116610100171660011790555b614089614cbf565b6001600160a01b03811615806141d75750609d54604080517f2d5ad3d50000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015291519190921691632d5ad3d5916024808301926020929190829003018186803b1580156141aa57600080fd5b505afa1580156141be573d6000803e3d6000fd5b505050506040513d60208110156141d457600080fd5b50515b61409b576040805162461bcd60e51b815260206004820152601560248201527f4e6f7420617070726f7665642063757272656e63790000000000000000000000604482015290519081900360640190fd5b6d21a7a62224a2afa0aaa1aa24a7a760911b811415801561425d57507029a1a422a22aa622a22fa0aaa1aa24a7a760791b8114155b1561409b576040805162461bcd60e51b815260206004820152601460248201527f496e76616c69642041756374696f6e2054797065000000000000000000000000604482015290519081900360640190fd5b6001600160a01b0382166142c257614394565b604080517fdd62ed3e0000000000000000000000000000000000000000000000000000000081523360048201523060248201529051839183916001600160a01b0384169163dd62ed3e916044808301926020929190829003018186803b15801561432b57600080fd5b505afa15801561433f573d6000803e3d6000fd5b505050506040513d602081101561435557600080fd5b505110156135225760405162461bcd60e51b81526004018080602001828103825260308152602001806157636030913960400191505060405180910390fd5b5050565b6000826143a75750600061380b565b828202828482816143b457fe5b04146138085760405162461bcd60e51b81526004018080602001828103825260218152602001806155996021913960400191505060405180910390fd5b6000808211614447576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b81838161445057fe5b049392505050565b6001600160a01b0382166144bf578034146144ba576040805162461bcd60e51b815260206004820152601360248201527f6e6f7420656e6f756768206574682073656e7400000000000000000000000000604482015290519081900360640190fd5b614394565b34156144fc5760405162461bcd60e51b81526004018080602001828103825260288152602001806155716028913960400191505060405180910390fd5b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905183916000916001600160a01b038416916370a08231916024808301926020929190829003018186803b15801561456057600080fd5b505afa158015614574573d6000803e3d6000fd5b505050506040513d602081101561458a57600080fd5b505190506145a36001600160a01b038316333086614d65565b6000826001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b1580156145f257600080fd5b505afa158015614606573d6000803e3d6000fd5b505050506040513d602081101561461c57600080fd5b505190508361462b828461486a565b146137a7576040805162461bcd60e51b815260206004820152601c60248201527f6e6f7420656e6f75676820746f6b656e73207472616e73666572656400000000604482015290519081900360640190fd5b8261468757613671565b60006146a261469b6064612e778787614398565b85906137ae565b90506001600160a01b03851661484d57609e54604080516001600160a01b038581166024830152604480830186905283518084039091018152606490920183526020820180516001600160e01b03167f410085df000000000000000000000000000000000000000000000000000000001781529251825160009560609593169387939092918291908083835b6020831061474d5780518252601f19909201916020918201910161472e565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146147af576040519150601f19603f3d011682016040523d82523d6000602084013e6147b4565b606091505b50915091508181906148445760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156148095781810151838201526020016147f1565b50505050905090810190601f1680156148365780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50505050613671565b846148626001600160a01b0382168484614dbf565b505050505050565b6000828211156148c1576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6001600160a01b038416614ac757609e5460408051602481019182528451606482015284516000936060936001600160a01b039091169288927fc176e63900000000000000000000000000000000000000000000000000000000928992899282916044810191608490910190602080880191028083838f5b8381101561495757818101518382015260200161493f565b50505050905001838103825284818151815260200191508051906020019060200280838360005b8381101561499657818101518382015260200161497e565b50505050905001945050505050604051602081830303815290604052906001600160e01b0319166020820180516001600160e01b0383818316178352505050506040518082805190602001908083835b60208310614a055780518252601f1990920191602091820191016149e6565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114614a67576040519150601f19603f3d011682016040523d82523d6000602084013e614a6c565b606091505b5091509150818190614abf5760405162461bcd60e51b81526020600482018181528351602484015283519092839260449091019190850190808383600083156148095781810151838201526020016147f1565b505050613671565b8360005b835181101561486257614b18848281518110614ae357fe5b6020026020010151848381518110614af757fe5b6020026020010151846001600160a01b0316614dbf9092919063ffffffff16565b600101614acb565b3b151590565b600054610100900460ff1680614b3f5750614b3f613fdb565b80614b4d575060005460ff16155b614b885760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015614089576000805460ff1961ff001990911661010017166001179055801561409b576000805461ff001916905550565b600054610100900460ff1680614bdf5750614bdf613fdb565b80614bed575060005460ff16155b614c285760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015614c53576000805460ff1961ff0019909116610100171660011790555b6000614c5d613fd7565b603380546001600160a01b0319166001600160a01b038316908117909155604051919250906000907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350801561409b576000805461ff001916905550565b600054610100900460ff1680614cd85750614cd8613fdb565b80614ce6575060005460ff16155b614d215760405162461bcd60e51b815260040180806020018281038252602e8152602001806154ea602e913960400191505060405180910390fd5b600054610100900460ff16158015614d4c576000805460ff1961ff0019909116610100171660011790555b6001606555801561409b576000805461ff001916905550565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052613671908590614e26565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b03167fa9059cbb000000000000000000000000000000000000000000000000000000001790526135229084905b6060614e7b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316614ed79092919063ffffffff16565b80519091501561352257808060200190516020811015614e9a57600080fd5b50516135225760405162461bcd60e51b815260040180806020018281038252602a8152602001806157f4602a913960400191505060405180910390fd5b6060614ee68484600085614ef0565b90505b9392505050565b606082471015614f315760405162461bcd60e51b81526004018080602001828103825260268152602001806154956026913960400191505060405180910390fd5b614f3a85614b20565b614f8b576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b60006060866001600160a01b031685876040518082805190602001908083835b60208310614fca5780518252601f199092019160209182019101614fab565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d806000811461502c576040519150601f19603f3d011682016040523d82523d6000602084013e615031565b606091505b509150915061504182828661504c565b979650505050505050565b6060831561505b575081614ee9565b82511561506b5782518084602001fd5b60405162461bcd60e51b81526020600482018181528451602484015284518593919283926044019190850190808383600083156148095781810151838201526020016147f1565b60405180610120016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600081526020016000801916815260200160608152602001606081525090565b6040805160a08101825260008082526020820181905291810182905260608101829052608081019190915290565b828054828255906000526020600020908101928215615196579160200282015b8281111561519657825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190615161565b506151a29291506152ad565b5090565b82805482825590600052602060002090601f016020900481019282156151965791602002820160005b8382111561520d57835183826101000a81548160ff021916908360ff16021790555092602001926001016020816000010492830192600103026151cf565b801561523a5782816101000a81549060ff021916905560010160208160000104928301926001030261520d565b50506151a29291506152ad565b60408051608081018252600080825260208201819052918101829052606081019190915290565b508054600082559060005260206000209081019061409b91906152ad565b50805460008255601f01602090049060005260206000209081019061409b91905b5b808211156151a257600081556001016152ae56fe6269643a3a43616e6e6f74206265206c6f776572207468616e206d696e696d756d206269642e636865636b53706c6974733a3a53706c69747320616e6420726174696f73206d75737420626520657175616c4f776e61626c653a206e6577206f776e657220697320746865207a65726f20616464726573736269643a3a43616e6e6f7420626964206f6e20796f7572206f776e2061756374696f6e2e736574746c6541756374696f6e3a3a4d757374206861766520612063757272656e742076616c69642061756374696f6e2e63616e63656c41756374696f6e3a3a41756374696f6e206d757374206e6f74206861766520737461727465642e6269643a3a4d757374206861766520612063757272656e742061756374696f6e2e636f6e766572744f66666572546f41756374696f6e3a3a436f6e76657274696e67206f66666572207769746820646966666572656e7420616d6f756e742e63616e63656c41756374696f6e3a3a4d757374206861766520616e2061756374696f6e20636f6e666967757265642e6269643a3a41756374696f6e2063726561746f72206d757374206265206f776e65722e636865636b53706c6974733a3a546f74616c206d75737420626520657175616c20746f20313030416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c636f6e766572744f66666572546f41756374696f6e3a3a4f66666572206973206e6f7420636f6e7665727469626c65496e697469616c697a61626c653a20636f6e747261637420697320616c726561647920696e697469616c697a656463616e63656c41756374696f6e3a3a4d7573742062652063726561746f72206f72206f776e65722e6269643a3a4d75737420626520686967686572207468616e207072657620626964202b206d696e20696e6372656173652e6d73672e76616c75652073686f756c642062652030207768656e206e6f74207573696e6720657468536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f776f776e6572206d757374206861766520617070726f76656420636f6e7472616374636865636b53706c6974733a3a53706c6974206578636565646564206d61782073697a65636f6e66696775726541756374696f6e3a3a41756374696f6e20746f6f206c6f6e672e636f6e66696775726541756374696f6e3a3a43616e6e6f7420736574207374617274696e6720707269636520686967686572207468616e206d61782076616c75652e636f6e66696775726541756374696f6e3a3a43616e6e6f74206861766520612063757272656e742061756374696f6e2e636865636b53706c6974733a3a4d7573742068617665206174206c6561737420312073706c6974636f6e66696775726541756374696f6e3a3a4c656e677468206d757374206265203e2030636f6e766572744f66666572546f41756374696f6e3a3a43616e6e6f74206861766520612063757272656e742061756374696f6e2e736574746c6541756374696f6e3a3a43616e206f6e6c7920736574746c6520656e6465642061756374696f6e732e6269643a3a4d757374206265206c657373207468616e206d61782076616c75652e73656e646572206e6565647320746f20617070726f7665206d61726b6574706c61636520666f722063757272656e6379636f6e66696775726541756374696f6e3a3a5363686564756c65642061756374696f6e2063616e6e6f7420737461727420696e20706173742e636f6e766572744f66666572546f41756374696f6e3a3a41756374696f6e20746f6f206c6f6e672e5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564636f6e66696775726541756374696f6e3a3a436f6c646965207374617274696e67207072696365206d757374206265203e20306269643a3a43757272656e6379206d75737420626520696e20636f6e666967757265642064656e6f6d696e6174696f6e4e756d626572206f662073706c69742061646472657373657320616e6420726174696f73206d75737420626520657175616c2ea2646970667358221220bab2ad1dbb352e7d3bc0ecd2526d514f19aab8451578a601bb190165663d4f7864736f6c63430007030033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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