Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- EnglishAuctionsLogic
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 1000
- EVM Version
- default
- Verified at
- 2023-08-01T21:15:37.963731Z
Constructor Arguments
0x00000000000000000000000070499adebb11efd915e3b69e700c331778628707
Arg [0] (address) : 0x70499adebb11efd915e3b69e700c331778628707
contracts/marketplace/english-auctions/EnglishAuctionsLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/// @author thirdweb
import "./EnglishAuctionsStorage.sol";
// ====== External imports ======
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
// ====== Internal imports ======
import "@thirdweb-dev/contracts/extension/plugin/ERC2771ContextConsumer.sol";
import "@thirdweb-dev/contracts/extension/interface/IPlatformFee.sol";
import "@thirdweb-dev/contracts/extension/plugin/ReentrancyGuardLogic.sol";
import "@thirdweb-dev/contracts/extension/plugin/PermissionsEnumerableLogic.sol";
import { CurrencyTransferLib } from "@thirdweb-dev/contracts/lib/CurrencyTransferLib.sol";
import "../../Constants.sol";
import { IEnglishAuctions } from "../IMarketplace.sol";
/**
* @author thirdweb.com
*/
contract EnglishAuctionsLogic is IEnglishAuctions, ReentrancyGuardLogic, ERC2771ContextConsumer, Constants {
/*///////////////////////////////////////////////////////////////
Constants / Immutables
//////////////////////////////////////////////////////////////*/
/// @dev Only lister role holders can create auctions, when auctions are restricted by lister address.
bytes32 private constant LISTER_ROLE = keccak256("LISTER_ROLE");
/// @dev Only assets from NFT contracts with asset role can be auctioned, when auctions are restricted by asset address.
bytes32 private constant ASSET_ROLE = keccak256("ASSET_ROLE");
/// @dev The max bps of the contract. So, 10_000 == 100 %
uint64 private constant MAX_BPS = 10_000;
/// @dev The address of the native token wrapper contract.
address private immutable nativeTokenWrapper;
/*///////////////////////////////////////////////////////////////
Modifiers
//////////////////////////////////////////////////////////////*/
modifier onlyListerRole() {
require(PermissionsLogic(address(this)).hasRoleWithSwitch(LISTER_ROLE, _msgSender()), "!LISTER_ROLE");
_;
}
modifier onlyAssetRole(address _asset) {
require(PermissionsLogic(address(this)).hasRoleWithSwitch(ASSET_ROLE, _asset), "!ASSET_ROLE");
_;
}
/// @dev Checks whether caller is a auction creator.
modifier onlyAuctionCreator(uint256 _auctionId) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
require(data.auctions[_auctionId].auctionCreator == _msgSender(), "Marketplace: not auction creator.");
_;
}
/// @dev Checks whether an auction exists.
modifier onlyExistingAuction(uint256 _auctionId) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
require(data.auctions[_auctionId].status == IEnglishAuctions.Status.CREATED, "Marketplace: invalid auction.");
_;
}
/*///////////////////////////////////////////////////////////////
Constructor logic
//////////////////////////////////////////////////////////////*/
constructor(address _nativeTokenWrapper) {
nativeTokenWrapper = _nativeTokenWrapper;
}
/*///////////////////////////////////////////////////////////////
External functions
//////////////////////////////////////////////////////////////*/
/// @notice Auction ERC721 or ERC1155 NFTs.
function createAuction(AuctionParameters calldata _params)
external
onlyListerRole
onlyAssetRole(_params.assetContract)
returns (uint256 auctionId)
{
auctionId = _getNextAuctionId();
address auctionCreator = _msgSender();
TokenType tokenType = _getTokenType(_params.assetContract);
_validateNewAuction(_params, tokenType);
Auction memory auction = Auction({
auctionId: auctionId,
auctionCreator: auctionCreator,
assetContract: _params.assetContract,
tokenId: _params.tokenId,
quantity: _params.quantity,
currency: _params.currency,
minimumBidAmount: _params.minimumBidAmount,
buyoutBidAmount: _params.buyoutBidAmount,
timeBufferInSeconds: _params.timeBufferInSeconds,
bidBufferBps: _params.bidBufferBps,
startTimestamp: _params.startTimestamp,
endTimestamp: _params.endTimestamp,
tokenType: tokenType,
status: IEnglishAuctions.Status.CREATED
});
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
data.auctions[auctionId] = auction;
_transferAuctionTokens(auctionCreator, address(this), auction);
emit NewAuction(auctionCreator, auctionId, _params.assetContract, _params.tokenId, auction);
}
function bidInAuction(uint256 _auctionId, uint256 _bidAmount)
external
payable
nonReentrant
onlyExistingAuction(_auctionId)
{
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
Auction memory _targetAuction = data.auctions[_auctionId];
require(
_targetAuction.endTimestamp > block.timestamp && _targetAuction.startTimestamp <= block.timestamp,
"Marketplace: inactive auction."
);
require(_bidAmount != 0, "Marketplace: Bidding with zero amount.");
Bid memory newBid = Bid({ auctionId: _auctionId, bidder: _msgSender(), bidAmount: _bidAmount });
_handleBid(_targetAuction, newBid);
}
function collectAuctionPayout(uint256 _auctionId) external nonReentrant onlyAuctionCreator(_auctionId) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
require(!data.payoutStatus[_auctionId].paidOutBidAmount, "Marketplace: payout already completed.");
data.payoutStatus[_auctionId].paidOutBidAmount = true;
Auction memory _targetAuction = data.auctions[_auctionId];
Bid memory _winningBid = data.winningBid[_auctionId];
require(_targetAuction.status != IEnglishAuctions.Status.CANCELLED, "Marketplace: invalid auction.");
require(_targetAuction.endTimestamp <= block.timestamp, "Marketplace: auction still active.");
require(_winningBid.bidder != address(0), "Marketplace: no bids were made.");
_closeAuctionForAuctionCreator(_targetAuction, _winningBid);
if (_targetAuction.status != IEnglishAuctions.Status.COMPLETED) {
data.auctions[_auctionId].status = IEnglishAuctions.Status.COMPLETED;
}
}
function collectAuctionTokens(uint256 _auctionId) external nonReentrant {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
Auction memory _targetAuction = data.auctions[_auctionId];
Bid memory _winningBid = data.winningBid[_auctionId];
require(_targetAuction.status != IEnglishAuctions.Status.CANCELLED, "Marketplace: invalid auction.");
require(_targetAuction.endTimestamp <= block.timestamp, "Marketplace: auction still active.");
require(_winningBid.bidder != address(0), "Marketplace: no bids were made.");
_closeAuctionForBidder(_targetAuction, _winningBid);
if (_targetAuction.status != IEnglishAuctions.Status.COMPLETED) {
data.auctions[_auctionId].status = IEnglishAuctions.Status.COMPLETED;
}
}
function collectAuction(uint256 _auctionId) external nonReentrant onlyAuctionCreator(_auctionId) {
this.collectAuctionPayout(_auctionId);
this.collectAuctionTokens(_auctionId);
}
/// @dev Cancels an auction.
function cancelAuction(uint256 _auctionId) external onlyExistingAuction(_auctionId) onlyAuctionCreator(_auctionId) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
Auction memory _targetAuction = data.auctions[_auctionId];
Bid memory _winningBid = data.winningBid[_auctionId];
require(_winningBid.bidder == address(0), "Marketplace: bids already made.");
data.auctions[_auctionId].status = IEnglishAuctions.Status.CANCELLED;
_transferAuctionTokens(address(this), _targetAuction.auctionCreator, _targetAuction);
emit CancelledAuction(_targetAuction.auctionCreator, _auctionId, _targetAuction.assetContract, _targetAuction.tokenId);
}
/*///////////////////////////////////////////////////////////////
View functions
//////////////////////////////////////////////////////////////*/
function isNewWinningBid(uint256 _auctionId, uint256 _bidAmount)
external
view
onlyExistingAuction(_auctionId)
returns (bool)
{
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
Auction memory _targetAuction = data.auctions[_auctionId];
Bid memory _currentWinningBid = data.winningBid[_auctionId];
return
_isNewWinningBid(
_targetAuction.minimumBidAmount,
_currentWinningBid.bidAmount,
_bidAmount,
_targetAuction.bidBufferBps
);
}
function totalAuctions() external view returns (uint256) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
return data.totalAuctions;
}
function getAuction(uint256 _auctionId) external view returns (Auction memory _auction) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
_auction = data.auctions[_auctionId];
}
function getAllAuctions(uint256 _startId, uint256 _endId) external view returns (Auction[] memory _allAuctions) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
require(_startId <= _endId && _endId < data.totalAuctions, "invalid range");
_allAuctions = new Auction[](_endId - _startId + 1);
for (uint256 i = _startId; i <= _endId; i += 1) {
_allAuctions[i - _startId] = data.auctions[i];
}
}
function getAllValidAuctions(uint256 _startId, uint256 _endId)
external
view
returns (Auction[] memory _validAuctions)
{
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
require(_startId <= _endId && _endId < data.totalAuctions, "invalid range");
Auction[] memory _auctions = new Auction[](_endId - _startId + 1);
uint256 _auctionCount;
for (uint256 i = _startId; i <= _endId; i += 1) {
uint256 j = i - _startId;
_auctions[j] = data.auctions[i];
if (
_auctions[j].startTimestamp <= block.timestamp &&
_auctions[j].endTimestamp > block.timestamp &&
_auctions[j].status == IEnglishAuctions.Status.CREATED &&
_auctions[j].assetContract != address(0)
) {
_auctionCount += 1;
}
}
_validAuctions = new Auction[](_auctionCount);
uint256 index = 0;
uint256 count = _auctions.length;
for (uint256 i = 0; i < count; i += 1) {
if (
_auctions[i].startTimestamp <= block.timestamp &&
_auctions[i].endTimestamp > block.timestamp &&
_auctions[i].status == IEnglishAuctions.Status.CREATED &&
_auctions[i].assetContract != address(0)
) {
_validAuctions[index++] = _auctions[i];
}
}
}
function getWinningBid(uint256 _auctionId)
external
view
onlyExistingAuction(_auctionId)
returns (
address _bidder,
address _currency,
uint256 _bidAmount
)
{
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
Auction memory _targetAuction = data.auctions[_auctionId];
Bid memory _currentWinningBid = data.winningBid[_auctionId];
_bidder = _currentWinningBid.bidder;
_currency = _targetAuction.currency;
_bidAmount = _currentWinningBid.bidAmount;
}
function isAuctionExpired(uint256 _auctionId) external view onlyExistingAuction(_auctionId) returns (bool) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
return data.auctions[_auctionId].endTimestamp >= block.timestamp;
}
/*///////////////////////////////////////////////////////////////
Internal functions
//////////////////////////////////////////////////////////////*/
/// @dev Returns the next auction Id.
function _getNextAuctionId() internal returns (uint256 id) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
id = data.totalAuctions;
data.totalAuctions += 1;
}
/// @dev Returns the interface supported by a contract.
function _getTokenType(address _assetContract) internal view returns (TokenType tokenType) {
if (IERC165(_assetContract).supportsInterface(type(IERC1155).interfaceId)) {
tokenType = TokenType.ERC1155;
} else if (IERC165(_assetContract).supportsInterface(type(IERC721).interfaceId)) {
tokenType = TokenType.ERC721;
} else {
revert("Marketplace: auctioned token must be ERC1155 or ERC721.");
}
}
/// @dev Checks whether the auction creator owns and has approved marketplace to transfer auctioned tokens.
function _validateNewAuction(AuctionParameters memory _params, TokenType _tokenType) internal view {
require(_params.quantity > 0, "Marketplace: auctioning zero quantity.");
require(_params.quantity == 1 || _tokenType == TokenType.ERC1155, "Marketplace: auctioning invalid quantity.");
require(_params.timeBufferInSeconds > 0, "Marketplace: no time-buffer.");
require(_params.bidBufferBps > 0, "Marketplace: no bid-buffer.");
require(
_params.startTimestamp + 60 minutes >= block.timestamp && _params.startTimestamp < _params.endTimestamp,
"Marketplace: invalid timestamps."
);
require(
_params.buyoutBidAmount == 0 || _params.buyoutBidAmount >= _params.minimumBidAmount,
"Marketplace: invalid bid amounts."
);
}
/// @dev Processes an incoming bid in an auction.
function _handleBid(Auction memory _targetAuction, Bid memory _incomingBid) internal {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
Bid memory currentWinningBid = data.winningBid[_targetAuction.auctionId];
uint256 currentBidAmount = currentWinningBid.bidAmount;
uint256 incomingBidAmount = _incomingBid.bidAmount;
address _nativeTokenWrapper = nativeTokenWrapper;
// Close auction and execute sale if there's a buyout price and incoming bid amount is buyout price.
if (_targetAuction.buyoutBidAmount > 0 && incomingBidAmount >= _targetAuction.buyoutBidAmount) {
incomingBidAmount = _targetAuction.buyoutBidAmount;
_closeAuctionForBidder(_targetAuction, _incomingBid);
} else {
/**
* If there's an exisitng winning bid, incoming bid amount must be bid buffer % greater.
* Else, bid amount must be at least as great as minimum bid amount
*/
require(
_isNewWinningBid(
_targetAuction.minimumBidAmount,
currentBidAmount,
incomingBidAmount,
_targetAuction.bidBufferBps
),
"Marketplace: not winning bid."
);
// Update the winning bid and auction's end time before external contract calls.
data.winningBid[_targetAuction.auctionId] = _incomingBid;
if (_targetAuction.endTimestamp - block.timestamp <= _targetAuction.timeBufferInSeconds) {
_targetAuction.endTimestamp += _targetAuction.timeBufferInSeconds;
data.auctions[_targetAuction.auctionId] = _targetAuction;
}
}
// Payout previous highest bid.
if (currentWinningBid.bidder != address(0) && currentBidAmount > 0) {
CurrencyTransferLib.transferCurrencyWithWrapper(
_targetAuction.currency,
address(this),
currentWinningBid.bidder,
currentBidAmount,
_nativeTokenWrapper
);
}
// Collect incoming bid
CurrencyTransferLib.transferCurrencyWithWrapper(
_targetAuction.currency,
_incomingBid.bidder,
address(this),
incomingBidAmount,
_nativeTokenWrapper
);
emit NewBid(
_incomingBid.bidder,
_targetAuction.auctionId,
_targetAuction.assetContract,
_targetAuction.tokenId,
_incomingBid.bidAmount,
_targetAuction
);
}
/// @dev Checks whether an incoming bid is the new current highest bid.
function _isNewWinningBid(
uint256 _minimumBidAmount,
uint256 _currentWinningBidAmount,
uint256 _incomingBidAmount,
uint256 _bidBufferBps
) internal pure returns (bool isValidNewBid) {
if (_currentWinningBidAmount == 0) {
isValidNewBid = _incomingBidAmount >= _minimumBidAmount;
} else {
isValidNewBid = (_incomingBidAmount > _currentWinningBidAmount &&
((_incomingBidAmount - _currentWinningBidAmount) * MAX_BPS) / _currentWinningBidAmount >=
_bidBufferBps);
}
}
/// @dev Closes an auction for the winning bidder; distributes auction items to the winning bidder.
function _closeAuctionForBidder(Auction memory _targetAuction, Bid memory _winningBid) internal {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
require(
!data.payoutStatus[_targetAuction.auctionId].paidOutAuctionTokens,
"Marketplace: payout already completed."
);
data.payoutStatus[_targetAuction.auctionId].paidOutAuctionTokens = true;
_targetAuction.endTimestamp = uint64(block.timestamp);
data.winningBid[_targetAuction.auctionId] = _winningBid;
data.auctions[_targetAuction.auctionId] = _targetAuction;
_transferAuctionTokens(address(this), _winningBid.bidder, _targetAuction);
emit AuctionClosed(
_winningBid.bidder,
_targetAuction.auctionId,
_targetAuction.assetContract,
_targetAuction.tokenId,
_msgSender(),
_winningBid.bidAmount,
_targetAuction.currency
);
}
/// @dev Closes an auction for an auction creator; distributes winning bid amount to auction creator.
function _closeAuctionForAuctionCreator(Auction memory _targetAuction, Bid memory _winningBid) internal {
uint256 payoutAmount = _winningBid.bidAmount;
_payout(address(this), _targetAuction.auctionCreator, _targetAuction.currency, payoutAmount, _targetAuction);
emit AuctionClosed(
_winningBid.bidder,
_targetAuction.auctionId,
_targetAuction.assetContract,
_targetAuction.tokenId,
_msgSender(),
_winningBid.bidAmount,
_targetAuction.currency
);
}
/// @dev Transfers tokens for auction.
function _transferAuctionTokens(
address _from,
address _to,
Auction memory _auction
) internal {
if (_auction.tokenType == TokenType.ERC1155) {
IERC1155(_auction.assetContract).safeTransferFrom(_from, _to, _auction.tokenId, _auction.quantity, "");
} else if (_auction.tokenType == TokenType.ERC721) {
IERC721(_auction.assetContract).safeTransferFrom(_from, _to, _auction.tokenId, "");
}
}
/// @dev Pays out stakeholders in auction.
function _payout(
address _payer,
address _payee,
address _currencyToUse,
uint256 _totalPayoutAmount,
Auction memory _targetAuction
) internal {
(address platformFeeRecipient, uint16 platformFeeBps) = IPlatformFee(address(this)).getPlatformFeeInfo();
if(_currencyToUse == HOC_DIME_ADDRESS)
platformFeeBps = 0;
uint256 platformFeeCut = (_totalPayoutAmount * platformFeeBps) / MAX_BPS;
uint256 royaltyCut;
address royaltyRecipient;
// Distribute royalties. See Sushiswap's https://github.com/sushiswap/shoyu/blob/master/contracts/base/BaseExchange.sol#L296
try IERC2981(_targetAuction.assetContract).royaltyInfo(_targetAuction.tokenId, _totalPayoutAmount) returns (
address royaltyFeeRecipient,
uint256 royaltyFeeAmount
) {
if (royaltyFeeRecipient != address(0) && royaltyFeeAmount > 0) {
require(royaltyFeeAmount + platformFeeCut <= _totalPayoutAmount, "fees exceed the price");
royaltyRecipient = royaltyFeeRecipient;
royaltyCut = royaltyFeeAmount;
}
} catch {}
// Distribute price to token owner
address _nativeTokenWrapper = nativeTokenWrapper;
if(platformFeeCut > 0) {
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
platformFeeRecipient,
platformFeeCut,
_nativeTokenWrapper
);
}
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
royaltyRecipient,
royaltyCut,
_nativeTokenWrapper
);
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
_payee,
_totalPayoutAmount - (platformFeeCut + royaltyCut),
_nativeTokenWrapper
);
}
function validateAuction(uint256 _auctionId) external onlyExistingAuction(_auctionId) view returns (bool isValid) {
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
Auction memory auction = data.auctions[_auctionId];
isValid =
auction.startTimestamp <= block.timestamp &&
auction.endTimestamp > block.timestamp &&
auction.status == IEnglishAuctions.Status.CREATED &&
auction.assetContract != address(0)
;
}
uint8 constant FILTER_CREATOR = 0x80;
uint8 constant FILTER_ASSET_CONTRACT = 0x40;
uint8 constant FILTER_TOKEN_ID = 0x20;
uint8 constant FILTER_WINNING_BIDDER = 0x10;
uint8 constant FILTER_ONLY_NOT_CANCELLED = 0x04;
uint8 constant FILTER_ONLY_COMPLETED = 0x02;
uint8 constant FILTER_ONLY_CREATED = 0x01;
struct AuctionWinningBidAndPayoutStatus {
Auction auction;
Bid winningBid;
AuctionPayoutStatus payoutStatus;
}
function selectAuctions(
uint256 _startId,
uint16 _filterFlags,
address _filterCreator,
address _filterAssetContract,
uint256 _filterTokenId,
address _filterWinningBidder,
uint32 _maxScannedItems,
uint32 _maxOutputItems)
external
view
returns (AuctionWinningBidAndPayoutStatus[] memory _auctions, uint256 _nextStartId, uint256 blockTimeStamp)
{
blockTimeStamp = block.timestamp;
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
uint256 totalItems = data.totalAuctions;
uint256[] memory matchedItems = new uint256[](_maxOutputItems);
uint32 matchedItemsCount = 0;
while (_startId < totalItems && _maxScannedItems > 0 && _maxOutputItems > 0) {
Auction memory item = data.auctions[_startId];
if ((_filterFlags & FILTER_CREATOR) == 0 || item.auctionCreator == _filterCreator) {
if ((_filterFlags & FILTER_ASSET_CONTRACT) == 0 || item.assetContract == _filterAssetContract) {
if ((_filterFlags & FILTER_TOKEN_ID) == 0 || item.tokenId == _filterTokenId) {
if ((_filterFlags & FILTER_ONLY_CREATED) == 0 || item.status == IEnglishAuctions.Status.CREATED) {
if ((_filterFlags & FILTER_ONLY_COMPLETED) == 0 || item.status == IEnglishAuctions.Status.COMPLETED) {
if ((_filterFlags & FILTER_ONLY_NOT_CANCELLED) == 0 || item.status != IEnglishAuctions.Status.CANCELLED) {
if ((_filterFlags & FILTER_WINNING_BIDDER) == 0 || data.winningBid[_startId].bidder == _filterWinningBidder) {
matchedItems[matchedItemsCount] = _startId;
unchecked { ++matchedItemsCount; --_maxOutputItems; }
}
}
}
}
}
}
}
unchecked { ++_startId; --_maxScannedItems; }
}
_nextStartId = _startId < totalItems ? _startId : 0;
_auctions = new AuctionWinningBidAndPayoutStatus[](matchedItemsCount);
for (uint32 i = 0; i < matchedItemsCount; ) {
uint256 id = matchedItems[i];
_auctions[i] = AuctionWinningBidAndPayoutStatus(data.auctions[id], data.winningBid[id], data.payoutStatus[id]);
unchecked { ++i; }
}
}
}
@thirdweb-dev/contracts/extension/plugin/ReentrancyGuardStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
library ReentrancyGuardStorage {
bytes32 public constant REENTRANCY_GUARD_STORAGE_POSITION = keccak256("reentrancy.guard.storage");
struct Data {
uint256 _status;
}
function reentrancyGuardStorage() internal pure returns (Data storage reentrancyGuardData) {
bytes32 position = REENTRANCY_GUARD_STORAGE_POSITION;
assembly {
reentrancyGuardData.slot := position
}
}
}
@thirdweb-dev/contracts/interfaces/IWETH.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
interface IWETH {
function deposit() external payable;
function withdraw(uint256 amount) external;
function transfer(address to, uint256 value) external returns (bool);
}
@openzeppelin/contracts/interfaces/IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}
@openzeppelin/contracts/token/ERC1155/IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.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 IERC1155 is IERC165 {
/**
* @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;
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
@thirdweb-dev/contracts/eip/interface/IERC20.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
@thirdweb-dev/contracts/extension/interface/IPermissions.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IPermissions {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
@thirdweb-dev/contracts/extension/interface/IPermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./IPermissions.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IPermissionsEnumerable is IPermissions {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* [forum post](https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296)
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
@thirdweb-dev/contracts/extension/interface/IPlatformFee.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* Thirdweb's `PlatformFee` is a contract extension to be used with any base contract. It exposes functions for setting and reading
* the recipient of platform fee and the platform fee basis points, and lets the inheriting contract perform conditional logic
* that uses information about platform fees, if desired.
*/
interface IPlatformFee {
/// @dev Fee type variants: percentage fee and flat fee
enum PlatformFeeType {
Bps,
Flat
}
/// @dev Returns the platform fee bps and recipient.
function getPlatformFeeInfo() external view returns (address, uint16);
/// @dev Lets a module admin update the fees on primary sales.
function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps) external;
/// @dev Emitted when fee on primary sales is updated.
event PlatformFeeInfoUpdated(address indexed platformFeeRecipient, uint256 platformFeeBps);
/// @dev Emitted when the flat platform fee is updated.
event FlatPlatformFeeUpdated(address platformFeeRecipient, uint256 flatFee);
/// @dev Emitted when the platform fee type is updated.
event PlatformFeeTypeUpdated(PlatformFeeType feeType);
}
@thirdweb-dev/contracts/extension/plugin/ERC2771ContextConsumer.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./ERC2771ContextLogic.sol";
interface IERC2771Context {
function isTrustedForwarder(address forwarder) external view returns (bool);
}
/**
* @dev Context variant with ERC2771 support.
*/
abstract contract ERC2771ContextConsumer {
function _msgSender() public view virtual returns (address sender) {
if (IERC2771Context(address(this)).isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
assembly {
sender := shr(96, calldataload(sub(calldatasize(), 20)))
}
} else {
return msg.sender;
}
}
function _msgData() public view virtual returns (bytes calldata) {
if (IERC2771Context(address(this)).isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 20];
} else {
return msg.data;
}
}
}
@thirdweb-dev/contracts/extension/plugin/ERC2771ContextLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./ERC2771ContextStorage.sol";
/**
* @dev Context variant with ERC2771 support.
*/
abstract contract ERC2771ContextLogic {
constructor(address[] memory trustedForwarder) {
ERC2771ContextStorage.Data storage data = ERC2771ContextStorage.erc2771ContextStorage();
for (uint256 i = 0; i < trustedForwarder.length; i++) {
data._trustedForwarder[trustedForwarder[i]] = true;
}
}
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
ERC2771ContextStorage.Data storage data = ERC2771ContextStorage.erc2771ContextStorage();
return data._trustedForwarder[forwarder];
}
function _msgSender() internal view virtual returns (address sender) {
if (isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
assembly {
sender := shr(96, calldataload(sub(calldatasize(), 20)))
}
} else {
return msg.sender;
}
}
function _msgData() internal view virtual returns (bytes calldata) {
if (isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 20];
} else {
return msg.data;
}
}
}
@thirdweb-dev/contracts/extension/plugin/ERC2771ContextStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
library ERC2771ContextStorage {
bytes32 public constant ERC2771_CONTEXT_STORAGE_POSITION = keccak256("erc2771.context.storage");
struct Data {
mapping(address => bool) _trustedForwarder;
}
function erc2771ContextStorage() internal pure returns (Data storage erc2771ContextData) {
bytes32 position = ERC2771_CONTEXT_STORAGE_POSITION;
assembly {
erc2771ContextData.slot := position
}
}
}
@thirdweb-dev/contracts/extension/plugin/PermissionsEnumerableLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./PermissionsEnumerableStorage.sol";
import "./PermissionsLogic.sol";
/**
* @author thirdweb.com
*
* @title PermissionsEnumerable
* @dev This contracts provides extending-contracts with role-based access control mechanisms.
* Also provides interfaces to view all members with a given role, and total count of members.
*/
contract PermissionsEnumerableLogic is IPermissionsEnumerable, PermissionsLogic {
/**
* @notice Returns the role-member from a list of members for a role,
* at a given index.
* @dev Returns `member` who has `role`, at `index` of role-members list.
* See struct {RoleMembers}, and mapping {roleMembers}
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param index Index in list of current members for the role.
*
* @return member Address of account that has `role`
*/
function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) {
PermissionsEnumerableStorage.Data storage data = PermissionsEnumerableStorage.permissionsEnumerableStorage();
uint256 currentIndex = data.roleMembers[role].index;
uint256 check;
for (uint256 i = 0; i < currentIndex; i += 1) {
if (data.roleMembers[role].members[i] != address(0)) {
if (check == index) {
member = data.roleMembers[role].members[i];
return member;
}
check += 1;
} else if (hasRole(role, address(0)) && i == data.roleMembers[role].indexOf[address(0)]) {
check += 1;
}
}
}
/**
* @notice Returns total number of accounts that have a role.
* @dev Returns `count` of accounts that have `role`.
* See struct {RoleMembers}, and mapping {roleMembers}
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
*
* @return count Total number of accounts that have `role`
*/
function getRoleMemberCount(bytes32 role) external view override returns (uint256 count) {
PermissionsEnumerableStorage.Data storage data = PermissionsEnumerableStorage.permissionsEnumerableStorage();
uint256 currentIndex = data.roleMembers[role].index;
for (uint256 i = 0; i < currentIndex; i += 1) {
if (data.roleMembers[role].members[i] != address(0)) {
count += 1;
}
}
if (hasRole(role, address(0))) {
count += 1;
}
}
/// @dev Revokes `role` from `account`, and removes `account` from {roleMembers}
/// See {_removeMember}
function _revokeRole(bytes32 role, address account) internal override {
super._revokeRole(role, account);
_removeMember(role, account);
}
/// @dev Grants `role` to `account`, and adds `account` to {roleMembers}
/// See {_addMember}
function _setupRole(bytes32 role, address account) internal override {
super._setupRole(role, account);
_addMember(role, account);
}
/// @dev adds `account` to {roleMembers}, for `role`
function _addMember(bytes32 role, address account) internal {
PermissionsEnumerableStorage.Data storage data = PermissionsEnumerableStorage.permissionsEnumerableStorage();
uint256 idx = data.roleMembers[role].index;
data.roleMembers[role].index += 1;
data.roleMembers[role].members[idx] = account;
data.roleMembers[role].indexOf[account] = idx;
}
/// @dev removes `account` from {roleMembers}, for `role`
function _removeMember(bytes32 role, address account) internal {
PermissionsEnumerableStorage.Data storage data = PermissionsEnumerableStorage.permissionsEnumerableStorage();
uint256 idx = data.roleMembers[role].indexOf[account];
delete data.roleMembers[role].members[idx];
delete data.roleMembers[role].indexOf[account];
}
}
@thirdweb-dev/contracts/extension/plugin/PermissionsEnumerableStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "../../extension/interface/IPermissionsEnumerable.sol";
/**
* @author thirdweb.com
*/
library PermissionsEnumerableStorage {
bytes32 public constant PERMISSIONS_ENUMERABLE_STORAGE_POSITION = keccak256("permissions.enumerable.storage");
/**
* @notice A data structure to store data of members for a given role.
*
* @param index Current index in the list of accounts that have a role.
* @param members map from index => address of account that has a role
* @param indexOf map from address => index which the account has.
*/
struct RoleMembers {
uint256 index;
mapping(uint256 => address) members;
mapping(address => uint256) indexOf;
}
struct Data {
/// @dev map from keccak256 hash of a role to its members' data. See {RoleMembers}.
mapping(bytes32 => RoleMembers) roleMembers;
}
function permissionsEnumerableStorage() internal pure returns (Data storage permissionsEnumerableData) {
bytes32 position = PERMISSIONS_ENUMERABLE_STORAGE_POSITION;
assembly {
permissionsEnumerableData.slot := position
}
}
}
@thirdweb-dev/contracts/extension/plugin/PermissionsLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "../../extension/interface/IPermissions.sol";
import "./PermissionsStorage.sol";
import "../../lib/TWStrings.sol";
/**
* @author thirdweb.com
*
* @title Permissions
* @dev This contracts provides extending-contracts with role-based access control mechanisms
*/
contract PermissionsLogic is IPermissions {
/// @dev Default admin role for all roles. Only accounts with this role can grant/revoke other roles.
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @dev Modifier that checks if an account has the specified role; reverts otherwise.
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @notice Checks whether an account has a particular role.
* @dev Returns `true` if `account` has been granted `role`.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account for which the role is being checked.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
return data._hasRole[role][account];
}
/**
* @notice Checks whether an account has a particular role;
* role restrictions can be swtiched on and off.
*
* @dev Returns `true` if `account` has been granted `role`.
* Role restrictions can be swtiched on and off:
* - If address(0) has ROLE, then the ROLE restrictions
* don't apply.
* - If address(0) does not have ROLE, then the ROLE
* restrictions will apply.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account for which the role is being checked.
*/
function hasRoleWithSwitch(bytes32 role, address account) public view returns (bool) {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
if (!data._hasRole[role][address(0)]) {
return data._hasRole[role][account];
}
return true;
}
/**
* @notice Returns the admin role that controls the specified role.
* @dev See {grantRole} and {revokeRole}.
* To change a role's admin, use {_setRoleAdmin}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
*/
function getRoleAdmin(bytes32 role) external view override returns (bytes32) {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
return data._getRoleAdmin[role];
}
/**
* @notice Grants a role to an account, if not previously granted.
* @dev Caller must have admin role for the `role`.
* Emits {RoleGranted Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account to which the role is being granted.
*/
function grantRole(bytes32 role, address account) public virtual override {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
_checkRole(data._getRoleAdmin[role], _msgSender());
if (data._hasRole[role][account]) {
revert("Can only grant to non holders");
}
_setupRole(role, account);
}
/**
* @notice Revokes role from an account.
* @dev Caller must have admin role for the `role`.
* Emits {RoleRevoked Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account from which the role is being revoked.
*/
function revokeRole(bytes32 role, address account) public virtual override {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
_checkRole(data._getRoleAdmin[role], _msgSender());
_revokeRole(role, account);
}
/**
* @notice Revokes role from the account.
* @dev Caller must have the `role`, with caller being the same as `account`.
* Emits {RoleRevoked Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account from which the role is being revoked.
*/
function renounceRole(bytes32 role, address account) public virtual override {
if (_msgSender() != account) {
revert("Can only renounce for self");
}
_revokeRole(role, account);
}
/// @dev Sets `adminRole` as `role`'s admin role.
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
bytes32 previousAdminRole = data._getRoleAdmin[role];
data._getRoleAdmin[role] = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/// @dev Sets up `role` for `account`
function _setupRole(bytes32 role, address account) internal virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
data._hasRole[role][account] = true;
emit RoleGranted(role, account, _msgSender());
}
/// @dev Revokes `role` from `account`
function _revokeRole(bytes32 role, address account) internal virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
_checkRole(role, account);
delete data._hasRole[role][account];
emit RoleRevoked(role, account, _msgSender());
}
/// @dev Checks `role` for `account`. Reverts with a message including the required role.
function _checkRole(bytes32 role, address account) internal view virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
if (!data._hasRole[role][account]) {
revert(
string(
abi.encodePacked(
"Permissions: account ",
TWStrings.toHexString(uint160(account), 20),
" is missing role ",
TWStrings.toHexString(uint256(role), 32)
)
)
);
}
}
/// @dev Checks `role` for `account`. Reverts with a message including the required role.
function _checkRoleWithSwitch(bytes32 role, address account) internal view virtual {
if (!hasRoleWithSwitch(role, account)) {
revert(
string(
abi.encodePacked(
"Permissions: account ",
TWStrings.toHexString(uint160(account), 20),
" is missing role ",
TWStrings.toHexString(uint256(role), 32)
)
)
);
}
}
function _msgSender() internal view virtual returns (address sender) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
@thirdweb-dev/contracts/extension/plugin/PermissionsStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @author thirdweb.com
*/
library PermissionsStorage {
bytes32 public constant PERMISSIONS_STORAGE_POSITION = keccak256("permissions.storage");
struct Data {
/// @dev Map from keccak256 hash of a role => a map from address => whether address has role.
mapping(bytes32 => mapping(address => bool)) _hasRole;
/// @dev Map from keccak256 hash of a role to role admin. See {getRoleAdmin}.
mapping(bytes32 => bytes32) _getRoleAdmin;
}
function permissionsStorage() internal pure returns (Data storage permissionsData) {
bytes32 position = PERMISSIONS_STORAGE_POSITION;
assembly {
permissionsData.slot := position
}
}
}
@thirdweb-dev/contracts/extension/plugin/ReentrancyGuardLogic.sol
// SPDX-License-Identifier: Apache 2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./ReentrancyGuardStorage.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 ReentrancyGuardLogic {
// 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 {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal {
ReentrancyGuardStorage.Data storage data = ReentrancyGuardStorage.reentrancyGuardStorage();
data._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() {
ReentrancyGuardStorage.Data storage data = ReentrancyGuardStorage.reentrancyGuardStorage();
// On the first call to nonReentrant, _notEntered will be true
require(data._status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
data._status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
data._status = _NOT_ENTERED;
}
}
@thirdweb-dev/contracts/lib/CurrencyTransferLib.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
// Helper interfaces
import { IWETH } from "../interfaces/IWETH.sol";
import "../openzeppelin-presets/token/ERC20/utils/SafeERC20.sol";
library CurrencyTransferLib {
using SafeERC20 for IERC20;
/// @dev The address interpreted as native token of the chain.
address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @dev Transfers a given amount of currency.
function transferCurrency(
address _currency,
address _from,
address _to,
uint256 _amount
) internal {
if (_amount == 0) {
return;
}
if (_currency == NATIVE_TOKEN) {
safeTransferNativeToken(_to, _amount);
} else {
safeTransferERC20(_currency, _from, _to, _amount);
}
}
/// @dev Transfers a given amount of currency. (With native token wrapping)
function transferCurrencyWithWrapper(
address _currency,
address _from,
address _to,
uint256 _amount,
address _nativeTokenWrapper
) internal {
if (_amount == 0) {
return;
}
if (_currency == NATIVE_TOKEN) {
if (_from == address(this)) {
// withdraw from weth then transfer withdrawn native token to recipient
IWETH(_nativeTokenWrapper).withdraw(_amount);
safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
} else if (_to == address(this)) {
// store native currency in weth
require(_amount == msg.value, "msg.value != amount");
IWETH(_nativeTokenWrapper).deposit{ value: _amount }();
} else {
safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
}
} else {
safeTransferERC20(_currency, _from, _to, _amount);
}
}
/// @dev Transfer `amount` of ERC20 token from `from` to `to`.
function safeTransferERC20(
address _currency,
address _from,
address _to,
uint256 _amount
) internal {
if (_from == _to) {
return;
}
if (_from == address(this)) {
IERC20(_currency).safeTransfer(_to, _amount);
} else {
IERC20(_currency).safeTransferFrom(_from, _to, _amount);
}
}
/// @dev Transfers `amount` of native token to `to`.
function safeTransferNativeToken(address to, uint256 value) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "native token transfer failed");
}
/// @dev Transfers `amount` of native token to `to`. (With native token wrapping)
function safeTransferNativeTokenWithWrapper(
address to,
uint256 value,
address _nativeTokenWrapper
) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
if (!success) {
IWETH(_nativeTokenWrapper).deposit{ value: value }();
IERC20(_nativeTokenWrapper).safeTransfer(to, value);
}
}
}
@thirdweb-dev/contracts/lib/TWAddress.sol
// SPDX-License-Identifier: Apache 2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev Collection of functions related to the address type
*/
library TWAddress {
/**
* @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.
*
* [EIP1884](https://eips.ethereum.org/EIPS/eip-1884) increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
@thirdweb-dev/contracts/lib/TWStrings.sol
// SPDX-License-Identifier: Apache 2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev String operations.
*/
library TWStrings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
@thirdweb-dev/contracts/openzeppelin-presets/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../../../../eip/interface/IERC20.sol";
import "../../../../lib/TWAddress.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using TWAddress for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contracts/Constants.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.11;
contract Constants {
address internal constant HOC_DIME_ADDRESS = 0x716992D45Bc60E9Ead5f59206c0d049afbFf429F; // TODO: Mainnet
}
contracts/marketplace/IMarketplace.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/// @author thirdweb
/**
* @author thirdweb.com
*
* The `DirectListings` extension smart contract lets you buy and sell NFTs (ERC-721 or ERC-1155) for a fixed price.
*/
interface IDirectListings {
enum TokenType {
ERC721,
ERC1155
}
enum Status {
UNSET,
CREATED,
COMPLETED,
CANCELLED
}
/**
* @notice The parameters a seller sets when creating or updating a listing.
*
* @param assetContract The address of the smart contract of the NFTs being listed.
* @param tokenId The tokenId of the NFTs being listed.
* @param quantity The quantity of NFTs being listed. This must be non-zero, and is expected to
* be `1` for ERC-721 NFTs.
* @param currency The currency in which the price must be paid when buying the listed NFTs.
* @param pricePerToken The price to pay per unit of NFTs listed.
* @param startTimestamp The UNIX timestamp at and after which NFTs can be bought from the listing.
* @param endTimestamp The UNIX timestamp at and after which NFTs cannot be bought from the listing.
* @param reserved Whether the listing is reserved to be bought from a specific set of buyers.
*/
struct ListingParameters {
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 pricePerToken;
uint128 startTimestamp;
uint128 endTimestamp;
bool reserved;
}
/**
* @notice The information stored for a listing.
*
* @param listingId The unique ID of the listing.
* @param listingCreator The creator of the listing.
* @param assetContract The address of the smart contract of the NFTs being listed.
* @param tokenId The tokenId of the NFTs being listed.
* @param quantity The quantity of NFTs being listed. This must be non-zero, and is expected to
* be `1` for ERC-721 NFTs.
* @param currency The currency in which the price must be paid when buying the listed NFTs.
* @param pricePerToken The price to pay per unit of NFTs listed.
* @param startTimestamp The UNIX timestamp at and after which NFTs can be bought from the listing.
* @param endTimestamp The UNIX timestamp at and after which NFTs cannot be bought from the listing.
* @param reserved Whether the listing is reserved to be bought from a specific set of buyers.
* @param tokenType The type of token listed (ERC-721 or ERC-1155)
*/
struct Listing {
uint256 listingId;
address listingCreator;
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 pricePerToken;
uint128 startTimestamp;
uint128 endTimestamp;
bool reserved;
TokenType tokenType;
Status status;
}
/// @notice Emitted when a new listing is created.
event NewListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
Listing listing
);
/// @notice Emitted when a listing is updated.
event UpdatedListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
Listing listing
);
/// @notice Emitted when a listing is cancelled.
event CancelledListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId
);
/// @notice Emitted when a buyer is approved to buy from a reserved listing.
event BuyerApprovedForListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
address buyer,
bool approved
);
/// @notice Emitted when a currency is approved as a form of payment for the listing.
event CurrencyApprovedForListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
uint256 pricePerToken,
address currency
);
/// @notice Emitted when NFTs are bought from a listing.
event NewSale(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
address buyer,
uint256 quantityBought,
uint256 totalPricePaid,
address currency
);
/// @notice Emitted when NFTs are bought from a listing (indexed by buyer).
event NewPurchase(
address indexed buyer,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
address listingCreator,
uint256 quantityBought,
uint256 totalPricePaid,
address currency
);
/**
* @notice List NFTs (ERC721 or ERC1155) for sale at a fixed price.
*
* @param _params The parameters of a listing a seller sets when creating a listing.
*
* @return listingId The unique integer ID of the listing.
*/
function createListing(ListingParameters memory _params) external returns (uint256 listingId);
/**
* @notice Update parameters of a listing of NFTs.
*
* @param _listingId The ID of the listing to update.
* @param _params The parameters of a listing a seller sets when updating a listing.
*/
function updateListing(uint256 _listingId, ListingParameters memory _params) external;
/**
* @notice Cancel a listing.
*
* @param _listingId The ID of the listing to cancel.
*/
function cancelListing(uint256 _listingId) external;
/**
* @notice Approve a buyer to buy from a reserved listing.
*
* @param _listingId The ID of the listing to update.
* @param _buyer The address of the buyer to approve to buy from the listing.
* @param _toApprove Whether to approve the buyer to buy from the listing.
*/
function approveBuyerForListing(
uint256 _listingId,
address _buyer,
bool _toApprove
) external;
/**
* @notice Approve a currency as a form of payment for the listing.
*
* @param _listingId The ID of the listing to update.
* @param _currency The address of the currency to approve as a form of payment for the listing.
* @param _pricePerTokenInCurrency The price per token for the currency to approve.
*/
function approveCurrencyForListing(
uint256 _listingId,
address _currency,
uint256 _pricePerTokenInCurrency
) external;
/**
* @notice Buy NFTs from a listing.
*
* @param _listingId The ID of the listing to update.
* @param _buyFor The recipient of the NFTs being bought.
* @param _quantity The quantity of NFTs to buy from the listing.
* @param _currency The currency to use to pay for NFTs.
* @param _expectedTotalPrice The expected total price to pay for the NFTs being bought.
*/
function buyFromListing(
uint256 _listingId,
address _buyFor,
uint256 _quantity,
address _currency,
uint256 _expectedTotalPrice
) external payable;
/**
* @notice Returns the total number of listings created.
* @dev At any point, the return value is the ID of the next listing created.
*/
function totalListings() external view returns (uint256);
/// @notice Returns all listings between the start and end Id (both inclusive) provided.
function getAllListings(uint256 _startId, uint256 _endId) external view returns (Listing[] memory listings);
/**
* @notice Returns all valid listings between the start and end Id (both inclusive) provided.
* A valid listing is where the listing creator still owns and has approved Marketplace
* to transfer the listed NFTs.
*/
function getAllValidListings(uint256 _startId, uint256 _endId) external view returns (Listing[] memory listings);
/**
* @notice Returns a listing at the provided listing ID.
*
* @param _listingId The ID of the listing to fetch.
*/
function getListing(uint256 _listingId) external view returns (Listing memory listing);
}
/**
* The `EnglishAuctions` extension smart contract lets you sell NFTs (ERC-721 or ERC-1155) in an english auction.
*/
interface IEnglishAuctions {
enum TokenType {
ERC721,
ERC1155
}
enum Status {
UNSET,
CREATED,
COMPLETED,
CANCELLED
}
/**
* @notice The parameters a seller sets when creating an auction listing.
*
* @param assetContract The address of the smart contract of the NFTs being auctioned.
* @param tokenId The tokenId of the NFTs being auctioned.
* @param quantity The quantity of NFTs being auctioned. This must be non-zero, and is expected to
* be `1` for ERC-721 NFTs.
* @param currency The currency in which the bid must be made when bidding for the auctioned NFTs.
* @param minimumBidAmount The minimum bid amount for the auction.
* @param buyoutBidAmount The total bid amount for which the bidder can directly purchase the auctioned items and close the auction as a result.
* @param timeBufferInSeconds This is a buffer e.g. x seconds. If a new winning bid is made less than x seconds before expirationTimestamp, the
* expirationTimestamp is increased by x seconds.
* @param bidBufferBps This is a buffer in basis points e.g. x%. To be considered as a new winning bid, a bid must be at least x% greater than
* the current winning bid.
* @param startTimestamp The timestamp at and after which bids can be made to the auction
* @param endTimestamp The timestamp at and after which bids cannot be made to the auction.
*/
struct AuctionParameters {
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 minimumBidAmount;
uint256 buyoutBidAmount;
uint64 timeBufferInSeconds;
uint64 bidBufferBps;
uint64 startTimestamp;
uint64 endTimestamp;
}
/**
* @notice The information stored for an auction.
*
* @param auctionId The unique ID of the auction.
* @param auctionCreator The creator of the auction.
* @param assetContract The address of the smart contract of the NFTs being auctioned.
* @param tokenId The tokenId of the NFTs being auctioned.
* @param quantity The quantity of NFTs being auctioned. This must be non-zero, and is expected to
* be `1` for ERC-721 NFTs.
* @param currency The currency in which the bid must be made when bidding for the auctioned NFTs.
* @param minimumBidAmount The minimum bid amount for the auction.
* @param buyoutBidAmount The total bid amount for which the bidder can directly purchase the auctioned items and close the auction as a result.
* @param timeBufferInSeconds This is a buffer e.g. x seconds. If a new winning bid is made less than x seconds before expirationTimestamp, the
* expirationTimestamp is increased by x seconds.
* @param bidBufferBps This is a buffer in basis points e.g. x%. To be considered as a new winning bid, a bid must be at least x% greater than
* the current winning bid.
* @param startTimestamp The timestamp at and after which bids can be made to the auction
* @param endTimestamp The timestamp at and after which bids cannot be made to the auction.
* @param tokenType The type of NFTs auctioned (ERC-721 or ERC-1155)
*/
struct Auction {
uint256 auctionId;
address auctionCreator;
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 minimumBidAmount;
uint256 buyoutBidAmount;
uint64 timeBufferInSeconds;
uint64 bidBufferBps;
uint64 startTimestamp;
uint64 endTimestamp;
TokenType tokenType;
Status status;
}
/**
* @notice The information stored for a bid made in an auction.
*
* @param auctionId The unique ID of the auction.
* @param bidder The address of the bidder.
* @param bidAmount The total bid amount (in the currency specified by the auction).
*/
struct Bid {
uint256 auctionId;
address bidder;
uint256 bidAmount;
}
struct AuctionPayoutStatus {
bool paidOutAuctionTokens;
bool paidOutBidAmount;
}
/// @dev Emitted when a new auction is created.
event NewAuction(
address indexed auctionCreator,
uint256 auctionId,
address indexed assetContract,
uint256 indexed tokenId,
Auction auction
);
/// @dev Emitted when a new bid is made in an auction.
event NewBid(
address indexed bidder,
uint256 auctionId,
address indexed assetContract,
uint256 indexed tokenId,
uint256 bidAmount,
Auction auction
);
/// @notice Emitted when a auction is cancelled.
event CancelledAuction(
address indexed auctionCreator,
uint256 auctionId,
address indexed assetContract,
uint256 indexed tokenId
);
/// @dev Emitted when an auction is closed.
event AuctionClosed(
address indexed winningBidder,
uint256 auctionId,
address indexed assetContract,
uint256 indexed tokenId,
address closer,
uint256 winningAmount,
address currency
);
/**
* @notice Put up NFTs (ERC721 or ERC1155) for an english auction.
*
* @param _params The parameters of an auction a seller sets when creating an auction.
*
* @return auctionId The unique integer ID of the auction.
*/
function createAuction(AuctionParameters memory _params) external returns (uint256 auctionId);
/**
* @notice Cancel an auction.
*
* @param _auctionId The ID of the auction to cancel.
*/
function cancelAuction(uint256 _auctionId) external;
/**
* @notice Distribute the winning bid amount to the auction creator.
*
* @param _auctionId The ID of an auction.
*/
function collectAuctionPayout(uint256 _auctionId) external;
/**
* @notice Distribute the auctioned NFTs to the winning bidder.
*
* @param _auctionId The ID of an auction.
*/
function collectAuctionTokens(uint256 _auctionId) external;
/**
* @notice Distribute the winning bid amount and the auctioned NFTs.
*
* @param _auctionId The ID of an auction.
*/
function collectAuction(uint256 _auctionId) external;
/**
* @notice Bid in an active auction.
*
* @param _auctionId The ID of the auction to bid in.
* @param _bidAmount The bid amount in the currency specified by the auction.
*/
function bidInAuction(uint256 _auctionId, uint256 _bidAmount) external payable;
/**
* @notice Returns whether a given bid amount would make for a winning bid in an auction.
*
* @param _auctionId The ID of an auction.
* @param _bidAmount The bid amount to check.
*/
function isNewWinningBid(uint256 _auctionId, uint256 _bidAmount) external view returns (bool);
/// @notice Returns the auction of the provided auction ID.
function getAuction(uint256 _auctionId) external view returns (Auction memory auction);
/// @notice Returns all non-cancelled auctions.
function getAllAuctions(uint256 _startId, uint256 _endId) external view returns (Auction[] memory auctions);
/// @notice Returns all active auctions.
function getAllValidAuctions(uint256 _startId, uint256 _endId) external view returns (Auction[] memory auctions);
/// @notice Returns the winning bid of an active auction.
function getWinningBid(uint256 _auctionId)
external
view
returns (
address bidder,
address currency,
uint256 bidAmount
);
/// @notice Returns whether an auction is active.
function isAuctionExpired(uint256 _auctionId) external view returns (bool);
}
/**
* The `Offers` extension smart contract lets you make and accept offers made for NFTs (ERC-721 or ERC-1155).
*/
interface IOffers {
enum TokenType {
ERC721,
ERC1155,
ERC20
}
enum Status {
UNSET,
CREATED,
COMPLETED,
CANCELLED
}
/**
* @notice The parameters an offeror sets when making an offer for NFTs.
*
* @param assetContract The contract of the NFTs for which the offer is being made.
* @param tokenId The tokenId of the NFT for which the offer is being made.
* @param quantity The quantity of NFTs wanted.
* @param currency The currency offered for the NFTs.
* @param totalPrice The total offer amount for the NFTs.
* @param expirationTimestamp The timestamp at and after which the offer cannot be accepted.
*/
struct OfferParams {
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 totalPrice;
uint256 expirationTimestamp;
}
/**
* @notice The information stored for the offer made.
*
* @param offerId The ID of the offer.
* @param offeror The address of the offeror.
* @param assetContract The contract of the NFTs for which the offer is being made.
* @param tokenId The tokenId of the NFT for which the offer is being made.
* @param quantity The quantity of NFTs wanted.
* @param currency The currency offered for the NFTs.
* @param totalPrice The total offer amount for the NFTs.
* @param expirationTimestamp The timestamp at and after which the offer cannot be accepted.
* @param tokenType The type of token (ERC-721 or ERC-1155) the offer is made for.
*/
struct Offer {
uint256 offerId;
address offeror;
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 totalPrice;
uint256 expirationTimestamp;
TokenType tokenType;
Status status;
}
/// @dev Emitted when a new offer is created.
event NewOffer(
address indexed offeror,
uint256 offerId,
address indexed assetContract,
uint256 indexed tokenId,
Offer offer
);
/// @dev Emitted when an offer is cancelled.
event CancelledOffer(
address indexed offeror,
uint256 offerId,
address indexed assetContract,
uint256 indexed tokenId
);
/// @dev Emitted when an offer is accepted.
event AcceptedOffer(
address indexed seller,
uint256 offerId,
address indexed assetContract,
uint256 indexed tokenId,
address offeror,
uint256 quantityBought,
uint256 totalPricePaid,
address currency
);
/// @dev Emitted when an offer is accepted.
event AcceptedOfferor(
address indexed offeror,
uint256 offerId,
address indexed assetContract,
uint256 indexed tokenId,
address seller,
uint256 quantityBought,
uint256 totalPricePaid,
address currency
);
/**
* @notice Make an offer for NFTs (ERC-721 or ERC-1155)
*
* @param _params The parameters of an offer.
*
* @return offerId The unique integer ID assigned to the offer.
*/
function makeOffer(OfferParams memory _params) external returns (uint256 offerId);
/**
* @notice Cancel an offer.
*
* @param _offerId The ID of the offer to cancel.
*/
function cancelOffer(uint256 _offerId) external;
/**
* @notice Accept an offer.
*
* @param _offerId The ID of the offer to accept.
*/
function acceptOffer(uint256 _offerId) external;
/// @notice Returns an offer for the given offer ID.
function getOffer(uint256 _offerId) external view returns (Offer memory offer);
/// @notice Returns all active (i.e. non-expired or cancelled) offers.
function getAllOffers(uint256 _startId, uint256 _endId) external view returns (Offer[] memory offers);
/// @notice Returns all valid offers. An offer is valid if the offeror owns and has approved Marketplace to transfer the offer amount of currency.
function getAllValidOffers(uint256 _startId, uint256 _endId) external view returns (Offer[] memory offers);
}
contracts/marketplace/english-auctions/EnglishAuctionsStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/// @author thirdweb
import { IEnglishAuctions } from "../IMarketplace.sol";
/**
* @author thirdweb.com
*/
library EnglishAuctionsStorage {
bytes32 public constant ENGLISH_AUCTIONS_STORAGE_POSITION = keccak256("english.auctions.storage");
struct Data {
uint256 totalAuctions;
mapping(uint256 => IEnglishAuctions.Auction) auctions;
mapping(uint256 => IEnglishAuctions.Bid) winningBid;
mapping(uint256 => IEnglishAuctions.AuctionPayoutStatus) payoutStatus;
}
function englishAuctionsStorage() internal pure returns (Data storage englishAuctionsData) {
bytes32 position = ENGLISH_AUCTIONS_STORAGE_POSITION;
assembly {
englishAuctionsData.slot := position
}
}
}
Compiler Settings
{"viaIR":true,"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":1000,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"constructor","inputs":[{"type":"address","name":"_nativeTokenWrapper","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"_msgData","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"sender","internalType":"address"}],"name":"_msgSender","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"bidInAuction","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"},{"type":"uint256","name":"_bidAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelAuction","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"collectAuction","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"collectAuctionPayout","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"collectAuctionTokens","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"auctionId","internalType":"uint256"}],"name":"createAuction","inputs":[{"type":"tuple","name":"_params","internalType":"struct IEnglishAuctions.AuctionParameters","components":[{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_allAuctions","internalType":"struct IEnglishAuctions.Auction[]","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getAllAuctions","inputs":[{"type":"uint256","name":"_startId","internalType":"uint256"},{"type":"uint256","name":"_endId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_validAuctions","internalType":"struct IEnglishAuctions.Auction[]","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getAllValidAuctions","inputs":[{"type":"uint256","name":"_startId","internalType":"uint256"},{"type":"uint256","name":"_endId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"_auction","internalType":"struct IEnglishAuctions.Auction","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getAuction","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"_bidder","internalType":"address"},{"type":"address","name":"_currency","internalType":"address"},{"type":"uint256","name":"_bidAmount","internalType":"uint256"}],"name":"getWinningBid","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isAuctionExpired","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isNewWinningBid","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"},{"type":"uint256","name":"_bidAmount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_auctions","internalType":"struct EnglishAuctionsLogic.AuctionWinningBidAndPayoutStatus[]","components":[{"type":"tuple","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint8"},{"type":"uint8"}]},{"type":"tuple","components":[{"type":"uint256"},{"type":"address"},{"type":"uint256"}]},{"type":"tuple","components":[{"type":"bool"},{"type":"bool"}]}]},{"type":"uint256","name":"_nextStartId","internalType":"uint256"},{"type":"uint256","name":"blockTimeStamp","internalType":"uint256"}],"name":"selectAuctions","inputs":[{"type":"uint256","name":"_startId","internalType":"uint256"},{"type":"uint16","name":"_filterFlags","internalType":"uint16"},{"type":"address","name":"_filterCreator","internalType":"address"},{"type":"address","name":"_filterAssetContract","internalType":"address"},{"type":"uint256","name":"_filterTokenId","internalType":"uint256"},{"type":"address","name":"_filterWinningBidder","internalType":"address"},{"type":"uint32","name":"_maxScannedItems","internalType":"uint32"},{"type":"uint32","name":"_maxOutputItems","internalType":"uint32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalAuctions","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"isValid","internalType":"bool"}],"name":"validateAuction","inputs":[{"type":"uint256","name":"_auctionId","internalType":"uint256"}]},{"type":"event","name":"AuctionClosed","inputs":[{"type":"address","name":"winningBidder","indexed":true},{"type":"uint256","name":"auctionId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"address","name":"closer","indexed":false},{"type":"uint256","name":"winningAmount","indexed":false},{"type":"address","name":"currency","indexed":false}],"anonymous":false},{"type":"event","name":"CancelledAuction","inputs":[{"type":"address","name":"auctionCreator","indexed":true},{"type":"uint256","name":"auctionId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true}],"anonymous":false},{"type":"event","name":"NewAuction","inputs":[{"type":"address","name":"auctionCreator","indexed":true},{"type":"uint256","name":"auctionId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"tuple","name":"auction","indexed":false,"components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint8"},{"type":"uint8"}]}],"anonymous":false},{"type":"event","name":"NewBid","inputs":[{"type":"address","name":"bidder","indexed":true},{"type":"uint256","name":"auctionId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"uint256","name":"bidAmount","indexed":false},{"type":"tuple","name":"auction","indexed":false,"components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint64"},{"type":"uint8"},{"type":"uint8"}]}],"anonymous":false}]
Contract Creation Code
0x60a0346200007757601f62003c1938819003918201601f19168301916001600160401b038311848410176200007c578084926020946040528339810103126200007757516001600160a01b03811681036200007757608052604051613b869081620000938239608051818181612c0e01526136770152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604052600436101561001257600080fd5b60003560e01c806303a54fe0146101275780630858e5ad14610122578063119df25f1461011d5780631389b1171461011857806316002f4a1461011357806316654d401461010e5780632eb566bd146101095780636891939d1461010457806378bd7935146100ff5780637b063801146100fa5780638b49d47e146100f557806396b5a755146100f0578063a286b5a2146100eb578063c291537c146100e6578063cde0b4f9146100e1578063e2283ed8146100dc5763ebf05a62146100d757600080fd5b6115a1565b6111c9565b610fd6565b610ef6565b610d8c565b610be5565b610b9e565b610905565b61086b565b6106aa565b6105da565b61050f565b6104d2565b610451565b610425565b6102d8565b346102d35760203660031901126102d35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f61016b8282541415611ffd565b55600261019761019283600052600080516020613b31833981519152602052604060002090565b612093565b6102536101d56101d0856000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b612326565b6101a08301926101fb600385516101eb81610764565b6101f481610764565b1415612048565b61022761021461016083015167ffffffffffffffff1690565b67ffffffffffffffff4291161115612357565b61024e6001600160a01b0361024660208501516001600160a01b031690565b1615156123c8565b613384565b5161025d81610764565b61026681610764565b03610297575b61029560017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b005b60096102bd6102cd92600052600080516020613b31833981519152602052604060002090565b01805461ff001916610200179055565b3861026c565b600080fd5b60403660031901126102d35760043560243560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f61031a8282541415611ffd565b55600091808352600080516020613b31833981519152918260205260ff600960408620015460081c169260048410156104155761035c60016103cd9514612048565b82855260205261036e60408520612093565b9061039267ffffffffffffffff8061016085015116421090816103f9575b506121a4565b61039d8115156121ef565b6103c36103a8611806565b6103b0611a2d565b9485526001600160a01b03166020850152565b6040830152612b9e565b6103f660017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b80f35b6101408501514292501667ffffffffffffffff1611153861038c565b610737565b60009103126102d357565b346102d35760003660031901126102d3576020610440611806565b6001600160a01b0360405191168152f35b346102d35760203660031901126102d35760043580600052600080516020613b31833981519152908160205260ff60096040600020015460081c1660048110156104155760016104a19114612048565b6000526020526104ce60086040600020015460c01c60405191829142111582919091602081019215159052565b0390f35b346102d35760003660031901126102d35760207fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e354604051908152f35b346102d3576101403660031901126102d357610529611806565b6001600160a01b036040519163a32fa5b360e01b83527ff94103142c1baabe9ac2b5d1487bf783de9e69cfeea9a72f5c9c94afd7877b8c6004840152166024820152602081604481305afa80156105d55761058c916000916105a7575b506118f1565b6104ce610597611957565b6040519081529081906020820190565b6105c8915060203d81116105ce575b6105c081836117c0565b8101906117e2565b38610586565b503d6105b6565b6117fa565b346102d3576040806003193601126102d357600435906000828152600080516020613b31833981519152928360205260ff6009848420015460081c169360048510156104155783610699936106769261063860016104ce9914612048565b848252602052610649828220612093565b9381527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e560205220612326565b67ffffffffffffffff6101208560c0850151930151930151169160243591613336565b905190151581529081906020820190565b346102d35760203660031901126102d3576004356000818152600080516020613b31833981519152908160205260ff600960408320015460081c169060048210156104155761070192610638600160409414612048565b60208181015160a0939093015160409283015183516001600160a01b039586168152949091169184019190915290820152606090f35b634e487b7160e01b600052602160045260246000fd5b6002111561041557565b9060028210156104155752565b6004111561041557565b9060048210156104155752565b805182526020808201516001600160a01b03169083015261086991906040818101516001600160a01b03169083015260608101516060830152608081015160808301526107d860a082015160a08401906001600160a01b03169052565b60c081015160c083015260e081015160e0830152610808610100808301519084019067ffffffffffffffff169052565b6101208181015167ffffffffffffffff16908301526101408181015167ffffffffffffffff16908301526101608181015167ffffffffffffffff169083015261085a6101808083015190840190610757565b6101a08091015191019061076e565b565b346102d35760203660031901126102d35761088461245e565b50600435600052600080516020613b318339815191526020526101c06108ad6040600020612093565b6108ba604051809261077b565bf35b6020908160408183019282815285518094520193019160005b8281106108e3575050505090565b90919293826101c0826108f9600194895161077b565b019501939291016108d5565b346102d3576040806003193601126102d3576024356004358181111580610b74575b610930906124d8565b61094a610945610940838561187b565b612523565b612556565b91600091805b82811115610a795750505061096490612556565b906000815191815b838110610980578551806104ce87826108bc565b6109d290426109b56109a861014061099885886125a6565b51015167ffffffffffffffff1690565b67ffffffffffffffff1690565b111580610a5e575b80610a35575b80610a07575b6109d757612523565b61096c565b610a016109e482856125a6565b51946109ef816125d0565b956109fa828a6125a6565b52876125a6565b50612523565b506001600160a01b03610a2d88610a1e84876125a6565b5101516001600160a01b031690565b1615156109c9565b506001610a4f6101a0610a4884876125a6565b5101611bab565b610a5881610764565b146109c3565b5042610a736109a861016061099885886125a6565b116109bd565b610a83828261187b565b610aa761019283600052600080516020613b31833981519152602052604060002090565b610ab182886125a6565b52610abc81876125a6565b508642610ad26109a8610140610998868c6125a6565b11159182610b57575b82610b33575b82610b11575b5050610afc575b610af790612523565b610950565b92610b09610af791612523565b939050610aee565b6001600160a01b03925090610a1e610b2992896125a6565b1615158638610ae7565b91506001610b476101a0610a48858b6125a6565b610b5081610764565b1491610ae1565b915042610b6d6109a8610160610998868c6125a6565b1191610adb565b507fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3548210610927565b346102d35760003660031901126102d3576040610bb9611888565b919082825193849260208452816020850152848401376000828201840152601f01601f19168101030190f35b346102d35760203660031901126102d357600435600090808252600080516020613b318339815191528060205260ff600960408520015460081c166004811015610415576001610c359114612048565b8183526020526001600160a01b03610c608160016040862001541682610c59611806565b1614612260565b610c8461019283600052600080516020613b31833981519152602052604060002090565b91610cd982610cd26020610cc46101d0866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b01516001600160a01b031690565b1615612413565b610d0f6009610cff83600052600080516020613b31833981519152602052604060002090565b01805461ff001916610300179055565b7fb78a7099174b11eaf203c16216e524a48f8806eb956090d87d838ada4ebe68d3610d5f60208501610d5286610d4c83516001600160a01b031690565b30613832565b516001600160a01b031690565b926060610d7660408701516001600160a01b031690565b950151604051938452948116931691602090a480f35b346102d35760203660031901126102d35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f610dd08282541415611ffd565b55600090808252600080516020613b31833981519152602052610e076001600160a01b038060016040862001541690610c59611806565b303b15610ef2576040517febf05a6200000000000000000000000000000000000000000000000000000000815260048101829052828160248183305af180156105d557610edf575b5081303b15610edc576040517f03a54fe000000000000000000000000000000000000000000000000000000000815260048101929092528160248183305af180156105d557610ec3575b506103f660017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b80610ed0610ed69261176f565b8061041a565b38610e99565b80fd5b80610ed0610eec9261176f565b38610e4f565b5080fd5b346102d3576040806003193601126102d357600435602435918282111580610fac575b610f22906124d8565b818303838111610fa757600190818101809111610fa757610f4290612556565b92805b85811115610f5a578351806104ce87826108bc565b610f9a846000838152600080516020613b3183398151915260205220610f89610f83858561187b565b91612093565b610f9382896125a6565b52866125a6565b5082810180911115610f45575b611865565b507fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3548310610f19565b346102d35760203660031901126102d35760043580600052600080516020613b31833981519152908160205260ff60096040600020015460081c1660048110156104155760016110269114612048565b6000526020526104ce61103c6040600020612093565b6101408101514267ffffffffffffffff909116111590816110b1575b8161108e575b81611077575b5060405190151581529081906020820190565b604001516001600160a01b03161515905038611064565b905060016101a08201516110a181610764565b6110aa81610764565b149061105e565b9050426110cd6109a861016084015167ffffffffffffffff1690565b1190611058565b61ffff8116036102d357565b6001600160a01b038116036102d357565b60043590610869826110e0565b60643590610869826110e0565b60c4359063ffffffff821682036102d357565b60e4359063ffffffff821682036102d357565b9093929160608201606083528551809152608083019060208097019060005b8882821061116657505050509482015260400152565b61026084958260019495965161117d83825161077b565b8082015180516101c0850152808301516001600160a01b03166101e085015260409081015161020085015201518051151561022084015201511515610240820152019401929101611150565b346102d3576101003660031901126102d3576024356111e7816110d4565b604435906111f4826110e0565b606435611200816110e0565b6084359160a43591611211836110e0565b61121961110b565b9461122261111e565b95600435909487947fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3549761125d63ffffffff809b16613a3f565b956000946080841615968715915b8c811080611596575b8061158b575b1561146257806112a68f9261019290600052600080516020613b31833981519152602052604060002090565b8a85611449575b6112c2575b506001019b60001901169a61126b565b604080891615908115611430575b50156112b25760208816158015611423575b156112b257600190818916158015611403575b611300575b506112b2565b6002808a16159081156113e2575b50156112fa5760048916159081156113bf575b5061132d575b806112fa565b60108816158015611366575b15611327578280918b849f9c948f611356908560019816906125a6565b5201169960001901169b90611327565b506113ac8161139e846000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b01546001600160a01b031690565b6001600160a01b03808b16911614611339565b600391506101a001516113d181610764565b6113da81610764565b141538611321565b90506101a08201516113f381610764565b6113fc81610764565b143861130e565b50816101a082015161141481610764565b61141d81610764565b146112f5565b50866060820151146112e2565b8201516001600160a01b038881169116149050386112d0565b5060208101516001600160a01b038581169116146112ad565b8d88818f938d9460009082106000146115835750915b1661148281613a71565b9360005b8481168381101561157357859161156b826114a3600194876125a6565b516115556114c882600052600080516020613b31833981519152602052604060002090565b9161154b611532611502836000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b926000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b9161154461153e611a2d565b95612093565b8552612326565b6020840152613b0a565b6040820152611564828c6125a6565b52896125a6565b500116611486565b604051806104ce42888b84611131565b905091611478565b508d8b16151561127a565b508d8c161515611274565b346102d35760203660031901126102d35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f6115e58282541415611ffd565b5580600052600080516020613b3183398151915260205260026001600160a01b0361161d816001604060002001541682610c59611806565b61166c611667611663611659866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b5460081c60ff1690565b1590565b6122b5565b6116b16116a2846000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b805461ff001916610100179055565b6102536116d861019285600052600080516020613b31833981519152602052604060002090565b61170e6101d0866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b906117546101a0820194611728600387516101eb81610764565b61174161021461016085015167ffffffffffffffff1690565b60208401516001600160a01b0316610246565b613531565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff811161178357604052565b611759565b6060810190811067ffffffffffffffff82111761178357604052565b6040810190811067ffffffffffffffff82111761178357604052565b90601f8019910116810190811067ffffffffffffffff82111761178357604052565b908160209103126102d3575180151581036102d35790565b6040513d6000823e3d90fd5b60405163572b6c0560e01b8152336004820152602081602481305afa9081156105d557600091611847575b50156118435736601319013560601c90565b3390565b61185f915060203d81116105ce576105c081836117c0565b38611831565b634e487b7160e01b600052601160045260246000fd5b91908203918211610fa757565b60405163572b6c0560e01b8152336004820152602081602481305afa9081156105d5576000916118d3575b50156118cc57601319360190368211610fa75760009190565b6000903690565b6118eb915060203d81116105ce576105c081836117c0565b386118b3565b156118f857565b606460405162461bcd60e51b815260206004820152600c60248201527f214c49535445525f524f4c4500000000000000000000000000000000000000006044820152fd5b600435611948816110e0565b90565b606435611948816110e0565b600435611963816110e0565b6001600160a01b036040519163a32fa5b360e01b83527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae66004840152166024820152602081604481305afa9081156105d557600091611a0f575b50156119cb57611948611e61565b606460405162461bcd60e51b815260206004820152600b60248201527f2141535345545f524f4c450000000000000000000000000000000000000000006044820152fd5b611a27915060203d81116105ce576105c081836117c0565b386119bd565b6040519061086982611788565b60405190610140820182811067ffffffffffffffff82111761178357604052565b604051906101c0820182811067ffffffffffffffff82111761178357604052565b67ffffffffffffffff8116036102d357565b60c4359061086982611a7c565b60e4359061086982611a7c565b610104359061086982611a7c565b610124359061086982611a7c565b6101409060031901126102d357611ad9611a3a565b90611ae26110f1565b825260243560208301526044356040830152611afc6110fe565b6060830152608435608083015260a43560a0830152611b19611a8e565b60c0830152611b26611a9b565b60e0830152611b33611aa8565b610100830152611b41611ab6565b610120830152565b60c43561194881611a7c565b60e43561194881611a7c565b6101043561194881611a7c565b6101243561194881611a7c565b60028210156104155752565b60048210156104155752565b9060028110156104155760ff80198354169116179055565b5160048110156104155790565b9060048110156104155761ff0082549160081b169061ff001916179055565b906101a060096108699383518155611c28611bfc60208601516001600160a01b031690565b60018301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b611c6b611c3f60408601516001600160a01b031690565b60028301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b6060840151600382015560808401516004820155611cc2611c9660a08601516001600160a01b031690565b60058301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60c0840151600682015560e08401516007820155611e1f60088201611d14611cf661010088015167ffffffffffffffff1690565b825467ffffffffffffffff191667ffffffffffffffff909116178255565b611d6e611d2d61012088015167ffffffffffffffff1690565b82547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff1660409190911b6fffffffffffffffff000000000000000016178255565b611dd0611d8761014088015167ffffffffffffffff1690565b82547fffffffffffffffff0000000000000000ffffffffffffffffffffffffffffffff1660809190911b77ffffffffffffffff0000000000000000000000000000000016178255565b610160860151815477ffffffffffffffffffffffffffffffffffffffffffffffff1660c09190911b7fffffffffffffffff00000000000000000000000000000000000000000000000016179055565b0191611e39610180820151611e338161074d565b84611b93565b015190611e4582610764565b611bb8565b9081526101e081019291610869916020019061077b565b611e696125df565b90611e72611806565b611e7a61193c565b611e8390612613565b9081611e8e36611ac4565b90611e98916129d8565b611ea061193c565b60243592611eac61194b565b611eb4611b49565b611ebc611b55565b611ec4611b61565b91611ecd611b6e565b93611ed6611a5b565b8b81526001600160a01b0389166020820152966001600160a01b031660408801526060870189905260443560808801526001600160a01b031660a087015260843560c087015260a43560e087015267ffffffffffffffff1661010086015267ffffffffffffffff1661012085015267ffffffffffffffff1661014084015267ffffffffffffffff16610160830152611f72906101808301611b7b565b60016101a082015280611f9c86600052600080516020613b31833981519152602052604060002090565b90611fa691611bd7565b611fb1813084613832565b611fb961193c565b60405180916001600160a01b03809116941692611fd7908883611e4a565b037f90f6626183053b3cdf2d1bd5ecc58502e96e1d805a0cfe5cd0b01eabb5005d0291a4565b1561200457565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b1561204f57565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a20696e76616c69642061756374696f6e2e0000006044820152fd5b9061086960ff60096120a3611a5b565b94805486526120cf6120bf60018301546001600160a01b031690565b6001600160a01b03166020880152565b6120f66120e660028301546001600160a01b031690565b6001600160a01b03166040880152565b600381015460608701526004810154608087015261213161212160058301546001600160a01b031690565b6001600160a01b031660a0880152565b600681015460c0870152600781015460e0870152600881015467ffffffffffffffff808216610100890152604082901c8116610120890152608082901c166101408801526121849060c01c610160880152565b01546121968282166101808701611b7b565b60081c166101a08401611b87565b156121ab57565b606460405162461bcd60e51b815260206004820152601e60248201527f4d61726b6574706c6163653a20696e6163746976652061756374696f6e2e00006044820152fd5b156121f657565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a2042696464696e672077697468207a65726f206160448201527f6d6f756e742e00000000000000000000000000000000000000000000000000006064820152fd5b1561226757565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a206e6f742061756374696f6e2063726561746f726044820152601760f91b6064820152fd5b156122bc57565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a207061796f757420616c726561647920636f6d7060448201527f6c657465642e00000000000000000000000000000000000000000000000000006064820152fd5b9060405161233381611788565b604060028294805484526001600160a01b0360018201541660208501520154910152565b1561235e57565b608460405162461bcd60e51b815260206004820152602260248201527f4d61726b6574706c6163653a2061756374696f6e207374696c6c20616374697660448201527f652e0000000000000000000000000000000000000000000000000000000000006064820152fd5b156123cf57565b606460405162461bcd60e51b815260206004820152601f60248201527f4d61726b6574706c6163653a206e6f20626964732077657265206d6164652e006044820152fd5b1561241a57565b606460405162461bcd60e51b815260206004820152601f60248201527f4d61726b6574706c6163653a206269647320616c7265616479206d6164652e006044820152fd5b604051906101c0820182811067ffffffffffffffff82111761178357604052816101a06000918281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e082015282610100820152826101208201528261014082015282610160820152826101808201520152565b156124df57565b606460405162461bcd60e51b815260206004820152600d60248201527f696e76616c69642072616e6765000000000000000000000000000000000000006044820152fd5b9060018201809211610fa757565b91908201809211610fa757565b67ffffffffffffffff81116117835760051b60200190565b906125608261253e565b61256d60405191826117c0565b828152809261257e601f199161253e565b019060005b82811061258f57505050565b60209061259a61245e565b82828501015201612583565b80518210156125ba5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b6000198114610fa75760010190565b7fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3908154916001830190818411610fa75755565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082527fd9b67a260000000000000000000000000000000000000000000000000000000060048301526020926001600160a01b0316918381602481865afa9081156105d55760009161276d575b501561269257505050600190565b6040519081527f80ac58cd000000000000000000000000000000000000000000000000000000006004820152908290829060249082905afa9182156105d557600092612750575b5050156126e557600090565b60405162461bcd60e51b815260206004820152603760248201527f4d61726b6574706c6163653a2061756374696f6e656420746f6b656e206d757360448201527f742062652045524331313535206f72204552433732312e0000000000000000006064820152608490fd5b6127669250803d106105ce576105c081836117c0565b38806126d9565b6127849150843d86116105ce576105c081836117c0565b38612684565b1561279157565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a2061756374696f6e696e67207a65726f2071756160448201527f6e746974792e00000000000000000000000000000000000000000000000000006064820152fd5b1561280257565b608460405162461bcd60e51b815260206004820152602960248201527f4d61726b6574706c6163653a2061756374696f6e696e6720696e76616c69642060448201527f7175616e746974792e00000000000000000000000000000000000000000000006064820152fd5b1561287357565b606460405162461bcd60e51b815260206004820152601c60248201527f4d61726b6574706c6163653a206e6f2074696d652d6275666665722e000000006044820152fd5b156128be57565b606460405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574706c6163653a206e6f206269642d6275666665722e00000000006044820152fd5b90610e1067ffffffffffffffff80931601918211610fa757565b91909167ffffffffffffffff80809416911601918211610fa757565b1561293f57565b606460405162461bcd60e51b815260206004820152602060248201527f4d61726b6574706c6163653a20696e76616c69642074696d657374616d70732e6044820152fd5b1561298a57565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a20696e76616c69642062696420616d6f756e74736044820152601760f91b6064820152fd5b612a01610869926001604084016129f18151151561278a565b5114908115612ad2575b506127fb565b612a8467ffffffffffffffff612a2e81612a2660c086015167ffffffffffffffff1690565b16151561286c565b612a50612a496109a860e086015167ffffffffffffffff1690565b15156128b7565b610100830190612a70612a6b835167ffffffffffffffff1690565b612902565b8142911610159182612aa9575b5050612938565b60a08101518015918215612a9a575b5050612983565b60800151111590503880612a93565b5161012085015167ffffffffffffffff9182169350612ac891166109a8565b9116103880612a7d565b60019150612adf8161074d565b14386129fb565b15612aed57565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a206e6f742077696e6e696e67206269642e0000006044820152fd5b90604060029180518455612b786001600160a01b0360208301511660018601906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b0151910155565b604090610869939594929561020082019682526020820152019061077b565b90612bd66101d083516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b917f6b33f3b169c84eaaec29320da85952def04ba83c79cf51af8a9811c446ceeecc612caa604085015193610d5260408201968751907f00000000000000000000000000000000000000000000000000000000000000009160e0880190888a83518015159081612e39575b5015612d13575050506020612c5c915192610cc4878b613384565b826001600160a01b03998a8316151580612d0a575b612ce3575b5050506020612c8f60a08901516001600160a01b031690565b940193612ca385516001600160a01b031690565b3091612e8f565b92825192612cde612cc560408301516001600160a01b031690565b9160608101519751846040519586951698169684612b7f565b0390a4565b612d0292612cfb60a08c01516001600160a01b031690565b3090612e8f565b388281612c76565b50801515612c71565b612c5c9350612d498284612d4e93612d436109a861012060c060209a9c99015195015167ffffffffffffffff1690565b92613336565b612ae6565b612d8b87612d868c516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b612b31565b6101608a01805167ffffffffffffffff16908b612dca610100612dba67ffffffffffffffff958642911661187b565b92015167ffffffffffffffff1690565b9283161015612ddb575b5050610cc4565b612df9612e0792612df4835167ffffffffffffffff1690565b61291c565b67ffffffffffffffff169052565b612e328a612e2d8151600052600080516020613b31833981519152602052604060002090565b611bd7565b3880612dd4565b905083101538612c41565b15612e4b57565b606460405162461bcd60e51b815260206004820152601360248201527f6d73672e76616c756520213d20616d6f756e74000000000000000000000000006044820152fd5b90939291938215612faf576001600160a01b039180831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee03612fa0575081163003612f3f57821692833b156102d357600060405180957f2e1a7d4d000000000000000000000000000000000000000000000000000000008252818381612f1288600483019190602083019252565b03925af19384156105d55761086994612f2c575b50613087565b80610ed0612f399261176f565b38612f26565b9190923083821614600014612f945750612f5a348414612e44565b16803b156102d357600090600460405180948193630d0e30db60e41b83525af180156105d557612f875750565b80610ed06108699261176f565b61086993919250613087565b90915061086994929350612fb6565b5050505050565b6001600160a01b0391828116838516811461303f573003612fde5750610869939291166130ff565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000060208201526001600160a01b03918216602482015293166044840152606480840194909452928252610869926130396084846117c0565b166131d6565b505050505050565b3d15613082573d9067ffffffffffffffff82116117835760405191613076601f8201601f1916602001846117c0565b82523d6000602084013e565b606090565b6000928380808086865af161309a613047565b50156130a7575b50505050565b6001600160a01b0316803b156130fb5760405193630d0e30db60e41b85528460048186855af19384156105d5576130e3946130ec575b506130ff565b388080806130a1565b6130f59061176f565b386130dd565b8380fd5b916001600160a01b03604051927fa9059cbb000000000000000000000000000000000000000000000000000000006020850152166024830152604482015260448152608081019181831067ffffffffffffffff84111761178357610869926040526131d6565b1561316c57565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b031690604051906131ed826117a4565b6020928383527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656484840152803b15613264576000828192828761323f9796519301915af1613239613047565b906132a8565b8051908161324c57505050565b826108699361325f9383010191016117e2565b613165565b6064846040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b909190156132b4575090565b8151156132c45750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b82851061330a575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506132e7565b81810292918115918404141715610fa757565b929080613344575050101590565b8083119350909183613357575b50505090565b9080929350810390808211610fa757826127108084029384041491141715610fa757041015388080613351565b906133c96116676116636133c285516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b5460ff1690565b61340d61340083516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b805460ff19166001179055565b4267ffffffffffffffff1661016083015261345681612d8684516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b61347c82612e2d8151600052600080516020613b31833981519152602052604060002090565b61349860208201610d5284610d4c83516001600160a01b031690565b907f50ee19190cad04e39f76919237e06f8dbbd2b9d2b8b5dfd03934529ed5205e748351916134d160408601516001600160a01b031690565b612cde6060870151966134fb60a060406134e9611806565b9601519201516001600160a01b031690565b604080519788526001600160a01b0395861660208901528701919091528316606086015290821694909116929081906080820190565b90604081019081516001600160a01b03602085015116916001600160a01b0360a086015116916040517fd45573f6000000000000000000000000000000000000000000000000000000008152604081600481305afa9384156105d5576136bf956136b7610cc4946136b18b61365a9660209a6000918291613801575b5073716992d45bc60e9ead5f59206c0d049afbff429f88146137f9575b6135db61ffff6135e3921686613323565b612710900490565b978891600080946040888392606061361661360a61360a868501516001600160a01b031690565b6001600160a01b031690565b91015183518098819482937f2a55205a0000000000000000000000000000000000000000000000000000000084526004840160209093929193604081019481520152565b03915afa80839584926137c5575b50613771575b506136ac93508a7f000000000000000000000000000000000000000000000000000000000000000086819e95829661375d575b50505050308b612e8f565b612531565b9061187b565b913090612e8f565b907f50ee19190cad04e39f76919237e06f8dbbd2b9d2b8b5dfd03934529ed5205e746001600160a01b03845192612cde61370360408801516001600160a01b031690565b9160608801519761372860a0613717611806565b93519201516001600160a01b031690565b604080519889526001600160a01b0393841660208a015288019190915216606086015290821694909116929081906080820190565b613768933090612e8f565b8a8386386136a1565b915091926001600160a01b0381161515806137bc575b613796575b508291859161366e565b9094506136ac9291506137b4876137ad8688612531565b11156139f4565b90913861378c565b50811515613787565b9095506137ea915060403d6040116137f2575b6137e281836117c0565b8101906139d5565b909438613668565b503d6137d8565b5060006135ca565b9050613825915060403d60401161382b575b61381d81836117c0565b8101906139b0565b386135ad565b503d613813565b90916101808101600181516138468161074d565b61384f8161074d565b036138ff575061386f61360a61360a60408401516001600160a01b031690565b6080606083015192015193813b156102d357600080946138ee604051978896879586947ff242432a00000000000000000000000000000000000000000000000000000000865260048601929060c094926001600160a01b0380921685521660208401526040830152606082015260a06080820152600060a08201520190565b03925af180156105d557612f875750565b516139098161074d565b6139128161074d565b1561391c57505050565b606061393861360a61360a60408501516001600160a01b031690565b91015190803b156102d3576040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b03938416600482015293909216602484015260448301526080606483015260006084830181905290829060a490829084905af180156105d557612f875750565b91908260409103126102d357602082516139c9816110e0565b920151611948816110d4565b91908260409103126102d357602082516139ee816110e0565b92015190565b156139fb57565b606460405162461bcd60e51b815260206004820152601560248201527f66656573206578636565642074686520707269636500000000000000000000006044820152fd5b90613a498261253e565b613a5660405191826117c0565b8281528092613a67601f199161253e565b0190602036910137565b90613a7b8261253e565b604090613a8a825191826117c0565b8381528093613a9b601f199161253e565b019160005b838110613aad5750505050565b6020908251613abb81611788565b613ac361245e565b81528351613ad081611788565b600081528390600082820152600086820152818301528451613af1816117a4565b6000815260008282015285830152828601015201613aa0565b90604051613b17816117a4565b602060ff8294548181161515845260081c16151591015256fed526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e4a264697066735822122085a619bb1c43e558fe43d06713686f2ffd3c01d9537553d9880ffb19cc661d5a64736f6c6343000812003300000000000000000000000070499adebb11efd915e3b69e700c331778628707
Deployed ByteCode
0x6080604052600436101561001257600080fd5b60003560e01c806303a54fe0146101275780630858e5ad14610122578063119df25f1461011d5780631389b1171461011857806316002f4a1461011357806316654d401461010e5780632eb566bd146101095780636891939d1461010457806378bd7935146100ff5780637b063801146100fa5780638b49d47e146100f557806396b5a755146100f0578063a286b5a2146100eb578063c291537c146100e6578063cde0b4f9146100e1578063e2283ed8146100dc5763ebf05a62146100d757600080fd5b6115a1565b6111c9565b610fd6565b610ef6565b610d8c565b610be5565b610b9e565b610905565b61086b565b6106aa565b6105da565b61050f565b6104d2565b610451565b610425565b6102d8565b346102d35760203660031901126102d35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f61016b8282541415611ffd565b55600261019761019283600052600080516020613b31833981519152602052604060002090565b612093565b6102536101d56101d0856000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b612326565b6101a08301926101fb600385516101eb81610764565b6101f481610764565b1415612048565b61022761021461016083015167ffffffffffffffff1690565b67ffffffffffffffff4291161115612357565b61024e6001600160a01b0361024660208501516001600160a01b031690565b1615156123c8565b613384565b5161025d81610764565b61026681610764565b03610297575b61029560017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b005b60096102bd6102cd92600052600080516020613b31833981519152602052604060002090565b01805461ff001916610200179055565b3861026c565b600080fd5b60403660031901126102d35760043560243560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f61031a8282541415611ffd565b55600091808352600080516020613b31833981519152918260205260ff600960408620015460081c169260048410156104155761035c60016103cd9514612048565b82855260205261036e60408520612093565b9061039267ffffffffffffffff8061016085015116421090816103f9575b506121a4565b61039d8115156121ef565b6103c36103a8611806565b6103b0611a2d565b9485526001600160a01b03166020850152565b6040830152612b9e565b6103f660017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b80f35b6101408501514292501667ffffffffffffffff1611153861038c565b610737565b60009103126102d357565b346102d35760003660031901126102d3576020610440611806565b6001600160a01b0360405191168152f35b346102d35760203660031901126102d35760043580600052600080516020613b31833981519152908160205260ff60096040600020015460081c1660048110156104155760016104a19114612048565b6000526020526104ce60086040600020015460c01c60405191829142111582919091602081019215159052565b0390f35b346102d35760003660031901126102d35760207fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e354604051908152f35b346102d3576101403660031901126102d357610529611806565b6001600160a01b036040519163a32fa5b360e01b83527ff94103142c1baabe9ac2b5d1487bf783de9e69cfeea9a72f5c9c94afd7877b8c6004840152166024820152602081604481305afa80156105d55761058c916000916105a7575b506118f1565b6104ce610597611957565b6040519081529081906020820190565b6105c8915060203d81116105ce575b6105c081836117c0565b8101906117e2565b38610586565b503d6105b6565b6117fa565b346102d3576040806003193601126102d357600435906000828152600080516020613b31833981519152928360205260ff6009848420015460081c169360048510156104155783610699936106769261063860016104ce9914612048565b848252602052610649828220612093565b9381527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e560205220612326565b67ffffffffffffffff6101208560c0850151930151930151169160243591613336565b905190151581529081906020820190565b346102d35760203660031901126102d3576004356000818152600080516020613b31833981519152908160205260ff600960408320015460081c169060048210156104155761070192610638600160409414612048565b60208181015160a0939093015160409283015183516001600160a01b039586168152949091169184019190915290820152606090f35b634e487b7160e01b600052602160045260246000fd5b6002111561041557565b9060028210156104155752565b6004111561041557565b9060048210156104155752565b805182526020808201516001600160a01b03169083015261086991906040818101516001600160a01b03169083015260608101516060830152608081015160808301526107d860a082015160a08401906001600160a01b03169052565b60c081015160c083015260e081015160e0830152610808610100808301519084019067ffffffffffffffff169052565b6101208181015167ffffffffffffffff16908301526101408181015167ffffffffffffffff16908301526101608181015167ffffffffffffffff169083015261085a6101808083015190840190610757565b6101a08091015191019061076e565b565b346102d35760203660031901126102d35761088461245e565b50600435600052600080516020613b318339815191526020526101c06108ad6040600020612093565b6108ba604051809261077b565bf35b6020908160408183019282815285518094520193019160005b8281106108e3575050505090565b90919293826101c0826108f9600194895161077b565b019501939291016108d5565b346102d3576040806003193601126102d3576024356004358181111580610b74575b610930906124d8565b61094a610945610940838561187b565b612523565b612556565b91600091805b82811115610a795750505061096490612556565b906000815191815b838110610980578551806104ce87826108bc565b6109d290426109b56109a861014061099885886125a6565b51015167ffffffffffffffff1690565b67ffffffffffffffff1690565b111580610a5e575b80610a35575b80610a07575b6109d757612523565b61096c565b610a016109e482856125a6565b51946109ef816125d0565b956109fa828a6125a6565b52876125a6565b50612523565b506001600160a01b03610a2d88610a1e84876125a6565b5101516001600160a01b031690565b1615156109c9565b506001610a4f6101a0610a4884876125a6565b5101611bab565b610a5881610764565b146109c3565b5042610a736109a861016061099885886125a6565b116109bd565b610a83828261187b565b610aa761019283600052600080516020613b31833981519152602052604060002090565b610ab182886125a6565b52610abc81876125a6565b508642610ad26109a8610140610998868c6125a6565b11159182610b57575b82610b33575b82610b11575b5050610afc575b610af790612523565b610950565b92610b09610af791612523565b939050610aee565b6001600160a01b03925090610a1e610b2992896125a6565b1615158638610ae7565b91506001610b476101a0610a48858b6125a6565b610b5081610764565b1491610ae1565b915042610b6d6109a8610160610998868c6125a6565b1191610adb565b507fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3548210610927565b346102d35760003660031901126102d3576040610bb9611888565b919082825193849260208452816020850152848401376000828201840152601f01601f19168101030190f35b346102d35760203660031901126102d357600435600090808252600080516020613b318339815191528060205260ff600960408520015460081c166004811015610415576001610c359114612048565b8183526020526001600160a01b03610c608160016040862001541682610c59611806565b1614612260565b610c8461019283600052600080516020613b31833981519152602052604060002090565b91610cd982610cd26020610cc46101d0866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b01516001600160a01b031690565b1615612413565b610d0f6009610cff83600052600080516020613b31833981519152602052604060002090565b01805461ff001916610300179055565b7fb78a7099174b11eaf203c16216e524a48f8806eb956090d87d838ada4ebe68d3610d5f60208501610d5286610d4c83516001600160a01b031690565b30613832565b516001600160a01b031690565b926060610d7660408701516001600160a01b031690565b950151604051938452948116931691602090a480f35b346102d35760203660031901126102d35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f610dd08282541415611ffd565b55600090808252600080516020613b31833981519152602052610e076001600160a01b038060016040862001541690610c59611806565b303b15610ef2576040517febf05a6200000000000000000000000000000000000000000000000000000000815260048101829052828160248183305af180156105d557610edf575b5081303b15610edc576040517f03a54fe000000000000000000000000000000000000000000000000000000000815260048101929092528160248183305af180156105d557610ec3575b506103f660017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b80610ed0610ed69261176f565b8061041a565b38610e99565b80fd5b80610ed0610eec9261176f565b38610e4f565b5080fd5b346102d3576040806003193601126102d357600435602435918282111580610fac575b610f22906124d8565b818303838111610fa757600190818101809111610fa757610f4290612556565b92805b85811115610f5a578351806104ce87826108bc565b610f9a846000838152600080516020613b3183398151915260205220610f89610f83858561187b565b91612093565b610f9382896125a6565b52866125a6565b5082810180911115610f45575b611865565b507fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3548310610f19565b346102d35760203660031901126102d35760043580600052600080516020613b31833981519152908160205260ff60096040600020015460081c1660048110156104155760016110269114612048565b6000526020526104ce61103c6040600020612093565b6101408101514267ffffffffffffffff909116111590816110b1575b8161108e575b81611077575b5060405190151581529081906020820190565b604001516001600160a01b03161515905038611064565b905060016101a08201516110a181610764565b6110aa81610764565b149061105e565b9050426110cd6109a861016084015167ffffffffffffffff1690565b1190611058565b61ffff8116036102d357565b6001600160a01b038116036102d357565b60043590610869826110e0565b60643590610869826110e0565b60c4359063ffffffff821682036102d357565b60e4359063ffffffff821682036102d357565b9093929160608201606083528551809152608083019060208097019060005b8882821061116657505050509482015260400152565b61026084958260019495965161117d83825161077b565b8082015180516101c0850152808301516001600160a01b03166101e085015260409081015161020085015201518051151561022084015201511515610240820152019401929101611150565b346102d3576101003660031901126102d3576024356111e7816110d4565b604435906111f4826110e0565b606435611200816110e0565b6084359160a43591611211836110e0565b61121961110b565b9461122261111e565b95600435909487947fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3549761125d63ffffffff809b16613a3f565b956000946080841615968715915b8c811080611596575b8061158b575b1561146257806112a68f9261019290600052600080516020613b31833981519152602052604060002090565b8a85611449575b6112c2575b506001019b60001901169a61126b565b604080891615908115611430575b50156112b25760208816158015611423575b156112b257600190818916158015611403575b611300575b506112b2565b6002808a16159081156113e2575b50156112fa5760048916159081156113bf575b5061132d575b806112fa565b60108816158015611366575b15611327578280918b849f9c948f611356908560019816906125a6565b5201169960001901169b90611327565b506113ac8161139e846000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b01546001600160a01b031690565b6001600160a01b03808b16911614611339565b600391506101a001516113d181610764565b6113da81610764565b141538611321565b90506101a08201516113f381610764565b6113fc81610764565b143861130e565b50816101a082015161141481610764565b61141d81610764565b146112f5565b50866060820151146112e2565b8201516001600160a01b038881169116149050386112d0565b5060208101516001600160a01b038581169116146112ad565b8d88818f938d9460009082106000146115835750915b1661148281613a71565b9360005b8481168381101561157357859161156b826114a3600194876125a6565b516115556114c882600052600080516020613b31833981519152602052604060002090565b9161154b611532611502836000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b926000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b9161154461153e611a2d565b95612093565b8552612326565b6020840152613b0a565b6040820152611564828c6125a6565b52896125a6565b500116611486565b604051806104ce42888b84611131565b905091611478565b508d8b16151561127a565b508d8c161515611274565b346102d35760203660031901126102d35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f6115e58282541415611ffd565b5580600052600080516020613b3183398151915260205260026001600160a01b0361161d816001604060002001541682610c59611806565b61166c611667611663611659866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b5460081c60ff1690565b1590565b6122b5565b6116b16116a2846000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b805461ff001916610100179055565b6102536116d861019285600052600080516020613b31833981519152602052604060002090565b61170e6101d0866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b906117546101a0820194611728600387516101eb81610764565b61174161021461016085015167ffffffffffffffff1690565b60208401516001600160a01b0316610246565b613531565b634e487b7160e01b600052604160045260246000fd5b67ffffffffffffffff811161178357604052565b611759565b6060810190811067ffffffffffffffff82111761178357604052565b6040810190811067ffffffffffffffff82111761178357604052565b90601f8019910116810190811067ffffffffffffffff82111761178357604052565b908160209103126102d3575180151581036102d35790565b6040513d6000823e3d90fd5b60405163572b6c0560e01b8152336004820152602081602481305afa9081156105d557600091611847575b50156118435736601319013560601c90565b3390565b61185f915060203d81116105ce576105c081836117c0565b38611831565b634e487b7160e01b600052601160045260246000fd5b91908203918211610fa757565b60405163572b6c0560e01b8152336004820152602081602481305afa9081156105d5576000916118d3575b50156118cc57601319360190368211610fa75760009190565b6000903690565b6118eb915060203d81116105ce576105c081836117c0565b386118b3565b156118f857565b606460405162461bcd60e51b815260206004820152600c60248201527f214c49535445525f524f4c4500000000000000000000000000000000000000006044820152fd5b600435611948816110e0565b90565b606435611948816110e0565b600435611963816110e0565b6001600160a01b036040519163a32fa5b360e01b83527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae66004840152166024820152602081604481305afa9081156105d557600091611a0f575b50156119cb57611948611e61565b606460405162461bcd60e51b815260206004820152600b60248201527f2141535345545f524f4c450000000000000000000000000000000000000000006044820152fd5b611a27915060203d81116105ce576105c081836117c0565b386119bd565b6040519061086982611788565b60405190610140820182811067ffffffffffffffff82111761178357604052565b604051906101c0820182811067ffffffffffffffff82111761178357604052565b67ffffffffffffffff8116036102d357565b60c4359061086982611a7c565b60e4359061086982611a7c565b610104359061086982611a7c565b610124359061086982611a7c565b6101409060031901126102d357611ad9611a3a565b90611ae26110f1565b825260243560208301526044356040830152611afc6110fe565b6060830152608435608083015260a43560a0830152611b19611a8e565b60c0830152611b26611a9b565b60e0830152611b33611aa8565b610100830152611b41611ab6565b610120830152565b60c43561194881611a7c565b60e43561194881611a7c565b6101043561194881611a7c565b6101243561194881611a7c565b60028210156104155752565b60048210156104155752565b9060028110156104155760ff80198354169116179055565b5160048110156104155790565b9060048110156104155761ff0082549160081b169061ff001916179055565b906101a060096108699383518155611c28611bfc60208601516001600160a01b031690565b60018301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b611c6b611c3f60408601516001600160a01b031690565b60028301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b6060840151600382015560808401516004820155611cc2611c9660a08601516001600160a01b031690565b60058301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60c0840151600682015560e08401516007820155611e1f60088201611d14611cf661010088015167ffffffffffffffff1690565b825467ffffffffffffffff191667ffffffffffffffff909116178255565b611d6e611d2d61012088015167ffffffffffffffff1690565b82547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff1660409190911b6fffffffffffffffff000000000000000016178255565b611dd0611d8761014088015167ffffffffffffffff1690565b82547fffffffffffffffff0000000000000000ffffffffffffffffffffffffffffffff1660809190911b77ffffffffffffffff0000000000000000000000000000000016178255565b610160860151815477ffffffffffffffffffffffffffffffffffffffffffffffff1660c09190911b7fffffffffffffffff00000000000000000000000000000000000000000000000016179055565b0191611e39610180820151611e338161074d565b84611b93565b015190611e4582610764565b611bb8565b9081526101e081019291610869916020019061077b565b611e696125df565b90611e72611806565b611e7a61193c565b611e8390612613565b9081611e8e36611ac4565b90611e98916129d8565b611ea061193c565b60243592611eac61194b565b611eb4611b49565b611ebc611b55565b611ec4611b61565b91611ecd611b6e565b93611ed6611a5b565b8b81526001600160a01b0389166020820152966001600160a01b031660408801526060870189905260443560808801526001600160a01b031660a087015260843560c087015260a43560e087015267ffffffffffffffff1661010086015267ffffffffffffffff1661012085015267ffffffffffffffff1661014084015267ffffffffffffffff16610160830152611f72906101808301611b7b565b60016101a082015280611f9c86600052600080516020613b31833981519152602052604060002090565b90611fa691611bd7565b611fb1813084613832565b611fb961193c565b60405180916001600160a01b03809116941692611fd7908883611e4a565b037f90f6626183053b3cdf2d1bd5ecc58502e96e1d805a0cfe5cd0b01eabb5005d0291a4565b1561200457565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b1561204f57565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a20696e76616c69642061756374696f6e2e0000006044820152fd5b9061086960ff60096120a3611a5b565b94805486526120cf6120bf60018301546001600160a01b031690565b6001600160a01b03166020880152565b6120f66120e660028301546001600160a01b031690565b6001600160a01b03166040880152565b600381015460608701526004810154608087015261213161212160058301546001600160a01b031690565b6001600160a01b031660a0880152565b600681015460c0870152600781015460e0870152600881015467ffffffffffffffff808216610100890152604082901c8116610120890152608082901c166101408801526121849060c01c610160880152565b01546121968282166101808701611b7b565b60081c166101a08401611b87565b156121ab57565b606460405162461bcd60e51b815260206004820152601e60248201527f4d61726b6574706c6163653a20696e6163746976652061756374696f6e2e00006044820152fd5b156121f657565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a2042696464696e672077697468207a65726f206160448201527f6d6f756e742e00000000000000000000000000000000000000000000000000006064820152fd5b1561226757565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a206e6f742061756374696f6e2063726561746f726044820152601760f91b6064820152fd5b156122bc57565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a207061796f757420616c726561647920636f6d7060448201527f6c657465642e00000000000000000000000000000000000000000000000000006064820152fd5b9060405161233381611788565b604060028294805484526001600160a01b0360018201541660208501520154910152565b1561235e57565b608460405162461bcd60e51b815260206004820152602260248201527f4d61726b6574706c6163653a2061756374696f6e207374696c6c20616374697660448201527f652e0000000000000000000000000000000000000000000000000000000000006064820152fd5b156123cf57565b606460405162461bcd60e51b815260206004820152601f60248201527f4d61726b6574706c6163653a206e6f20626964732077657265206d6164652e006044820152fd5b1561241a57565b606460405162461bcd60e51b815260206004820152601f60248201527f4d61726b6574706c6163653a206269647320616c7265616479206d6164652e006044820152fd5b604051906101c0820182811067ffffffffffffffff82111761178357604052816101a06000918281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e082015282610100820152826101208201528261014082015282610160820152826101808201520152565b156124df57565b606460405162461bcd60e51b815260206004820152600d60248201527f696e76616c69642072616e6765000000000000000000000000000000000000006044820152fd5b9060018201809211610fa757565b91908201809211610fa757565b67ffffffffffffffff81116117835760051b60200190565b906125608261253e565b61256d60405191826117c0565b828152809261257e601f199161253e565b019060005b82811061258f57505050565b60209061259a61245e565b82828501015201612583565b80518210156125ba5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b6000198114610fa75760010190565b7fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3908154916001830190818411610fa75755565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082527fd9b67a260000000000000000000000000000000000000000000000000000000060048301526020926001600160a01b0316918381602481865afa9081156105d55760009161276d575b501561269257505050600190565b6040519081527f80ac58cd000000000000000000000000000000000000000000000000000000006004820152908290829060249082905afa9182156105d557600092612750575b5050156126e557600090565b60405162461bcd60e51b815260206004820152603760248201527f4d61726b6574706c6163653a2061756374696f6e656420746f6b656e206d757360448201527f742062652045524331313535206f72204552433732312e0000000000000000006064820152608490fd5b6127669250803d106105ce576105c081836117c0565b38806126d9565b6127849150843d86116105ce576105c081836117c0565b38612684565b1561279157565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a2061756374696f6e696e67207a65726f2071756160448201527f6e746974792e00000000000000000000000000000000000000000000000000006064820152fd5b1561280257565b608460405162461bcd60e51b815260206004820152602960248201527f4d61726b6574706c6163653a2061756374696f6e696e6720696e76616c69642060448201527f7175616e746974792e00000000000000000000000000000000000000000000006064820152fd5b1561287357565b606460405162461bcd60e51b815260206004820152601c60248201527f4d61726b6574706c6163653a206e6f2074696d652d6275666665722e000000006044820152fd5b156128be57565b606460405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574706c6163653a206e6f206269642d6275666665722e00000000006044820152fd5b90610e1067ffffffffffffffff80931601918211610fa757565b91909167ffffffffffffffff80809416911601918211610fa757565b1561293f57565b606460405162461bcd60e51b815260206004820152602060248201527f4d61726b6574706c6163653a20696e76616c69642074696d657374616d70732e6044820152fd5b1561298a57565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a20696e76616c69642062696420616d6f756e74736044820152601760f91b6064820152fd5b612a01610869926001604084016129f18151151561278a565b5114908115612ad2575b506127fb565b612a8467ffffffffffffffff612a2e81612a2660c086015167ffffffffffffffff1690565b16151561286c565b612a50612a496109a860e086015167ffffffffffffffff1690565b15156128b7565b610100830190612a70612a6b835167ffffffffffffffff1690565b612902565b8142911610159182612aa9575b5050612938565b60a08101518015918215612a9a575b5050612983565b60800151111590503880612a93565b5161012085015167ffffffffffffffff9182169350612ac891166109a8565b9116103880612a7d565b60019150612adf8161074d565b14386129fb565b15612aed57565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a206e6f742077696e6e696e67206269642e0000006044820152fd5b90604060029180518455612b786001600160a01b0360208301511660018601906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b0151910155565b604090610869939594929561020082019682526020820152019061077b565b90612bd66101d083516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b917f6b33f3b169c84eaaec29320da85952def04ba83c79cf51af8a9811c446ceeecc612caa604085015193610d5260408201968751907f00000000000000000000000070499adebb11efd915e3b69e700c3317786287079160e0880190888a83518015159081612e39575b5015612d13575050506020612c5c915192610cc4878b613384565b826001600160a01b03998a8316151580612d0a575b612ce3575b5050506020612c8f60a08901516001600160a01b031690565b940193612ca385516001600160a01b031690565b3091612e8f565b92825192612cde612cc560408301516001600160a01b031690565b9160608101519751846040519586951698169684612b7f565b0390a4565b612d0292612cfb60a08c01516001600160a01b031690565b3090612e8f565b388281612c76565b50801515612c71565b612c5c9350612d498284612d4e93612d436109a861012060c060209a9c99015195015167ffffffffffffffff1690565b92613336565b612ae6565b612d8b87612d868c516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b612b31565b6101608a01805167ffffffffffffffff16908b612dca610100612dba67ffffffffffffffff958642911661187b565b92015167ffffffffffffffff1690565b9283161015612ddb575b5050610cc4565b612df9612e0792612df4835167ffffffffffffffff1690565b61291c565b67ffffffffffffffff169052565b612e328a612e2d8151600052600080516020613b31833981519152602052604060002090565b611bd7565b3880612dd4565b905083101538612c41565b15612e4b57565b606460405162461bcd60e51b815260206004820152601360248201527f6d73672e76616c756520213d20616d6f756e74000000000000000000000000006044820152fd5b90939291938215612faf576001600160a01b039180831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee03612fa0575081163003612f3f57821692833b156102d357600060405180957f2e1a7d4d000000000000000000000000000000000000000000000000000000008252818381612f1288600483019190602083019252565b03925af19384156105d55761086994612f2c575b50613087565b80610ed0612f399261176f565b38612f26565b9190923083821614600014612f945750612f5a348414612e44565b16803b156102d357600090600460405180948193630d0e30db60e41b83525af180156105d557612f875750565b80610ed06108699261176f565b61086993919250613087565b90915061086994929350612fb6565b5050505050565b6001600160a01b0391828116838516811461303f573003612fde5750610869939291166130ff565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000060208201526001600160a01b03918216602482015293166044840152606480840194909452928252610869926130396084846117c0565b166131d6565b505050505050565b3d15613082573d9067ffffffffffffffff82116117835760405191613076601f8201601f1916602001846117c0565b82523d6000602084013e565b606090565b6000928380808086865af161309a613047565b50156130a7575b50505050565b6001600160a01b0316803b156130fb5760405193630d0e30db60e41b85528460048186855af19384156105d5576130e3946130ec575b506130ff565b388080806130a1565b6130f59061176f565b386130dd565b8380fd5b916001600160a01b03604051927fa9059cbb000000000000000000000000000000000000000000000000000000006020850152166024830152604482015260448152608081019181831067ffffffffffffffff84111761178357610869926040526131d6565b1561316c57565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b031690604051906131ed826117a4565b6020928383527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656484840152803b15613264576000828192828761323f9796519301915af1613239613047565b906132a8565b8051908161324c57505050565b826108699361325f9383010191016117e2565b613165565b6064846040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b909190156132b4575090565b8151156132c45750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b82851061330a575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506132e7565b81810292918115918404141715610fa757565b929080613344575050101590565b8083119350909183613357575b50505090565b9080929350810390808211610fa757826127108084029384041491141715610fa757041015388080613351565b906133c96116676116636133c285516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b5460ff1690565b61340d61340083516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b805460ff19166001179055565b4267ffffffffffffffff1661016083015261345681612d8684516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b61347c82612e2d8151600052600080516020613b31833981519152602052604060002090565b61349860208201610d5284610d4c83516001600160a01b031690565b907f50ee19190cad04e39f76919237e06f8dbbd2b9d2b8b5dfd03934529ed5205e748351916134d160408601516001600160a01b031690565b612cde6060870151966134fb60a060406134e9611806565b9601519201516001600160a01b031690565b604080519788526001600160a01b0395861660208901528701919091528316606086015290821694909116929081906080820190565b90604081019081516001600160a01b03602085015116916001600160a01b0360a086015116916040517fd45573f6000000000000000000000000000000000000000000000000000000008152604081600481305afa9384156105d5576136bf956136b7610cc4946136b18b61365a9660209a6000918291613801575b5073716992d45bc60e9ead5f59206c0d049afbff429f88146137f9575b6135db61ffff6135e3921686613323565b612710900490565b978891600080946040888392606061361661360a61360a868501516001600160a01b031690565b6001600160a01b031690565b91015183518098819482937f2a55205a0000000000000000000000000000000000000000000000000000000084526004840160209093929193604081019481520152565b03915afa80839584926137c5575b50613771575b506136ac93508a7f00000000000000000000000070499adebb11efd915e3b69e700c33177862870786819e95829661375d575b50505050308b612e8f565b612531565b9061187b565b913090612e8f565b907f50ee19190cad04e39f76919237e06f8dbbd2b9d2b8b5dfd03934529ed5205e746001600160a01b03845192612cde61370360408801516001600160a01b031690565b9160608801519761372860a0613717611806565b93519201516001600160a01b031690565b604080519889526001600160a01b0393841660208a015288019190915216606086015290821694909116929081906080820190565b613768933090612e8f565b8a8386386136a1565b915091926001600160a01b0381161515806137bc575b613796575b508291859161366e565b9094506136ac9291506137b4876137ad8688612531565b11156139f4565b90913861378c565b50811515613787565b9095506137ea915060403d6040116137f2575b6137e281836117c0565b8101906139d5565b909438613668565b503d6137d8565b5060006135ca565b9050613825915060403d60401161382b575b61381d81836117c0565b8101906139b0565b386135ad565b503d613813565b90916101808101600181516138468161074d565b61384f8161074d565b036138ff575061386f61360a61360a60408401516001600160a01b031690565b6080606083015192015193813b156102d357600080946138ee604051978896879586947ff242432a00000000000000000000000000000000000000000000000000000000865260048601929060c094926001600160a01b0380921685521660208401526040830152606082015260a06080820152600060a08201520190565b03925af180156105d557612f875750565b516139098161074d565b6139128161074d565b1561391c57505050565b606061393861360a61360a60408501516001600160a01b031690565b91015190803b156102d3576040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b03938416600482015293909216602484015260448301526080606483015260006084830181905290829060a490829084905af180156105d557612f875750565b91908260409103126102d357602082516139c9816110e0565b920151611948816110d4565b91908260409103126102d357602082516139ee816110e0565b92015190565b156139fb57565b606460405162461bcd60e51b815260206004820152601560248201527f66656573206578636565642074686520707269636500000000000000000000006044820152fd5b90613a498261253e565b613a5660405191826117c0565b8281528092613a67601f199161253e565b0190602036910137565b90613a7b8261253e565b604090613a8a825191826117c0565b8381528093613a9b601f199161253e565b019160005b838110613aad5750505050565b6020908251613abb81611788565b613ac361245e565b81528351613ad081611788565b600081528390600082820152600086820152818301528451613af1816117a4565b6000815260008282015285830152828601015201613aa0565b90604051613b17816117a4565b602060ff8294548181161515845260081c16151591015256fed526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e4a264697066735822122085a619bb1c43e558fe43d06713686f2ffd3c01d9537553d9880ffb19cc661d5a64736f6c63430008120033