ETH Price: $3,492.36 (-0.65%)
Gas: 12 Gwei

Contract

0xB4EfBC620a529b805854806568009a98213884C8
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Value
0x60806040181795152023-09-20 20:33:47266 days ago1695242027IN
 Create: AuctionUpgradeable
0 ETH0.1063161125.9055609

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AuctionUpgradeable

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 1000 runs

Other Settings:
default evmVersion
File 1 of 26 : AuctionUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;

import "@gnus.ai/contracts-upgradeable-diamond/contracts/interfaces/IERC20MetadataUpgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/interfaces/IERC20Upgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/token/ERC20/utils/SafeERC20Upgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/interfaces/IERC1155Upgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/security/ReentrancyGuardUpgradeable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/security/PausableUpgradeable.sol";

import "./AuctionStorage.sol";

import "../utils/EIP2535Initializable.sol";
import "../libraries/FullMath.sol";
import "../libraries/Constants.sol";

import "../interfaces/IPriceOracleUpgradeable.sol";
import "../interfaces/IWaterTowerUpgradeable.sol";

/// @title Auction Market for whitelisted erc20 tokens and erc1155 tranche nft
/// @dev  Auction contract allows users sell allowed tokens, buy or bid the tokens with allowed bid tokens
///     1. owner allow sell tokens and bid token groups, and set auction fee
///     2. seller(auctioner) create auction
///     * seller should have enough balance for sell tokens (sell amount + auction fee)
///     3. buyer buy listed tokens immediately or bid with any price in a range
///     * buyer shuold have enough balance for bid tokens (price * buy amount)
///     4. anyone(buyer, seller, or any) close auction after end time

contract AuctionUpgradeable is
    EIP2535Initializable,
    ReentrancyGuardUpgradeable,
    PausableUpgradeable
{
    using AuctionStorage for AuctionStorage.Layout;
    using SafeERC20Upgradeable for IERC20Upgradeable;
    /// @dev errors
    error InsufficientFee();
    error InsufficientReserveAsset();
    error NoListTrancheZ();
    error NoTransferEther();
    error InvalidTrancheAuction();
    error InvalidAuctionAmount();
    error InvalidStartTime();
    error InvalidMinBidAmount();
    error InvalidFixedPrice();
    error InvalidEndPrice();
    error InvalidSellToken();
    error NoClosedAuction();
    error NoAuction();
    error InvalidAuction();
    error InactiveAuction();
    error NoAuctioneer();
    error NoIdleAuction();
    error InvalidPurchaseAmount();
    error InvalidIncrementBidPrice();
    // bid and buy
    error LowBid();
    error OverPriceBid();
    error NoCancelBid();
    error ClaimedBid();
    error NoBidder();
    error SmallBidAmount();
    error InvalidBidToken();

    event AuctionCreated(
        AuctionSetting auctionSetting,
        address indexed seller,
        uint256 indexed auctionId
    );

    /// @notice Emitted by auction for buyNow
    /// @param buyer The address call buyNow
    /// @param amountIn Token amount paid by user to buy auctioning token
    /// @param amountOut Auctioning token amount that user received
    /// @param auctionId Id of auction list

    event AuctionBuy(
        address indexed buyer,
        uint256 amountIn,
        uint256 amountOut,
        address purchaseToken,
        uint256 indexed auctionId
    );

    /// @notice Emitted by auction when bidder places a bid
    /// @param bid bid token struct
    /// @param auctionId The id of auction list
    /// @param bidId The id of bid list

    event AuctionBid(Bid bid, uint indexed auctionId, uint indexed bidId, uint availableBidDepth);

    /// @notice Emitted by auction when bidder or auctioneer closes a auction
    /// @param unSoldAmount Amount of unsold auctioning token
    /// @param auctionId Auction id
    event AuctionClosed(uint256 unSoldAmount, uint256 indexed auctionId, uint256 settledBidCount);

    event AuctionUpdate(
        uint indexed auctionId,
        uint minBidAmount,
        uint priceRangeStart,
        uint incrementPrice
    );

    event ClaimBid(uint auctionId, uint bidId, bool isWinner, uint claimAmount);

    uint256 internal constant FEE_DENOMINATOR = 1000;
    uint256 internal constant BID_GAS_LIMIT = 470000;
    uint256 internal constant CLOSE_GAS_LIMIT = 180000;
    uint256 internal constant D30 = 1e30;
    uint256 internal constant MINBID_FACTOR = 100;
    uint256 internal constant INCREMENTBID_FACTOR = 2;

    function createAuction(
        AuctionSetting memory auctionSetting,
        uint8 periodId
    ) external payable whenNotPaused {
        AuctionStorage.Layout storage auctionStorage = AuctionStorage.layout();
        if (!auctionStorage.supportedSellTokens[auctionSetting.sellToken])
            revert InvalidSellToken();
        if (auctionSetting.bidTokenGroupId >= auctionStorage.countOfTokenGroups)
            revert InvalidBidToken();
        if (
            auctionSetting.minBidAmount < auctionSetting.sellAmount / MINBID_FACTOR ||
            auctionSetting.minBidAmount > auctionSetting.sellAmount
        ) revert InvalidMinBidAmount();
        if (auctionSetting.sellAmount == 0) revert InvalidAuctionAmount();

        if (
            (auctionSetting.auctionType == AuctionType.FixedPrice ||
                auctionSetting.auctionType == AuctionType.TimedAndFixed) &&
            auctionSetting.fixedPrice == 0
        ) revert InvalidFixedPrice();

        if (auctionSetting.auctionType != AuctionType.FixedPrice) {
            if (auctionSetting.priceRangeStart > auctionSetting.priceRangeEnd)
                revert InvalidEndPrice();
            if (
                auctionSetting.incrementBidPrice == 0 ||
                auctionSetting.incrementBidPrice * INCREMENTBID_FACTOR >
                auctionSetting.priceRangeStart
            ) revert InvalidIncrementBidPrice();
        }

        if (auctionSetting.startTime == 0) auctionSetting.startTime = uint48(block.timestamp);
        else if (
            auctionSetting.startTime < block.timestamp ||
            auctionSetting.startTime > block.timestamp + 30 days
        ) revert InvalidStartTime();
        auctionSetting.endTime = auctionSetting.startTime + auctionStorage.periods[periodId];
        uint256 auctionId = auctionStorage.currentAuctionId + 1;
        // receive auction asset
        if (auctionSetting.trancheIndex == 0) {
            IERC20Upgradeable(auctionSetting.sellToken).safeTransferFrom(
                msg.sender,
                address(this),
                (auctionSetting.sellAmount * (FEE_DENOMINATOR + auctionStorage.feeNumerator)) /
                    FEE_DENOMINATOR
            );
        } else {
            if (auctionSetting.trancheIndex & 3 == 3) revert NoListTrancheZ();
            if (auctionSetting.sellToken != address(this)) revert InvalidTrancheAuction();
            IERC1155Upgradeable(address(this)).safeTransferFrom(
                msg.sender,
                address(this),
                auctionSetting.trancheIndex,
                auctionSetting.sellAmount,
                Constants.EMPTY
            );
            /// @dev fee is calculated from usd value, and notation amount is BDV
            uint256 ethPrice = IPriceOracleUpgradeable(address(this)).getUnderlyingPriceETH();
            // tranche nft decimals is 6 and price decimals 18, so calculated factor = 10 ** (18+18-6)
            uint256 feeAmount = (((auctionSetting.sellAmount * D30) / ethPrice) *
                auctionStorage.feeNumerator) / FEE_DENOMINATOR;
            if (msg.value < feeAmount) revert InsufficientFee();
            else if (msg.value > feeAmount) {
                (bool success, ) = msg.sender.call{value: msg.value - feeAmount}("");
                if (!success) revert NoTransferEther();
            }
            auctionStorage.auctions[auctionId].feeAmount = feeAmount;
        }
        auctionStorage.currentAuctionId = auctionId;
        auctionSetting.reserve = auctionSetting.sellAmount;
        auctionStorage.auctions[auctionId].s = auctionSetting;
        auctionStorage.auctions[auctionId].seller = msg.sender;
        emit AuctionCreated(auctionSetting, msg.sender, auctionId);
    }

    /// @notice update important options of auction before any bidding
    /// @param auctionId auction id
    /// @param minBidAmount min bid amount to update
    /// @param priceRangeStart start price
    /// @param incrementBidPrice increment bid price
    function updateAuction(
        uint256 auctionId,
        uint128 minBidAmount,
        uint128 priceRangeStart,
        uint128 incrementBidPrice
    ) external whenNotPaused {
        AuctionStorage.Layout storage auctionStorage = AuctionStorage.layout();
        AuctionData memory auction = auctionStorage.auctions[auctionId];
        if (auction.seller != msg.sender) revert NoAuctioneer();
        if (
            auction.status != AuctionStatus.Open ||
            auction.s.endTime < block.timestamp ||
            auction.curBidId != 0
        ) revert NoIdleAuction();

        if (priceRangeStart > auction.s.priceRangeEnd) revert InvalidEndPrice();

        if (
            auction.s.minBidAmount >= auction.s.sellAmount / MINBID_FACTOR &&
            minBidAmount <= auction.s.sellAmount
        ) auctionStorage.auctions[auctionId].s.minBidAmount = minBidAmount;

        if (priceRangeStart != 0)
            auctionStorage.auctions[auctionId].s.priceRangeStart = priceRangeStart;
        if (
            incrementBidPrice != 0 &&
            incrementBidPrice * INCREMENTBID_FACTOR <=
            auctionStorage.auctions[auctionId].s.priceRangeStart
        ) auctionStorage.auctions[auctionId].s.incrementBidPrice = incrementBidPrice;

        emit AuctionUpdate(auctionId, minBidAmount, priceRangeStart, incrementBidPrice);
    }

    /// @notice buy token immediately with fixed price
    /// @param auctionId      auction id
    /// @param purchaseAmount amount to purchase
    /// @param buyTokenId     token id to buy with
    function buyNow(
        uint256 auctionId,
        uint128 purchaseAmount,
        uint16 buyTokenId
    ) external nonReentrant whenNotPaused {
        AuctionStorage.Layout storage auctionStorage = AuctionStorage.layout();
        AuctionData memory auction = auctionStorage.auctions[auctionId];
        // Check auction.seller if address(0) auction hasn't been initialized/created and then check the auction type.
        if (auction.seller == address(0) || auction.s.auctionType == AuctionType.TimedAuction)
            revert InvalidAuction();
        address _purchaseToken = AuctionStorage
            .layout()
            .bidTokenGroups[auction.s.bidTokenGroupId]
            .bidTokens[buyTokenId];
        checkAuctionInProgress(auction.s.endTime, auction.s.startTime);
        uint128 availableAmount = auction.s.reserve;
        uint256 trancheIndex = auction.s.trancheIndex;
        if (purchaseAmount > availableAmount) revert InsufficientReserveAsset();
        if (auction.s.minBidAmount > purchaseAmount) revert SmallBidAmount();

        unchecked {
            auctionStorage.auctions[auctionId].s.reserve = availableAmount - purchaseAmount;
        }
        uint8 sellTokenDecimals;
        if (trancheIndex == 0) {
            sellTokenDecimals = IERC20MetadataUpgradeable(auction.s.sellToken).decimals();
            IERC20Upgradeable(auction.s.sellToken).safeTransfer(msg.sender, purchaseAmount);
        } else {
            sellTokenDecimals = Constants.TRANCHE_DECIMALS;
            IERC1155Upgradeable(address(this)).safeTransferFrom(
                address(this),
                msg.sender,
                trancheIndex,
                purchaseAmount,
                Constants.EMPTY
            );
        }
        uint256 payAmount = getPayAmount(
            _purchaseToken,
            purchaseAmount,
            auction.s.fixedPrice,
            sellTokenDecimals
        );
        IERC20Upgradeable(_purchaseToken).safeTransferFrom(msg.sender, auction.seller, payAmount);

        emit AuctionBuy(msg.sender, payAmount, purchaseAmount, _purchaseToken, auctionId);
    }

    function placeBid(
        uint256 auctionId,
        uint128 bidAmount,
        uint16 bidTokenId,
        uint128 bidPrice,
        uint128 maxBidPrice
    ) external nonReentrant whenNotPaused returns (uint256) {
        AuctionStorage.Layout storage auctionStorage = AuctionStorage.layout();
        AuctionData memory auction = auctionStorage.auctions[auctionId];
        if (auction.seller == address(0) || auction.s.auctionType == AuctionType.FixedPrice)
            revert InvalidAuction();
        address _purchaseToken = AuctionStorage
            .layout()
            .bidTokenGroups[auction.s.bidTokenGroupId]
            .bidTokens[bidTokenId];
        checkAuctionInProgress(auction.s.endTime, auction.s.startTime);
        if (auction.s.minBidAmount > bidAmount) revert SmallBidAmount();
        if (bidAmount > auction.s.reserve) revert InsufficientReserveAsset();
        // bid price starts from priceRangeStart
        uint128 availableBidPrice = auction.curBidId == 0
            ? auction.s.priceRangeStart
            : auctionStorage.bids[auctionId][auction.curBidId].bidPrice +
                auction.s.incrementBidPrice;
        // if bidPrice is 0, place bid in increment way
        // if incrementBidPrice is 0, can place bid with same price as last bid
        if (bidPrice == 0) bidPrice = availableBidPrice;
        else if (bidPrice < availableBidPrice) revert LowBid();
        if (bidPrice > maxBidPrice) revert OverPriceBid();
        uint128 _bidPrice = bidPrice;
        uint256 payAmount = getPayAmount(
            _purchaseToken,
            bidAmount,
            _bidPrice,
            auction.s.trancheIndex > 0
                ? 6
                : IERC20MetadataUpgradeable(auction.s.sellToken).decimals()
        );
        IERC20Upgradeable(_purchaseToken).safeTransferFrom(msg.sender, address(this), payAmount);
        Bid memory bid = Bid({
            bidder: msg.sender,
            bidAmount: bidAmount,
            bidPrice: _bidPrice,
            paidAmount: uint128(payAmount),
            bidTokenId: bidTokenId,
            bCleared: false
        });
        uint128 currentBidId = auction.curBidId + 1;
        {
            uint256 gasRemaining = gasleft();
            uint256 _auctionId = auctionId;
            uint128 _bidAmount = bidAmount;
            auctionStorage.bids[_auctionId][currentBidId] = bid;
            uint256 availableBidDepth = uint256(auction.availableBidDepth) + 1;
            uint128 totalBidAmount = auction.totalBidAmount + _bidAmount;
            address[] memory bidTokens = AuctionStorage
                .layout()
                .bidTokenGroups[auction.s.bidTokenGroupId]
                .bidTokens;
            // cancel bids not eligible in a range of gas limit
            while (true) {
                uint256 _cancelBidId = currentBidId - availableBidDepth + 1;
                Bid memory cancelBid = auctionStorage.bids[_auctionId][_cancelBidId];
                // even though reserve sell amount is smaller than bidAmount, settle the bid and the bidder receives sell token as possible
                if (totalBidAmount < auction.s.reserve + cancelBid.bidAmount) break;
                unchecked {
                    totalBidAmount -= cancelBid.bidAmount;
                    availableBidDepth--;
                }
                /// cancel not eligible bids
                if (cancelBid.bCleared) revert NoCancelBid();
                IERC20Upgradeable(bidTokens[cancelBid.bidTokenId]).safeTransfer(
                    cancelBid.bidder,
                    cancelBid.paidAmount
                );
                AuctionStorage.layout().bids[_auctionId][_cancelBidId].bCleared = true;
                if (gasRemaining - gasleft() > BID_GAS_LIMIT) break;
            }
            AuctionStorage.layout().auctions[_auctionId].availableBidDepth = uint8(
                availableBidDepth
            );
            AuctionStorage.layout().auctions[_auctionId].totalBidAmount = totalBidAmount;
            AuctionStorage.layout().auctions[_auctionId].curBidId = currentBidId;
            emit AuctionBid(bid, _auctionId, currentBidId, availableBidDepth);
        }
        return currentBidId;
    }

    function closeAuction(uint256 auctionId) external nonReentrant whenNotPaused {
        AuctionData memory auction = AuctionStorage.layout().auctions[auctionId];
        require(
            block.timestamp >= auction.s.endTime && auction.status != AuctionStatus.Closed,
            "auction can't be closed"
        );
        _settleAuction(auctionId, auction);
    }

    /// @notice function to get status of bid
    /// @param auctionId auction id
    /// @param bidId  bid id
    /// @return isWinner true if the bid is winner
    /// @return isClaimed true if the bid was claimed

    function isWinnerBid(
        uint256 auctionId,
        uint256 bidId
    ) external view returns (bool isWinner, bool isClaimed, uint256 claimAmount) {
        AuctionStorage.Layout storage auctionStorage = AuctionStorage.layout();
        AuctionData memory auction = auctionStorage.auctions[auctionId];
        Bid memory bid = auctionStorage.bids[auctionId][bidId];
        return _isWinnerBid(auctionId, bidId, auction, bid);
    }

    /// @notice claim bid for winner or canceled bid after auction is closed
    /// @dev anyone can claim bid
    function claimBid(uint256 auctionId, uint256 bidId) external nonReentrant whenNotPaused {
        AuctionStorage.Layout storage auctionStorage = AuctionStorage.layout();
        AuctionData memory auction = auctionStorage.auctions[auctionId];
        Bid memory bid = auctionStorage.bids[auctionId][bidId];
        (bool isWinner, bool isClaimed, uint256 claimAmount) = _isWinnerBid(
            auctionId,
            bidId,
            auction,
            bid
        );
        if (isClaimed) revert ClaimedBid();
        auctionStorage.bids[auctionId][bidId].bCleared = true;
        if (auction.status != AuctionStatus.Closed) revert NoClosedAuction();
        IERC20Upgradeable _purchaseToken = IERC20Upgradeable(
            auctionStorage.bidTokenGroups[auction.s.bidTokenGroupId].bidTokens[bid.bidTokenId]
        );
        if (isWinner) {
            auctionStorage.auctions[auctionId].s.reserve = auction.s.reserve - uint128(claimAmount);
            _settleBid(
                auction.s.sellToken,
                auction.s.trancheIndex,
                _purchaseToken,
                bid,
                uint128(claimAmount)
            );
        } else {
            _purchaseToken.safeTransfer(bid.bidder, bid.paidAmount);
        }
        emit ClaimBid(auctionId, bidId, isWinner, claimAmount);
    }

    function _settleAuction(uint256 auctionId, AuctionData memory auction) internal {
        uint256 gasLimit = gasleft();
        // uint256 trancheIndex = auction.s.trancheIndex;
        uint128 availableAmount = auction.s.reserve;
        uint256 settledBidCount;
        uint256 curBidId = auction.curBidId;
        AuctionStorage.Layout storage auctionStorage = AuctionStorage.layout();
        address[] memory bidTokens = auctionStorage
            .bidTokenGroups[auction.s.bidTokenGroupId]
            .bidTokens;
        uint256[] memory payoutAmounts = new uint256[](bidTokens.length);
        bool bOverGasLimit = false;
        uint128 reserve = availableAmount;
        while (curBidId > 0 && reserve > 0) {
            Bid memory bid = auctionStorage.bids[auctionId][curBidId];
            if (bid.bCleared) break;
            if (!bOverGasLimit && gasLimit <= gasleft() + CLOSE_GAS_LIMIT) {
                auctionStorage.bids[auctionId][curBidId].bCleared = true;
                (uint128 settledAmount, uint128 payoutAmount) = _settleBid(
                    auction.s.sellToken,
                    auction.s.trancheIndex,
                    IERC20Upgradeable(bidTokens[bid.bidTokenId]),
                    bid,
                    availableAmount
                );
                payoutAmounts[bid.bidTokenId] += payoutAmount;
                unchecked {
                    availableAmount -= settledAmount;
                    reserve -= settledAmount;
                    ++settledBidCount;
                }
            } else {
                // it allows the calculation for gas limit done only one time
                if (!bOverGasLimit) bOverGasLimit = true;
                if (bid.bidAmount > reserve) {
                    payoutAmounts[bid.bidTokenId] += (bid.paidAmount * reserve) / bid.bidAmount;
                    reserve = 0;
                } else {
                    payoutAmounts[bid.bidTokenId] += bid.paidAmount;
                    unchecked {
                        reserve -= bid.bidAmount;
                    }
                }
            }
            unchecked {
                --curBidId;
            }
        }
        /// transfer paid tokens from contract to seller
        for (uint256 i; i < bidTokens.length; ) {
            uint256 payoutAmount = payoutAmounts[i];
            if (payoutAmount > 0) {
                IERC20Upgradeable(bidTokens[i]).safeTransfer(auction.seller, payoutAmount);
            }
            unchecked {
                ++i;
            }
        }
        /// transfer auction fee
        if (auction.s.sellAmount > reserve) {
            uint256 totalSettledAmount;
            unchecked {
                totalSettledAmount = auction.s.sellAmount - reserve;
            }
            if (auction.s.trancheIndex == 0) {
                IERC20Upgradeable(auction.s.sellToken).safeTransfer(
                    auctionStorage.feeReceiver,
                    (totalSettledAmount * auctionStorage.feeNumerator) / FEE_DENOMINATOR
                );
            } else {
                IWaterTowerUpgradeable(address(this)).addETHReward{
                    value: (auction.feeAmount * totalSettledAmount) / auction.s.sellAmount
                }();
            }
        }
        if (reserve > 0) {
            unchecked {
                availableAmount -= reserve;
            }
            if (auction.s.trancheIndex == 0) {
                IERC20Upgradeable(auction.s.sellToken).safeTransfer(
                    auction.seller,
                    (reserve * (FEE_DENOMINATOR + auctionStorage.feeNumerator)) / FEE_DENOMINATOR
                );
            } else {
                IERC1155Upgradeable(address(this)).safeTransferFrom(
                    address(this),
                    auction.seller,
                    auction.s.trancheIndex,
                    reserve,
                    Constants.EMPTY
                );
                (bool sent, ) = payable(auction.seller).call{
                    value: ((reserve * auction.feeAmount) / auction.s.sellAmount) / FEE_DENOMINATOR
                }("");
                require(sent, "failed to send ether");
            }
        }
        auctionStorage.auctions[auctionId].s.reserve = availableAmount;
        auctionStorage.auctions[auctionId].status = AuctionStatus.Closed;

        unchecked {
            auctionStorage.auctions[auctionId].totalBidAmount =
                auction.totalBidAmount -
                availableAmount;
            auctionStorage.auctions[auctionId].curBidId =
                auction.curBidId -
                uint128(settledBidCount);
        }
        emit AuctionClosed(availableAmount, auctionId, settledBidCount);
    }

    /// @notice transfer auctioning token to bidder
    function _settleBid(
        address sellToken,
        uint256 trancheIndex,
        IERC20Upgradeable _purchaseToken,
        Bid memory bid,
        uint128 availableAmount
    ) internal returns (uint128 settledAmount, uint128 payoutAmount) {
        settledAmount = bid.bidAmount;
        payoutAmount = bid.paidAmount;
        if (availableAmount < settledAmount) {
            uint128 repayAmount;
            unchecked {
                repayAmount = settledAmount - availableAmount;
            }
            // calculate as payout token
            repayAmount = (repayAmount * bid.paidAmount) / bid.bidAmount;
            payoutAmount -= repayAmount;
            settledAmount = availableAmount;
            _purchaseToken.safeTransfer(bid.bidder, repayAmount);
        }
        if (trancheIndex == 0) {
            IERC20Upgradeable(sellToken).safeTransfer(bid.bidder, settledAmount);
        } else {
            IERC1155Upgradeable(address(this)).safeTransferFrom(
                address(this),
                bid.bidder,
                trancheIndex,
                settledAmount,
                Constants.EMPTY
            );
        }
    }

    function _isWinnerBid(
        uint256 auctionId,
        uint256 bidId,
        AuctionData memory auction,
        Bid memory bid
    ) internal view returns (bool isWinner, bool isClaimed, uint256 claimAmount) {
        AuctionStorage.Layout storage auctionStorage = AuctionStorage.layout();
        if (bid.bCleared) isClaimed = true;
        if (auction.status != AuctionStatus.Closed) {
            return (false, isClaimed, 0);
        } else {
            uint256 curBidId = auction.curBidId;
            uint256 reserve = auction.s.reserve;
            unchecked {
                while (curBidId > bidId && reserve > 0) {
                    Bid memory seniorBid = auctionStorage.bids[auctionId][curBidId];
                    if (!seniorBid.bCleared) {
                        if (reserve > seniorBid.bidAmount) {
                            reserve -= seniorBid.bidAmount;
                        } else reserve = 0;
                    }
                    --curBidId;
                }
                if (reserve > 0) {
                    return (
                        true,
                        isClaimed,
                        reserve >= bid.bidAmount ? bid.bidAmount : bid.bidAmount - reserve
                    );
                } else return (false, isClaimed, 0);
            }
        }
    }

    // admin setters are implemented in IrrigationControl

    // getters
    function getAuctionFee() external view returns (uint256 numerator, uint256 dominator) {
        numerator = AuctionStorage.layout().feeNumerator;
        dominator = FEE_DENOMINATOR;
    }

    function getPayAmount(
        address purchaseToken,
        uint128 purchaseAmount,
        uint128 price,
        uint8 sellTokenDecimals
    ) public view returns (uint256) {
        uint256 denominator = (10 **
            (18 - IERC20MetadataUpgradeable(purchaseToken).decimals() + sellTokenDecimals));
        return FullMath.mulDivRoundingUp128(purchaseAmount, price, denominator);
    }

    function getAuction(uint256 auctionId) external view returns (AuctionData memory) {
        return AuctionStorage.layout().auctions[auctionId];
    }

    function getBid(uint256 auctionId, uint256 bidId) external view returns (Bid memory) {
        return AuctionStorage.layout().bids[auctionId][bidId];
    }

    function getAuctionsCount() external view returns (uint256 totalAuctionsCount) {
        return AuctionStorage.layout().currentAuctionId;
    }

    function getBidTokenGroup(
        uint256 tokenGroupId
    ) external view returns (BidTokenGroup memory tokenGroup) {
        return AuctionStorage.layout().bidTokenGroups[tokenGroupId];
    }

    function getBidTokenGroupCount() external view returns (uint256 countOfTokenGroup) {
        return AuctionStorage.layout().countOfTokenGroups;
    }

    function getAuctionPeriods() external view returns (uint48[] memory) {
        return AuctionStorage.layout().periods;
    }

    /// @dev returns true if auction in progress, false otherwise
    function checkAuctionInProgress(uint256 endTime, uint256 startTime) internal view {
        if (startTime > block.timestamp || (endTime > 0 && endTime <= block.timestamp))
            revert InactiveAuction();
    }
}

