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-07-25T04:20:20.261159Z
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;
}
}
/// @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
);
}
uint8 constant FILTER_CREATOR = 0x80;
uint8 constant FILTER_ASSET_CONTRACT = 0x40;
uint8 constant FILTER_TOKEN_ID = 0x20;
uint8 constant FILTER_ONLY_CREATED = 0x04;
uint8 constant FILTER_ONLY_COMPLETED = 0x02;
uint8 constant FILTER_ONLY_VALID = 0x01;
struct AuctionAndWinningBid {
Auction auction;
Bid winningBod;
}
function selectAuctions(
uint256 _startId,
uint8 _filterFlags,
address _filterCreator,
address _filterAssetContract,
uint256 _filterTokenId,
uint32 _maxScannedItems,
uint32 _maxOutputItems)
external
view
returns (AuctionAndWinningBid[] memory _auctions, uint256 _nextStartId)
{
EnglishAuctionsStorage.Data storage data = EnglishAuctionsStorage.englishAuctionsStorage();
uint256 totalItems = data.totalAuctions;
uint256[] memory matchedItems = new uint256[](_maxOutputItems);
uint32 matchedItemsCount = 0;
while (_startId < totalItems && _maxScannedItems > 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_VALID) == 0 || _validateExistingAuction(item)) {
matchedItems[matchedItemsCount] = _startId;
unchecked { matchedItemsCount += 1; }
}
}
}
}
}
}
unchecked { ++_startId; --_maxScannedItems; }
}
_nextStartId = _startId < totalItems ? _startId : 0;
_auctions = new AuctionAndWinningBid[](matchedItemsCount);
for (uint32 i = 0; i < matchedItemsCount; ) {
_auctions[i] = AuctionAndWinningBid(data.auctions[matchedItems[i]], data.winningBid[matchedItems[i]]);
unchecked { ++i; }
}
}
function _validateExistingAuction(Auction memory _targetAuction) internal view returns (bool isValid) {
isValid =
_targetAuction.startTimestamp <= block.timestamp &&
_targetAuction.endTimestamp > block.timestamp &&
_targetAuction.status == IEnglishAuctions.Status.CREATED &&
_targetAuction.assetContract != address(0)
/*_validateOwnershipAndApproval(
_targetAuction.auctionCreator,
_targetAuction.assetContract,
_targetAuction.tokenId,
_targetAuction.quantity,
_targetAuction.tokenType
)*/
;
}
}
@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/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);
}
@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 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 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 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":"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.AuctionAndWinningBid[]","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":"uint256","name":"_nextStartId","internalType":"uint256"}],"name":"selectAuctions","inputs":[{"type":"uint256","name":"_startId","internalType":"uint256"},{"type":"uint8","name":"_filterFlags","internalType":"uint8"},{"type":"address","name":"_filterCreator","internalType":"address"},{"type":"address","name":"_filterAssetContract","internalType":"address"},{"type":"uint256","name":"_filterTokenId","internalType":"uint256"},{"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":"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
0x60a0346200007757601f620038f938819003918201601f19168301916001600160401b038311848410176200007c578084926020946040528339810103126200007757516001600160a01b0381168103620000775760805260405161386690816200009382396080518181816125f101526130600152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604052600436101561001257600080fd5b60003560e01c806303a54fe0146101075780630858e5ad14610102578063119df25f146100fd5780631389b117146100f857806316002f4a146100f357806316654d40146100ee578063233c23c9146100e95780632eb566bd146100e45780636891939d146100df57806378bd7935146100da5780637b063801146100d55780638b49d47e146100d057806396b5a755146100cb578063c291537c146100c65763ebf05a62146100c157600080fd5b610f77565b610e97565b610cf0565b610ca9565b610a10565b610976565b6108e9565b610819565b6107a8565b6104ef565b6104b2565b610431565b610405565b6102b8565b346102b35760203660031901126102b35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f61014b82825414156119e0565b55600261017761017283600052600080516020613811833981519152602052604060002090565b611a76565b6102336101b56101b0856000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b611d09565b6101a08301926101db600385516101cb81610627565b6101d481610627565b1415611a2b565b6102076101f461016083015167ffffffffffffffff1690565b67ffffffffffffffff4291161115611d3a565b61022e6001600160a01b0361022660208501516001600160a01b031690565b161515611dab565b612d6d565b5161023d81610627565b61024681610627565b03610277575b61027560017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b005b600961029d6102ad92600052600080516020613811833981519152602052604060002090565b01805461ff001916610200179055565b3861024c565b600080fd5b60403660031901126102b35760043560243560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f6102fa82825414156119e0565b55600091808352600080516020613811833981519152918260205260ff600960408620015460081c169260048410156103f55761033c60016103ad9514611a2b565b82855260205261034e60408520611a76565b9061037267ffffffffffffffff8061016085015116421090816103d9575b50611b87565b61037d811515611bd2565b6103a36103886111dc565b610390611403565b9485526001600160a01b03166020850152565b6040830152612581565b6103d660017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b80f35b6101408501514292501667ffffffffffffffff1611153861036c565b6105fa565b60009103126102b357565b346102b35760003660031901126102b35760206104206111dc565b6001600160a01b0360405191168152f35b346102b35760203660031901126102b35760043580600052600080516020613811833981519152908160205260ff60096040600020015460081c1660048110156103f55760016104819114611a2b565b6000526020526104ae60086040600020015460c01c60405191829142111582919091602081019215159052565b0390f35b346102b35760003660031901126102b35760207fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e354604051908152f35b346102b3576101403660031901126102b3576105096111dc565b6001600160a01b036040519163a32fa5b360e01b83527ff94103142c1baabe9ac2b5d1487bf783de9e69cfeea9a72f5c9c94afd7877b8c6004840152166024820152602081604481305afa80156105b55761056c91600091610587575b506112c7565b6104ae61057761132d565b6040519081529081906020820190565b6105a8915060203d81116105ae575b6105a08183611196565b8101906111b8565b38610566565b503d610596565b6111d0565b6001600160a01b038116036102b357565b600435906105d8826105ba565b565b606435906105d8826105ba565b60c4359063ffffffff821682036102b357565b634e487b7160e01b600052602160045260246000fd5b600211156103f557565b9060028210156103f55752565b600411156103f557565b9060048210156103f55752565b805182526020808201516001600160a01b0316908301526105d891906040818101516001600160a01b031690830152606081015160608301526080810151608083015261069b60a082015160a08401906001600160a01b03169052565b60c081015160c083015260e081015160e08301526106cb610100808301519084019067ffffffffffffffff169052565b6101208181015167ffffffffffffffff16908301526101408181015167ffffffffffffffff16908301526101608181015167ffffffffffffffff169083015261071d610180808301519084019061061a565b6101a080910151910190610631565b929190604080850190808652825180925260608601916020809401916000905b8583831061075e575050505050930152565b610220859683836001959697985161077784825161063e565b015180516101c0840152848101516001600160a01b03166101e084015201516102008201520195019392019061074c565b346102b35760e03660031901126102b35760243560ff811681036102b3576044356107d2816105ba565b606435916107df836105ba565b60a4359063ffffffff821682036102b357610809936107fc6105e7565b93608435926004356134f0565b906104ae6040519283928361072c565b346102b3576040806003193601126102b357600435906000828152600080516020613811833981519152928360205260ff6009848420015460081c169360048510156103f557836108d8936108b59261087760016104ae9914611a2b565b848252602052610888828220611a76565b9381527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e560205220611d09565b67ffffffffffffffff6101208560c0850151930151930151169160243591612d1f565b905190151581529081906020820190565b346102b35760203660031901126102b3576004356000818152600080516020613811833981519152908160205260ff600960408320015460081c169060048210156103f55761094092610877600160409414611a2b565b60208181015160a0939093015160409283015183516001600160a01b039586168152949091169184019190915290820152606090f35b346102b35760203660031901126102b35761098f611e41565b506004356000526000805160206138118339815191526020526101c06109b86040600020611a76565b6109c5604051809261063e565bf35b6020908160408183019282815285518094520193019160005b8281106109ee575050505090565b90919293826101c082610a04600194895161063e565b019501939291016109e0565b346102b3576040806003193601126102b3576024356004358181111580610c7f575b610a3b90611ebb565b610a55610a50610a4b8385611251565b611f06565b611f39565b91600091805b82811115610b8457505050610a6f90611f39565b906000815191815b838110610a8b578551806104ae87826109c7565b610add9042610ac0610ab3610140610aa38588611f89565b51015167ffffffffffffffff1690565b67ffffffffffffffff1690565b111580610b69575b80610b40575b80610b12575b610ae257611f06565b610a77565b610b0c610aef8285611f89565b5194610afa81611fb3565b95610b05828a611f89565b5287611f89565b50611f06565b506001600160a01b03610b3888610b298487611f89565b5101516001600160a01b031690565b161515610ad4565b506001610b5a6101a0610b538487611f89565b510161158e565b610b6381610627565b14610ace565b5042610b7e610ab3610160610aa38588611f89565b11610ac8565b610b8e8282611251565b610bb261017283600052600080516020613811833981519152602052604060002090565b610bbc8288611f89565b52610bc78187611f89565b508642610bdd610ab3610140610aa3868c611f89565b11159182610c62575b82610c3e575b82610c1c575b5050610c07575b610c0290611f06565b610a5b565b92610c14610c0291611f06565b939050610bf9565b6001600160a01b03925090610b29610c349289611f89565b1615158638610bf2565b91506001610c526101a0610b53858b611f89565b610c5b81610627565b1491610bec565b915042610c78610ab3610160610aa3868c611f89565b1191610be6565b507fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3548210610a32565b346102b35760003660031901126102b3576040610cc461125e565b919082825193849260208452816020850152848401376000828201840152601f01601f19168101030190f35b346102b35760203660031901126102b3576004356000908082526000805160206138118339815191528060205260ff600960408520015460081c1660048110156103f5576001610d409114611a2b565b8183526020526001600160a01b03610d6b8160016040862001541682610d646111dc565b1614611c43565b610d8f61017283600052600080516020613811833981519152602052604060002090565b91610de482610ddd6020610dcf6101b0866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b01516001600160a01b031690565b1615611df6565b610e1a6009610e0a83600052600080516020613811833981519152602052604060002090565b01805461ff001916610300179055565b7fb78a7099174b11eaf203c16216e524a48f8806eb956090d87d838ada4ebe68d3610e6a60208501610e5d86610e5783516001600160a01b031690565b3061321b565b516001600160a01b031690565b926060610e8160408701516001600160a01b031690565b950151604051938452948116931691602090a480f35b346102b3576040806003193601126102b357600435602435918282111580610f4d575b610ec390611ebb565b818303838111610f4857600190818101809111610f4857610ee390611f39565b92805b85811115610efb578351806104ae87826109c7565b610f3b84600083815260008051602061381183398151915260205220610f2a610f248585611251565b91611a76565b610f348289611f89565b5286611f89565b5082810180911115610ee6575b61123b565b507fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3548310610eba565b346102b35760203660031901126102b35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f610fbb82825414156119e0565b558060005260008051602061381183398151915260205260026001600160a01b03610ff3816001604060002001541682610d646111dc565b61104261103d61103961102f866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b5460081c60ff1690565b1590565b611c98565b611087611078846000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b805461ff001916610100179055565b6102336110ae61017285600052600080516020613811833981519152602052604060002090565b6110e46101b0866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b9061112a6101a08201946110fe600387516101cb81610627565b6111176101f461016085015167ffffffffffffffff1690565b60208401516001600160a01b0316610226565b612f1a565b634e487b7160e01b600052604160045260246000fd5b6060810190811067ffffffffffffffff82111761116157604052565b61112f565b67ffffffffffffffff811161116157604052565b6040810190811067ffffffffffffffff82111761116157604052565b90601f8019910116810190811067ffffffffffffffff82111761116157604052565b908160209103126102b3575180151581036102b35790565b6040513d6000823e3d90fd5b60405163572b6c0560e01b8152336004820152602081602481305afa9081156105b55760009161121d575b50156112195736601319013560601c90565b3390565b611235915060203d81116105ae576105a08183611196565b38611207565b634e487b7160e01b600052601160045260246000fd5b91908203918211610f4857565b60405163572b6c0560e01b8152336004820152602081602481305afa9081156105b5576000916112a9575b50156112a257601319360190368211610f485760009190565b6000903690565b6112c1915060203d81116105ae576105a08183611196565b38611289565b156112ce57565b606460405162461bcd60e51b815260206004820152600c60248201527f214c49535445525f524f4c4500000000000000000000000000000000000000006044820152fd5b60043561131e816105ba565b90565b60643561131e816105ba565b600435611339816105ba565b6001600160a01b036040519163a32fa5b360e01b83527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae66004840152166024820152602081604481305afa9081156105b5576000916113e5575b50156113a15761131e611844565b606460405162461bcd60e51b815260206004820152600b60248201527f2141535345545f524f4c450000000000000000000000000000000000000000006044820152fd5b6113fd915060203d81116105ae576105a08183611196565b38611393565b604051906105d882611145565b60405190610140820182811067ffffffffffffffff82111761116157604052565b604051906101c0820182811067ffffffffffffffff82111761116157604052565b604051906105d88261117a565b67ffffffffffffffff8116036102b357565b60c435906105d88261145f565b60e435906105d88261145f565b61010435906105d88261145f565b61012435906105d88261145f565b6101409060031901126102b3576114bc611410565b906114c56105cb565b8252602435602083015260443560408301526114df6105da565b6060830152608435608083015260a43560a08301526114fc611471565b60c083015261150961147e565b60e083015261151661148b565b610100830152611524611499565b610120830152565b60c43561131e8161145f565b60e43561131e8161145f565b6101043561131e8161145f565b6101243561131e8161145f565b60028210156103f55752565b60048210156103f55752565b9060028110156103f55760ff80198354169116179055565b5160048110156103f55790565b9060048110156103f55761ff0082549160081b169061ff001916179055565b906101a060096105d8938351815561160b6115df60208601516001600160a01b031690565b60018301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b61164e61162260408601516001600160a01b031690565b60028301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60608401516003820155608084015160048201556116a561167960a08601516001600160a01b031690565b60058301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60c0840151600682015560e08401516007820155611802600882016116f76116d961010088015167ffffffffffffffff1690565b825467ffffffffffffffff191667ffffffffffffffff909116178255565b61175161171061012088015167ffffffffffffffff1690565b82547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff1660409190911b6fffffffffffffffff000000000000000016178255565b6117b361176a61014088015167ffffffffffffffff1690565b82547fffffffffffffffff0000000000000000ffffffffffffffffffffffffffffffff1660809190911b77ffffffffffffffff0000000000000000000000000000000016178255565b610160860151815477ffffffffffffffffffffffffffffffffffffffffffffffff1660c09190911b7fffffffffffffffff00000000000000000000000000000000000000000000000016179055565b019161181c61018082015161181681610610565b84611576565b01519061182882610627565b61159b565b9081526101e0810192916105d8916020019061063e565b61184c611fc2565b906118556111dc565b61185d611312565b61186690611ff6565b9081611871366114a7565b9061187b916123bb565b611883611312565b6024359261188f611321565b61189761152c565b61189f611538565b6118a7611544565b916118b0611551565b936118b9611431565b8b81526001600160a01b0389166020820152966001600160a01b031660408801526060870189905260443560808801526001600160a01b031660a087015260843560c087015260a43560e087015267ffffffffffffffff1661010086015267ffffffffffffffff1661012085015267ffffffffffffffff1661014084015267ffffffffffffffff1661016083015261195590610180830161155e565b60016101a08201528061197f86600052600080516020613811833981519152602052604060002090565b90611989916115ba565b61199481308461321b565b61199c611312565b60405180916001600160a01b038091169416926119ba90888361182d565b037f90f6626183053b3cdf2d1bd5ecc58502e96e1d805a0cfe5cd0b01eabb5005d0291a4565b156119e757565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b15611a3257565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a20696e76616c69642061756374696f6e2e0000006044820152fd5b906105d860ff6009611a86611431565b9480548652611ab2611aa260018301546001600160a01b031690565b6001600160a01b03166020880152565b611ad9611ac960028301546001600160a01b031690565b6001600160a01b03166040880152565b6003810154606087015260048101546080870152611b14611b0460058301546001600160a01b031690565b6001600160a01b031660a0880152565b600681015460c0870152600781015460e0870152600881015467ffffffffffffffff808216610100890152604082901c8116610120890152608082901c16610140880152611b679060c01c610160880152565b0154611b79828216610180870161155e565b60081c166101a0840161156a565b15611b8e57565b606460405162461bcd60e51b815260206004820152601e60248201527f4d61726b6574706c6163653a20696e6163746976652061756374696f6e2e00006044820152fd5b15611bd957565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a2042696464696e672077697468207a65726f206160448201527f6d6f756e742e00000000000000000000000000000000000000000000000000006064820152fd5b15611c4a57565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a206e6f742061756374696f6e2063726561746f726044820152601760f91b6064820152fd5b15611c9f57565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a207061796f757420616c726561647920636f6d7060448201527f6c657465642e00000000000000000000000000000000000000000000000000006064820152fd5b90604051611d1681611145565b604060028294805484526001600160a01b0360018201541660208501520154910152565b15611d4157565b608460405162461bcd60e51b815260206004820152602260248201527f4d61726b6574706c6163653a2061756374696f6e207374696c6c20616374697660448201527f652e0000000000000000000000000000000000000000000000000000000000006064820152fd5b15611db257565b606460405162461bcd60e51b815260206004820152601f60248201527f4d61726b6574706c6163653a206e6f20626964732077657265206d6164652e006044820152fd5b15611dfd57565b606460405162461bcd60e51b815260206004820152601f60248201527f4d61726b6574706c6163653a206269647320616c7265616479206d6164652e006044820152fd5b604051906101c0820182811067ffffffffffffffff82111761116157604052816101a06000918281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e082015282610100820152826101208201528261014082015282610160820152826101808201520152565b15611ec257565b606460405162461bcd60e51b815260206004820152600d60248201527f696e76616c69642072616e6765000000000000000000000000000000000000006044820152fd5b9060018201809211610f4857565b91908201809211610f4857565b67ffffffffffffffff81116111615760051b60200190565b90611f4382611f21565b611f506040519182611196565b8281528092611f61601f1991611f21565b019060005b828110611f7257505050565b602090611f7d611e41565b82828501015201611f66565b8051821015611f9d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b6000198114610f485760010190565b7fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3908154916001830190818411610f485755565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082527fd9b67a260000000000000000000000000000000000000000000000000000000060048301526020926001600160a01b0316918381602481865afa9081156105b557600091612150575b501561207557505050600190565b6040519081527f80ac58cd000000000000000000000000000000000000000000000000000000006004820152908290829060249082905afa9182156105b557600092612133575b5050156120c857600090565b60405162461bcd60e51b815260206004820152603760248201527f4d61726b6574706c6163653a2061756374696f6e656420746f6b656e206d757360448201527f742062652045524331313535206f72204552433732312e0000000000000000006064820152608490fd5b6121499250803d106105ae576105a08183611196565b38806120bc565b6121679150843d86116105ae576105a08183611196565b38612067565b1561217457565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a2061756374696f6e696e67207a65726f2071756160448201527f6e746974792e00000000000000000000000000000000000000000000000000006064820152fd5b156121e557565b608460405162461bcd60e51b815260206004820152602960248201527f4d61726b6574706c6163653a2061756374696f6e696e6720696e76616c69642060448201527f7175616e746974792e00000000000000000000000000000000000000000000006064820152fd5b1561225657565b606460405162461bcd60e51b815260206004820152601c60248201527f4d61726b6574706c6163653a206e6f2074696d652d6275666665722e000000006044820152fd5b156122a157565b606460405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574706c6163653a206e6f206269642d6275666665722e00000000006044820152fd5b90610e1067ffffffffffffffff80931601918211610f4857565b91909167ffffffffffffffff80809416911601918211610f4857565b1561232257565b606460405162461bcd60e51b815260206004820152602060248201527f4d61726b6574706c6163653a20696e76616c69642074696d657374616d70732e6044820152fd5b1561236d57565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a20696e76616c69642062696420616d6f756e74736044820152601760f91b6064820152fd5b6123e46105d8926001604084016123d48151151561216d565b51149081156124b5575b506121de565b61246767ffffffffffffffff6124118161240960c086015167ffffffffffffffff1690565b16151561224f565b61243361242c610ab360e086015167ffffffffffffffff1690565b151561229a565b61010083019061245361244e835167ffffffffffffffff1690565b6122e5565b814291161015918261248c575b505061231b565b60a0810151801591821561247d575b5050612366565b60800151111590503880612476565b5161012085015167ffffffffffffffff91821693506124ab9116610ab3565b9116103880612460565b600191506124c281610610565b14386123de565b156124d057565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a206e6f742077696e6e696e67206269642e0000006044820152fd5b9060406002918051845561255b6001600160a01b0360208301511660018601906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b0151910155565b6040906105d8939594929561020082019682526020820152019061063e565b906125b96101b083516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b917f6b33f3b169c84eaaec29320da85952def04ba83c79cf51af8a9811c446ceeecc61268d604085015193610e5d60408201968751907f00000000000000000000000000000000000000000000000000000000000000009160e0880190888a8351801515908161281c575b50156126f657505050602061263f915192610dcf878b612d6d565b826001600160a01b03998a83161515806126ed575b6126c6575b505050602061267260a08901516001600160a01b031690565b94019361268685516001600160a01b031690565b3091612872565b928251926126c16126a860408301516001600160a01b031690565b9160608101519751846040519586951698169684612562565b0390a4565b6126e5926126de60a08c01516001600160a01b031690565b3090612872565b388281612659565b50801515612654565b61263f935061272c828461273193612726610ab361012060c060209a9c99015195015167ffffffffffffffff1690565b92612d1f565b6124c9565b61276e876127698c516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b612514565b6101608a01805167ffffffffffffffff16908b6127ad61010061279d67ffffffffffffffff9586429116611251565b92015167ffffffffffffffff1690565b92831610156127be575b5050610dcf565b6127dc6127ea926127d7835167ffffffffffffffff1690565b6122ff565b67ffffffffffffffff169052565b6128158a6128108151600052600080516020613811833981519152602052604060002090565b6115ba565b38806127b7565b905083101538612624565b1561282e57565b606460405162461bcd60e51b815260206004820152601360248201527f6d73672e76616c756520213d20616d6f756e74000000000000000000000000006044820152fd5b90939291938215612998576001600160a01b039180831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0361298957508116300361292857821692833b156102b357600060405180957f2e1a7d4d0000000000000000000000000000000000000000000000000000000082528183816128f588600483019190602083019252565b03925af19384156105b5576105d89461290f575b50612a70565b8061291c61292292611166565b806103fa565b38612909565b919092308382161460001461297d5750612943348414612827565b16803b156102b357600090600460405180948193630d0e30db60e41b83525af180156105b5576129705750565b8061291c6105d892611166565b6105d893919250612a70565b9091506105d89492935061299f565b5050505050565b6001600160a01b03918281168385168114612a285730036129c757506105d893929116612ae8565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000060208201526001600160a01b039182166024820152931660448401526064808401949094529282526105d892612a22608484611196565b16612bbf565b505050505050565b3d15612a6b573d9067ffffffffffffffff82116111615760405191612a5f601f8201601f191660200184611196565b82523d6000602084013e565b606090565b6000928380808086865af1612a83612a30565b5015612a90575b50505050565b6001600160a01b0316803b15612ae45760405193630d0e30db60e41b85528460048186855af19384156105b557612acc94612ad5575b50612ae8565b38808080612a8a565b612ade90611166565b38612ac6565b8380fd5b916001600160a01b03604051927fa9059cbb000000000000000000000000000000000000000000000000000000006020850152166024830152604482015260448152608081019181831067ffffffffffffffff841117611161576105d892604052612bbf565b15612b5557565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b03169060405190612bd68261117a565b6020928383527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656484840152803b15612c4d5760008281928287612c289796519301915af1612c22612a30565b90612c91565b80519081612c3557505050565b826105d893612c489383010191016111b8565b612b4e565b6064846040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b90919015612c9d575090565b815115612cad5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510612cf3575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350612cd0565b81810292918115918404141715610f4857565b929080612d2d575050101590565b8083119350909183612d40575b50505090565b9080929350810390808211610f4857826127108084029384041491141715610f4857041015388080612d3a565b90612db261103d611039612dab85516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b5460ff1690565b612df6612de983516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b805460ff19166001179055565b4267ffffffffffffffff16610160830152612e3f8161276984516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b612e65826128108151600052600080516020613811833981519152602052604060002090565b612e8160208201610e5d84610e5783516001600160a01b031690565b907f50ee19190cad04e39f76919237e06f8dbbd2b9d2b8b5dfd03934529ed5205e74835191612eba60408601516001600160a01b031690565b6126c1606087015196612ee460a06040612ed26111dc565b9601519201516001600160a01b031690565b604080519788526001600160a01b0395861660208901528701919091528316606086015290821694909116929081906080820190565b90604081019081516001600160a01b03602085015116916001600160a01b0360a086015116916040517fd45573f6000000000000000000000000000000000000000000000000000000008152604081600481305afa9384156105b5576130a8956130a0610dcf9461309a8b6130439660209a60009182916131ea575b5073716992d45bc60e9ead5f59206c0d049afbff429f88146131e2575b612fc461ffff612fcc921686612d0c565b612710900490565b9788916000809460408883926060612fff612ff3612ff3868501516001600160a01b031690565b6001600160a01b031690565b91015183518098819482937f2a55205a0000000000000000000000000000000000000000000000000000000084526004840160209093929193604081019481520152565b03915afa80839584926131ae575b5061315a575b5061309593508a7f000000000000000000000000000000000000000000000000000000000000000086819e958296613146575b50505050308b612872565b611f14565b90611251565b913090612872565b907f50ee19190cad04e39f76919237e06f8dbbd2b9d2b8b5dfd03934529ed5205e746001600160a01b038451926126c16130ec60408801516001600160a01b031690565b9160608801519761311160a06131006111dc565b93519201516001600160a01b031690565b604080519889526001600160a01b0393841660208a015288019190915216606086015290821694909116929081906080820190565b613151933090612872565b8a83863861308a565b915091926001600160a01b0381161515806131a5575b61317f575b5082918591613057565b90945061309592915061319d876131968688611f14565b11156133e2565b909138613175565b50811515613170565b9095506131d3915060403d6040116131db575b6131cb8183611196565b8101906133c3565b909438613051565b503d6131c1565b506000612fb3565b905061320e915060403d604011613214575b6132068183611196565b810190613399565b38612f96565b503d6131fc565b909161018081016001815161322f81610610565b61323881610610565b036132e85750613258612ff3612ff360408401516001600160a01b031690565b6080606083015192015193813b156102b357600080946132d7604051978896879586947ff242432a00000000000000000000000000000000000000000000000000000000865260048601929060c094926001600160a01b0380921685521660208401526040830152606082015260a06080820152600060a08201520190565b03925af180156105b5576129705750565b516132f281610610565b6132fb81610610565b1561330557505050565b6060613321612ff3612ff360408501516001600160a01b031690565b91015190803b156102b3576040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b03938416600482015293909216602484015260448301526080606483015260006084830181905290829060a490829084905af180156105b5576129705750565b91908260409103126102b357602082516133b2816105ba565b92015161ffff811681036102b35790565b91908260409103126102b357602082516133dc816105ba565b92015190565b156133e957565b606460405162461bcd60e51b815260206004820152601560248201527f66656573206578636565642074686520707269636500000000000000000000006044820152fd5b9061343782611f21565b6134446040519182611196565b8281528092613455601f1991611f21565b0190602036910137565b9061346982611f21565b60409061347882519182611196565b8381528093613489601f1991611f21565b0190600092835b83811061349e575050505050565b8151908282019180831067ffffffffffffffff8411176111615760209284526134c5611e41565b815283516134d281611145565b87815283908882820152888682015281830152828601015201613490565b9691909294937fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3549561352963ffffffff80991661342d565b938860009a5b8981108061378f575b156136a45761356161017282600052600080516020613811833981519152602052604060002090565b6080891615801561368b575b613584575b5060010197600019011696899061352f565b6040808a1615908115613672575b5061359d575b613572565b60208916158015613665575b156135725760048916158015613644575b15613572576002808a1615908115613623575b50156135985790915060019081891615908115613613575b506135f3575b908a91613572565b8a6001918d849e94613608848097168c611f89565b5201169b91506135eb565b61361d915061379a565b386135e5565b90506101a082015161363481610627565b61363d81610627565b14386135cd565b5060016101a082015161365681610627565b61365f81610627565b146135ba565b50856060820151146135a9565b8201516001600160a01b03878116911614905038613592565b5060208101516001600160a01b0388811691161461356d565b95975095509692505050600090821060001461378857505b9416906136c88261345f565b9460005b858116848110156137805786916137788261370a6136ec60019589611f89565b51600052600080516020613811833981519152602052604060002090565b61376261374a61371a848b611f89565b516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b61375b613755611452565b93611a76565b8352611d09565b6020820152613771828d611f89565b528a611f89565b5001166136cc565b505093505050565b90506136bc565b508189161515613538565b67ffffffffffffffff90816101408201511642101591826137fe575b50816137da575b816137c6575090565b6001600160a01b0391506040015116151590565b90506101a081015160048110156103f557806137f7600192610627565b14906137bd565b610160820151429116119150386137b656fed526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e4a264697066735822122080cf3434af9e43b3bb8bcea1d4e98c87d076c77e1b440b962dd8e342c88d084f64736f6c6343000812003300000000000000000000000070499adebb11efd915e3b69e700c331778628707
Deployed ByteCode
0x6080604052600436101561001257600080fd5b60003560e01c806303a54fe0146101075780630858e5ad14610102578063119df25f146100fd5780631389b117146100f857806316002f4a146100f357806316654d40146100ee578063233c23c9146100e95780632eb566bd146100e45780636891939d146100df57806378bd7935146100da5780637b063801146100d55780638b49d47e146100d057806396b5a755146100cb578063c291537c146100c65763ebf05a62146100c157600080fd5b610f77565b610e97565b610cf0565b610ca9565b610a10565b610976565b6108e9565b610819565b6107a8565b6104ef565b6104b2565b610431565b610405565b6102b8565b346102b35760203660031901126102b35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f61014b82825414156119e0565b55600261017761017283600052600080516020613811833981519152602052604060002090565b611a76565b6102336101b56101b0856000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b611d09565b6101a08301926101db600385516101cb81610627565b6101d481610627565b1415611a2b565b6102076101f461016083015167ffffffffffffffff1690565b67ffffffffffffffff4291161115611d3a565b61022e6001600160a01b0361022660208501516001600160a01b031690565b161515611dab565b612d6d565b5161023d81610627565b61024681610627565b03610277575b61027560017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b005b600961029d6102ad92600052600080516020613811833981519152602052604060002090565b01805461ff001916610200179055565b3861024c565b600080fd5b60403660031901126102b35760043560243560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f6102fa82825414156119e0565b55600091808352600080516020613811833981519152918260205260ff600960408620015460081c169260048410156103f55761033c60016103ad9514611a2b565b82855260205261034e60408520611a76565b9061037267ffffffffffffffff8061016085015116421090816103d9575b50611b87565b61037d811515611bd2565b6103a36103886111dc565b610390611403565b9485526001600160a01b03166020850152565b6040830152612581565b6103d660017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b80f35b6101408501514292501667ffffffffffffffff1611153861036c565b6105fa565b60009103126102b357565b346102b35760003660031901126102b35760206104206111dc565b6001600160a01b0360405191168152f35b346102b35760203660031901126102b35760043580600052600080516020613811833981519152908160205260ff60096040600020015460081c1660048110156103f55760016104819114611a2b565b6000526020526104ae60086040600020015460c01c60405191829142111582919091602081019215159052565b0390f35b346102b35760003660031901126102b35760207fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e354604051908152f35b346102b3576101403660031901126102b3576105096111dc565b6001600160a01b036040519163a32fa5b360e01b83527ff94103142c1baabe9ac2b5d1487bf783de9e69cfeea9a72f5c9c94afd7877b8c6004840152166024820152602081604481305afa80156105b55761056c91600091610587575b506112c7565b6104ae61057761132d565b6040519081529081906020820190565b6105a8915060203d81116105ae575b6105a08183611196565b8101906111b8565b38610566565b503d610596565b6111d0565b6001600160a01b038116036102b357565b600435906105d8826105ba565b565b606435906105d8826105ba565b60c4359063ffffffff821682036102b357565b634e487b7160e01b600052602160045260246000fd5b600211156103f557565b9060028210156103f55752565b600411156103f557565b9060048210156103f55752565b805182526020808201516001600160a01b0316908301526105d891906040818101516001600160a01b031690830152606081015160608301526080810151608083015261069b60a082015160a08401906001600160a01b03169052565b60c081015160c083015260e081015160e08301526106cb610100808301519084019067ffffffffffffffff169052565b6101208181015167ffffffffffffffff16908301526101408181015167ffffffffffffffff16908301526101608181015167ffffffffffffffff169083015261071d610180808301519084019061061a565b6101a080910151910190610631565b929190604080850190808652825180925260608601916020809401916000905b8583831061075e575050505050930152565b610220859683836001959697985161077784825161063e565b015180516101c0840152848101516001600160a01b03166101e084015201516102008201520195019392019061074c565b346102b35760e03660031901126102b35760243560ff811681036102b3576044356107d2816105ba565b606435916107df836105ba565b60a4359063ffffffff821682036102b357610809936107fc6105e7565b93608435926004356134f0565b906104ae6040519283928361072c565b346102b3576040806003193601126102b357600435906000828152600080516020613811833981519152928360205260ff6009848420015460081c169360048510156103f557836108d8936108b59261087760016104ae9914611a2b565b848252602052610888828220611a76565b9381527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e560205220611d09565b67ffffffffffffffff6101208560c0850151930151930151169160243591612d1f565b905190151581529081906020820190565b346102b35760203660031901126102b3576004356000818152600080516020613811833981519152908160205260ff600960408320015460081c169060048210156103f55761094092610877600160409414611a2b565b60208181015160a0939093015160409283015183516001600160a01b039586168152949091169184019190915290820152606090f35b346102b35760203660031901126102b35761098f611e41565b506004356000526000805160206138118339815191526020526101c06109b86040600020611a76565b6109c5604051809261063e565bf35b6020908160408183019282815285518094520193019160005b8281106109ee575050505090565b90919293826101c082610a04600194895161063e565b019501939291016109e0565b346102b3576040806003193601126102b3576024356004358181111580610c7f575b610a3b90611ebb565b610a55610a50610a4b8385611251565b611f06565b611f39565b91600091805b82811115610b8457505050610a6f90611f39565b906000815191815b838110610a8b578551806104ae87826109c7565b610add9042610ac0610ab3610140610aa38588611f89565b51015167ffffffffffffffff1690565b67ffffffffffffffff1690565b111580610b69575b80610b40575b80610b12575b610ae257611f06565b610a77565b610b0c610aef8285611f89565b5194610afa81611fb3565b95610b05828a611f89565b5287611f89565b50611f06565b506001600160a01b03610b3888610b298487611f89565b5101516001600160a01b031690565b161515610ad4565b506001610b5a6101a0610b538487611f89565b510161158e565b610b6381610627565b14610ace565b5042610b7e610ab3610160610aa38588611f89565b11610ac8565b610b8e8282611251565b610bb261017283600052600080516020613811833981519152602052604060002090565b610bbc8288611f89565b52610bc78187611f89565b508642610bdd610ab3610140610aa3868c611f89565b11159182610c62575b82610c3e575b82610c1c575b5050610c07575b610c0290611f06565b610a5b565b92610c14610c0291611f06565b939050610bf9565b6001600160a01b03925090610b29610c349289611f89565b1615158638610bf2565b91506001610c526101a0610b53858b611f89565b610c5b81610627565b1491610bec565b915042610c78610ab3610160610aa3868c611f89565b1191610be6565b507fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3548210610a32565b346102b35760003660031901126102b3576040610cc461125e565b919082825193849260208452816020850152848401376000828201840152601f01601f19168101030190f35b346102b35760203660031901126102b3576004356000908082526000805160206138118339815191528060205260ff600960408520015460081c1660048110156103f5576001610d409114611a2b565b8183526020526001600160a01b03610d6b8160016040862001541682610d646111dc565b1614611c43565b610d8f61017283600052600080516020613811833981519152602052604060002090565b91610de482610ddd6020610dcf6101b0866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b01516001600160a01b031690565b1615611df6565b610e1a6009610e0a83600052600080516020613811833981519152602052604060002090565b01805461ff001916610300179055565b7fb78a7099174b11eaf203c16216e524a48f8806eb956090d87d838ada4ebe68d3610e6a60208501610e5d86610e5783516001600160a01b031690565b3061321b565b516001600160a01b031690565b926060610e8160408701516001600160a01b031690565b950151604051938452948116931691602090a480f35b346102b3576040806003193601126102b357600435602435918282111580610f4d575b610ec390611ebb565b818303838111610f4857600190818101809111610f4857610ee390611f39565b92805b85811115610efb578351806104ae87826109c7565b610f3b84600083815260008051602061381183398151915260205220610f2a610f248585611251565b91611a76565b610f348289611f89565b5286611f89565b5082810180911115610ee6575b61123b565b507fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3548310610eba565b346102b35760203660031901126102b35760043560027fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f610fbb82825414156119e0565b558060005260008051602061381183398151915260205260026001600160a01b03610ff3816001604060002001541682610d646111dc565b61104261103d61103961102f866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b5460081c60ff1690565b1590565b611c98565b611087611078846000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b805461ff001916610100179055565b6102336110ae61017285600052600080516020613811833981519152602052604060002090565b6110e46101b0866000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b9061112a6101a08201946110fe600387516101cb81610627565b6111176101f461016085015167ffffffffffffffff1690565b60208401516001600160a01b0316610226565b612f1a565b634e487b7160e01b600052604160045260246000fd5b6060810190811067ffffffffffffffff82111761116157604052565b61112f565b67ffffffffffffffff811161116157604052565b6040810190811067ffffffffffffffff82111761116157604052565b90601f8019910116810190811067ffffffffffffffff82111761116157604052565b908160209103126102b3575180151581036102b35790565b6040513d6000823e3d90fd5b60405163572b6c0560e01b8152336004820152602081602481305afa9081156105b55760009161121d575b50156112195736601319013560601c90565b3390565b611235915060203d81116105ae576105a08183611196565b38611207565b634e487b7160e01b600052601160045260246000fd5b91908203918211610f4857565b60405163572b6c0560e01b8152336004820152602081602481305afa9081156105b5576000916112a9575b50156112a257601319360190368211610f485760009190565b6000903690565b6112c1915060203d81116105ae576105a08183611196565b38611289565b156112ce57565b606460405162461bcd60e51b815260206004820152600c60248201527f214c49535445525f524f4c4500000000000000000000000000000000000000006044820152fd5b60043561131e816105ba565b90565b60643561131e816105ba565b600435611339816105ba565b6001600160a01b036040519163a32fa5b360e01b83527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae66004840152166024820152602081604481305afa9081156105b5576000916113e5575b50156113a15761131e611844565b606460405162461bcd60e51b815260206004820152600b60248201527f2141535345545f524f4c450000000000000000000000000000000000000000006044820152fd5b6113fd915060203d81116105ae576105a08183611196565b38611393565b604051906105d882611145565b60405190610140820182811067ffffffffffffffff82111761116157604052565b604051906101c0820182811067ffffffffffffffff82111761116157604052565b604051906105d88261117a565b67ffffffffffffffff8116036102b357565b60c435906105d88261145f565b60e435906105d88261145f565b61010435906105d88261145f565b61012435906105d88261145f565b6101409060031901126102b3576114bc611410565b906114c56105cb565b8252602435602083015260443560408301526114df6105da565b6060830152608435608083015260a43560a08301526114fc611471565b60c083015261150961147e565b60e083015261151661148b565b610100830152611524611499565b610120830152565b60c43561131e8161145f565b60e43561131e8161145f565b6101043561131e8161145f565b6101243561131e8161145f565b60028210156103f55752565b60048210156103f55752565b9060028110156103f55760ff80198354169116179055565b5160048110156103f55790565b9060048110156103f55761ff0082549160081b169061ff001916179055565b906101a060096105d8938351815561160b6115df60208601516001600160a01b031690565b60018301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b61164e61162260408601516001600160a01b031690565b60028301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60608401516003820155608084015160048201556116a561167960a08601516001600160a01b031690565b60058301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60c0840151600682015560e08401516007820155611802600882016116f76116d961010088015167ffffffffffffffff1690565b825467ffffffffffffffff191667ffffffffffffffff909116178255565b61175161171061012088015167ffffffffffffffff1690565b82547fffffffffffffffffffffffffffffffff0000000000000000ffffffffffffffff1660409190911b6fffffffffffffffff000000000000000016178255565b6117b361176a61014088015167ffffffffffffffff1690565b82547fffffffffffffffff0000000000000000ffffffffffffffffffffffffffffffff1660809190911b77ffffffffffffffff0000000000000000000000000000000016178255565b610160860151815477ffffffffffffffffffffffffffffffffffffffffffffffff1660c09190911b7fffffffffffffffff00000000000000000000000000000000000000000000000016179055565b019161181c61018082015161181681610610565b84611576565b01519061182882610627565b61159b565b9081526101e0810192916105d8916020019061063e565b61184c611fc2565b906118556111dc565b61185d611312565b61186690611ff6565b9081611871366114a7565b9061187b916123bb565b611883611312565b6024359261188f611321565b61189761152c565b61189f611538565b6118a7611544565b916118b0611551565b936118b9611431565b8b81526001600160a01b0389166020820152966001600160a01b031660408801526060870189905260443560808801526001600160a01b031660a087015260843560c087015260a43560e087015267ffffffffffffffff1661010086015267ffffffffffffffff1661012085015267ffffffffffffffff1661014084015267ffffffffffffffff1661016083015261195590610180830161155e565b60016101a08201528061197f86600052600080516020613811833981519152602052604060002090565b90611989916115ba565b61199481308461321b565b61199c611312565b60405180916001600160a01b038091169416926119ba90888361182d565b037f90f6626183053b3cdf2d1bd5ecc58502e96e1d805a0cfe5cd0b01eabb5005d0291a4565b156119e757565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b15611a3257565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a20696e76616c69642061756374696f6e2e0000006044820152fd5b906105d860ff6009611a86611431565b9480548652611ab2611aa260018301546001600160a01b031690565b6001600160a01b03166020880152565b611ad9611ac960028301546001600160a01b031690565b6001600160a01b03166040880152565b6003810154606087015260048101546080870152611b14611b0460058301546001600160a01b031690565b6001600160a01b031660a0880152565b600681015460c0870152600781015460e0870152600881015467ffffffffffffffff808216610100890152604082901c8116610120890152608082901c16610140880152611b679060c01c610160880152565b0154611b79828216610180870161155e565b60081c166101a0840161156a565b15611b8e57565b606460405162461bcd60e51b815260206004820152601e60248201527f4d61726b6574706c6163653a20696e6163746976652061756374696f6e2e00006044820152fd5b15611bd957565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a2042696464696e672077697468207a65726f206160448201527f6d6f756e742e00000000000000000000000000000000000000000000000000006064820152fd5b15611c4a57565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a206e6f742061756374696f6e2063726561746f726044820152601760f91b6064820152fd5b15611c9f57565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a207061796f757420616c726561647920636f6d7060448201527f6c657465642e00000000000000000000000000000000000000000000000000006064820152fd5b90604051611d1681611145565b604060028294805484526001600160a01b0360018201541660208501520154910152565b15611d4157565b608460405162461bcd60e51b815260206004820152602260248201527f4d61726b6574706c6163653a2061756374696f6e207374696c6c20616374697660448201527f652e0000000000000000000000000000000000000000000000000000000000006064820152fd5b15611db257565b606460405162461bcd60e51b815260206004820152601f60248201527f4d61726b6574706c6163653a206e6f20626964732077657265206d6164652e006044820152fd5b15611dfd57565b606460405162461bcd60e51b815260206004820152601f60248201527f4d61726b6574706c6163653a206269647320616c7265616479206d6164652e006044820152fd5b604051906101c0820182811067ffffffffffffffff82111761116157604052816101a06000918281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e082015282610100820152826101208201528261014082015282610160820152826101808201520152565b15611ec257565b606460405162461bcd60e51b815260206004820152600d60248201527f696e76616c69642072616e6765000000000000000000000000000000000000006044820152fd5b9060018201809211610f4857565b91908201809211610f4857565b67ffffffffffffffff81116111615760051b60200190565b90611f4382611f21565b611f506040519182611196565b8281528092611f61601f1991611f21565b019060005b828110611f7257505050565b602090611f7d611e41565b82828501015201611f66565b8051821015611f9d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b6000198114610f485760010190565b7fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3908154916001830190818411610f485755565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082527fd9b67a260000000000000000000000000000000000000000000000000000000060048301526020926001600160a01b0316918381602481865afa9081156105b557600091612150575b501561207557505050600190565b6040519081527f80ac58cd000000000000000000000000000000000000000000000000000000006004820152908290829060249082905afa9182156105b557600092612133575b5050156120c857600090565b60405162461bcd60e51b815260206004820152603760248201527f4d61726b6574706c6163653a2061756374696f6e656420746f6b656e206d757360448201527f742062652045524331313535206f72204552433732312e0000000000000000006064820152608490fd5b6121499250803d106105ae576105a08183611196565b38806120bc565b6121679150843d86116105ae576105a08183611196565b38612067565b1561217457565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a2061756374696f6e696e67207a65726f2071756160448201527f6e746974792e00000000000000000000000000000000000000000000000000006064820152fd5b156121e557565b608460405162461bcd60e51b815260206004820152602960248201527f4d61726b6574706c6163653a2061756374696f6e696e6720696e76616c69642060448201527f7175616e746974792e00000000000000000000000000000000000000000000006064820152fd5b1561225657565b606460405162461bcd60e51b815260206004820152601c60248201527f4d61726b6574706c6163653a206e6f2074696d652d6275666665722e000000006044820152fd5b156122a157565b606460405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574706c6163653a206e6f206269642d6275666665722e00000000006044820152fd5b90610e1067ffffffffffffffff80931601918211610f4857565b91909167ffffffffffffffff80809416911601918211610f4857565b1561232257565b606460405162461bcd60e51b815260206004820152602060248201527f4d61726b6574706c6163653a20696e76616c69642074696d657374616d70732e6044820152fd5b1561236d57565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a20696e76616c69642062696420616d6f756e74736044820152601760f91b6064820152fd5b6123e46105d8926001604084016123d48151151561216d565b51149081156124b5575b506121de565b61246767ffffffffffffffff6124118161240960c086015167ffffffffffffffff1690565b16151561224f565b61243361242c610ab360e086015167ffffffffffffffff1690565b151561229a565b61010083019061245361244e835167ffffffffffffffff1690565b6122e5565b814291161015918261248c575b505061231b565b60a0810151801591821561247d575b5050612366565b60800151111590503880612476565b5161012085015167ffffffffffffffff91821693506124ab9116610ab3565b9116103880612460565b600191506124c281610610565b14386123de565b156124d057565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a206e6f742077696e6e696e67206269642e0000006044820152fd5b9060406002918051845561255b6001600160a01b0360208301511660018601906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b0151910155565b6040906105d8939594929561020082019682526020820152019061063e565b906125b96101b083516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b917f6b33f3b169c84eaaec29320da85952def04ba83c79cf51af8a9811c446ceeecc61268d604085015193610e5d60408201968751907f00000000000000000000000070499adebb11efd915e3b69e700c3317786287079160e0880190888a8351801515908161281c575b50156126f657505050602061263f915192610dcf878b612d6d565b826001600160a01b03998a83161515806126ed575b6126c6575b505050602061267260a08901516001600160a01b031690565b94019361268685516001600160a01b031690565b3091612872565b928251926126c16126a860408301516001600160a01b031690565b9160608101519751846040519586951698169684612562565b0390a4565b6126e5926126de60a08c01516001600160a01b031690565b3090612872565b388281612659565b50801515612654565b61263f935061272c828461273193612726610ab361012060c060209a9c99015195015167ffffffffffffffff1690565b92612d1f565b6124c9565b61276e876127698c516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b612514565b6101608a01805167ffffffffffffffff16908b6127ad61010061279d67ffffffffffffffff9586429116611251565b92015167ffffffffffffffff1690565b92831610156127be575b5050610dcf565b6127dc6127ea926127d7835167ffffffffffffffff1690565b6122ff565b67ffffffffffffffff169052565b6128158a6128108151600052600080516020613811833981519152602052604060002090565b6115ba565b38806127b7565b905083101538612624565b1561282e57565b606460405162461bcd60e51b815260206004820152601360248201527f6d73672e76616c756520213d20616d6f756e74000000000000000000000000006044820152fd5b90939291938215612998576001600160a01b039180831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee0361298957508116300361292857821692833b156102b357600060405180957f2e1a7d4d0000000000000000000000000000000000000000000000000000000082528183816128f588600483019190602083019252565b03925af19384156105b5576105d89461290f575b50612a70565b8061291c61292292611166565b806103fa565b38612909565b919092308382161460001461297d5750612943348414612827565b16803b156102b357600090600460405180948193630d0e30db60e41b83525af180156105b5576129705750565b8061291c6105d892611166565b6105d893919250612a70565b9091506105d89492935061299f565b5050505050565b6001600160a01b03918281168385168114612a285730036129c757506105d893929116612ae8565b6040517f23b872dd0000000000000000000000000000000000000000000000000000000060208201526001600160a01b039182166024820152931660448401526064808401949094529282526105d892612a22608484611196565b16612bbf565b505050505050565b3d15612a6b573d9067ffffffffffffffff82116111615760405191612a5f601f8201601f191660200184611196565b82523d6000602084013e565b606090565b6000928380808086865af1612a83612a30565b5015612a90575b50505050565b6001600160a01b0316803b15612ae45760405193630d0e30db60e41b85528460048186855af19384156105b557612acc94612ad5575b50612ae8565b38808080612a8a565b612ade90611166565b38612ac6565b8380fd5b916001600160a01b03604051927fa9059cbb000000000000000000000000000000000000000000000000000000006020850152166024830152604482015260448152608081019181831067ffffffffffffffff841117611161576105d892604052612bbf565b15612b5557565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b03169060405190612bd68261117a565b6020928383527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656484840152803b15612c4d5760008281928287612c289796519301915af1612c22612a30565b90612c91565b80519081612c3557505050565b826105d893612c489383010191016111b8565b612b4e565b6064846040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b90919015612c9d575090565b815115612cad5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510612cf3575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350612cd0565b81810292918115918404141715610f4857565b929080612d2d575050101590565b8083119350909183612d40575b50505090565b9080929350810390808211610f4857826127108084029384041491141715610f4857041015388080612d3a565b90612db261103d611039612dab85516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b5460ff1690565b612df6612de983516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e6602052604060002090565b805460ff19166001179055565b4267ffffffffffffffff16610160830152612e3f8161276984516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b612e65826128108151600052600080516020613811833981519152602052604060002090565b612e8160208201610e5d84610e5783516001600160a01b031690565b907f50ee19190cad04e39f76919237e06f8dbbd2b9d2b8b5dfd03934529ed5205e74835191612eba60408601516001600160a01b031690565b6126c1606087015196612ee460a06040612ed26111dc565b9601519201516001600160a01b031690565b604080519788526001600160a01b0395861660208901528701919091528316606086015290821694909116929081906080820190565b90604081019081516001600160a01b03602085015116916001600160a01b0360a086015116916040517fd45573f6000000000000000000000000000000000000000000000000000000008152604081600481305afa9384156105b5576130a8956130a0610dcf9461309a8b6130439660209a60009182916131ea575b5073716992d45bc60e9ead5f59206c0d049afbff429f88146131e2575b612fc461ffff612fcc921686612d0c565b612710900490565b9788916000809460408883926060612fff612ff3612ff3868501516001600160a01b031690565b6001600160a01b031690565b91015183518098819482937f2a55205a0000000000000000000000000000000000000000000000000000000084526004840160209093929193604081019481520152565b03915afa80839584926131ae575b5061315a575b5061309593508a7f00000000000000000000000070499adebb11efd915e3b69e700c33177862870786819e958296613146575b50505050308b612872565b611f14565b90611251565b913090612872565b907f50ee19190cad04e39f76919237e06f8dbbd2b9d2b8b5dfd03934529ed5205e746001600160a01b038451926126c16130ec60408801516001600160a01b031690565b9160608801519761311160a06131006111dc565b93519201516001600160a01b031690565b604080519889526001600160a01b0393841660208a015288019190915216606086015290821694909116929081906080820190565b613151933090612872565b8a83863861308a565b915091926001600160a01b0381161515806131a5575b61317f575b5082918591613057565b90945061309592915061319d876131968688611f14565b11156133e2565b909138613175565b50811515613170565b9095506131d3915060403d6040116131db575b6131cb8183611196565b8101906133c3565b909438613051565b503d6131c1565b506000612fb3565b905061320e915060403d604011613214575b6132068183611196565b810190613399565b38612f96565b503d6131fc565b909161018081016001815161322f81610610565b61323881610610565b036132e85750613258612ff3612ff360408401516001600160a01b031690565b6080606083015192015193813b156102b357600080946132d7604051978896879586947ff242432a00000000000000000000000000000000000000000000000000000000865260048601929060c094926001600160a01b0380921685521660208401526040830152606082015260a06080820152600060a08201520190565b03925af180156105b5576129705750565b516132f281610610565b6132fb81610610565b1561330557505050565b6060613321612ff3612ff360408501516001600160a01b031690565b91015190803b156102b3576040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b03938416600482015293909216602484015260448301526080606483015260006084830181905290829060a490829084905af180156105b5576129705750565b91908260409103126102b357602082516133b2816105ba565b92015161ffff811681036102b35790565b91908260409103126102b357602082516133dc816105ba565b92015190565b156133e957565b606460405162461bcd60e51b815260206004820152601560248201527f66656573206578636565642074686520707269636500000000000000000000006044820152fd5b9061343782611f21565b6134446040519182611196565b8281528092613455601f1991611f21565b0190602036910137565b9061346982611f21565b60409061347882519182611196565b8381528093613489601f1991611f21565b0190600092835b83811061349e575050505050565b8151908282019180831067ffffffffffffffff8411176111615760209284526134c5611e41565b815283516134d281611145565b87815283908882820152888682015281830152828601015201613490565b9691909294937fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e3549561352963ffffffff80991661342d565b938860009a5b8981108061378f575b156136a45761356161017282600052600080516020613811833981519152602052604060002090565b6080891615801561368b575b613584575b5060010197600019011696899061352f565b6040808a1615908115613672575b5061359d575b613572565b60208916158015613665575b156135725760048916158015613644575b15613572576002808a1615908115613623575b50156135985790915060019081891615908115613613575b506135f3575b908a91613572565b8a6001918d849e94613608848097168c611f89565b5201169b91506135eb565b61361d915061379a565b386135e5565b90506101a082015161363481610627565b61363d81610627565b14386135cd565b5060016101a082015161365681610627565b61365f81610627565b146135ba565b50856060820151146135a9565b8201516001600160a01b03878116911614905038613592565b5060208101516001600160a01b0388811691161461356d565b95975095509692505050600090821060001461378857505b9416906136c88261345f565b9460005b858116848110156137805786916137788261370a6136ec60019589611f89565b51600052600080516020613811833981519152602052604060002090565b61376261374a61371a848b611f89565b516000527fd526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e5602052604060002090565b61375b613755611452565b93611a76565b8352611d09565b6020820152613771828d611f89565b528a611f89565b5001166136cc565b505093505050565b90506136bc565b508189161515613538565b67ffffffffffffffff90816101408201511642101591826137fe575b50816137da575b816137c6575090565b6001600160a01b0391506040015116151590565b90506101a081015160048110156103f557806137f7600192610627565b14906137bd565b610160820151429116119150386137b656fed526f5655f36f7dc8e8bd7b8ff16d8886b1e27059b0d19a6ab0f4742ac8dc6e4a264697066735822122080cf3434af9e43b3bb8bcea1d4e98c87d076c77e1b440b962dd8e342c88d084f64736f6c63430008120033