File 2 of 26 : IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155.sol)

pragma solidity ^0.8.0;

import "../token/ERC1155/IERC1155Upgradeable.sol";

File 3 of 26 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/extensions/IERC20MetadataUpgradeable.sol";

File 4 of 26 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/IERC20Upgradeable.sol";

File 5 of 26 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";
import { InitializableStorage } from "./InitializableStorage.sol";

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

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

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

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!InitializableStorage.layout()._initializing && InitializableStorage.layout()._initialized < version, "Initializable: contract is already initialized");
        InitializableStorage.layout()._initialized = version;
        InitializableStorage.layout()._initializing = true;
        _;
        InitializableStorage.layout()._initializing = false;
        emit Initialized(version);
    }

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

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

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return InitializableStorage.layout()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return InitializableStorage.layout()._initializing;
    }
}

File 6 of 26 : InitializableStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { Initializable } from "./Initializable.sol";

library InitializableStorage {

  struct Layout {
    /*
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 _initialized;

    /*
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool _initializing;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.Initializable');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

File 7 of 26 : PausableStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { PausableUpgradeable } from "./PausableUpgradeable.sol";

library PausableStorage {

  struct Layout {

    bool _paused;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.Pausable');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

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

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import { PausableStorage } from "./PausableStorage.sol";
import "../proxy/utils/Initializable.sol";

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

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

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal onlyInitializing {
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal onlyInitializing {
        PausableStorage.layout()._paused = false;
    }

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

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

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

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

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

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

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

File 9 of 26 : ReentrancyGuardStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;


import { ReentrancyGuardUpgradeable } from "./ReentrancyGuardUpgradeable.sol";

library ReentrancyGuardStorage {

  struct Layout {

    uint256 _status;
  
  }
  
  bytes32 internal constant STORAGE_SLOT = keccak256('openzeppelin.contracts.storage.ReentrancyGuard');

  function layout() internal pure returns (Layout storage l) {
    bytes32 slot = STORAGE_SLOT;
    assembly {
      l.slot := slot
    }
  }
}

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

pragma solidity ^0.8.0;
import { ReentrancyGuardStorage } from "./ReentrancyGuardStorage.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuardUpgradeable is Initializable {
    using ReentrancyGuardStorage for ReentrancyGuardStorage.Layout;
    // 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;

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

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

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

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

        // Any calls to nonReentrant after this point will fail
        ReentrancyGuardStorage.layout()._status = _ENTERED;
    }

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

File 11 of 26 : IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

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

pragma solidity ^0.8.0;

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

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

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

File 13 of 26 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";
import "../extensions/draft-IERC20PermitUpgradeable.sol";
import "../../../utils/AddressUpgradeable.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 SafeERC20Upgradeable {
    using AddressUpgradeable for address;

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

    function safeTransferFrom(
        IERC20Upgradeable 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(
        IERC20Upgradeable token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

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

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

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

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

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

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

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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


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

File 17 of 26 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/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 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 onlyInitializing {
    }

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

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

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

pragma solidity ^0.8.0;

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

File 19 of 26 : AuctionStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

enum AuctionType {
    TimedAuction,
    FixedPrice,
    TimedAndFixed
}

enum AuctionStatus {
    Open,
    Closed
}

struct Bid {
    uint128 bidAmount;
    uint128 bidPrice;
    address bidder;
    // bid token amount paid out when bidding
    uint128 paidAmount;
    uint16 bidTokenId;
    bool bCleared;
}

struct BidTokenGroup {
    // tokens in one group should be max 255
    address[] bidTokens;
    // calculated price by this address
    address basePriceToken;
    bytes32 name;
}

struct AuctionSetting {
    // start and expired time
    uint48 startTime;
    uint48 endTime;
    // listed token address
    address sellToken;
    // tranche id for tranche nft auction
    uint256 trancheIndex;
    // minimum bid or buy amount
    uint128 minBidAmount;
    // fixed price used when buying directly, without bidding
    uint128 fixedPrice;
    // lowest and highest bid price
    uint128 priceRangeStart;
    uint128 priceRangeEnd;
    // total amount of listed token
    uint128 sellAmount;
    // while auction is open, available token amount
    uint128 reserve;
    // price used when bidding in increment way
    uint128 incrementBidPrice;
    // bid token group id
    uint16 bidTokenGroupId;
    // auction type
    AuctionType auctionType;
}
/// @dev Contains all data for erc20 or tranche auction
struct AuctionData {
    // config params set by autioneer
    AuctionSetting s;
    // current bid id
    uint128 curBidId;
    // total amount of bids that can win after auction is closed
    uint128 totalBidAmount;
    // seller address
    address seller;
    // number of bids that can win after auction is closed. all bids out the range of availableBidDepth are canceled when bidding.
    uint8 availableBidDepth;
    // auction status
    AuctionStatus status;
    // fee amount used for refunded fee calculation
    uint256 feeAmount;
}

library AuctionStorage {
    struct Layout {
        // count of auctions and current auction id
        uint256 currentAuctionId;
        // all auctions by auction id
        mapping(uint256 => AuctionData) auctions;
        // all bids by auction id and bid id
        mapping(uint256 => mapping(uint256 => Bid)) bids;
        // whitelist for sell tokens
        mapping(address => bool) supportedSellTokens;
        // bid token groups
        mapping(uint256 => BidTokenGroup) bidTokenGroups;
        // count of bid token groups
        uint256 countOfTokenGroups;
        // fee amount and fee receiver address        
        uint256 feeNumerator;
        address feeReceiver;
        // deprecated
        uint96 maxIncrementRate;
        // available auction periods like 1 day, 3 days,
        uint48[] periods;
    }

    bytes32 internal constant STORAGE_SLOT = keccak256("irrigation.contracts.storage.Auction");

    function layout() internal pure returns (Layout storage ls) {
        bytes32 slot = STORAGE_SLOT;
        assembly {
            ls.slot := slot
        }
    }
}

File 20 of 26 : IDiamondCut.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

interface IDiamondCut {
    enum FacetCutAction {Add, Replace, Remove}
    // Add=0, Replace=1, Remove=2

    struct FacetCut {
        address facetAddress;
        FacetCutAction action;
        bytes4[] functionSelectors;
    }

    /// @notice Add/replace/remove any number of functions and optionally execute
    ///         a function with delegatecall
    /// @param _diamondCut Contains the facet addresses and function selectors
    /// @param _init The address of the contract or facet to execute _calldata
    /// @param _calldata A function call, including function selector and arguments
    ///                  _calldata is executed with delegatecall on _init
    function diamondCut(
        FacetCut[] calldata _diamondCut,
        address _init,
        bytes calldata _calldata
    ) external;

    event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata);
}

File 21 of 26 : IPriceOracleUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

interface IPriceOracleUpgradeable {
    /**
     * @notice Get latest price normalized to 1e18 for asset
     */
    function getPrice(address asset) external view returns (uint256);

    function getUnderlyingPriceETH() external view returns (uint);

    function getWaterPrice() external view returns (uint256);
}

File 22 of 26 : IWaterTowerUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/// @title WaterTower Interface

interface IWaterTowerUpgradeable {
    
    /// @dev events
    event Deposited(address indexed user, uint amount);
    event Withdrawn(address indexed user, uint amount);
    event Claimed(address indexed user, uint amount);
    event Irrigate(
        address indexed user,
        address middleAsset,
        uint irrigateAmount,
        uint waterAmount,
        uint bonusAmount
    );
    event SetAutoIrrigate(address indexed user, uint timestamp, bool bAutoIrrigate);
    event AutoIrrigate(address indexed user, uint rewardAmount, uint gasFee);
    event AddETHReward(uint256 amount);
    event UpdateRewardPeriod(uint poolIndex, uint endTime, uint monthlyRewards);

    function addETHReward() external payable;
}

File 23 of 26 : Constants.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

library Constants {
    /// Addresses
    address internal constant CURVE_ROUTER = 0x99a58482BD75cbab83b27EC03CA68fF489b5788f;
    address internal constant BEAN = 0xBEA0000029AD1c77D3d5D23Ba2D8893dB9d1Efab;
    address internal constant ETHER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
    address internal constant TRI_CRYPTO_POOL = 0xD51a44d3FaE010294C616388b506AcdA1bfAAE46;
    address internal constant USDT = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
    address internal constant CURVE_BEAN_METAPOOL = 0xc9C32cd16Bf7eFB85Ff14e0c8603cc90F6F2eE49;
    address internal constant BEANSTALK_PRICE = 0xF2C2b7eabcB353bF6f2128a7f8e1e32Eeb112530;
    address internal constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
    address internal constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
    address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
    address internal constant ZERO = 0x0000000000000000000000000000000000000000;
    address internal constant BEANSTALK = 0xC1E088fC1323b20BCBee9bd1B9fC9546db5624C5;
    address internal constant FERTILIZER = 0x402c84De2Ce49aF88f5e2eF3710ff89bFED36cB6;

    /// @notice time out to get price from chainlink
    /// @dev should update before deploying on mainnet
    uint256 internal constant GRACE_PERIOD_TIME = 72000000;

    /// underlying decimals
    uint256 internal constant D18 = 1e18;
    // tranche nft is fractionalized with decimals 6
    uint8 internal constant TRANCHE_DECIMALS = 6;
    uint8 internal constant WATER_DECIMALS = 18;    

    bytes internal constant EMPTY = "";

    /// function selectors
    bytes4 internal constant ERC1155_ACCEPTED = 0xf23a6e61; // bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))
    bytes4 internal constant ERC1155_BATCH_ACCEPTED = 0xbc197c81; // bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))
}

File 24 of 26 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/// @title Contains math functions
library FullMath {
    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivRoundingUp(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        result = (a * b) / denominator;
        if (mulmod(a, b, denominator) > 0) {
            require(result < type(uint256).max);
            result++;
        }
    }

    function mulDivRoundingUp128(
        uint128 a,
        uint128 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        result = (uint256(a) * uint256(b)) / denominator;
        if (mulmod(uint256(a), uint256(b), denominator) > 0) {
            // require(result < type(uint256).max); // no overflow for uint128
            result++;
        }
    }
}

File 25 of 26 : LibDiamond.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

/******************************************************************************\
* Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen)
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/
import { IDiamondCut } from "../interfaces/IDiamondCut.sol";

// Remember to add the loupe functions from DiamondLoupeFacet to the diamond.
// The loupe functions are required by the EIP2535 Diamonds standard

library LibDiamond {
    bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage");

    struct DiamondStorage {
        // maps function selectors to the facets that execute the functions.
        // and maps the selectors to their position in the selectorSlots array.
        // func selector => address facet, selector position
        mapping(bytes4 => bytes32) facets;
        // array of slots of function selectors.
        // each slot holds 8 function selectors.
        mapping(uint256 => bytes32) selectorSlots;
        // The number of function selectors in selectorSlots
        uint16 selectorCount;
        // Used to query if a contract implements an interface.
        // Used to implement ERC-165.
        mapping(bytes4 => bool) supportedInterfaces;
        // owner of the contract
        address contractOwner;
    }

    function diamondStorage() internal pure returns (DiamondStorage storage ds) {
        bytes32 position = DIAMOND_STORAGE_POSITION;
        assembly {
            ds.slot := position
        }
    }

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

    function setContractOwner(address _newOwner) internal {
        DiamondStorage storage ds = diamondStorage();
        address previousOwner = ds.contractOwner;
        ds.contractOwner = _newOwner;
        emit OwnershipTransferred(previousOwner, _newOwner);
    }

    function contractOwner() internal view returns (address contractOwner_) {
        contractOwner_ = diamondStorage().contractOwner;
    }

    function enforceIsContractOwner() internal view {
        require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner");
    }

    event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata);

    bytes32 constant CLEAR_ADDRESS_MASK = bytes32(uint256(0xffffffffffffffffffffffff));
    bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224));

    // Internal function version of diamondCut
    // This code is almost the same as the external diamondCut,
    // except it is using 'Facet[] memory _diamondCut' instead of
    // 'Facet[] calldata _diamondCut'.
    // The code is duplicated to prevent copying calldata to memory which
    // causes an error for a two dimensional array.
    function diamondCut(
        IDiamondCut.FacetCut[] memory _diamondCut,
        address _init,
        bytes memory _calldata
    ) internal {
        DiamondStorage storage ds = diamondStorage();
        uint256 originalSelectorCount = ds.selectorCount;
        uint256 selectorCount = originalSelectorCount;
        bytes32 selectorSlot;
        // Check if last selector slot is not full
        // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8"
        if (selectorCount & 7 > 0) {
            // get last selectorSlot
            // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8"
            selectorSlot = ds.selectorSlots[selectorCount >> 3];
        }
        // loop through diamond cut
        for (uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++) {
            (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors(
                selectorCount,
                selectorSlot,
                _diamondCut[facetIndex].facetAddress,
                _diamondCut[facetIndex].action,
                _diamondCut[facetIndex].functionSelectors
            );
        }
        if (selectorCount != originalSelectorCount) {
            ds.selectorCount = uint16(selectorCount);
        }
        // If last selector slot is not full
        // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8"
        if (selectorCount & 7 > 0) {
            // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8"
            ds.selectorSlots[selectorCount >> 3] = selectorSlot;
        }
        emit DiamondCut(_diamondCut, _init, _calldata);
        initializeDiamondCut(_init, _calldata);
    }

    function addReplaceRemoveFacetSelectors(
        uint256 _selectorCount,
        bytes32 _selectorSlot,
        address _newFacetAddress,
        IDiamondCut.FacetCutAction _action,
        bytes4[] memory _selectors
    ) internal returns (uint256, bytes32) {
        DiamondStorage storage ds = diamondStorage();
        require(_selectors.length > 0, "LibDiamondCut: No selectors in facet to cut");
        if (_action == IDiamondCut.FacetCutAction.Add) {
            enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Add facet has no code");
            for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
                bytes4 selector = _selectors[selectorIndex];
                bytes32 oldFacet = ds.facets[selector];
                require(address(bytes20(oldFacet)) == address(0), "LibDiamondCut: Can't add function that already exists");
                // add facet for selector
                ds.facets[selector] = bytes20(_newFacetAddress) | bytes32(_selectorCount);
                // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8"
                // " << 5 is the same as multiplying by 32 ( * 32)
                uint256 selectorInSlotPosition = (_selectorCount & 7) << 5;
                // clear selector position in slot and add selector
                _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) | (bytes32(selector) >> selectorInSlotPosition);
                // if slot is full then write it to storage
                if (selectorInSlotPosition == 224) {
                    // "_selectorSlot >> 3" is a gas efficient division by 8 "_selectorSlot / 8"
                    ds.selectorSlots[_selectorCount >> 3] = _selectorSlot;
                    _selectorSlot = 0;
                }
                _selectorCount++;
            }
        } else if (_action == IDiamondCut.FacetCutAction.Replace) {
            enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Replace facet has no code");
            for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
                bytes4 selector = _selectors[selectorIndex];
                bytes32 oldFacet = ds.facets[selector];
                address oldFacetAddress = address(bytes20(oldFacet));
                // only useful if immutable functions exist
                require(oldFacetAddress != address(this), "LibDiamondCut: Can't replace immutable function");
                require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function");
                require(oldFacetAddress != address(0), "LibDiamondCut: Can't replace function that doesn't exist");
                // replace old facet address
                ds.facets[selector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(_newFacetAddress);
            }
        } else if (_action == IDiamondCut.FacetCutAction.Remove) {
            require(_newFacetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)");
            // "_selectorCount >> 3" is a gas efficient division by 8 "_selectorCount / 8"
            uint256 selectorSlotCount = _selectorCount >> 3;
            // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8"
            uint256 selectorInSlotIndex = _selectorCount & 7;
            for (uint256 selectorIndex; selectorIndex < _selectors.length; selectorIndex++) {
                if (_selectorSlot == 0) {
                    // get last selectorSlot
                    selectorSlotCount--;
                    _selectorSlot = ds.selectorSlots[selectorSlotCount];
                    selectorInSlotIndex = 7;
                } else {
                    selectorInSlotIndex--;
                }
                bytes4 lastSelector;
                uint256 oldSelectorsSlotCount;
                uint256 oldSelectorInSlotPosition;
                // adding a block here prevents stack too deep error
                {
                    bytes4 selector = _selectors[selectorIndex];
                    bytes32 oldFacet = ds.facets[selector];
                    require(address(bytes20(oldFacet)) != address(0), "LibDiamondCut: Can't remove function that doesn't exist");
                    // only useful if immutable functions exist
                    require(address(bytes20(oldFacet)) != address(this), "LibDiamondCut: Can't remove immutable function");
                    // replace selector with last selector in ds.facets
                    // gets the last selector
                    // " << 5 is the same as multiplying by 32 ( * 32)
                    lastSelector = bytes4(_selectorSlot << (selectorInSlotIndex << 5));
                    if (lastSelector != selector) {
                        // update last selector slot position info
                        ds.facets[lastSelector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(ds.facets[lastSelector]);
                    }
                    delete ds.facets[selector];
                    uint256 oldSelectorCount = uint16(uint256(oldFacet));
                    // "oldSelectorCount >> 3" is a gas efficient division by 8 "oldSelectorCount / 8"
                    oldSelectorsSlotCount = oldSelectorCount >> 3;
                    // "oldSelectorCount & 7" is a gas efficient modulo by eight "oldSelectorCount % 8"
                    // " << 5 is the same as multiplying by 32 ( * 32)
                    oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5;
                }
                if (oldSelectorsSlotCount != selectorSlotCount) {
                    bytes32 oldSelectorSlot = ds.selectorSlots[oldSelectorsSlotCount];
                    // clears the selector we are deleting and puts the last selector in its place.
                    oldSelectorSlot =
                        (oldSelectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) |
                        (bytes32(lastSelector) >> oldSelectorInSlotPosition);
                    // update storage with the modified slot
                    ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot;
                } else {
                    // clears the selector we are deleting and puts the last selector in its place.
                    _selectorSlot =
                        (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) |
                        (bytes32(lastSelector) >> oldSelectorInSlotPosition);
                }
                if (selectorInSlotIndex == 0) {
                    delete ds.selectorSlots[selectorSlotCount];
                    _selectorSlot = 0;
                }
            }
            _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex;
        } else {
            revert("LibDiamondCut: Incorrect FacetCutAction");
        }
        return (_selectorCount, _selectorSlot);
    }

    function initializeDiamondCut(address _init, bytes memory _calldata) internal {
        if (_init == address(0)) {
            return;
        }
        enforceHasContractCode(_init, "LibDiamondCut: _init address has no code");
        (bool success, bytes memory error) = _init.delegatecall(_calldata);
        if (!success) {
            if (error.length > 0) {
                // bubble up error
                /// @solidity memory-safe-assembly
                assembly {
                    let returndata_size := mload(error)
                    revert(add(32, error), returndata_size)
                }
            } else {
                revert("InitializationFunctionReverted(address, bytes)");
            }
        }
    }

    function enforceHasContractCode(address _contract, string memory _errorMessage) internal view {
        uint256 contractSize;
        assembly {
            contractSize := extcodesize(_contract)
        }
        require(contractSize > 0, _errorMessage);
    }
}

File 26 of 26 : EIP2535Initializable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@gnus.ai/contracts-upgradeable-diamond/contracts/proxy/utils/Initializable.sol";
import "@gnus.ai/contracts-upgradeable-diamond/contracts/proxy/utils/InitializableStorage.sol";
import "../libraries/LibDiamond.sol";

abstract contract EIP2535Initializable is Initializable {

    // override Initializable::initializer modifier
    modifier EIP2535Initializer() {
        require(!InitializableStorage.layout()._initializing && InitializableStorage.layout()._initialized < 1, "Initializable: contract is already initialized");
        InitializableStorage.layout()._initialized = 1;
        InitializableStorage.layout()._initializing = true;
        _;
        // multiple facet contracts needed initialization on deployment
        InitializableStorage.layout()._initialized = 0;
        InitializableStorage.layout()._initializing = false;
    }

    modifier EIP2535Reinitializer(uint8 version) {
        require(!InitializableStorage.layout()._initializing && InitializableStorage.layout()._initialized < version, "Initializable: contract is already initialized");
        InitializableStorage.layout()._initialized = version;
        InitializableStorage.layout()._initializing = true;
        _;
        // multiple facet contracts needed re-initialization on ugrades for instance
        InitializableStorage.layout()._initialized = 0;
        InitializableStorage.layout()._initializing = false;
        }

}

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

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"ClaimedBid","type":"error"},{"inputs":[],"name":"InactiveAuction","type":"error"},{"inputs":[],"name":"InsufficientFee","type":"error"},{"inputs":[],"name":"InsufficientReserveAsset","type":"error"},{"inputs":[],"name":"InvalidAuction","type":"error"},{"inputs":[],"name":"InvalidAuctionAmount","type":"error"},{"inputs":[],"name":"InvalidBidToken","type":"error"},{"inputs":[],"name":"InvalidEndPrice","type":"error"},{"inputs":[],"name":"InvalidFixedPrice","type":"error"},{"inputs":[],"name":"InvalidIncrementBidPrice","type":"error"},{"inputs":[],"name":"InvalidMinBidAmount","type":"error"},{"inputs":[],"name":"InvalidPurchaseAmount","type":"error"},{"inputs":[],"name":"InvalidSellToken","type":"error"},{"inputs":[],"name":"InvalidStartTime","type":"error"},{"inputs":[],"name":"InvalidTrancheAuction","type":"error"},{"inputs":[],"name":"LowBid","type":"error"},{"inputs":[],"name":"NoAuction","type":"error"},{"inputs":[],"name":"NoAuctioneer","type":"error"},{"inputs":[],"name":"NoBidder","type":"error"},{"inputs":[],"name":"NoCancelBid","type":"error"},{"inputs":[],"name":"NoClosedAuction","type":"error"},{"inputs":[],"name":"NoIdleAuction","type":"error"},{"inputs":[],"name":"NoListTrancheZ","type":"error"},{"inputs":[],"name":"NoTransferEther","type":"error"},{"inputs":[],"name":"OverPriceBid","type":"error"},{"inputs":[],"name":"SmallBidAmount","type":"error"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint128","name":"bidAmount","type":"uint128"},{"internalType":"uint128","name":"bidPrice","type":"uint128"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint128","name":"paidAmount","type":"uint128"},{"internalType":"uint16","name":"bidTokenId","type":"uint16"},{"internalType":"bool","name":"bCleared","type":"bool"}],"indexed":false,"internalType":"struct Bid","name":"bid","type":"tuple"},{"indexed":true,"internalType":"uint256","name":"auctionId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"bidId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"availableBidDepth","type":"uint256"}],"name":"AuctionBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountOut","type":"uint256"},{"indexed":false,"internalType":"address","name":"purchaseToken","type":"address"},{"indexed":true,"internalType":"uint256","name":"auctionId","type":"uint256"}],"name":"AuctionBuy","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"unSoldAmount","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"auctionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"settledBidCount","type":"uint256"}],"name":"AuctionClosed","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"uint48","name":"startTime","type":"uint48"},{"internalType":"uint48","name":"endTime","type":"uint48"},{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"uint256","name":"trancheIndex","type":"uint256"},{"internalType":"uint128","name":"minBidAmount","type":"uint128"},{"internalType":"uint128","name":"fixedPrice","type":"uint128"},{"internalType":"uint128","name":"priceRangeStart","type":"uint128"},{"internalType":"uint128","name":"priceRangeEnd","type":"uint128"},{"internalType":"uint128","name":"sellAmount","type":"uint128"},{"internalType":"uint128","name":"reserve","type":"uint128"},{"internalType":"uint128","name":"incrementBidPrice","type":"uint128"},{"internalType":"uint16","name":"bidTokenGroupId","type":"uint16"},{"internalType":"enum AuctionType","name":"auctionType","type":"uint8"}],"indexed":false,"internalType":"struct AuctionSetting","name":"auctionSetting","type":"tuple"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"uint256","name":"auctionId","type":"uint256"}],"name":"AuctionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"auctionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minBidAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"priceRangeStart","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"incrementPrice","type":"uint256"}],"name":"AuctionUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"auctionId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"bidId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isWinner","type":"bool"},{"indexed":false,"internalType":"uint256","name":"claimAmount","type":"uint256"}],"name":"ClaimBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"uint256","name":"auctionId","type":"uint256"},{"internalType":"uint128","name":"purchaseAmount","type":"uint128"},{"internalType":"uint16","name":"buyTokenId","type":"uint16"}],"name":"buyNow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"auctionId","type":"uint256"},{"internalType":"uint256","name":"bidId","type":"uint256"}],"name":"claimBid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"auctionId","type":"uint256"}],"name":"closeAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint48","name":"startTime","type":"uint48"},{"internalType":"uint48","name":"endTime","type":"uint48"},{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"uint256","name":"trancheIndex","type":"uint256"},{"internalType":"uint128","name":"minBidAmount","type":"uint128"},{"internalType":"uint128","name":"fixedPrice","type":"uint128"},{"internalType":"uint128","name":"priceRangeStart","type":"uint128"},{"internalType":"uint128","name":"priceRangeEnd","type":"uint128"},{"internalType":"uint128","name":"sellAmount","type":"uint128"},{"internalType":"uint128","name":"reserve","type":"uint128"},{"internalType":"uint128","name":"incrementBidPrice","type":"uint128"},{"internalType":"uint16","name":"bidTokenGroupId","type":"uint16"},{"internalType":"enum AuctionType","name":"auctionType","type":"uint8"}],"internalType":"struct AuctionSetting","name":"auctionSetting","type":"tuple"},{"internalType":"uint8","name":"periodId","type":"uint8"}],"name":"createAuction","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"auctionId","type":"uint256"}],"name":"getAuction","outputs":[{"components":[{"components":[{"internalType":"uint48","name":"startTime","type":"uint48"},{"internalType":"uint48","name":"endTime","type":"uint48"},{"internalType":"address","name":"sellToken","type":"address"},{"internalType":"uint256","name":"trancheIndex","type":"uint256"},{"internalType":"uint128","name":"minBidAmount","type":"uint128"},{"internalType":"uint128","name":"fixedPrice","type":"uint128"},{"internalType":"uint128","name":"priceRangeStart","type":"uint128"},{"internalType":"uint128","name":"priceRangeEnd","type":"uint128"},{"internalType":"uint128","name":"sellAmount","type":"uint128"},{"internalType":"uint128","name":"reserve","type":"uint128"},{"internalType":"uint128","name":"incrementBidPrice","type":"uint128"},{"internalType":"uint16","name":"bidTokenGroupId","type":"uint16"},{"internalType":"enum AuctionType","name":"auctionType","type":"uint8"}],"internalType":"struct AuctionSetting","name":"s","type":"tuple"},{"internalType":"uint128","name":"curBidId","type":"uint128"},{"internalType":"uint128","name":"totalBidAmount","type":"uint128"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint8","name":"availableBidDepth","type":"uint8"},{"internalType":"enum AuctionStatus","name":"status","type":"uint8"},{"internalType":"uint256","name":"feeAmount","type":"uint256"}],"internalType":"struct AuctionData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAuctionFee","outputs":[{"internalType":"uint256","name":"numerator","type":"uint256"},{"internalType":"uint256","name":"dominator","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAuctionPeriods","outputs":[{"internalType":"uint48[]","name":"","type":"uint48[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAuctionsCount","outputs":[{"internalType":"uint256","name":"totalAuctionsCount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"auctionId","type":"uint256"},{"internalType":"uint256","name":"bidId","type":"uint256"}],"name":"getBid","outputs":[{"components":[{"internalType":"uint128","name":"bidAmount","type":"uint128"},{"internalType":"uint128","name":"bidPrice","type":"uint128"},{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint128","name":"paidAmount","type":"uint128"},{"internalType":"uint16","name":"bidTokenId","type":"uint16"},{"internalType":"bool","name":"bCleared","type":"bool"}],"internalType":"struct Bid","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenGroupId","type":"uint256"}],"name":"getBidTokenGroup","outputs":[{"components":[{"internalType":"address[]","name":"bidTokens","type":"address[]"},{"internalType":"address","name":"basePriceToken","type":"address"},{"internalType":"bytes32","name":"name","type":"bytes32"}],"internalType":"struct BidTokenGroup","name":"tokenGroup","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getBidTokenGroupCount","outputs":[{"internalType":"uint256","name":"countOfTokenGroup","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"purchaseToken","type":"address"},{"internalType":"uint128","name":"purchaseAmount","type":"uint128"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"uint8","name":"sellTokenDecimals","type":"uint8"}],"name":"getPayAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"auctionId","type":"uint256"},{"internalType":"uint256","name":"bidId","type":"uint256"}],"name":"isWinnerBid","outputs":[{"internalType":"bool","name":"isWinner","type":"bool"},{"internalType":"bool","name":"isClaimed","type":"bool"},{"internalType":"uint256","name":"claimAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"auctionId","type":"uint256"},{"internalType":"uint128","name":"bidAmount","type":"uint128"},{"internalType":"uint16","name":"bidTokenId","type":"uint16"},{"internalType":"uint128","name":"bidPrice","type":"uint128"},{"internalType":"uint128","name":"maxBidPrice","type":"uint128"}],"name":"placeBid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"auctionId","type":"uint256"},{"internalType":"uint128","name":"minBidAmount","type":"uint128"},{"internalType":"uint128","name":"priceRangeStart","type":"uint128"},{"internalType":"uint128","name":"incrementBidPrice","type":"uint128"}],"name":"updateAuction","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50614965806100206000396000f3fe6080604052600436106100f35760003560e01c8063808bf40c1161008a578063ca03901711610059578063ca0390171461031a578063d14228d31461033c578063e45c18791461035c578063e47fd1f11461037e57600080fd5b8063808bf40c1461029a5780638f031880146102ba578063a6523f8f146102cd578063c34a7336146102fa57600080fd5b80635c975abb116100c65780635c975abb146101ce5780635e06f72b1461021057806376741bb91461023057806378bd79351461026d57600080fd5b80631031ca44146100f8578063236ed8f3146101415780634c1cafc614610163578063582c7ffd146101a1575b600080fd5b34801561010457600080fd5b507f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173aa54604080519182526103e86020830152015b60405180910390f35b34801561014d57600080fd5b5061016161015c366004613eca565b61039e565b005b34801561016f57600080fd5b507f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a9545b604051908152602001610138565b3480156101ad57600080fd5b506101c16101bc366004613ee3565b610622565b6040516101389190613f05565b3480156101da57600080fd5b507f7a6a842f4b254b253ecba70474976063c6e762839bf3f5aef2536e9bee8f5e655460ff166040519015158152602001610138565b34801561021c57600080fd5b5061019361022b366004613f94565b6106ef565b34801561023c57600080fd5b5061025061024b366004613ee3565b6111e9565b604080519315158452911515602084015290820152606001610138565b34801561027957600080fd5b5061028d610288366004613eca565b611459565b6040516101389190614139565b3480156102a657600080fd5b506101936102b53660046141e7565b6116ae565b6101616102c83660046142b0565b61174d565b3480156102d957600080fd5b506102ed6102e8366004613eca565b61201b565b60405161013891906143ce565b34801561030657600080fd5b50610161610315366004613ee3565b6120ea565b34801561032657600080fd5b5061032f61256e565b6040516101389190614446565b34801561034857600080fd5b50610161610357366004614492565b612606565b34801561036857600080fd5b5060008051602061493983398151915254610193565b34801561038a57600080fd5b506101616103993660046144ce565b612b1d565b6103a6612fa6565b6103ae61303d565b60008181527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff166102408601528492918491610260850191600160901b90910460ff16908111156104c9576104c9613ff2565b60028111156104da576104da613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b90910416600181111561054657610546613ff2565b600181111561055757610557613ff2565b8152600891909101546020918201528151015190915065ffffffffffff16421080159061059a575060018160a00151600181111561059757610597613ff2565b14155b6105eb5760405162461bcd60e51b815260206004820152601760248201527f61756374696f6e2063616e277420626520636c6f73656400000000000000000060448201526064015b60405180910390fd5b6105f582826130b1565b5061061f60017f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b50565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a08101919091526000805160206149398339815191526000848152600291820160209081526040808320868452825291829020825160c08101845281546001600160801b038082168352600160801b9182900481169483019490945260018301546001600160a01b031694820194909452930154908116606084015290810461ffff166080830152600160901b900460ff16151560a082015290505b92915050565b60006106f9612fa6565b61070161303d565b60008681527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff1661024086015260008051602061493983398151915295949392849290918491610260850191600160901b900460ff169081111561082f5761082f613ff2565b600281111561084057610840613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b9091041660018111156108ac576108ac613ff2565b60018111156108bd576108bd613ff2565b81526008919091015460209091015260608101519091506001600160a01b03161580610900575060018151610180015160028111156108fe576108fe613ff2565b145b1561091e5760405163010ab10b60e51b815260040160405180910390fd5b8051610160015161ffff90811660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a8602052604081208054919290919089169081106109705761097061451b565b6000918252602091829020015483519182015191516001600160a01b0390911692506109a79165ffffffffffff9081169116613851565b8151608001516001600160801b03808a16911611156109d957604051630cca9d2b60e21b815260040160405180910390fd5b816000015161012001516001600160801b0316886001600160801b03161115610a1557604051632beee6cf60e01b815260040160405180910390fd5b600082602001516001600160801b0316600014610a75578251610140015160008b81526002860160209081526040808320828801516001600160801b039081168552925290912054610a709291600160801b90910416614547565b610a7c565b825160c001515b9050866001600160801b0316600003610a9757809650610ae3565b806001600160801b0316876001600160801b03161015610ae3576040517fbecfaa2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160801b0316876001600160801b03161115610b2f576040517f2c4a793c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008790506000610bbd848c84600089600001516060015111610bb6578860000151604001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b92573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b5919061456e565b60066116ae565b9050610bd46001600160a01b0385163330846138a1565b60006040518060c001604052808d6001600160801b03168152602001846001600160801b03168152602001336001600160a01b03168152602001836001600160801b031681526020018c61ffff168152602001600015158152509050600086602001516001610c439190614547565b905060005a905060008f905060008f9050848b60020160008481526020019081526020016000206000866001600160801b0316815260200190815260200160002060008201518160000160006101000a8154816001600160801b0302191690836001600160801b0316021790555060208201518160000160106101000a8154816001600160801b0302191690836001600160801b0316021790555060408201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160020160006101000a8154816001600160801b0302191690836001600160801b0316021790555060808201518160020160106101000a81548161ffff021916908361ffff16021790555060a08201518160020160126101000a81548160ff02191690831515021790555090505060008a6080015160ff166001610d94919061458b565b90506000828c60400151610da89190614547565b8c51610160015161ffff1660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a86020908152604080832080548251818502810185019093528083529495509293909291830182828015610e3557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610e17575b505050505090505b6000610e52846001600160801b038a1661459e565b610e5d90600161458b565b905060008f600201600088815260200190815260200160002060008381526020019081526020016000206040518060c00160405290816000820160009054906101000a90046001600160801b03166001600160801b03166001600160801b031681526020016000820160109054906101000a90046001600160801b03166001600160801b03166001600160801b031681526020016001820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681526020016002820160009054906101000a90046001600160801b03166001600160801b03166001600160801b031681526020016002820160109054906101000a900461ffff1661ffff1661ffff1681526020016002820160129054906101000a900460ff161515151581525050905080600001518f600001516101200151610fa49190614547565b6001600160801b0316846001600160801b03161015610fc45750506110cb565b805160a0820151600019909601959403931561100c576040517f11da50f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61105c816040015182606001516001600160801b031685846080015161ffff168151811061103c5761103c61451b565b60200260200101516001600160a01b03166139589092919063ffffffff16565b60008781527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a6602090815260408083208584529091529020600201805460ff60901b1916600160901b17905562072bf05a6110b7908a61459e565b11156110c45750506110cb565b5050610e3d565b60008581527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a56020526040908190206007810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b60ff8816021790556001600160801b03848116600160801b026fffffffffffffffffffffffffffffffff1916908a16908117600690920191909155905186907ff1630e8b4f09b0a9920a444540e8af405633f4cc2d5336befdff66637a4ccaf290611195908c9088906145b1565b60405180910390a3505050505050806001600160801b0316985050505050505050506111e060017f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b95945050505050565b60008281527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff16610240860152859485946000805160206149398339815191529486949293919284928491610260850191600160901b900460ff169081111561131c5761131c613ff2565b600281111561132d5761132d613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b90910416600181111561139957611399613ff2565b60018111156113aa576113aa613ff2565b81526008919091015460209182015260008981526002858101835260408083208b8452845291829020825160c08101845281546001600160801b038082168352600160801b9182900481169683019690965260018301546001600160a01b031694820194909452910154928316606082015290820461ffff166080820152600160901b90910460ff16151560a0820152909150611449888884846139a1565b9550955095505050509250925092565b6040805161028081018252600060e08201818152610100830182905261012083018290526101408301829052610160830182905261018083018290526101a083018290526101c083018290526101e083018290526102008301829052610220830182905261024083018290526102608301829052825260208201819052918101829052606081018290526080810182905260a0810182905260c08101919091526000805160206149398339815191526000838152600191820160205260409081902081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b0316610120840152928101546101408301526002808201546001600160801b03808216610160860152600160801b91829004811661018086015260038401548082166101a087015282900481166101c086015260048401548082166101e08701528290048116610200860152600584015490811661022086015290810461ffff16610240850152929391928492918491610260850191600160901b90910460ff169081111561160b5761160b613ff2565b600281111561161c5761161c613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b90910416600181111561168857611688613ff2565b600181111561169957611699613ff2565b81526020016008820154815250509050919050565b60008082866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611714919061456e565b61171f90601261461f565b6117299190614638565b61173490600a614735565b9050611741858583613b45565b9150505b949350505050565b61175561303d565b6040828101516001600160a01b031660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a760205220546000805160206149398339815191529060ff166117d8576040517f5110df2400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806005015483610160015161ffff161061181e576040517f02777d5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60648361010001516001600160801b0316611839919061475a565b83608001516001600160801b0316108061186d57508261010001516001600160801b031683608001516001600160801b0316115b156118a4576040517f2304cb6e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8261010001516001600160801b03166000036118ec576040517f5a5a1b3000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001836101800151600281111561190557611905613ff2565b148061192757506002836101800151600281111561192557611925613ff2565b145b801561193e575060a08301516001600160801b0316155b15611975576040517f84477d0400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001836101800151600281111561198e5761198e613ff2565b14611a46578260e001516001600160801b03168360c001516001600160801b031611156119ce57604051630455852f60e51b815260040160405180910390fd5b6101408301516001600160801b03161580611a0f57508260c001516001600160801b031660028461014001516001600160801b0316611a0d919061476e565b115b15611a46576040517fda6b4f0a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b825165ffffffffffff16600003611a675765ffffffffffff42168352611acc565b42836000015165ffffffffffff161080611a955750611a894262278d0061458b565b835165ffffffffffff16115b15611acc576040517fb290253c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806008018260ff1681548110611ae457611ae461451b565b90600052602060002090600591828204019190066006029054906101000a900465ffffffffffff168360000151611b1b9190614785565b65ffffffffffff1660208401528054600090611b3890600161458b565b90508360600151600003611b9e57611b9933306103e885600601546103e8611b60919061458b565b8861010001516001600160801b0316611b79919061476e565b611b83919061475a565b60408801516001600160a01b03169291906138a1565b611e32565b8360600151600316600303611bdf576040517f2dbdd4d100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408401516001600160a01b03163014611c25576040517fc99421ae00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606084015161010085015160408051602081018252600081529051637921219560e11b8152309363f242432a93611c6593339387939291906004016147f4565b600060405180830381600087803b158015611c7f57600080fd5b505af1158015611c93573d6000803e3d6000fd5b505050506000306001600160a01b03166384a2ce136040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfb9190614835565b905060006103e88460060154836c0c9f2c9cd04674edea400000008961010001516001600160801b0316611d2f919061476e565b611d39919061475a565b611d43919061476e565b611d4d919061475a565b905080341015611d89576040517f025dbdd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80341115611e1c57600033611d9e833461459e565b604051600081818185875af1925050503d8060008114611dda576040519150601f19603f3d011682016040523d82523d6000602084013e611ddf565b606091505b5050905080611e1a576040517f305bcd3c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b6000838152600185016020526040902060080155505b808255610100840180516001600160801b0390811661012087019081526000848152600180870160209081526040928390208a518154928c0151948c01516001600160a01b0316600160601b026bffffffffffffffffffffffff65ffffffffffff9687166601000000000000026bffffffffffffffffffffffff1990951696909216959095179290921791909116929092178255606089015190820155608088015160a08901518416600160801b9081029185169190911760028084019190915560c08a015160e08b01518616830290861617600384015594519251841681029284169290921760048201556101408801516005820180546101608b015161ffff169094027fffffffffffffffffffffffffffff000000000000000000000000000000000000909416919094161791909117808355610180880151889492939092909160ff60901b191690600160901b908490811115611f9457611f94613ff2565b0217905550505060008181526001830160205260409081902060070180547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915590518291907ff68eef6cdaf5fca4b176f66d13fb98bd2ceeb400fee5eee535f0925ac180e8469061200d90889061484e565b60405180910390a350505050565b6040805160608082018352808252600060208084018290528385018290528582527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a88152908490208451815492830281016080908101909652928301828152939492939092849284918401828280156120bd57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161209f575b505050918352505060018201546001600160a01b0316602082015260029091015460409091015292915050565b6120f2612fa6565b6120fa61303d565b60008281527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff1661024086015260008051602061493983398151915295949392849290918491610260850191600160901b900460ff169081111561222857612228613ff2565b600281111561223957612239613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b9091041660018111156122a5576122a5613ff2565b60018111156122b6576122b6613ff2565b81526008919091015460209182015260008681526002858101835260408083208884528452808320815160c08101835281546001600160801b038082168352600160801b9182900481169783019790975260018301546001600160a01b0316938201939093529201549384166060830152830461ffff166080820152600160901b90920460ff16151560a0830152919250908080612356888887876139a1565b9250925092508115612394576040517fb3f0f1d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008881526002808801602090815260408084208b855290915290912001805460ff60901b1916600160901b17905560018560a0015160018111156123db576123db613ff2565b14612412576040517f5814bd1f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8451610160015161ffff908116600090815260048801602052604081206080870151815492939192911690811061244b5761244b61451b565b6000918252602090912001546001600160a01b0316905083156124cb578551610120015161247a90839061485d565b60008a81526001890160205260409081902060040180546001600160801b03938416600160801b029316929092179091558651908101516060909101516124c49190838886613baa565b50506124f2565b604085015160608601516124f2916001600160a01b038416916001600160801b0316613958565b604080518a8152602081018a9052851515818301526060810184905290517f5880a3c41abda1f5b6bfd10e0a0c7493be1522323e7b01e912e3e73d187fff689181900360800190a15050505050505061256a60017f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b5050565b60606000805160206149398339815191526008018054806020026020016040519081016040528092919081815260200182805480156125fc57602002820191906000526020600020906000905b82829054906101000a900465ffffffffffff1665ffffffffffff16815260200190600601906020826005010492830192600103820291508084116125bb5790505b5050505050905090565b61260e612fa6565b61261661303d565b60008381527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff1661024086015260008051602061493983398151915295949392849290918491610260850191600160901b900460ff169081111561274457612744613ff2565b600281111561275557612755613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b9091041660018111156127c1576127c1613ff2565b60018111156127d2576127d2613ff2565b81526008919091015460209091015260608101519091506001600160a01b031615806128155750600081516101800151600281111561281357612813613ff2565b145b156128335760405163010ab10b60e51b815260040160405180910390fd5b8051610160015161ffff90811660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a8602052604081208054919290919086169081106128855761288561451b565b6000918252602091829020015483519182015191516001600160a01b0390911692506128bc9165ffffffffffff9081169116613851565b81516101208101516060909101516001600160801b0380831690881611156128f757604051632beee6cf60e01b815260040160405180910390fd5b8351608001516001600160801b038089169116111561292957604051630cca9d2b60e21b815260040160405180910390fd5b6000888152600186016020526040812060040180546001600160801b038a86038116600160801b0291161790558181036129f2578460000151604001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c7919061456e565b8551604001519091506129ed906001600160a01b0316336001600160801b038b16613958565b612a5f565b5060408051602081018252600081529051637921219560e11b8152600691309163f242432a91612a2c918491339188918f916004016147f4565b600060405180830381600087803b158015612a4657600080fd5b505af1158015612a5a573d6000803e3d6000fd5b505050505b6000612a75858a886000015160a00151856116ae565b6060870151909150612a94906001600160a01b038716903390846138a1565b604080518281526001600160801b038b1660208201526001600160a01b0387168183015290518b9133917ffda4db17d28a65b6cf5fb6f7798cf59cc1294e5b3bc1fc9c70d6f65c1dedacaf9181900360600190a350505050505050612b1860017f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b505050565b612b2561303d565b60008481527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff1661024086015260008051602061493983398151915295949392849290918491610260850191600160901b900460ff1690811115612c5357612c53613ff2565b6002811115612c6457612c64613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b909104166001811115612cd057612cd0613ff2565b6001811115612ce157612ce1613ff2565b81526020016008820154815250509050336001600160a01b031681606001516001600160a01b031614612d40576040517f49734eca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008160a001516001811115612d5857612d58613ff2565b141580612d7457504281600001516020015165ffffffffffff16105b80612d8b575060208101516001600160801b031615155b15612dc2576040517f8ccce47e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806000015160e001516001600160801b0316846001600160801b03161115612dfd57604051630455852f60e51b815260040160405180910390fd5b80516101000151612e19906064906001600160801b031661475a565b8151608001516001600160801b031610801590612e515750806000015161010001516001600160801b0316856001600160801b031611155b15612e8c576000868152600183016020526040902060020180546fffffffffffffffffffffffffffffffff19166001600160801b0387161790555b6001600160801b03841615612ed1576000868152600183016020526040902060030180546fffffffffffffffffffffffffffffffff19166001600160801b0386161790555b6001600160801b03831615801590612f15575060008681526001830160205260409020600301546001600160801b0390811690612f1290600290861661476e565b11155b15612f50576000868152600183016020526040902060050180546fffffffffffffffffffffffffffffffff19166001600160801b0385161790555b604080516001600160801b0387811682528681166020830152851681830152905187917fcc9d5e33604a3e02e9b278635bf2852ee06f4363a3f23d3e748708fd1d1ec853919081900360600190a2505050505050565b60027f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32154036130175760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105e2565b60027f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b7f7a6a842f4b254b253ecba70474976063c6e762839bf3f5aef2536e9bee8f5e655460ff16156130af5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016105e2565b565b60005a82516101208101516020808601516101609093015161ffff1660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a8825260408082208054825181860281018601909352808352969750939591946001600160801b0316936000805160206149398339815191529386939083018282801561316857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161314a575b505050505090506000815167ffffffffffffffff81111561318b5761318b61423d565b6040519080825280602002602001820160405280156131b4578160200160208202803683370190505b5090506000865b6000861180156131d457506000816001600160801b0316115b156134205760008b81526002868101602090815260408084208a8552825292839020835160c08101855281546001600160801b038082168352600160801b9182900481169483019490945260018301546001600160a01b031695820195909552920154908116606083015291820461ffff166080820152600160901b90910460ff1615801560a08301526132685750613420565b8215801561328457506202bf205a613280919061458b565b8a11155b1561334f5760008c81526002808801602090815260408084208b8552909152808320909101805460ff60901b1916600160901b1790558c51908101516060909101516080840151885184936132fb93909290918b9161ffff169081106132ec576132ec61451b565b6020026020010151868f613baa565b91509150806001600160801b031686846080015161ffff16815181106133235761332361451b565b60200260200101818151613337919061458b565b90525050988990039860019098019790910390613413565b8261335957600192505b80516001600160801b03808416911611156133cd578051606082015161338090849061487d565b61338a91906148a8565b6001600160801b031684826080015161ffff16815181106133ad576133ad61451b565b602002602001018181516133c1919061458b565b90525060009150613413565b80606001516001600160801b031684826080015161ffff16815181106133f5576133f561451b565b60200260200101818151613409919061458b565b9052508051909103905b50600019909501946131bb565b60005b84518110156134775760008482815181106134405761344061451b565b60200260200101519050600081111561346e5761346e8c606001518288858151811061103c5761103c61451b565b50600101613423565b50895161010001516001600160801b0380831691161115613589576000818b600001516101000151036001600160801b031690508a60000151606001516000036135065760078601546006870154613501916001600160a01b0316906103e8906134e1908561476e565b6134eb919061475a565b8d51604001516001600160a01b03169190613958565b613587565b306001600160a01b03166341f894ff8c6000015161010001516001600160801b0316838e60c00151613538919061476e565b613542919061475a565b6040518263ffffffff1660e01b81526004016000604051808303818588803b15801561356d57600080fd5b505af1158015613581573d6000803e3d6000fd5b50505050505b505b6001600160801b038116156137575789516060015197819003976000036135ff576135fa8a606001516103e887600601546103e86135c7919061458b565b6135da906001600160801b03861661476e565b6135e4919061475a565b8c51604001516001600160a01b03169190613958565b613757565b6060808b01518b519091015160408051602081018252600081529051637921219560e11b8152309363f242432a9361363e9386938891906004016147f4565b600060405180830381600087803b15801561365857600080fd5b505af115801561366c573d6000803e3d6000fd5b5050505060008a606001516001600160a01b03166103e88c6000015161010001516001600160801b03168d60c00151856001600160801b03166136af919061476e565b6136b9919061475a565b6136c3919061475a565b604051600081818185875af1925050503d80600081146136ff576040519150601f19603f3d011682016040523d82523d6000602084013e613704565b606091505b50509050806137555760405162461bcd60e51b815260206004820152601460248201527f6661696c656420746f2073656e6420657468657200000000000000000000000060448201526064016105e2565b505b60008b8152600180870160205260409091206004810180546001600160801b03808d16600160801b02911617905560070180547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16600160a81b83021790555060408a81015160008d815260018801602090815290839020818e01516fffffffffffffffffffffffffffffffff19600160801b948e90036001600160801b039081169590950216908c90038416176006909101558251918b16825281018990528c917fb1318b18051ae7825ed56b03ed2431a994f919d5c4f4229b7123ef2afd74ba1a910160405180910390a25050505050505050505050565b4281118061386a575060008211801561386a5750428211155b1561256a576040517fd6c4122000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040516001600160a01b03808516602483015283166044820152606481018290526139529085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613cc2565b50505050565b6040516001600160a01b038316602482015260448101829052612b189084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016138ee565b600080808060008051602061493983398151915290508460a00151156139c657600192505b60018660a0015160018111156139de576139de613ff2565b146139f0575060009250829050613b3b565b6020860151865161012001516001600160801b0391821691165b8882118015613a195750600081115b15613ae05760008a8152600284810160209081526040808420868552825292839020835160c08101855281546001600160801b038082168352600160801b9182900481169483019490945260018301546001600160a01b031695820195909552920154908116606083015291820461ffff166080820152600160901b90910460ff16151560a08201819052613ad35780516001600160801b0316821115613ace5780516001600160801b031690910390613ad3565b600091505b5060001990910190613a0a565b8015613b2b5760018588600001516001600160801b0316831015613b115788516001600160801b0316839003613b1d565b88516001600160801b03165b955095509550505050613b3b565b5060009450849250613b3b915050565b9450945094915050565b600081613b5e6001600160801b0380861690871661476e565b613b68919061475a565b905060008280613b7a57613b7a614744565b846001600160801b0316866001600160801b0316091115613ba35780613b9f816148ce565b9150505b9392505050565b815160608301516001600160801b038083169084161015613c1c57835160608501518484039190613bdb908361487d565b613be591906148a8565b9050613bf1818361485d565b6040860151859450909250613c1a906001600160a01b038816906001600160801b038416613958565b505b85600003613c4c576040840151613c47906001600160a01b038916906001600160801b038516613958565b613cb8565b6040808501518151602081018352600081529151637921219560e11b8152309263f242432a92613c859285928c918991906004016147f4565b600060405180830381600087803b158015613c9f57600080fd5b505af1158015613cb3573d6000803e3d6000fd5b505050505b9550959350505050565b6000613d17826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613da79092919063ffffffff16565b805190915015612b185780806020019051810190613d3591906148e7565b612b185760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016105e2565b6060611745848460008585600080866001600160a01b03168587604051613dce9190614909565b60006040518083038185875af1925050503d8060008114613e0b576040519150601f19603f3d011682016040523d82523d6000602084013e613e10565b606091505b5091509150613e2187838387613e2c565b979650505050505050565b60608315613e9b578251600003613e94576001600160a01b0385163b613e945760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105e2565b5081611745565b6117458383815115613eb05781518083602001fd5b8060405162461bcd60e51b81526004016105e29190614925565b600060208284031215613edc57600080fd5b5035919050565b60008060408385031215613ef657600080fd5b50508035926020909101359150565b60c081016106e982846001600160801b038082511683528060208301511660208401526001600160a01b0360408301511660408401528060608301511660608401525061ffff608082015116608083015260a0810151151560a08301525050565b80356001600160801b0381168114613f7d57600080fd5b919050565b803561ffff81168114613f7d57600080fd5b600080600080600060a08688031215613fac57600080fd5b85359450613fbc60208701613f66565b9350613fca60408701613f82565b9250613fd860608701613f66565b9150613fe660808701613f66565b90509295509295909350565b634e487b7160e01b600052602160045260246000fd5b6003811061401857614018613ff2565b9052565b805165ffffffffffff1682526020810151614041602084018265ffffffffffff169052565b50604081015161405c60408401826001600160a01b03169052565b5060608101516060830152608081015161408160808401826001600160801b03169052565b5060a081015161409c60a08401826001600160801b03169052565b5060c08101516140b760c08401826001600160801b03169052565b5060e08101516140d260e08401826001600160801b03169052565b50610100818101516001600160801b03908116918401919091526101208083015182169084015261014080830151909116908301526101608082015161ffff16908301526101808082015161395282850182614008565b6002811061401857614018613ff2565b60006102608201905061414d82845161401c565b60208301516001600160801b039081166101a08401526040840151166101c083015260608301516001600160a01b03166101e0830152608083015160ff1661020083015260a08301516141a4610220840182614129565b5060c083015161024083015292915050565b80356001600160a01b0381168114613f7d57600080fd5b60ff8116811461061f57600080fd5b8035613f7d816141cd565b600080600080608085870312156141fd57600080fd5b614206856141b6565b935061421460208601613f66565b925061422260408601613f66565b91506060850135614232816141cd565b939692955090935050565b634e487b7160e01b600052604160045260246000fd5b6040516101a0810167ffffffffffffffff8111828210171561428557634e487b7160e01b600052604160045260246000fd5b60405290565b803565ffffffffffff81168114613f7d57600080fd5b803560038110613f7d57600080fd5b6000808284036101c08112156142c557600080fd5b6101a0808212156142d557600080fd5b6142dd614253565b91506142e88561428b565b82526142f66020860161428b565b6020830152614307604086016141b6565b60408301526060850135606083015261432260808601613f66565b608083015261433360a08601613f66565b60a083015261434460c08601613f66565b60c083015261435560e08601613f66565b60e0830152610100614368818701613f66565b9083015261012061437a868201613f66565b9083015261014061438c868201613f66565b9083015261016061439e868201613f82565b908301526101806143b08682016142a1565b81840152508193506143c38186016141dc565b925050509250929050565b6020808252825160608383015280516080840181905260009291820190839060a08601905b8083101561441c5783516001600160a01b031682529284019260019290920191908401906143f3565b506001600160a01b0384880151166040870152604087015160608701528094505050505092915050565b6020808252825182820181905260009190848201906040850190845b8181101561448657835165ffffffffffff1683529284019291840191600101614462565b50909695505050505050565b6000806000606084860312156144a757600080fd5b833592506144b760208501613f66565b91506144c560408501613f82565b90509250925092565b600080600080608085870312156144e457600080fd5b843593506144f460208601613f66565b925061450260408601613f66565b915061451060608601613f66565b905092959194509250565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6001600160801b0381811683821601908082111561456757614567614531565b5092915050565b60006020828403121561458057600080fd5b8151613ba3816141cd565b808201808211156106e9576106e9614531565b818103818111156106e9576106e9614531565b60e0810161461282856001600160801b038082511683528060208301511660208401526001600160a01b0360408301511660408401528060608301511660608401525061ffff608082015116608083015260a0810151151560a08301525050565b8260c08301529392505050565b60ff82811682821603908111156106e9576106e9614531565b60ff81811683821601908111156106e9576106e9614531565b600181815b8085111561468c57816000190482111561467257614672614531565b8085161561467f57918102915b93841c9390800290614656565b509250929050565b6000826146a3575060016106e9565b816146b0575060006106e9565b81600181146146c657600281146146d0576146ec565b60019150506106e9565b60ff8411156146e1576146e1614531565b50506001821b6106e9565b5060208310610133831016604e8410600b841016171561470f575081810a6106e9565b6147198383614651565b806000190482111561472d5761472d614531565b029392505050565b6000613ba360ff841683614694565b634e487b7160e01b600052601260045260246000fd5b60008261476957614769614744565b500490565b80820281158282048414176106e9576106e9614531565b65ffffffffffff81811683821601908082111561456757614567614531565b60005b838110156147bf5781810151838201526020016147a7565b50506000910152565b600081518084526147e08160208601602086016147a4565b601f01601f19169290920160200192915050565b60006001600160a01b0380881683528087166020840152508460408301526001600160801b038416606083015260a06080830152613e2160a08301846147c8565b60006020828403121561484757600080fd5b5051919050565b6101a081016106e9828461401c565b6001600160801b0382811682821603908082111561456757614567614531565b6001600160801b038181168382160280821691908281146148a0576148a0614531565b505092915050565b60006001600160801b03808416806148c2576148c2614744565b92169190910492915050565b6000600182016148e0576148e0614531565b5060010190565b6000602082840312156148f957600080fd5b81518015158114613ba357600080fd5b6000825161491b8184602087016147a4565b9190910192915050565b602081526000613ba360208301846147c856fe31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a4a164736f6c6343000811000a

Deployed Bytecode

0x6080604052600436106100f35760003560e01c8063808bf40c1161008a578063ca03901711610059578063ca0390171461031a578063d14228d31461033c578063e45c18791461035c578063e47fd1f11461037e57600080fd5b8063808bf40c1461029a5780638f031880146102ba578063a6523f8f146102cd578063c34a7336146102fa57600080fd5b80635c975abb116100c65780635c975abb146101ce5780635e06f72b1461021057806376741bb91461023057806378bd79351461026d57600080fd5b80631031ca44146100f8578063236ed8f3146101415780634c1cafc614610163578063582c7ffd146101a1575b600080fd5b34801561010457600080fd5b507f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173aa54604080519182526103e86020830152015b60405180910390f35b34801561014d57600080fd5b5061016161015c366004613eca565b61039e565b005b34801561016f57600080fd5b507f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a9545b604051908152602001610138565b3480156101ad57600080fd5b506101c16101bc366004613ee3565b610622565b6040516101389190613f05565b3480156101da57600080fd5b507f7a6a842f4b254b253ecba70474976063c6e762839bf3f5aef2536e9bee8f5e655460ff166040519015158152602001610138565b34801561021c57600080fd5b5061019361022b366004613f94565b6106ef565b34801561023c57600080fd5b5061025061024b366004613ee3565b6111e9565b604080519315158452911515602084015290820152606001610138565b34801561027957600080fd5b5061028d610288366004613eca565b611459565b6040516101389190614139565b3480156102a657600080fd5b506101936102b53660046141e7565b6116ae565b6101616102c83660046142b0565b61174d565b3480156102d957600080fd5b506102ed6102e8366004613eca565b61201b565b60405161013891906143ce565b34801561030657600080fd5b50610161610315366004613ee3565b6120ea565b34801561032657600080fd5b5061032f61256e565b6040516101389190614446565b34801561034857600080fd5b50610161610357366004614492565b612606565b34801561036857600080fd5b5060008051602061493983398151915254610193565b34801561038a57600080fd5b506101616103993660046144ce565b612b1d565b6103a6612fa6565b6103ae61303d565b60008181527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff166102408601528492918491610260850191600160901b90910460ff16908111156104c9576104c9613ff2565b60028111156104da576104da613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b90910416600181111561054657610546613ff2565b600181111561055757610557613ff2565b8152600891909101546020918201528151015190915065ffffffffffff16421080159061059a575060018160a00151600181111561059757610597613ff2565b14155b6105eb5760405162461bcd60e51b815260206004820152601760248201527f61756374696f6e2063616e277420626520636c6f73656400000000000000000060448201526064015b60405180910390fd5b6105f582826130b1565b5061061f60017f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b50565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a08101919091526000805160206149398339815191526000848152600291820160209081526040808320868452825291829020825160c08101845281546001600160801b038082168352600160801b9182900481169483019490945260018301546001600160a01b031694820194909452930154908116606084015290810461ffff166080830152600160901b900460ff16151560a082015290505b92915050565b60006106f9612fa6565b61070161303d565b60008681527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff1661024086015260008051602061493983398151915295949392849290918491610260850191600160901b900460ff169081111561082f5761082f613ff2565b600281111561084057610840613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b9091041660018111156108ac576108ac613ff2565b60018111156108bd576108bd613ff2565b81526008919091015460209091015260608101519091506001600160a01b03161580610900575060018151610180015160028111156108fe576108fe613ff2565b145b1561091e5760405163010ab10b60e51b815260040160405180910390fd5b8051610160015161ffff90811660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a8602052604081208054919290919089169081106109705761097061451b565b6000918252602091829020015483519182015191516001600160a01b0390911692506109a79165ffffffffffff9081169116613851565b8151608001516001600160801b03808a16911611156109d957604051630cca9d2b60e21b815260040160405180910390fd5b816000015161012001516001600160801b0316886001600160801b03161115610a1557604051632beee6cf60e01b815260040160405180910390fd5b600082602001516001600160801b0316600014610a75578251610140015160008b81526002860160209081526040808320828801516001600160801b039081168552925290912054610a709291600160801b90910416614547565b610a7c565b825160c001515b9050866001600160801b0316600003610a9757809650610ae3565b806001600160801b0316876001600160801b03161015610ae3576040517fbecfaa2b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b856001600160801b0316876001600160801b03161115610b2f576040517f2c4a793c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008790506000610bbd848c84600089600001516060015111610bb6578860000151604001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b92573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b5919061456e565b60066116ae565b9050610bd46001600160a01b0385163330846138a1565b60006040518060c001604052808d6001600160801b03168152602001846001600160801b03168152602001336001600160a01b03168152602001836001600160801b031681526020018c61ffff168152602001600015158152509050600086602001516001610c439190614547565b905060005a905060008f905060008f9050848b60020160008481526020019081526020016000206000866001600160801b0316815260200190815260200160002060008201518160000160006101000a8154816001600160801b0302191690836001600160801b0316021790555060208201518160000160106101000a8154816001600160801b0302191690836001600160801b0316021790555060408201518160010160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160020160006101000a8154816001600160801b0302191690836001600160801b0316021790555060808201518160020160106101000a81548161ffff021916908361ffff16021790555060a08201518160020160126101000a81548160ff02191690831515021790555090505060008a6080015160ff166001610d94919061458b565b90506000828c60400151610da89190614547565b8c51610160015161ffff1660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a86020908152604080832080548251818502810185019093528083529495509293909291830182828015610e3557602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610e17575b505050505090505b6000610e52846001600160801b038a1661459e565b610e5d90600161458b565b905060008f600201600088815260200190815260200160002060008381526020019081526020016000206040518060c00160405290816000820160009054906101000a90046001600160801b03166001600160801b03166001600160801b031681526020016000820160109054906101000a90046001600160801b03166001600160801b03166001600160801b031681526020016001820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b031681526020016002820160009054906101000a90046001600160801b03166001600160801b03166001600160801b031681526020016002820160109054906101000a900461ffff1661ffff1661ffff1681526020016002820160129054906101000a900460ff161515151581525050905080600001518f600001516101200151610fa49190614547565b6001600160801b0316846001600160801b03161015610fc45750506110cb565b805160a0820151600019909601959403931561100c576040517f11da50f100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61105c816040015182606001516001600160801b031685846080015161ffff168151811061103c5761103c61451b565b60200260200101516001600160a01b03166139589092919063ffffffff16565b60008781527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a6602090815260408083208584529091529020600201805460ff60901b1916600160901b17905562072bf05a6110b7908a61459e565b11156110c45750506110cb565b5050610e3d565b60008581527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a56020526040908190206007810180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b60ff8816021790556001600160801b03848116600160801b026fffffffffffffffffffffffffffffffff1916908a16908117600690920191909155905186907ff1630e8b4f09b0a9920a444540e8af405633f4cc2d5336befdff66637a4ccaf290611195908c9088906145b1565b60405180910390a3505050505050806001600160801b0316985050505050505050506111e060017f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b95945050505050565b60008281527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff16610240860152859485946000805160206149398339815191529486949293919284928491610260850191600160901b900460ff169081111561131c5761131c613ff2565b600281111561132d5761132d613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b90910416600181111561139957611399613ff2565b60018111156113aa576113aa613ff2565b81526008919091015460209182015260008981526002858101835260408083208b8452845291829020825160c08101845281546001600160801b038082168352600160801b9182900481169683019690965260018301546001600160a01b031694820194909452910154928316606082015290820461ffff166080820152600160901b90910460ff16151560a0820152909150611449888884846139a1565b9550955095505050509250925092565b6040805161028081018252600060e08201818152610100830182905261012083018290526101408301829052610160830182905261018083018290526101a083018290526101c083018290526101e083018290526102008301829052610220830182905261024083018290526102608301829052825260208201819052918101829052606081018290526080810182905260a0810182905260c08101919091526000805160206149398339815191526000838152600191820160205260409081902081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b0316610120840152928101546101408301526002808201546001600160801b03808216610160860152600160801b91829004811661018086015260038401548082166101a087015282900481166101c086015260048401548082166101e08701528290048116610200860152600584015490811661022086015290810461ffff16610240850152929391928492918491610260850191600160901b90910460ff169081111561160b5761160b613ff2565b600281111561161c5761161c613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b90910416600181111561168857611688613ff2565b600181111561169957611699613ff2565b81526020016008820154815250509050919050565b60008082866001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611714919061456e565b61171f90601261461f565b6117299190614638565b61173490600a614735565b9050611741858583613b45565b9150505b949350505050565b61175561303d565b6040828101516001600160a01b031660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a760205220546000805160206149398339815191529060ff166117d8576040517f5110df2400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806005015483610160015161ffff161061181e576040517f02777d5e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60648361010001516001600160801b0316611839919061475a565b83608001516001600160801b0316108061186d57508261010001516001600160801b031683608001516001600160801b0316115b156118a4576040517f2304cb6e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8261010001516001600160801b03166000036118ec576040517f5a5a1b3000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001836101800151600281111561190557611905613ff2565b148061192757506002836101800151600281111561192557611925613ff2565b145b801561193e575060a08301516001600160801b0316155b15611975576040517f84477d0400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001836101800151600281111561198e5761198e613ff2565b14611a46578260e001516001600160801b03168360c001516001600160801b031611156119ce57604051630455852f60e51b815260040160405180910390fd5b6101408301516001600160801b03161580611a0f57508260c001516001600160801b031660028461014001516001600160801b0316611a0d919061476e565b115b15611a46576040517fda6b4f0a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b825165ffffffffffff16600003611a675765ffffffffffff42168352611acc565b42836000015165ffffffffffff161080611a955750611a894262278d0061458b565b835165ffffffffffff16115b15611acc576040517fb290253c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806008018260ff1681548110611ae457611ae461451b565b90600052602060002090600591828204019190066006029054906101000a900465ffffffffffff168360000151611b1b9190614785565b65ffffffffffff1660208401528054600090611b3890600161458b565b90508360600151600003611b9e57611b9933306103e885600601546103e8611b60919061458b565b8861010001516001600160801b0316611b79919061476e565b611b83919061475a565b60408801516001600160a01b03169291906138a1565b611e32565b8360600151600316600303611bdf576040517f2dbdd4d100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408401516001600160a01b03163014611c25576040517fc99421ae00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606084015161010085015160408051602081018252600081529051637921219560e11b8152309363f242432a93611c6593339387939291906004016147f4565b600060405180830381600087803b158015611c7f57600080fd5b505af1158015611c93573d6000803e3d6000fd5b505050506000306001600160a01b03166384a2ce136040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cd7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfb9190614835565b905060006103e88460060154836c0c9f2c9cd04674edea400000008961010001516001600160801b0316611d2f919061476e565b611d39919061475a565b611d43919061476e565b611d4d919061475a565b905080341015611d89576040517f025dbdd400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80341115611e1c57600033611d9e833461459e565b604051600081818185875af1925050503d8060008114611dda576040519150601f19603f3d011682016040523d82523d6000602084013e611ddf565b606091505b5050905080611e1a576040517f305bcd3c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505b6000838152600185016020526040902060080155505b808255610100840180516001600160801b0390811661012087019081526000848152600180870160209081526040928390208a518154928c0151948c01516001600160a01b0316600160601b026bffffffffffffffffffffffff65ffffffffffff9687166601000000000000026bffffffffffffffffffffffff1990951696909216959095179290921791909116929092178255606089015190820155608088015160a08901518416600160801b9081029185169190911760028084019190915560c08a015160e08b01518616830290861617600384015594519251841681029284169290921760048201556101408801516005820180546101608b015161ffff169094027fffffffffffffffffffffffffffff000000000000000000000000000000000000909416919094161791909117808355610180880151889492939092909160ff60901b191690600160901b908490811115611f9457611f94613ff2565b0217905550505060008181526001830160205260409081902060070180547fffffffffffffffffffffffff0000000000000000000000000000000000000000163390811790915590518291907ff68eef6cdaf5fca4b176f66d13fb98bd2ceeb400fee5eee535f0925ac180e8469061200d90889061484e565b60405180910390a350505050565b6040805160608082018352808252600060208084018290528385018290528582527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a88152908490208451815492830281016080908101909652928301828152939492939092849284918401828280156120bd57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161209f575b505050918352505060018201546001600160a01b0316602082015260029091015460409091015292915050565b6120f2612fa6565b6120fa61303d565b60008281527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff1661024086015260008051602061493983398151915295949392849290918491610260850191600160901b900460ff169081111561222857612228613ff2565b600281111561223957612239613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b9091041660018111156122a5576122a5613ff2565b60018111156122b6576122b6613ff2565b81526008919091015460209182015260008681526002858101835260408083208884528452808320815160c08101835281546001600160801b038082168352600160801b9182900481169783019790975260018301546001600160a01b0316938201939093529201549384166060830152830461ffff166080820152600160901b90920460ff16151560a0830152919250908080612356888887876139a1565b9250925092508115612394576040517fb3f0f1d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008881526002808801602090815260408084208b855290915290912001805460ff60901b1916600160901b17905560018560a0015160018111156123db576123db613ff2565b14612412576040517f5814bd1f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8451610160015161ffff908116600090815260048801602052604081206080870151815492939192911690811061244b5761244b61451b565b6000918252602090912001546001600160a01b0316905083156124cb578551610120015161247a90839061485d565b60008a81526001890160205260409081902060040180546001600160801b03938416600160801b029316929092179091558651908101516060909101516124c49190838886613baa565b50506124f2565b604085015160608601516124f2916001600160a01b038416916001600160801b0316613958565b604080518a8152602081018a9052851515818301526060810184905290517f5880a3c41abda1f5b6bfd10e0a0c7493be1522323e7b01e912e3e73d187fff689181900360800190a15050505050505061256a60017f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b5050565b60606000805160206149398339815191526008018054806020026020016040519081016040528092919081815260200182805480156125fc57602002820191906000526020600020906000905b82829054906101000a900465ffffffffffff1665ffffffffffff16815260200190600601906020826005010492830192600103820291508084116125bb5790505b5050505050905090565b61260e612fa6565b61261661303d565b60008381527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff1661024086015260008051602061493983398151915295949392849290918491610260850191600160901b900460ff169081111561274457612744613ff2565b600281111561275557612755613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b9091041660018111156127c1576127c1613ff2565b60018111156127d2576127d2613ff2565b81526008919091015460209091015260608101519091506001600160a01b031615806128155750600081516101800151600281111561281357612813613ff2565b145b156128335760405163010ab10b60e51b815260040160405180910390fd5b8051610160015161ffff90811660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a8602052604081208054919290919086169081106128855761288561451b565b6000918252602091829020015483519182015191516001600160a01b0390911692506128bc9165ffffffffffff9081169116613851565b81516101208101516060909101516001600160801b0380831690881611156128f757604051632beee6cf60e01b815260040160405180910390fd5b8351608001516001600160801b038089169116111561292957604051630cca9d2b60e21b815260040160405180910390fd5b6000888152600186016020526040812060040180546001600160801b038a86038116600160801b0291161790558181036129f2578460000151604001516001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156129a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129c7919061456e565b8551604001519091506129ed906001600160a01b0316336001600160801b038b16613958565b612a5f565b5060408051602081018252600081529051637921219560e11b8152600691309163f242432a91612a2c918491339188918f916004016147f4565b600060405180830381600087803b158015612a4657600080fd5b505af1158015612a5a573d6000803e3d6000fd5b505050505b6000612a75858a886000015160a00151856116ae565b6060870151909150612a94906001600160a01b038716903390846138a1565b604080518281526001600160801b038b1660208201526001600160a01b0387168183015290518b9133917ffda4db17d28a65b6cf5fb6f7798cf59cc1294e5b3bc1fc9c70d6f65c1dedacaf9181900360600190a350505050505050612b1860017f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b505050565b612b2561303d565b60008481527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a5602052604080822081516102808101909252805465ffffffffffff80821660e0850190815266010000000000008304909116610100850152600160601b9091046001600160a01b031661012084015260018201546101408401526002808301546001600160801b03808216610160870152600160801b91829004811661018087015260038501548082166101a088015282900481166101c087015260048501548082166101e08801528290048116610200870152600585015490811661022087015290810461ffff1661024086015260008051602061493983398151915295949392849290918491610260850191600160901b900460ff1690811115612c5357612c53613ff2565b6002811115612c6457612c64613ff2565b905250815260068201546001600160801b038082166020840152600160801b90910416604082015260078201546001600160a01b038116606083015260ff600160a01b82048116608084015260a090920191600160a81b909104166001811115612cd057612cd0613ff2565b6001811115612ce157612ce1613ff2565b81526020016008820154815250509050336001600160a01b031681606001516001600160a01b031614612d40576040517f49734eca00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008160a001516001811115612d5857612d58613ff2565b141580612d7457504281600001516020015165ffffffffffff16105b80612d8b575060208101516001600160801b031615155b15612dc2576040517f8ccce47e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806000015160e001516001600160801b0316846001600160801b03161115612dfd57604051630455852f60e51b815260040160405180910390fd5b80516101000151612e19906064906001600160801b031661475a565b8151608001516001600160801b031610801590612e515750806000015161010001516001600160801b0316856001600160801b031611155b15612e8c576000868152600183016020526040902060020180546fffffffffffffffffffffffffffffffff19166001600160801b0387161790555b6001600160801b03841615612ed1576000868152600183016020526040902060030180546fffffffffffffffffffffffffffffffff19166001600160801b0386161790555b6001600160801b03831615801590612f15575060008681526001830160205260409020600301546001600160801b0390811690612f1290600290861661476e565b11155b15612f50576000868152600183016020526040902060050180546fffffffffffffffffffffffffffffffff19166001600160801b0385161790555b604080516001600160801b0387811682528681166020830152851681830152905187917fcc9d5e33604a3e02e9b278635bf2852ee06f4363a3f23d3e748708fd1d1ec853919081900360600190a2505050505050565b60027f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32154036130175760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105e2565b60027f85e1ca0cb738650ceae09b8e7a40cba718d04131dd54b748289da0a916d2f32155565b7f7a6a842f4b254b253ecba70474976063c6e762839bf3f5aef2536e9bee8f5e655460ff16156130af5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a207061757365640000000000000000000000000000000060448201526064016105e2565b565b60005a82516101208101516020808601516101609093015161ffff1660009081527f31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a8825260408082208054825181860281018601909352808352969750939591946001600160801b0316936000805160206149398339815191529386939083018282801561316857602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161314a575b505050505090506000815167ffffffffffffffff81111561318b5761318b61423d565b6040519080825280602002602001820160405280156131b4578160200160208202803683370190505b5090506000865b6000861180156131d457506000816001600160801b0316115b156134205760008b81526002868101602090815260408084208a8552825292839020835160c08101855281546001600160801b038082168352600160801b9182900481169483019490945260018301546001600160a01b031695820195909552920154908116606083015291820461ffff166080820152600160901b90910460ff1615801560a08301526132685750613420565b8215801561328457506202bf205a613280919061458b565b8a11155b1561334f5760008c81526002808801602090815260408084208b8552909152808320909101805460ff60901b1916600160901b1790558c51908101516060909101516080840151885184936132fb93909290918b9161ffff169081106132ec576132ec61451b565b6020026020010151868f613baa565b91509150806001600160801b031686846080015161ffff16815181106133235761332361451b565b60200260200101818151613337919061458b565b90525050988990039860019098019790910390613413565b8261335957600192505b80516001600160801b03808416911611156133cd578051606082015161338090849061487d565b61338a91906148a8565b6001600160801b031684826080015161ffff16815181106133ad576133ad61451b565b602002602001018181516133c1919061458b565b90525060009150613413565b80606001516001600160801b031684826080015161ffff16815181106133f5576133f561451b565b60200260200101818151613409919061458b565b9052508051909103905b50600019909501946131bb565b60005b84518110156134775760008482815181106134405761344061451b565b60200260200101519050600081111561346e5761346e8c606001518288858151811061103c5761103c61451b565b50600101613423565b50895161010001516001600160801b0380831691161115613589576000818b600001516101000151036001600160801b031690508a60000151606001516000036135065760078601546006870154613501916001600160a01b0316906103e8906134e1908561476e565b6134eb919061475a565b8d51604001516001600160a01b03169190613958565b613587565b306001600160a01b03166341f894ff8c6000015161010001516001600160801b0316838e60c00151613538919061476e565b613542919061475a565b6040518263ffffffff1660e01b81526004016000604051808303818588803b15801561356d57600080fd5b505af1158015613581573d6000803e3d6000fd5b50505050505b505b6001600160801b038116156137575789516060015197819003976000036135ff576135fa8a606001516103e887600601546103e86135c7919061458b565b6135da906001600160801b03861661476e565b6135e4919061475a565b8c51604001516001600160a01b03169190613958565b613757565b6060808b01518b519091015160408051602081018252600081529051637921219560e11b8152309363f242432a9361363e9386938891906004016147f4565b600060405180830381600087803b15801561365857600080fd5b505af115801561366c573d6000803e3d6000fd5b5050505060008a606001516001600160a01b03166103e88c6000015161010001516001600160801b03168d60c00151856001600160801b03166136af919061476e565b6136b9919061475a565b6136c3919061475a565b604051600081818185875af1925050503d80600081146136ff576040519150601f19603f3d011682016040523d82523d6000602084013e613704565b606091505b50509050806137555760405162461bcd60e51b815260206004820152601460248201527f6661696c656420746f2073656e6420657468657200000000000000000000000060448201526064016105e2565b505b60008b8152600180870160205260409091206004810180546001600160801b03808d16600160801b02911617905560070180547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff16600160a81b83021790555060408a81015160008d815260018801602090815290839020818e01516fffffffffffffffffffffffffffffffff19600160801b948e90036001600160801b039081169590950216908c90038416176006909101558251918b16825281018990528c917fb1318b18051ae7825ed56b03ed2431a994f919d5c4f4229b7123ef2afd74ba1a910160405180910390a25050505050505050505050565b4281118061386a575060008211801561386a5750428211155b1561256a576040517fd6c4122000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040516001600160a01b03808516602483015283166044820152606481018290526139529085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152613cc2565b50505050565b6040516001600160a01b038316602482015260448101829052612b189084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064016138ee565b600080808060008051602061493983398151915290508460a00151156139c657600192505b60018660a0015160018111156139de576139de613ff2565b146139f0575060009250829050613b3b565b6020860151865161012001516001600160801b0391821691165b8882118015613a195750600081115b15613ae05760008a8152600284810160209081526040808420868552825292839020835160c08101855281546001600160801b038082168352600160801b9182900481169483019490945260018301546001600160a01b031695820195909552920154908116606083015291820461ffff166080820152600160901b90910460ff16151560a08201819052613ad35780516001600160801b0316821115613ace5780516001600160801b031690910390613ad3565b600091505b5060001990910190613a0a565b8015613b2b5760018588600001516001600160801b0316831015613b115788516001600160801b0316839003613b1d565b88516001600160801b03165b955095509550505050613b3b565b5060009450849250613b3b915050565b9450945094915050565b600081613b5e6001600160801b0380861690871661476e565b613b68919061475a565b905060008280613b7a57613b7a614744565b846001600160801b0316866001600160801b0316091115613ba35780613b9f816148ce565b9150505b9392505050565b815160608301516001600160801b038083169084161015613c1c57835160608501518484039190613bdb908361487d565b613be591906148a8565b9050613bf1818361485d565b6040860151859450909250613c1a906001600160a01b038816906001600160801b038416613958565b505b85600003613c4c576040840151613c47906001600160a01b038916906001600160801b038516613958565b613cb8565b6040808501518151602081018352600081529151637921219560e11b8152309263f242432a92613c859285928c918991906004016147f4565b600060405180830381600087803b158015613c9f57600080fd5b505af1158015613cb3573d6000803e3d6000fd5b505050505b9550959350505050565b6000613d17826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316613da79092919063ffffffff16565b805190915015612b185780806020019051810190613d3591906148e7565b612b185760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016105e2565b6060611745848460008585600080866001600160a01b03168587604051613dce9190614909565b60006040518083038185875af1925050503d8060008114613e0b576040519150601f19603f3d011682016040523d82523d6000602084013e613e10565b606091505b5091509150613e2187838387613e2c565b979650505050505050565b60608315613e9b578251600003613e94576001600160a01b0385163b613e945760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105e2565b5081611745565b6117458383815115613eb05781518083602001fd5b8060405162461bcd60e51b81526004016105e29190614925565b600060208284031215613edc57600080fd5b5035919050565b60008060408385031215613ef657600080fd5b50508035926020909101359150565b60c081016106e982846001600160801b038082511683528060208301511660208401526001600160a01b0360408301511660408401528060608301511660608401525061ffff608082015116608083015260a0810151151560a08301525050565b80356001600160801b0381168114613f7d57600080fd5b919050565b803561ffff81168114613f7d57600080fd5b600080600080600060a08688031215613fac57600080fd5b85359450613fbc60208701613f66565b9350613fca60408701613f82565b9250613fd860608701613f66565b9150613fe660808701613f66565b90509295509295909350565b634e487b7160e01b600052602160045260246000fd5b6003811061401857614018613ff2565b9052565b805165ffffffffffff1682526020810151614041602084018265ffffffffffff169052565b50604081015161405c60408401826001600160a01b03169052565b5060608101516060830152608081015161408160808401826001600160801b03169052565b5060a081015161409c60a08401826001600160801b03169052565b5060c08101516140b760c08401826001600160801b03169052565b5060e08101516140d260e08401826001600160801b03169052565b50610100818101516001600160801b03908116918401919091526101208083015182169084015261014080830151909116908301526101608082015161ffff16908301526101808082015161395282850182614008565b6002811061401857614018613ff2565b60006102608201905061414d82845161401c565b60208301516001600160801b039081166101a08401526040840151166101c083015260608301516001600160a01b03166101e0830152608083015160ff1661020083015260a08301516141a4610220840182614129565b5060c083015161024083015292915050565b80356001600160a01b0381168114613f7d57600080fd5b60ff8116811461061f57600080fd5b8035613f7d816141cd565b600080600080608085870312156141fd57600080fd5b614206856141b6565b935061421460208601613f66565b925061422260408601613f66565b91506060850135614232816141cd565b939692955090935050565b634e487b7160e01b600052604160045260246000fd5b6040516101a0810167ffffffffffffffff8111828210171561428557634e487b7160e01b600052604160045260246000fd5b60405290565b803565ffffffffffff81168114613f7d57600080fd5b803560038110613f7d57600080fd5b6000808284036101c08112156142c557600080fd5b6101a0808212156142d557600080fd5b6142dd614253565b91506142e88561428b565b82526142f66020860161428b565b6020830152614307604086016141b6565b60408301526060850135606083015261432260808601613f66565b608083015261433360a08601613f66565b60a083015261434460c08601613f66565b60c083015261435560e08601613f66565b60e0830152610100614368818701613f66565b9083015261012061437a868201613f66565b9083015261014061438c868201613f66565b9083015261016061439e868201613f82565b908301526101806143b08682016142a1565b81840152508193506143c38186016141dc565b925050509250929050565b6020808252825160608383015280516080840181905260009291820190839060a08601905b8083101561441c5783516001600160a01b031682529284019260019290920191908401906143f3565b506001600160a01b0384880151166040870152604087015160608701528094505050505092915050565b6020808252825182820181905260009190848201906040850190845b8181101561448657835165ffffffffffff1683529284019291840191600101614462565b50909695505050505050565b6000806000606084860312156144a757600080fd5b833592506144b760208501613f66565b91506144c560408501613f82565b90509250925092565b600080600080608085870312156144e457600080fd5b843593506144f460208601613f66565b925061450260408601613f66565b915061451060608601613f66565b905092959194509250565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6001600160801b0381811683821601908082111561456757614567614531565b5092915050565b60006020828403121561458057600080fd5b8151613ba3816141cd565b808201808211156106e9576106e9614531565b818103818111156106e9576106e9614531565b60e0810161461282856001600160801b038082511683528060208301511660208401526001600160a01b0360408301511660408401528060608301511660608401525061ffff608082015116608083015260a0810151151560a08301525050565b8260c08301529392505050565b60ff82811682821603908111156106e9576106e9614531565b60ff81811683821601908111156106e9576106e9614531565b600181815b8085111561468c57816000190482111561467257614672614531565b8085161561467f57918102915b93841c9390800290614656565b509250929050565b6000826146a3575060016106e9565b816146b0575060006106e9565b81600181146146c657600281146146d0576146ec565b60019150506106e9565b60ff8411156146e1576146e1614531565b50506001821b6106e9565b5060208310610133831016604e8410600b841016171561470f575081810a6106e9565b6147198383614651565b806000190482111561472d5761472d614531565b029392505050565b6000613ba360ff841683614694565b634e487b7160e01b600052601260045260246000fd5b60008261476957614769614744565b500490565b80820281158282048414176106e9576106e9614531565b65ffffffffffff81811683821601908082111561456757614567614531565b60005b838110156147bf5781810151838201526020016147a7565b50506000910152565b600081518084526147e08160208601602086016147a4565b601f01601f19169290920160200192915050565b60006001600160a01b0380881683528087166020840152508460408301526001600160801b038416606083015260a06080830152613e2160a08301846147c8565b60006020828403121561484757600080fd5b5051919050565b6101a081016106e9828461401c565b6001600160801b0382811682821603908082111561456757614567614531565b6001600160801b038181168382160280821691908281146148a0576148a0614531565b505092915050565b60006001600160801b03808416806148c2576148c2614744565b92169190910492915050565b6000600182016148e0576148e0614531565b5060010190565b6000602082840312156148f957600080fd5b81518015158114613ba357600080fd5b6000825161491b8184602087016147a4565b9190910192915050565b602081526000613ba360208301846147c856fe31ca04e2c6322aa5a039d3b5f0501939e2c062101fe6c8c295d9080d4ed173a4a164736f6c6343000811000a

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.