Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- DirectListingsLogic
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 1000
- EVM Version
- default
- Verified at
- 2023-07-25T04:19:47.992856Z
Constructor Arguments
0x00000000000000000000000070499adebb11efd915e3b69e700c331778628707
Arg [0] (address) : 0x70499adebb11efd915e3b69e700c331778628707
contracts/marketplace/direct-listings/DirectListingsLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/// @author thirdweb
import "./DirectListingsStorage.sol";
// ====== External imports ======
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/PlatformFeeLogic.sol";
import "@thirdweb-dev/contracts/extension/plugin/ERC2771ContextConsumer.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";
/**
* @author thirdweb.com
*/
contract DirectListingsLogic is IDirectListings, ReentrancyGuardLogic, ERC2771ContextConsumer, Constants {
/*///////////////////////////////////////////////////////////////
Constants / Immutables
//////////////////////////////////////////////////////////////*/
/// @dev Only lister role holders can create listings, when listings are restricted by lister address.
bytes32 private constant LISTER_ROLE = keccak256("LISTER_ROLE");
/// @dev Only assets from NFT contracts with asset role can be listed, when listings 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;
/*///////////////////////////////////////////////////////////////
Modifier
//////////////////////////////////////////////////////////////*/
/// @dev Checks whether the caller has LISTER_ROLE.
modifier onlyListerRole() {
require(PermissionsEnumerableLogic(address(this)).hasRoleWithSwitch(LISTER_ROLE, _msgSender()), "!LISTER_ROLE");
_;
}
/// @dev Checks whether the caller has ASSET_ROLE.
modifier onlyAssetRole(address _asset) {
require(PermissionsEnumerableLogic(address(this)).hasRoleWithSwitch(ASSET_ROLE, _asset), "!ASSET_ROLE");
_;
}
/// @dev Checks whether caller is a listing creator.
modifier onlyListingCreator(uint256 _listingId) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
require(data.listings[_listingId].listingCreator == _msgSender(), "Marketplace: not listing creator.");
_;
}
/// @dev Checks whether a listing exists.
modifier onlyExistingListing(uint256 _listingId) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
require(data.listings[_listingId].status == IDirectListings.Status.CREATED, "Marketplace: invalid listing.");
_;
}
/*///////////////////////////////////////////////////////////////
Constructor logic
//////////////////////////////////////////////////////////////*/
constructor(address _nativeTokenWrapper) {
nativeTokenWrapper = _nativeTokenWrapper;
}
/*///////////////////////////////////////////////////////////////
External functions
//////////////////////////////////////////////////////////////*/
/// @notice List NFTs (ERC721 or ERC1155) for sale at a fixed price.
function createListing(ListingParameters calldata _params)
external
onlyListerRole
onlyAssetRole(_params.assetContract)
returns (uint256 listingId)
{
listingId = _getNextListingId();
address listingCreator = _msgSender();
TokenType tokenType = _getTokenType(_params.assetContract);
uint128 startTime = _params.startTimestamp;
uint128 endTime = _params.endTimestamp;
require(startTime < endTime, "Marketplace: endTimestamp not greater than startTimestamp.");
if (startTime < block.timestamp) {
require(startTime + 60 minutes >= block.timestamp, "Marketplace: invalid startTimestamp.");
startTime = uint128(block.timestamp);
endTime = endTime == type(uint128).max
? endTime
: startTime + (_params.endTimestamp - _params.startTimestamp);
}
_validateNewListing(_params, tokenType);
Listing memory listing = Listing({
listingId: listingId,
listingCreator: listingCreator,
assetContract: _params.assetContract,
tokenId: _params.tokenId,
quantity: _params.quantity,
currency: _params.currency,
pricePerToken: _params.pricePerToken,
startTimestamp: startTime,
endTimestamp: endTime,
reserved: _params.reserved,
tokenType: tokenType,
status: IDirectListings.Status.CREATED
});
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
data.listings[listingId] = listing;
emit NewListing(listingCreator, listingId, _params.assetContract, _params.tokenId, listing);
}
/// @notice Update parameters of a listing of NFTs.
function updateListing(uint256 _listingId, ListingParameters memory _params)
external
onlyExistingListing(_listingId)
onlyAssetRole(_params.assetContract)
onlyListingCreator(_listingId)
{
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
address listingCreator = _msgSender();
Listing memory listing = data.listings[_listingId];
TokenType tokenType = _getTokenType(_params.assetContract);
require(listing.endTimestamp > block.timestamp, "Marketplace: listing expired.");
require(
listing.assetContract == _params.assetContract && listing.tokenId == _params.tokenId,
"Marketplace: cannot update what token is listed."
);
uint128 startTime = _params.startTimestamp;
uint128 endTime = _params.endTimestamp;
require(startTime < endTime, "Marketplace: endTimestamp not greater than startTimestamp.");
require(
listing.startTimestamp > block.timestamp ||
(startTime == listing.startTimestamp && endTime > block.timestamp),
"Marketplace: listing already active."
);
if (startTime != listing.startTimestamp && startTime < block.timestamp) {
require(startTime + 60 minutes >= block.timestamp, "Marketplace: invalid startTimestamp.");
startTime = uint128(block.timestamp);
endTime = endTime == listing.endTimestamp || endTime == type(uint128).max
? endTime
: startTime + (_params.endTimestamp - _params.startTimestamp);
}
{
uint256 _approvedCurrencyPrice = data.currencyPriceForListing[_listingId][_params.currency];
require(
_approvedCurrencyPrice == 0 || _params.pricePerToken == _approvedCurrencyPrice,
"Marketplace: price different from approved price"
);
}
_validateNewListing(_params, tokenType);
listing = Listing({
listingId: _listingId,
listingCreator: listingCreator,
assetContract: _params.assetContract,
tokenId: _params.tokenId,
quantity: _params.quantity,
currency: _params.currency,
pricePerToken: _params.pricePerToken,
startTimestamp: startTime,
endTimestamp: endTime,
reserved: _params.reserved,
tokenType: tokenType,
status: IDirectListings.Status.CREATED
});
data.listings[_listingId] = listing;
emit UpdatedListing(listingCreator, _listingId, _params.assetContract, _params.tokenId, listing);
}
/// @notice Cancel a listing.
function cancelListing(uint256 _listingId) external onlyExistingListing(_listingId) onlyListingCreator(_listingId) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
data.listings[_listingId].status = IDirectListings.Status.CANCELLED;
Listing memory listing = data.listings[_listingId];
emit CancelledListing(_msgSender(), _listingId, listing.assetContract, listing.tokenId);
}
/// @notice Approve a buyer to buy from a reserved listing.
function approveBuyerForListing(
uint256 _listingId,
address _buyer,
bool _toApprove
) external onlyExistingListing(_listingId) onlyListingCreator(_listingId) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
Listing memory listing = data.listings[_listingId];
require(listing.reserved, "Marketplace: listing not reserved.");
data.isBuyerApprovedForListing[_listingId][_buyer] = _toApprove;
emit BuyerApprovedForListing(_msgSender(), _listingId, listing.assetContract, listing.tokenId, _buyer, _toApprove);
}
/// @notice Approve a currency as a form of payment for the listing.
function approveCurrencyForListing(
uint256 _listingId,
address _currency,
uint256 _pricePerTokenInCurrency
) external onlyExistingListing(_listingId) onlyListingCreator(_listingId) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
Listing memory listing = data.listings[_listingId];
require(
_currency != listing.currency || _pricePerTokenInCurrency == listing.pricePerToken,
"Marketplace: approving listing currency with different price."
);
require(
data.currencyPriceForListing[_listingId][_currency] != _pricePerTokenInCurrency,
"Marketplace: price unchanged."
);
data.currencyPriceForListing[_listingId][_currency] = _pricePerTokenInCurrency;
emit CurrencyApprovedForListing(_msgSender(), _listingId, listing.assetContract, listing.tokenId, _pricePerTokenInCurrency, _currency);
}
/// @notice Buy NFTs from a listing.
function buyFromListing(
uint256 _listingId,
address _buyFor,
uint256 _quantity,
address _currency,
uint256 _expectedTotalPrice
) external payable nonReentrant onlyExistingListing(_listingId) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
Listing memory listing = data.listings[_listingId];
address buyer = _msgSender();
require(!listing.reserved || data.isBuyerApprovedForListing[_listingId][buyer], "buyer not approved");
require(_quantity > 0 && _quantity <= listing.quantity, "Buying invalid quantity");
require(
block.timestamp < listing.endTimestamp && block.timestamp >= listing.startTimestamp,
"not within sale window."
);
require(
_validateOwnershipAndApproval(
listing.listingCreator,
listing.assetContract,
listing.tokenId,
_quantity,
listing.tokenType
),
"Marketplace: not owner or approved tokens."
);
uint256 targetTotalPrice;
if (data.currencyPriceForListing[_listingId][_currency] > 0) {
targetTotalPrice = _quantity * data.currencyPriceForListing[_listingId][_currency];
} else {
require(_currency == listing.currency, "Paying in invalid currency.");
targetTotalPrice = _quantity * listing.pricePerToken;
}
require(targetTotalPrice == _expectedTotalPrice, "Unexpected total price");
// Check: buyer owns and has approved sufficient currency for sale.
if (_currency == CurrencyTransferLib.NATIVE_TOKEN) {
require(msg.value == targetTotalPrice, "Marketplace: msg.value must exactly be the total price.");
} else {
_validateERC20BalAndAllowance(buyer, _currency, targetTotalPrice);
}
if (listing.quantity == _quantity) {
data.listings[_listingId].status = IDirectListings.Status.COMPLETED;
}
data.listings[_listingId].quantity -= _quantity;
_payout(buyer, listing.listingCreator, _currency, targetTotalPrice, listing);
_transferListingTokens(listing.listingCreator, _buyFor, _quantity, listing);
emit NewSale(
listing.listingCreator,
listing.listingId,
listing.assetContract,
listing.tokenId,
buyer,
_quantity,
targetTotalPrice,
listing.currency
);
}
/*///////////////////////////////////////////////////////////////
View functions
//////////////////////////////////////////////////////////////*/
/**
* @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) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
return data.totalListings;
}
/// @notice Returns whether a buyer is approved for a listing.
function isBuyerApprovedForListing(uint256 _listingId, address _buyer) external view returns (bool) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
return data.isBuyerApprovedForListing[_listingId][_buyer];
}
/// @notice Returns whether a currency is approved for a listing.
function isCurrencyApprovedForListing(uint256 _listingId, address _currency) external view returns (bool) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
return data.currencyPriceForListing[_listingId][_currency] > 0;
}
/// @notice Returns the price per token for a listing, in the given currency.
function currencyPriceForListing(uint256 _listingId, address _currency) external view returns (uint256) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
if (data.currencyPriceForListing[_listingId][_currency] == 0) {
revert("Currency not approved for listing");
}
return data.currencyPriceForListing[_listingId][_currency];
}
/// @notice Returns all non-cancelled listings.
function getAllListings(uint256 _startId, uint256 _endId) external view returns (Listing[] memory _allListings) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
require(_startId <= _endId && _endId < data.totalListings, "invalid range");
_allListings = new Listing[](_endId - _startId + 1);
for (uint256 i = _startId; i <= _endId; i += 1) {
_allListings[i - _startId] = data.listings[i];
}
}
/**
* @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 _validListings)
{
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
require(_startId <= _endId && _endId < data.totalListings, "invalid range");
Listing[] memory _listings = new Listing[](_endId - _startId + 1);
uint256 _listingCount;
for (uint256 i = _startId; i <= _endId; i += 1) {
_listings[i - _startId] = data.listings[i];
if (_validateExistingListing(_listings[i - _startId])) {
_listingCount += 1;
}
}
_validListings = new Listing[](_listingCount);
uint256 index = 0;
uint256 count = _listings.length;
for (uint256 i = 0; i < count; i += 1) {
if (_validateExistingListing(_listings[i])) {
_validListings[index++] = _listings[i];
}
}
}
/// @notice Returns a listing at a particular listing ID.
function getListing(uint256 _listingId) external view returns (Listing memory listing) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
listing = data.listings[_listingId];
}
/*///////////////////////////////////////////////////////////////
Internal functions
//////////////////////////////////////////////////////////////*/
/// @dev Returns the next listing Id.
function _getNextListingId() internal returns (uint256 id) {
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
id = data.totalListings;
data.totalListings += 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: listed token must be ERC1155 or ERC721.");
}
}
/// @dev Checks whether the listing creator owns and has approved marketplace to transfer listed tokens.
function _validateNewListing(ListingParameters memory _params, TokenType _tokenType) internal view {
require(_params.quantity > 0, "Marketplace: listing zero quantity.");
require(_params.quantity == 1 || _tokenType == TokenType.ERC1155, "Marketplace: listing invalid quantity.");
require(
_validateOwnershipAndApproval(
_msgSender(),
_params.assetContract,
_params.tokenId,
_params.quantity,
_tokenType
),
"Marketplace: not owner or approved tokens."
);
}
/// @dev Checks whether the listing exists, is active, and if the lister has sufficient balance.
function _validateExistingListing(Listing memory _targetListing) internal view returns (bool isValid) {
isValid =
_targetListing.startTimestamp <= block.timestamp &&
_targetListing.endTimestamp > block.timestamp &&
_targetListing.status == IDirectListings.Status.CREATED &&
_validateOwnershipAndApproval(
_targetListing.listingCreator,
_targetListing.assetContract,
_targetListing.tokenId,
_targetListing.quantity,
_targetListing.tokenType
);
}
/// @dev Validates that `_tokenOwner` owns and has approved Marketplace to transfer NFTs.
function _validateOwnershipAndApproval(
address _tokenOwner,
address _assetContract,
uint256 _tokenId,
uint256 _quantity,
TokenType _tokenType
) internal view returns (bool isValid) {
address market = address(this);
if (_tokenType == TokenType.ERC1155) {
isValid =
IERC1155(_assetContract).balanceOf(_tokenOwner, _tokenId) >= _quantity &&
IERC1155(_assetContract).isApprovedForAll(_tokenOwner, market);
} else if (_tokenType == TokenType.ERC721) {
isValid =
IERC721(_assetContract).ownerOf(_tokenId) == _tokenOwner &&
(IERC721(_assetContract).getApproved(_tokenId) == market ||
IERC721(_assetContract).isApprovedForAll(_tokenOwner, market));
}
}
/// @dev Validates that `_tokenOwner` owns and has approved Markeplace to transfer the appropriate amount of currency
function _validateERC20BalAndAllowance(
address _tokenOwner,
address _currency,
uint256 _amount
) internal view {
require(
IERC20(_currency).balanceOf(_tokenOwner) >= _amount &&
IERC20(_currency).allowance(_tokenOwner, address(this)) >= _amount,
"!BAL20"
);
}
/// @dev Transfers tokens listed for sale in a direct or auction listing.
function _transferListingTokens(
address _from,
address _to,
uint256 _quantity,
Listing memory _listing
) internal {
if (_listing.tokenType == TokenType.ERC1155) {
IERC1155(_listing.assetContract).safeTransferFrom(_from, _to, _listing.tokenId, _quantity, "");
} else if (_listing.tokenType == TokenType.ERC721) {
IERC721(_listing.assetContract).safeTransferFrom(_from, _to, _listing.tokenId, "");
}
}
/// @dev Pays out stakeholders in a sale.
function _payout(
address _payer,
address _payee,
address _currencyToUse,
uint256 _totalPayoutAmount,
Listing memory _listing
) internal {
(address platformFeeRecipient, uint16 platformFeeBps) = PlatformFeeLogic(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(_listing.assetContract).royaltyInfo(_listing.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;
function selectListings(
uint256 _startId,
uint8 _filterFlags,
address _filterCreator,
address _filterAssetContract,
uint256 _filterTokenId,
uint32 _maxScannedItems,
uint32 _maxOutputItems)
external
view
returns (Listing[] memory _listings, uint256 _nextStartId)
{
DirectListingsStorage.Data storage data = DirectListingsStorage.directListingsStorage();
uint256 totalItems = data.totalListings;
uint256[] memory matchedItems = new uint256[](_maxOutputItems);
uint32 matchedItemsCount = 0;
while (_startId < totalItems && _maxScannedItems > 0) {
Listing memory item = data.listings[_startId];
if ((_filterFlags & FILTER_CREATOR) == 0 || item.listingCreator == _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 == IDirectListings.Status.CREATED) {
if ((_filterFlags & FILTER_ONLY_COMPLETED) == 0 || item.status == IDirectListings.Status.COMPLETED) {
if ((_filterFlags & FILTER_ONLY_VALID) == 0 || _validateExistingListing(item)) {
matchedItems[matchedItemsCount] = _startId;
unchecked { matchedItemsCount += 1; }
}
}
}
}
}
}
unchecked { ++_startId; --_maxScannedItems; }
}
_nextStartId = _startId < totalItems ? _startId : 0;
_listings = new Listing[](matchedItemsCount);
for (uint32 i = 0; i < matchedItemsCount; ) {
_listings[i] = data.listings[matchedItems[i]];
unchecked { ++i; }
}
}
}
@thirdweb-dev/contracts/extension/plugin/ReentrancyGuardStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
library ReentrancyGuardStorage {
bytes32 public constant REENTRANCY_GUARD_STORAGE_POSITION = keccak256("reentrancy.guard.storage");
struct Data {
uint256 _status;
}
function reentrancyGuardStorage() internal pure returns (Data storage reentrancyGuardData) {
bytes32 position = REENTRANCY_GUARD_STORAGE_POSITION;
assembly {
reentrancyGuardData.slot := position
}
}
}
@thirdweb-dev/contracts/interfaces/IWETH.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
interface IWETH {
function deposit() external payable;
function withdraw(uint256 amount) external;
function transfer(address to, uint256 value) external returns (bool);
}
@openzeppelin/contracts/interfaces/IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}
@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);
}
}
}
@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/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/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/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/PlatformFeeLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./PlatformFeeStorage.sol";
import "../../extension/interface/IPlatformFee.sol";
/**
* @author thirdweb.com
*
* @title Platform Fee
* @notice 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.
*/
abstract contract PlatformFeeLogic is IPlatformFee {
/// @dev Returns the platform fee recipient and bps.
function getPlatformFeeInfo() public view override returns (address, uint16) {
PlatformFeeStorage.Data storage data = PlatformFeeStorage.platformFeeStorage();
return (data.platformFeeRecipient, uint16(data.platformFeeBps));
}
/**
* @notice Updates the platform fee recipient and bps.
* @dev Caller should be authorized to set platform fee info.
* See {_canSetPlatformFeeInfo}.
* Emits {PlatformFeeInfoUpdated Event}; See {_setupPlatformFeeInfo}.
*
* @param _platformFeeRecipient Address to be set as new platformFeeRecipient.
* @param _platformFeeBps Updated platformFeeBps.
*/
function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps) external override {
if (!_canSetPlatformFeeInfo()) {
revert("Not authorized");
}
_setupPlatformFeeInfo(_platformFeeRecipient, _platformFeeBps);
}
/// @dev Lets a contract admin update the platform fee recipient and bps
function _setupPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps) internal {
PlatformFeeStorage.Data storage data = PlatformFeeStorage.platformFeeStorage();
if (_platformFeeBps > 10_000) {
revert("Exceeds max bps");
}
data.platformFeeBps = uint16(_platformFeeBps);
data.platformFeeRecipient = _platformFeeRecipient;
emit PlatformFeeInfoUpdated(_platformFeeRecipient, _platformFeeBps);
}
/// @dev Returns whether platform fee info can be set in the given execution context.
function _canSetPlatformFeeInfo() internal view virtual returns (bool);
}
@thirdweb-dev/contracts/extension/plugin/PlatformFeeStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @author thirdweb.com
*/
library PlatformFeeStorage {
bytes32 public constant PLATFORM_FEE_STORAGE_POSITION = keccak256("platform.fee.storage");
struct Data {
/// @dev The address that receives all platform fees from all sales.
address platformFeeRecipient;
/// @dev The % of primary sales collected as platform fees.
uint16 platformFeeBps;
}
function platformFeeStorage() internal pure returns (Data storage platformFeeData) {
bytes32 position = PLATFORM_FEE_STORAGE_POSITION;
assembly {
platformFeeData.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/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/direct-listings/DirectListingsStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/// @author thirdweb
import { IDirectListings } from "../IMarketplace.sol";
/**
* @author thirdweb.com
*/
library DirectListingsStorage {
bytes32 public constant DIRECT_LISTINGS_STORAGE_POSITION = keccak256("direct.listings.storage");
struct Data {
uint256 totalListings;
mapping(uint256 => IDirectListings.Listing) listings;
mapping(uint256 => mapping(address => bool)) isBuyerApprovedForListing;
mapping(uint256 => mapping(address => uint256)) currencyPriceForListing;
}
function directListingsStorage() internal pure returns (Data storage directListingsData) {
bytes32 position = DIRECT_LISTINGS_STORAGE_POSITION;
assembly {
directListingsData.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":"nonpayable","outputs":[],"name":"approveBuyerForListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"},{"type":"address","name":"_buyer","internalType":"address"},{"type":"bool","name":"_toApprove","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"approveCurrencyForListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"},{"type":"address","name":"_currency","internalType":"address"},{"type":"uint256","name":"_pricePerTokenInCurrency","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buyFromListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"},{"type":"address","name":"_buyFor","internalType":"address"},{"type":"uint256","name":"_quantity","internalType":"uint256"},{"type":"address","name":"_currency","internalType":"address"},{"type":"uint256","name":"_expectedTotalPrice","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"listingId","internalType":"uint256"}],"name":"createListing","inputs":[{"type":"tuple","name":"_params","internalType":"struct IDirectListings.ListingParameters","components":[{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint128"},{"type":"uint128"},{"type":"bool"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currencyPriceForListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"},{"type":"address","name":"_currency","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_allListings","internalType":"struct IDirectListings.Listing[]","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint128"},{"type":"uint128"},{"type":"bool"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getAllListings","inputs":[{"type":"uint256","name":"_startId","internalType":"uint256"},{"type":"uint256","name":"_endId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_validListings","internalType":"struct IDirectListings.Listing[]","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint128"},{"type":"uint128"},{"type":"bool"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getAllValidListings","inputs":[{"type":"uint256","name":"_startId","internalType":"uint256"},{"type":"uint256","name":"_endId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"listing","internalType":"struct IDirectListings.Listing","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint128"},{"type":"uint128"},{"type":"bool"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isBuyerApprovedForListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"},{"type":"address","name":"_buyer","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isCurrencyApprovedForListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"},{"type":"address","name":"_currency","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_listings","internalType":"struct IDirectListings.Listing[]","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint128"},{"type":"uint128"},{"type":"bool"},{"type":"uint8"},{"type":"uint8"}]},{"type":"uint256","name":"_nextStartId","internalType":"uint256"}],"name":"selectListings","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":"totalListings","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateListing","inputs":[{"type":"uint256","name":"_listingId","internalType":"uint256"},{"type":"tuple","name":"_params","internalType":"struct IDirectListings.ListingParameters","components":[{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint128"},{"type":"uint128"},{"type":"bool"}]}]},{"type":"event","name":"BuyerApprovedForListing","inputs":[{"type":"address","name":"listingCreator","indexed":true},{"type":"uint256","name":"listingId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"address","name":"buyer","indexed":false},{"type":"bool","name":"approved","indexed":false}],"anonymous":false},{"type":"event","name":"CancelledListing","inputs":[{"type":"address","name":"listingCreator","indexed":true},{"type":"uint256","name":"listingId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true}],"anonymous":false},{"type":"event","name":"CurrencyApprovedForListing","inputs":[{"type":"address","name":"listingCreator","indexed":true},{"type":"uint256","name":"listingId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"uint256","name":"pricePerToken","indexed":false},{"type":"address","name":"currency","indexed":false}],"anonymous":false},{"type":"event","name":"NewListing","inputs":[{"type":"address","name":"listingCreator","indexed":true},{"type":"uint256","name":"listingId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"tuple","name":"listing","indexed":false,"components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint128"},{"type":"uint128"},{"type":"bool"},{"type":"uint8"},{"type":"uint8"}]}],"anonymous":false},{"type":"event","name":"NewSale","inputs":[{"type":"address","name":"listingCreator","indexed":true},{"type":"uint256","name":"listingId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"address","name":"buyer","indexed":false},{"type":"uint256","name":"quantityBought","indexed":false},{"type":"uint256","name":"totalPricePaid","indexed":false},{"type":"address","name":"currency","indexed":false}],"anonymous":false},{"type":"event","name":"UpdatedListing","inputs":[{"type":"address","name":"listingCreator","indexed":true},{"type":"uint256","name":"listingId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"tuple","name":"listing","indexed":false,"components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint128"},{"type":"uint128"},{"type":"bool"},{"type":"uint8"},{"type":"uint8"}]}],"anonymous":false}]
Contract Creation Code
0x60a0346200007057601f62003da638819003918201601f19168301916001600160401b0383118484101762000075578084926020946040528339810103126200007057516001600160a01b03811681036200007057608052604051613d1a90816200008c8239608051816134490152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080604052600436101561001257600080fd5b60003560e01c806307b6775814610117578063107a274a14610112578063119df25f1461010d578063305a67a81461010857806331654b4d1461010357806348dd77df146100fe5780634a36e5f7146100f9578063704232dc146100f4578063746415b5146100ef5780638b49d47e146100ea5780639cfbe2a6146100e5578063a8519047146100e0578063c5275fb0146100db578063c78b616c146100d6578063ea8f9a3c146100d15763fb14079d146100cc57600080fd5b6114c9565b6112f8565b6112bb565b6111e8565b611175565b6110ff565b6110b8565b611002565b610b15565b610aa4565b61087f565b6106fe565b6105ba565b61058e565b610532565b61032d565b634e487b7160e01b600052604160045260246000fd5b610100810190811067ffffffffffffffff82111761014f57604052565b61011c565b67ffffffffffffffff811161014f57604052565b6040810190811067ffffffffffffffff82111761014f57604052565b90601f8019910116810190811067ffffffffffffffff82111761014f57604052565b60405190610180820182811067ffffffffffffffff82111761014f57604052565b6001600160a01b038116036101d857565b600080fd5b6001600160801b038116036101d857565b60c435906101fb826101dd565b565b60e435906101fb826101dd565b60a435906101fb826101dd565b801515036101d857565b61010435906101fb82610217565b60e435906101fb82610217565b6101009060231901126101d8576040519061025682610132565b81602435610263816101c7565b815260443560208201526064356040820152608435610281816101c7565b606082015260a43560808201526102966101ee565b60a08201526102a36101fd565b60c082015260e06102b2610221565b910152565b6101009060031901126101d857604051906102d182610132565b816004356102de816101c7565b8152602435602082015260443560408201526064356102fc816101c7565b6060820152608435608082015261031161020a565b60a082015261031e6101ee565b60c082015260e06102b261022f565b346101d8576101203660031901126101d85760043561034b3661023c565b81600052600080516020613cc583398151915260205260ff60086040600020015460101c16600481101561042a5760016103859114611d5b565b6001600160a01b03815116916040519263a32fa5b360e01b84527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae660048501526024840152602083604481305afa928315610425576103f5936103f0916000916103f7575b5061174f565b611e17565b005b610418915060203d811161041e575b6104108183610184565b8101906115e0565b386103ea565b503d610406565b6115f5565b634e487b7160e01b600052602160045260246000fd5b6002111561042a57565b90600282101561042a5752565b6004111561042a57565b90600482101561042a5752565b805182526020808201516001600160a01b0316908301526101fb91906040818101516001600160a01b03169083015260608101516060830152608081015160808301526104cb60a082015160a08401906001600160a01b03169052565b60c081015160c08301526104ef60e082015160e08401906001600160801b03169052565b610100818101516001600160801b03169083015261012081810151151590830152610523610140808301519084019061044a565b61016080910151910190610461565b346101d85760203660031901126101d85761054b61283e565b50600435600052600080516020613cc58339815191526020526101806105746040600020612208565b610581604051809261046e565bf35b60009103126101d857565b346101d85760003660031901126101d85760206105a9611601565b6001600160a01b0360405191168152f35b346101d85760203660031901126101d857600435600090808252600080516020613cc5833981519152908160205260ff600860408520015460101c16600481101561042a57600161060b9114611d5b565b808352816020526001600160a01b03916106388360016040872001541684610631611601565b1614611da6565b8184526020526106626040842061065d600882016203000062ff000019825416179055565b612208565b907ff6c642d3740871bb0cc3af17e90e3b3c6817bf2f664e608ef515f0b2d4619400602061068e611601565b94606081604087015116950151956040519485521692a480f35b90815180825260208080930193019160005b8281106106c8575050505090565b9091929382610180826106de600194895161046e565b019501939291016106ba565b9060206106fb9281815201906106a8565b90565b346101d85760403660031901126101d8576024356004358181111580610855575b610728906127c0565b61074261073d6107388385611676565b61280b565b6128aa565b90600090805b848111156107ce578361075a846128aa565b81516000805b828110610779576040518061077586826106ea565b0390f35b8061079061078a61079993886128fa565b51612c12565b61079e5761280b565b610760565b6107c86107ab82886128fa565b51936107b681612924565b946107c182896128fa565b52866128fa565b5061280b565b6108166107f282600052600080516020613cc5833981519152602052604060002090565b6108056107ff8585611676565b91612208565b61080f82886128fa565b52856128fa565b5061082d61078a6108278484611676565b866128fa565b610840575b61083b9061280b565b610748565b9161084d61083b9161280b565b929050610832565b507fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61354821061071f565b346101d85760603660031901126101d85760043560243561089f816101c7565b604435906108ac82610217565b600092808452600080516020613cc58339815191528060205260409360ff6008868820015460101c16600481101561042a5760016108ea9114611d5b565b828652816020526001600160a01b039161090f836001888a2001541684610631611601565b838752602052610920858720612208565b9061012082015115610a0c5790610a06826109b77f95d1943057fb89b5ee466790dce365efcbdf2a9bb48f90e9e414f788144efd7295946109a68961098e8a6000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe615602052604060002090565b906001600160a01b0316600052602052604060002090565b9060ff801983541691151516179055565b6109bf611601565b968460606109d68b8701516001600160a01b031690565b9501519951958695169816968491926001600160a01b036040929594606085019685521660208401521515910152565b0390a480f35b6084865162461bcd60e51b815260206004820152602260248201527f4d61726b6574706c6163653a206c697374696e67206e6f74207265736572766560448201527f642e0000000000000000000000000000000000000000000000000000000000006064820152fd5b60c4359063ffffffff821682036101d857565b929190610a9f6020916040865260408601906106a8565b930152565b346101d85760e03660031901126101d85760243560ff811681036101d857604435610ace816101c7565b60643591610adb836101c7565b60a4359063ffffffff821682036101d857610b0593610af8610a75565b9360843592600435613a74565b9061077560405192839283610a88565b60a03660031901126101d857602435600435610b30826101c7565b60443590606435610b40816101c7565b7fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f6002815414610fbe576002905581600052600080516020613cc583398151915260205260ff60086040600020015460101c16600481101561042a576001610ba89114611d5b565b610bcc61065d83600052600080516020613cc5833981519152602052604060002090565b93610bd5611601565b610bea610be6610120880151151590565b1590565b8015610f72575b610bfa90612554565b84151580610f64575b610c0c9061259f565b610c30610c246101008801516001600160801b031690565b6001600160801b031690565b421080610f3f575b610c41906125ea565b6020860193610c5785516001600160a01b031690565b916040880195610c98610c93610c7489516001600160a01b031690565b958a8c60608101986101408a5192015193610c8e85610440565b612ce7565b612635565b610ccf8661098e856000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b5415610ef45781610d17610d108861098e876000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b548a6126f1565b915b610d266084358414612704565b828b8b6001600160a01b03998b83858d831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146000149e7f5398195e862365e23fa3bc3091c346bd1828d83daca58f0001534c20acb7516a9f610dc3610e659e610dff9c610df29b610de298600495610ee65750610d9b9150341461274f565b88608087015114610e9157600052600080516020613cc5833981519152602052604060002090565b01610dcf878254611676565b905588516001600160a01b03168c613329565b84516001600160a01b0316613105565b516001600160a01b031690565b97610e2960a0610e188c519a516001600160a01b031690565b96519b01516001600160a01b031690565b9286604051978897169a169886936080939695919660a086019786526001600160a01b0380941660208701526040860152606085015216910152565b0390a46103f560017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b610ec96008610eb783600052600080516020613cc5833981519152602052604060002090565b01805462ff0000191662020000179055565b600052600080516020613cc5833981519152602052604060002090565b610eef92612ff3565b610d9b565b610f2a610f1a610f0e60a08c01516001600160a01b031690565b6001600160a01b031690565b6001600160a01b038816146126a6565b81610f3960c08b01518a6126f1565b91610d19565b50610c41610f5a610c2460e08901516001600160801b031690565b4210159050610c38565b506080860151851115610c03565b50610bfa610fb7610fb08361098e886000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe615602052604060002090565b5460ff1690565b9050610bf1565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b346101d8576101003660031901126101d85761101c611601565b6001600160a01b036040519163a32fa5b360e01b83527ff94103142c1baabe9ac2b5d1487bf783de9e69cfeea9a72f5c9c94afd7877b8c6004840152166024820152602081604481305afa80156104255761107f9160009161109a575b506116ec565b61077561108a61179a565b6040519081529081906020820190565b6110b2915060203d811161041e576104108183610184565b38611079565b346101d85760003660031901126101d85760406110d3611683565b919082825193849260208452816020850152848401376000828201840152601f01601f19168101030190f35b346101d85760403660031901126101d857602060ff611169602435611123816101c7565b6004356000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61584526040600020906001600160a01b0316600052602052604060002090565b54166040519015158152f35b346101d85760403660031901126101d85760206111dd602435611197816101c7565b6004356000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61683526040600020906001600160a01b0316600052602052604060002090565b541515604051908152f35b346101d8576040806003193601126101d857600435602435918282111580611291575b611214906127c0565b81830383811161128c5760019081810180911161128c57611234906128aa565b92805b8581111561124c5783518061077587826106ea565b61127f846000838152600080516020613cc5833981519152602052206112756107ff8585611676565b6107c182896128fa565b5082810180911115611237575b611660565b507fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61354831061120b565b346101d85760003660031901126101d85760207fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61354604051908152f35b346101d85760603660031901126101d857600435602435611318816101c7565b60443590600092808452600080516020613cc58339815191528060205260ff600860408720015460101c16600481101561042a5760016113589114611d5b565b8185526020527fb1b6fcc424a359a39ab8cb7e9b4f096eb7d33c984037cc276c89eebae01022826001600160a01b0361139d8160016040892001541682610631611601565b6113c161065d84600052600080516020613cc5833981519152602052604060002090565b6113d8610f0e60a08301516001600160a01b031690565b828616148015906114bc575b6113ed90612498565b611430866114288761098e886000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b541415612509565b856114688661098e876000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b55610a06611474611601565b95606061148b60408501516001600160a01b031690565b930151978460405195869516981696849160409194936001600160a01b039160608501968552602085015216910152565b5060c081015186146113e4565b346101d85760403660031901126101d8576024356004356114e9826101c7565b806000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe6169182602052611534816040600020906001600160a01b0316600052602052604060002090565b54156115765761077592611565926000526020526040600020906001600160a01b0316600052602052604060002090565b546040519081529081906020820190565b608460405162461bcd60e51b815260206004820152602160248201527f43757272656e6379206e6f7420617070726f76656420666f72206c697374696e60448201527f67000000000000000000000000000000000000000000000000000000000000006064820152fd5b908160209103126101d857516106fb81610217565b6040513d6000823e3d90fd5b60405163572b6c0560e01b8152336004820152602081602481305afa90811561042557600091611642575b501561163e5736601319013560601c90565b3390565b61165a915060203d811161041e576104108183610184565b3861162c565b634e487b7160e01b600052601160045260246000fd5b9190820391821161128c57565b60405163572b6c0560e01b8152336004820152602081602481305afa908115610425576000916116ce575b50156116c75760131936019036821161128c5760009190565b6000903690565b6116e6915060203d811161041e576104108183610184565b386116ae565b156116f357565b606460405162461bcd60e51b815260206004820152600c60248201527f214c49535445525f524f4c4500000000000000000000000000000000000000006044820152fd5b6004356106fb816101c7565b6064356106fb816101c7565b1561175657565b606460405162461bcd60e51b815260206004820152600b60248201527f2141535345545f524f4c450000000000000000000000000000000000000000006044820152fd5b6004356117a6816101c7565b60405163a32fa5b360e01b81527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae660048201526001600160a01b038092166024820152602081604481305afa801561042557611809916000916103f7575061174f565b611811612933565b9061181a611601565b61182a611825611737565b612967565b916118336119e5565b9061183c6119f1565b936001600160801b03808616908085166118578382106119fd565b421161198e575b5050803661186b906102b7565b9061187591612ade565b61187d611737565b926024359561188a611743565b91611893611b2b565b9261189c6101a6565b8a81526001600160a01b0389166020820152966001600160a01b031660408801526060870189905260443560808801526001600160a01b031660a087015260843560c08701526001600160801b031660e08601526001600160801b03166101008501521515610120840152611915906101408401611b37565b60016101608301528161193f86600052600080516020613cc5833981519152602052604060002090565b9061194991611b8f565b611951611737565b8160405192839216941692611967908783611d44565b037ff194797f7a3b28aa59aa1fed0bc4d2ac612468c554a30f539adf759e0ddb8a4091a490565b90936119ab906119a4610c249894984292611a6e565b1015611aa2565b42811693036119bd575b93388061185e565b506119e06119da6119cc6119f1565b6119d46119e5565b90611b12565b83611a87565b6119b5565b60a4356106fb816101dd565b60c4356106fb816101dd565b15611a0457565b608460405162461bcd60e51b815260206004820152603a60248201527f4d61726b6574706c6163653a20656e6454696d657374616d70206e6f7420677260448201527f6561746572207468616e20737461727454696d657374616d702e0000000000006064820152fd5b90610e106001600160801b038093160191821161128c57565b9190916001600160801b038080941691160191821161128c57565b15611aa957565b608460405162461bcd60e51b8152602060048201526024808201527f4d61726b6574706c6163653a20696e76616c696420737461727454696d65737460448201527f616d702e000000000000000000000000000000000000000000000000000000006064820152fd5b6001600160801b03918216908216039190821161128c57565b60e4356106fb81610217565b600282101561042a5752565b600482101561042a5752565b90600281101561042a5761ff0082549160081b169061ff001916179055565b90600481101561042a5762ff000082549160101b169062ff00001916179055565b9061016060086101fb9383518155611be0611bb460208601516001600160a01b031690565b60018301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b611c23611bf760408601516001600160a01b031690565b60028301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b6060840151600382015560808401516004820155611c7a611c4e60a08601516001600160a01b031690565b60058301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60c08401516006820155611cf660078201611cc7611ca260e08801516001600160801b031690565b82906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b61010086015181546001600160801b031660809190911b6fffffffffffffffffffffffffffffffff1916179055565b0191611d1b611d09610120830151151590565b849060ff801983541691151516179055565b611d33610140820151611d2d81610440565b84611b4f565b015190611d3f82610457565b611b6e565b9081526101a0810192916101fb916020019061046e565b15611d6257565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a20696e76616c6964206c697374696e672e0000006044820152fd5b15611dad57565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a206e6f74206c697374696e672063726561746f7260448201527f2e000000000000000000000000000000000000000000000000000000000000006064820152fd5b9081600052600080516020613cc58339815191526020526001600160a01b0390611e4e826001604060002001541683610631611601565b611e56611601565b918291611e7d61065d86600052600080516020613cc5833981519152602052604060002090565b90611e9261182582516001600160a01b031690565b866101009384810194611eac86516001600160801b031690565b95611ec36001600160801b039788429116116122fb565b60408301516001600160a01b031688611ee6610f0e89516001600160a01b031690565b911614806121f7575b611ef890612346565b60a0860180516001600160801b0316978860c0890191611f1f83516001600160801b031690565b96611f70610c2460e084808c16961693611f3a8786106119fd565b01611f4f610c2482516001600160801b031690565b42811180156121dc575b611f6391506123b7565b516001600160801b031690565b81141590816121d2575b50612143575b5050505050611fb8836000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b95611ffd611fec6060880198611fd58a516001600160a01b031690565b6001600160a01b0316600052602052604060002090565b548015908115612135575b50612427565b6120078587612ade565b85516001600160a01b0316602087019788519060408901519051612031906001600160a01b031690565b9160808a01519360e08b015161204690151590565b9861204f6101a6565b9081526001600160a01b039e8f1660208201529d1660408e015260608d015260808c01526001600160a01b031660a08b015260c08a01526001600160801b031660e08901526001600160801b039091169087015215156101208601526120b9906101408601611b37565b6001610160850152836120e387600052600080516020613cc5833981519152602052604060002090565b906120ed91611b8f565b516001600160a01b0316905194826040519384931695169361210f9183611d44565b037fd3121ae0c6b3b9785de05c944ecb239f232d04465d34940ed7cbd205c37bc58f91a4565b905060808801511438611ff7565b909192939961215c906119a4610c249897984292611a6e565b612173610c248242169b516001600160801b031690565b82149182156121c8575b5050156121925750505b903880808080611f80565b6121c39250906119d46121af6121bd93516001600160801b031690565b91516001600160801b031690565b86611a87565b612187565b149050388061217d565b9050421138611f7a565b508414806121ee575b611f6390611f59565b504286116121e5565b506060830151602087015114611eef565b906101fb60ff60086122186101a6565b948054865261224461223460018301546001600160a01b031690565b6001600160a01b03166020880152565b61226b61225b60028301546001600160a01b031690565b6001600160a01b03166040880152565b60038101546060870152600481015460808701526122a661229660058301546001600160a01b031690565b6001600160a01b031660a0880152565b600681015460c087015260078101546001600160801b03811660e088015260801c610100870152015481811615156101208601526122ed828260081c166101408701611b37565b60101c166101608401611b43565b1561230257565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a206c697374696e6720657870697265642e0000006044820152fd5b1561234d57565b608460405162461bcd60e51b815260206004820152603060248201527f4d61726b6574706c6163653a2063616e6e6f742075706461746520776861742060448201527f746f6b656e206973206c69737465642e000000000000000000000000000000006064820152fd5b156123be57565b608460405162461bcd60e51b8152602060048201526024808201527f4d61726b6574706c6163653a206c697374696e6720616c72656164792061637460448201527f6976652e000000000000000000000000000000000000000000000000000000006064820152fd5b1561242e57565b608460405162461bcd60e51b815260206004820152603060248201527f4d61726b6574706c6163653a20707269636520646966666572656e742066726f60448201527f6d20617070726f766564207072696365000000000000000000000000000000006064820152fd5b1561249f57565b608460405162461bcd60e51b815260206004820152603d60248201527f4d61726b6574706c6163653a20617070726f76696e67206c697374696e67206360448201527f757272656e6379207769746820646966666572656e742070726963652e0000006064820152fd5b1561251057565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a20707269636520756e6368616e6765642e0000006044820152fd5b1561255b57565b606460405162461bcd60e51b815260206004820152601260248201527f6275796572206e6f7420617070726f76656400000000000000000000000000006044820152fd5b156125a657565b606460405162461bcd60e51b815260206004820152601760248201527f427579696e6720696e76616c6964207175616e746974790000000000000000006044820152fd5b156125f157565b606460405162461bcd60e51b815260206004820152601760248201527f6e6f742077697468696e2073616c652077696e646f772e0000000000000000006044820152fd5b1561263c57565b608460405162461bcd60e51b815260206004820152602a60248201527f4d61726b6574706c6163653a206e6f74206f776e6572206f7220617070726f7660448201527f656420746f6b656e732e000000000000000000000000000000000000000000006064820152fd5b156126ad57565b606460405162461bcd60e51b815260206004820152601b60248201527f506179696e6720696e20696e76616c69642063757272656e63792e00000000006044820152fd5b8181029291811591840414171561128c57565b1561270b57565b606460405162461bcd60e51b815260206004820152601660248201527f556e657870656374656420746f74616c207072696365000000000000000000006044820152fd5b1561275657565b608460405162461bcd60e51b815260206004820152603760248201527f4d61726b6574706c6163653a206d73672e76616c7565206d757374206578616360448201527f746c792062652074686520746f74616c2070726963652e0000000000000000006064820152fd5b156127c757565b606460405162461bcd60e51b815260206004820152600d60248201527f696e76616c69642072616e6765000000000000000000000000000000000000006044820152fd5b906001820180921161128c57565b9190820180921161128c57565b67ffffffffffffffff811161014f5760051b60200190565b60405190610180820182811067ffffffffffffffff82111761014f57604052816101606000918281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201528261010082015282610120820152826101408201520152565b906128b482612826565b6128c16040519182610184565b82815280926128d2601f1991612826565b019060005b8281106128e357505050565b6020906128ee61283e565b828285010152016128d7565b805182101561290e5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b600019811461128c5760010190565b7fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61390815491600183019081841161128c5755565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082527fd9b67a260000000000000000000000000000000000000000000000000000000060048301526020926001600160a01b0316918381602481865afa90811561042557600091612ac1575b50156129e657505050600190565b6040519081527f80ac58cd000000000000000000000000000000000000000000000000000000006004820152908290829060249082905afa91821561042557600092612aa4575b505015612a3957600090565b60405162461bcd60e51b815260206004820152603460248201527f4d61726b6574706c6163653a206c697374656420746f6b656e206d757374206260448201527f652045524331313535206f72204552433732312e0000000000000000000000006064820152608490fd5b612aba9250803d1061041e576104108183610184565b3880612a2d565b612ad89150843d861161041e576104108183610184565b386129d8565b906040820190815115612ba85760018251148015612b95575b15612b2b576101fb92610c9392612b0c611601565b916020612b2082516001600160a01b031690565b910151915192612ce7565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a206c697374696e6720696e76616c69642071756160448201527f6e746974792e00000000000000000000000000000000000000000000000000006064820152fd5b50612b9f81610440565b60018114612af7565b608460405162461bcd60e51b815260206004820152602360248201527f4d61726b6574706c6163653a206c697374696e67207a65726f207175616e746960448201527f74792e00000000000000000000000000000000000000000000000000000000006064820152fd5b60e0810151426001600160801b0390911611159081612ca1575b81612c7e575b81612c3b575090565b60208101516106fb92506001600160a01b031690612c6360408201516001600160a01b031690565b606082015190610140608084015193015193610c8e85610440565b90506001610160820151612c9181610457565b612c9a81610457565b1490612c32565b905042612cbc610c246101008401516001600160801b031690565b1190612c2c565b908160209103126101d857516106fb816101c7565b908160209103126101d8575190565b929193600090612cf681610440565b60018103612e035750506040517efdd58e0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526024820195909552931692602091908281604481885afa90811561042557600091612dd6575b5010159182612d6c575b5050905090565b60405163e985e9c560e01b81526001600160a01b0391909116600482015230602482015290929091508290829060449082905afa91821561042557600092612db9575b5050803880612d65565b612dcf9250803d1061041e576104108183610184565b3880612daf565b612df69150833d8511612dfc575b612dee8183610184565b810190612cd8565b38612d5b565b503d612de4565b90959493919250612e1381610440565b15612e1d57505050565b6040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810184905293945091926001600160a01b0391821692916020918281602481885afa90811561042557600091612f8b575b508116838216149485612e8c575b505050505090565b6040517f081812fc0000000000000000000000000000000000000000000000000000000081526004810191909152939450919290918282602481885afa91821561042557600092612f5c575b50163014918215612ef2575b505090503880808080612e84565b60405163e985e9c560e01b81526001600160a01b0391909116600482015230602482015290929091508290829060449082905afa91821561042557600092612f3f575b5050803880612ee4565b612f559250803d1061041e576104108183610184565b3880612f35565b612f7d919250833d8511612f84575b612f758183610184565b810190612cc3565b9038612ed8565b503d612f6b565b612fa29150833d8511612f8457612f758183610184565b38612e76565b15612faf57565b606460405162461bcd60e51b815260206004820152600660248201527f2142414c323000000000000000000000000000000000000000000000000000006044820152fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b03828116600483015260209493169291908481602481875afa80156104255783916000916130e8575b5010159283613060575b5050506101fb9150612fa8565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081526001600160a01b03929092166004830152306024830152919250908390829060449082905afa908115610425576101fb936000926130cb575b50501015388080613053565b6130e19250803d10612dfc57612dee8183610184565b38806130bf565b6130ff9150863d8811612dfc57612dee8183610184565b38613049565b919261014081016001815161311981610440565b61312281610440565b036131e057506060613144610f0e610f0e60408501516001600160a01b031690565b91015191813b156101d857600080946131bc604051978896879586947ff242432a00000000000000000000000000000000000000000000000000000000865260048601929060c094926001600160a01b0380921685521660208401526040830152606082015260a06080820152600060a08201520190565b03925af18015610425576131cd5750565b806131da6101fb92610154565b80610583565b90919350516131ee81610440565b6131f781610440565b1561320157505050565b606061321d610f0e610f0e60408501516001600160a01b031690565b91015190803b156101d8576040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b03938416600482015293909216602484015260448301526080606483015260006084830181905290829060a490829084905af18015610425576131cd5750565b91908260409103126101d857602082516132ae816101c7565b92015161ffff811681036101d85790565b91908260409103126101d857602082516132d8816101c7565b92015190565b156132e557565b606460405162461bcd60e51b815260206004820152601560248201527f66656573206578636565642074686520707269636500000000000000000000006044820152fd5b6040938451947fd45573f60000000000000000000000000000000000000000000000000000000086528086600481305afa968715610425576101fb97600097889161352f575b5091613483916134296134899594996001600160a01b039a73716992d45bc60e9ead5f59206c0d049afbff429f8c8c1614613527575b6133b661ffff6133be9216886126f1565b612710900490565b9a8b936000958692818a859460606133e5610f0e610f0e868501516001600160a01b031690565b9101518351809a819482937f2a55205a0000000000000000000000000000000000000000000000000000000084526004840160209093929193604081019481520152565b03915afa8096859386986134f0575b50506134a2575b505061347e93508b7f000000000000000000000000000000000000000000000000000000000000000086819f958d839761348f575b93925050506135be565b612819565b90611676565b926135be565b613498946135be565b8b8386388d613474565b90809294959350161515806134e7575b6134c1575b918392869261343f565b90945061347e9291506134df876134d88688612819565b11156132de565b9091386134b7565b508115156134b2565b8091929850613515939450903d10613520575b61350d8183610184565b8101906132bf565b919091953880613438565b503d613503565b5060006133a5565b61342998508391509161355e6134839361348996953d851161356c575b6135568183610184565b810190613295565b99909992949550509161336f565b503d61354c565b1561357a57565b606460405162461bcd60e51b815260206004820152601360248201527f6d73672e76616c756520213d20616d6f756e74000000000000000000000000006044820152fd5b909392919382156136d1576001600160a01b039180831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee036136c257508116300361366e57821692833b156101d857600060405180957f2e1a7d4d00000000000000000000000000000000000000000000000000000000825281838161364188600483019190602083019252565b03925af1938415610425576101fb9461365b575b506137b2565b806131da61366892610154565b38613655565b91909230838216146000146136b65750613689348414613573565b16803b156101d857600090600460405180948193630d0e30db60e41b83525af18015610425576131cd5750565b6101fb939192506137b2565b9091506101fb949293506136d8565b5050505050565b9291906001600160a01b0390811681831681811461376a573082036137035750506101fb931661382a565b9093919250604051937f23b872dd0000000000000000000000000000000000000000000000000000000060208601526024850152604484015260648301526064825260a082019282841067ffffffffffffffff85111761014f576101fb93604052166138f5565b505050505050565b3d156137ad573d9067ffffffffffffffff821161014f57604051916137a1601f8201601f191660200184610184565b82523d6000602084013e565b606090565b6000928380808086865af16137c5613772565b50156137d2575b50505050565b6001600160a01b0316803b156138265760405193630d0e30db60e41b85528460048186855af19384156104255761380e94613817575b5061382a565b388080806137cc565b61382090610154565b38613808565b8380fd5b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000060208201526001600160a01b039290921660248301526044808301939093529181526101fb9161387f606483610184565b6138f5565b1561388b57565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b0316906040519061390c82610168565b6020928383527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656484840152803b15613983576000828192828761395e9796519301915af1613958613772565b906139c7565b8051908161396b57505050565b826101fb9361397e9383010191016115e0565b613884565b6064846040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b909190156139d3575090565b8151156139e35750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510613a29575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350613a06565b90613a4c82612826565b613a596040519182610184565b8281528092613a6a601f1991612826565b0190602036910137565b9691909294937fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe6135495613aad63ffffffff809916613a42565b938860009a5b89811080613cb9575b15613c2857613ae561065d82600052600080516020613cc5833981519152602052604060002090565b60808916158015613c0f575b613b08575b50600101976000190116968990613ab3565b6040808a1615908115613bf6575b50613b21575b613af6565b60208916158015613be9575b15613af65760048916158015613bc8575b15613af6576002808a1615908115613ba7575b5015613b1c5790915060019081891615908115613b97575b50613b77575b908a91613af6565b8a6001918d849e94613b8c848097168c6128fa565b5201169b9150613b6f565b613ba19150612c12565b38613b69565b9050610160820151613bb881610457565b613bc181610457565b1438613b51565b506001610160820151613bda81610457565b613be381610457565b14613b3e565b5085606082015114613b2d565b8201516001600160a01b03878116911614905038613b16565b5060208101516001600160a01b03888116911614613af1565b959750955096925050506000908210600014613cb257505b941690613c4c826128aa565b9460005b85811684811015613caa578691613ca282613c9161065d613c736001968a6128fa565b51600052600080516020613cc5833981519152602052604060002090565b613c9b828d6128fa565b528a6128fa565b500116613c50565b505093505050565b9050613c40565b508189161515613abc56febde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe614a2646970667358221220c7316cbf917ca7c8e54b07205768587be270b352adaf6fcb5ca84b541ed2b3b664736f6c6343000812003300000000000000000000000070499adebb11efd915e3b69e700c331778628707
Deployed ByteCode
0x6080604052600436101561001257600080fd5b60003560e01c806307b6775814610117578063107a274a14610112578063119df25f1461010d578063305a67a81461010857806331654b4d1461010357806348dd77df146100fe5780634a36e5f7146100f9578063704232dc146100f4578063746415b5146100ef5780638b49d47e146100ea5780639cfbe2a6146100e5578063a8519047146100e0578063c5275fb0146100db578063c78b616c146100d6578063ea8f9a3c146100d15763fb14079d146100cc57600080fd5b6114c9565b6112f8565b6112bb565b6111e8565b611175565b6110ff565b6110b8565b611002565b610b15565b610aa4565b61087f565b6106fe565b6105ba565b61058e565b610532565b61032d565b634e487b7160e01b600052604160045260246000fd5b610100810190811067ffffffffffffffff82111761014f57604052565b61011c565b67ffffffffffffffff811161014f57604052565b6040810190811067ffffffffffffffff82111761014f57604052565b90601f8019910116810190811067ffffffffffffffff82111761014f57604052565b60405190610180820182811067ffffffffffffffff82111761014f57604052565b6001600160a01b038116036101d857565b600080fd5b6001600160801b038116036101d857565b60c435906101fb826101dd565b565b60e435906101fb826101dd565b60a435906101fb826101dd565b801515036101d857565b61010435906101fb82610217565b60e435906101fb82610217565b6101009060231901126101d8576040519061025682610132565b81602435610263816101c7565b815260443560208201526064356040820152608435610281816101c7565b606082015260a43560808201526102966101ee565b60a08201526102a36101fd565b60c082015260e06102b2610221565b910152565b6101009060031901126101d857604051906102d182610132565b816004356102de816101c7565b8152602435602082015260443560408201526064356102fc816101c7565b6060820152608435608082015261031161020a565b60a082015261031e6101ee565b60c082015260e06102b261022f565b346101d8576101203660031901126101d85760043561034b3661023c565b81600052600080516020613cc583398151915260205260ff60086040600020015460101c16600481101561042a5760016103859114611d5b565b6001600160a01b03815116916040519263a32fa5b360e01b84527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae660048501526024840152602083604481305afa928315610425576103f5936103f0916000916103f7575b5061174f565b611e17565b005b610418915060203d811161041e575b6104108183610184565b8101906115e0565b386103ea565b503d610406565b6115f5565b634e487b7160e01b600052602160045260246000fd5b6002111561042a57565b90600282101561042a5752565b6004111561042a57565b90600482101561042a5752565b805182526020808201516001600160a01b0316908301526101fb91906040818101516001600160a01b03169083015260608101516060830152608081015160808301526104cb60a082015160a08401906001600160a01b03169052565b60c081015160c08301526104ef60e082015160e08401906001600160801b03169052565b610100818101516001600160801b03169083015261012081810151151590830152610523610140808301519084019061044a565b61016080910151910190610461565b346101d85760203660031901126101d85761054b61283e565b50600435600052600080516020613cc58339815191526020526101806105746040600020612208565b610581604051809261046e565bf35b60009103126101d857565b346101d85760003660031901126101d85760206105a9611601565b6001600160a01b0360405191168152f35b346101d85760203660031901126101d857600435600090808252600080516020613cc5833981519152908160205260ff600860408520015460101c16600481101561042a57600161060b9114611d5b565b808352816020526001600160a01b03916106388360016040872001541684610631611601565b1614611da6565b8184526020526106626040842061065d600882016203000062ff000019825416179055565b612208565b907ff6c642d3740871bb0cc3af17e90e3b3c6817bf2f664e608ef515f0b2d4619400602061068e611601565b94606081604087015116950151956040519485521692a480f35b90815180825260208080930193019160005b8281106106c8575050505090565b9091929382610180826106de600194895161046e565b019501939291016106ba565b9060206106fb9281815201906106a8565b90565b346101d85760403660031901126101d8576024356004358181111580610855575b610728906127c0565b61074261073d6107388385611676565b61280b565b6128aa565b90600090805b848111156107ce578361075a846128aa565b81516000805b828110610779576040518061077586826106ea565b0390f35b8061079061078a61079993886128fa565b51612c12565b61079e5761280b565b610760565b6107c86107ab82886128fa565b51936107b681612924565b946107c182896128fa565b52866128fa565b5061280b565b6108166107f282600052600080516020613cc5833981519152602052604060002090565b6108056107ff8585611676565b91612208565b61080f82886128fa565b52856128fa565b5061082d61078a6108278484611676565b866128fa565b610840575b61083b9061280b565b610748565b9161084d61083b9161280b565b929050610832565b507fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61354821061071f565b346101d85760603660031901126101d85760043560243561089f816101c7565b604435906108ac82610217565b600092808452600080516020613cc58339815191528060205260409360ff6008868820015460101c16600481101561042a5760016108ea9114611d5b565b828652816020526001600160a01b039161090f836001888a2001541684610631611601565b838752602052610920858720612208565b9061012082015115610a0c5790610a06826109b77f95d1943057fb89b5ee466790dce365efcbdf2a9bb48f90e9e414f788144efd7295946109a68961098e8a6000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe615602052604060002090565b906001600160a01b0316600052602052604060002090565b9060ff801983541691151516179055565b6109bf611601565b968460606109d68b8701516001600160a01b031690565b9501519951958695169816968491926001600160a01b036040929594606085019685521660208401521515910152565b0390a480f35b6084865162461bcd60e51b815260206004820152602260248201527f4d61726b6574706c6163653a206c697374696e67206e6f74207265736572766560448201527f642e0000000000000000000000000000000000000000000000000000000000006064820152fd5b60c4359063ffffffff821682036101d857565b929190610a9f6020916040865260408601906106a8565b930152565b346101d85760e03660031901126101d85760243560ff811681036101d857604435610ace816101c7565b60643591610adb836101c7565b60a4359063ffffffff821682036101d857610b0593610af8610a75565b9360843592600435613a74565b9061077560405192839283610a88565b60a03660031901126101d857602435600435610b30826101c7565b60443590606435610b40816101c7565b7fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f6002815414610fbe576002905581600052600080516020613cc583398151915260205260ff60086040600020015460101c16600481101561042a576001610ba89114611d5b565b610bcc61065d83600052600080516020613cc5833981519152602052604060002090565b93610bd5611601565b610bea610be6610120880151151590565b1590565b8015610f72575b610bfa90612554565b84151580610f64575b610c0c9061259f565b610c30610c246101008801516001600160801b031690565b6001600160801b031690565b421080610f3f575b610c41906125ea565b6020860193610c5785516001600160a01b031690565b916040880195610c98610c93610c7489516001600160a01b031690565b958a8c60608101986101408a5192015193610c8e85610440565b612ce7565b612635565b610ccf8661098e856000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b5415610ef45781610d17610d108861098e876000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b548a6126f1565b915b610d266084358414612704565b828b8b6001600160a01b03998b83858d831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee146000149e7f5398195e862365e23fa3bc3091c346bd1828d83daca58f0001534c20acb7516a9f610dc3610e659e610dff9c610df29b610de298600495610ee65750610d9b9150341461274f565b88608087015114610e9157600052600080516020613cc5833981519152602052604060002090565b01610dcf878254611676565b905588516001600160a01b03168c613329565b84516001600160a01b0316613105565b516001600160a01b031690565b97610e2960a0610e188c519a516001600160a01b031690565b96519b01516001600160a01b031690565b9286604051978897169a169886936080939695919660a086019786526001600160a01b0380941660208701526040860152606085015216910152565b0390a46103f560017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b610ec96008610eb783600052600080516020613cc5833981519152602052604060002090565b01805462ff0000191662020000179055565b600052600080516020613cc5833981519152602052604060002090565b610eef92612ff3565b610d9b565b610f2a610f1a610f0e60a08c01516001600160a01b031690565b6001600160a01b031690565b6001600160a01b038816146126a6565b81610f3960c08b01518a6126f1565b91610d19565b50610c41610f5a610c2460e08901516001600160801b031690565b4210159050610c38565b506080860151851115610c03565b50610bfa610fb7610fb08361098e886000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe615602052604060002090565b5460ff1690565b9050610bf1565b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b346101d8576101003660031901126101d85761101c611601565b6001600160a01b036040519163a32fa5b360e01b83527ff94103142c1baabe9ac2b5d1487bf783de9e69cfeea9a72f5c9c94afd7877b8c6004840152166024820152602081604481305afa80156104255761107f9160009161109a575b506116ec565b61077561108a61179a565b6040519081529081906020820190565b6110b2915060203d811161041e576104108183610184565b38611079565b346101d85760003660031901126101d85760406110d3611683565b919082825193849260208452816020850152848401376000828201840152601f01601f19168101030190f35b346101d85760403660031901126101d857602060ff611169602435611123816101c7565b6004356000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61584526040600020906001600160a01b0316600052602052604060002090565b54166040519015158152f35b346101d85760403660031901126101d85760206111dd602435611197816101c7565b6004356000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61683526040600020906001600160a01b0316600052602052604060002090565b541515604051908152f35b346101d8576040806003193601126101d857600435602435918282111580611291575b611214906127c0565b81830383811161128c5760019081810180911161128c57611234906128aa565b92805b8581111561124c5783518061077587826106ea565b61127f846000838152600080516020613cc5833981519152602052206112756107ff8585611676565b6107c182896128fa565b5082810180911115611237575b611660565b507fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61354831061120b565b346101d85760003660031901126101d85760207fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61354604051908152f35b346101d85760603660031901126101d857600435602435611318816101c7565b60443590600092808452600080516020613cc58339815191528060205260ff600860408720015460101c16600481101561042a5760016113589114611d5b565b8185526020527fb1b6fcc424a359a39ab8cb7e9b4f096eb7d33c984037cc276c89eebae01022826001600160a01b0361139d8160016040892001541682610631611601565b6113c161065d84600052600080516020613cc5833981519152602052604060002090565b6113d8610f0e60a08301516001600160a01b031690565b828616148015906114bc575b6113ed90612498565b611430866114288761098e886000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b541415612509565b856114688661098e876000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b55610a06611474611601565b95606061148b60408501516001600160a01b031690565b930151978460405195869516981696849160409194936001600160a01b039160608501968552602085015216910152565b5060c081015186146113e4565b346101d85760403660031901126101d8576024356004356114e9826101c7565b806000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe6169182602052611534816040600020906001600160a01b0316600052602052604060002090565b54156115765761077592611565926000526020526040600020906001600160a01b0316600052602052604060002090565b546040519081529081906020820190565b608460405162461bcd60e51b815260206004820152602160248201527f43757272656e6379206e6f7420617070726f76656420666f72206c697374696e60448201527f67000000000000000000000000000000000000000000000000000000000000006064820152fd5b908160209103126101d857516106fb81610217565b6040513d6000823e3d90fd5b60405163572b6c0560e01b8152336004820152602081602481305afa90811561042557600091611642575b501561163e5736601319013560601c90565b3390565b61165a915060203d811161041e576104108183610184565b3861162c565b634e487b7160e01b600052601160045260246000fd5b9190820391821161128c57565b60405163572b6c0560e01b8152336004820152602081602481305afa908115610425576000916116ce575b50156116c75760131936019036821161128c5760009190565b6000903690565b6116e6915060203d811161041e576104108183610184565b386116ae565b156116f357565b606460405162461bcd60e51b815260206004820152600c60248201527f214c49535445525f524f4c4500000000000000000000000000000000000000006044820152fd5b6004356106fb816101c7565b6064356106fb816101c7565b1561175657565b606460405162461bcd60e51b815260206004820152600b60248201527f2141535345545f524f4c450000000000000000000000000000000000000000006044820152fd5b6004356117a6816101c7565b60405163a32fa5b360e01b81527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae660048201526001600160a01b038092166024820152602081604481305afa801561042557611809916000916103f7575061174f565b611811612933565b9061181a611601565b61182a611825611737565b612967565b916118336119e5565b9061183c6119f1565b936001600160801b03808616908085166118578382106119fd565b421161198e575b5050803661186b906102b7565b9061187591612ade565b61187d611737565b926024359561188a611743565b91611893611b2b565b9261189c6101a6565b8a81526001600160a01b0389166020820152966001600160a01b031660408801526060870189905260443560808801526001600160a01b031660a087015260843560c08701526001600160801b031660e08601526001600160801b03166101008501521515610120840152611915906101408401611b37565b60016101608301528161193f86600052600080516020613cc5833981519152602052604060002090565b9061194991611b8f565b611951611737565b8160405192839216941692611967908783611d44565b037ff194797f7a3b28aa59aa1fed0bc4d2ac612468c554a30f539adf759e0ddb8a4091a490565b90936119ab906119a4610c249894984292611a6e565b1015611aa2565b42811693036119bd575b93388061185e565b506119e06119da6119cc6119f1565b6119d46119e5565b90611b12565b83611a87565b6119b5565b60a4356106fb816101dd565b60c4356106fb816101dd565b15611a0457565b608460405162461bcd60e51b815260206004820152603a60248201527f4d61726b6574706c6163653a20656e6454696d657374616d70206e6f7420677260448201527f6561746572207468616e20737461727454696d657374616d702e0000000000006064820152fd5b90610e106001600160801b038093160191821161128c57565b9190916001600160801b038080941691160191821161128c57565b15611aa957565b608460405162461bcd60e51b8152602060048201526024808201527f4d61726b6574706c6163653a20696e76616c696420737461727454696d65737460448201527f616d702e000000000000000000000000000000000000000000000000000000006064820152fd5b6001600160801b03918216908216039190821161128c57565b60e4356106fb81610217565b600282101561042a5752565b600482101561042a5752565b90600281101561042a5761ff0082549160081b169061ff001916179055565b90600481101561042a5762ff000082549160101b169062ff00001916179055565b9061016060086101fb9383518155611be0611bb460208601516001600160a01b031690565b60018301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b611c23611bf760408601516001600160a01b031690565b60028301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b6060840151600382015560808401516004820155611c7a611c4e60a08601516001600160a01b031690565b60058301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60c08401516006820155611cf660078201611cc7611ca260e08801516001600160801b031690565b82906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b61010086015181546001600160801b031660809190911b6fffffffffffffffffffffffffffffffff1916179055565b0191611d1b611d09610120830151151590565b849060ff801983541691151516179055565b611d33610140820151611d2d81610440565b84611b4f565b015190611d3f82610457565b611b6e565b9081526101a0810192916101fb916020019061046e565b15611d6257565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a20696e76616c6964206c697374696e672e0000006044820152fd5b15611dad57565b608460405162461bcd60e51b815260206004820152602160248201527f4d61726b6574706c6163653a206e6f74206c697374696e672063726561746f7260448201527f2e000000000000000000000000000000000000000000000000000000000000006064820152fd5b9081600052600080516020613cc58339815191526020526001600160a01b0390611e4e826001604060002001541683610631611601565b611e56611601565b918291611e7d61065d86600052600080516020613cc5833981519152602052604060002090565b90611e9261182582516001600160a01b031690565b866101009384810194611eac86516001600160801b031690565b95611ec36001600160801b039788429116116122fb565b60408301516001600160a01b031688611ee6610f0e89516001600160a01b031690565b911614806121f7575b611ef890612346565b60a0860180516001600160801b0316978860c0890191611f1f83516001600160801b031690565b96611f70610c2460e084808c16961693611f3a8786106119fd565b01611f4f610c2482516001600160801b031690565b42811180156121dc575b611f6391506123b7565b516001600160801b031690565b81141590816121d2575b50612143575b5050505050611fb8836000527fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe616602052604060002090565b95611ffd611fec6060880198611fd58a516001600160a01b031690565b6001600160a01b0316600052602052604060002090565b548015908115612135575b50612427565b6120078587612ade565b85516001600160a01b0316602087019788519060408901519051612031906001600160a01b031690565b9160808a01519360e08b015161204690151590565b9861204f6101a6565b9081526001600160a01b039e8f1660208201529d1660408e015260608d015260808c01526001600160a01b031660a08b015260c08a01526001600160801b031660e08901526001600160801b039091169087015215156101208601526120b9906101408601611b37565b6001610160850152836120e387600052600080516020613cc5833981519152602052604060002090565b906120ed91611b8f565b516001600160a01b0316905194826040519384931695169361210f9183611d44565b037fd3121ae0c6b3b9785de05c944ecb239f232d04465d34940ed7cbd205c37bc58f91a4565b905060808801511438611ff7565b909192939961215c906119a4610c249897984292611a6e565b612173610c248242169b516001600160801b031690565b82149182156121c8575b5050156121925750505b903880808080611f80565b6121c39250906119d46121af6121bd93516001600160801b031690565b91516001600160801b031690565b86611a87565b612187565b149050388061217d565b9050421138611f7a565b508414806121ee575b611f6390611f59565b504286116121e5565b506060830151602087015114611eef565b906101fb60ff60086122186101a6565b948054865261224461223460018301546001600160a01b031690565b6001600160a01b03166020880152565b61226b61225b60028301546001600160a01b031690565b6001600160a01b03166040880152565b60038101546060870152600481015460808701526122a661229660058301546001600160a01b031690565b6001600160a01b031660a0880152565b600681015460c087015260078101546001600160801b03811660e088015260801c610100870152015481811615156101208601526122ed828260081c166101408701611b37565b60101c166101608401611b43565b1561230257565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a206c697374696e6720657870697265642e0000006044820152fd5b1561234d57565b608460405162461bcd60e51b815260206004820152603060248201527f4d61726b6574706c6163653a2063616e6e6f742075706461746520776861742060448201527f746f6b656e206973206c69737465642e000000000000000000000000000000006064820152fd5b156123be57565b608460405162461bcd60e51b8152602060048201526024808201527f4d61726b6574706c6163653a206c697374696e6720616c72656164792061637460448201527f6976652e000000000000000000000000000000000000000000000000000000006064820152fd5b1561242e57565b608460405162461bcd60e51b815260206004820152603060248201527f4d61726b6574706c6163653a20707269636520646966666572656e742066726f60448201527f6d20617070726f766564207072696365000000000000000000000000000000006064820152fd5b1561249f57565b608460405162461bcd60e51b815260206004820152603d60248201527f4d61726b6574706c6163653a20617070726f76696e67206c697374696e67206360448201527f757272656e6379207769746820646966666572656e742070726963652e0000006064820152fd5b1561251057565b606460405162461bcd60e51b815260206004820152601d60248201527f4d61726b6574706c6163653a20707269636520756e6368616e6765642e0000006044820152fd5b1561255b57565b606460405162461bcd60e51b815260206004820152601260248201527f6275796572206e6f7420617070726f76656400000000000000000000000000006044820152fd5b156125a657565b606460405162461bcd60e51b815260206004820152601760248201527f427579696e6720696e76616c6964207175616e746974790000000000000000006044820152fd5b156125f157565b606460405162461bcd60e51b815260206004820152601760248201527f6e6f742077697468696e2073616c652077696e646f772e0000000000000000006044820152fd5b1561263c57565b608460405162461bcd60e51b815260206004820152602a60248201527f4d61726b6574706c6163653a206e6f74206f776e6572206f7220617070726f7660448201527f656420746f6b656e732e000000000000000000000000000000000000000000006064820152fd5b156126ad57565b606460405162461bcd60e51b815260206004820152601b60248201527f506179696e6720696e20696e76616c69642063757272656e63792e00000000006044820152fd5b8181029291811591840414171561128c57565b1561270b57565b606460405162461bcd60e51b815260206004820152601660248201527f556e657870656374656420746f74616c207072696365000000000000000000006044820152fd5b1561275657565b608460405162461bcd60e51b815260206004820152603760248201527f4d61726b6574706c6163653a206d73672e76616c7565206d757374206578616360448201527f746c792062652074686520746f74616c2070726963652e0000000000000000006064820152fd5b156127c757565b606460405162461bcd60e51b815260206004820152600d60248201527f696e76616c69642072616e6765000000000000000000000000000000000000006044820152fd5b906001820180921161128c57565b9190820180921161128c57565b67ffffffffffffffff811161014f5760051b60200190565b60405190610180820182811067ffffffffffffffff82111761014f57604052816101606000918281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e08201528261010082015282610120820152826101408201520152565b906128b482612826565b6128c16040519182610184565b82815280926128d2601f1991612826565b019060005b8281106128e357505050565b6020906128ee61283e565b828285010152016128d7565b805182101561290e5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b600019811461128c5760010190565b7fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe61390815491600183019081841161128c5755565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082527fd9b67a260000000000000000000000000000000000000000000000000000000060048301526020926001600160a01b0316918381602481865afa90811561042557600091612ac1575b50156129e657505050600190565b6040519081527f80ac58cd000000000000000000000000000000000000000000000000000000006004820152908290829060249082905afa91821561042557600092612aa4575b505015612a3957600090565b60405162461bcd60e51b815260206004820152603460248201527f4d61726b6574706c6163653a206c697374656420746f6b656e206d757374206260448201527f652045524331313535206f72204552433732312e0000000000000000000000006064820152608490fd5b612aba9250803d1061041e576104108183610184565b3880612a2d565b612ad89150843d861161041e576104108183610184565b386129d8565b906040820190815115612ba85760018251148015612b95575b15612b2b576101fb92610c9392612b0c611601565b916020612b2082516001600160a01b031690565b910151915192612ce7565b608460405162461bcd60e51b815260206004820152602660248201527f4d61726b6574706c6163653a206c697374696e6720696e76616c69642071756160448201527f6e746974792e00000000000000000000000000000000000000000000000000006064820152fd5b50612b9f81610440565b60018114612af7565b608460405162461bcd60e51b815260206004820152602360248201527f4d61726b6574706c6163653a206c697374696e67207a65726f207175616e746960448201527f74792e00000000000000000000000000000000000000000000000000000000006064820152fd5b60e0810151426001600160801b0390911611159081612ca1575b81612c7e575b81612c3b575090565b60208101516106fb92506001600160a01b031690612c6360408201516001600160a01b031690565b606082015190610140608084015193015193610c8e85610440565b90506001610160820151612c9181610457565b612c9a81610457565b1490612c32565b905042612cbc610c246101008401516001600160801b031690565b1190612c2c565b908160209103126101d857516106fb816101c7565b908160209103126101d8575190565b929193600090612cf681610440565b60018103612e035750506040517efdd58e0000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301526024820195909552931692602091908281604481885afa90811561042557600091612dd6575b5010159182612d6c575b5050905090565b60405163e985e9c560e01b81526001600160a01b0391909116600482015230602482015290929091508290829060449082905afa91821561042557600092612db9575b5050803880612d65565b612dcf9250803d1061041e576104108183610184565b3880612daf565b612df69150833d8511612dfc575b612dee8183610184565b810190612cd8565b38612d5b565b503d612de4565b90959493919250612e1381610440565b15612e1d57505050565b6040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810184905293945091926001600160a01b0391821692916020918281602481885afa90811561042557600091612f8b575b508116838216149485612e8c575b505050505090565b6040517f081812fc0000000000000000000000000000000000000000000000000000000081526004810191909152939450919290918282602481885afa91821561042557600092612f5c575b50163014918215612ef2575b505090503880808080612e84565b60405163e985e9c560e01b81526001600160a01b0391909116600482015230602482015290929091508290829060449082905afa91821561042557600092612f3f575b5050803880612ee4565b612f559250803d1061041e576104108183610184565b3880612f35565b612f7d919250833d8511612f84575b612f758183610184565b810190612cc3565b9038612ed8565b503d612f6b565b612fa29150833d8511612f8457612f758183610184565b38612e76565b15612faf57565b606460405162461bcd60e51b815260206004820152600660248201527f2142414c323000000000000000000000000000000000000000000000000000006044820152fd5b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b03828116600483015260209493169291908481602481875afa80156104255783916000916130e8575b5010159283613060575b5050506101fb9150612fa8565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081526001600160a01b03929092166004830152306024830152919250908390829060449082905afa908115610425576101fb936000926130cb575b50501015388080613053565b6130e19250803d10612dfc57612dee8183610184565b38806130bf565b6130ff9150863d8811612dfc57612dee8183610184565b38613049565b919261014081016001815161311981610440565b61312281610440565b036131e057506060613144610f0e610f0e60408501516001600160a01b031690565b91015191813b156101d857600080946131bc604051978896879586947ff242432a00000000000000000000000000000000000000000000000000000000865260048601929060c094926001600160a01b0380921685521660208401526040830152606082015260a06080820152600060a08201520190565b03925af18015610425576131cd5750565b806131da6101fb92610154565b80610583565b90919350516131ee81610440565b6131f781610440565b1561320157505050565b606061321d610f0e610f0e60408501516001600160a01b031690565b91015190803b156101d8576040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b03938416600482015293909216602484015260448301526080606483015260006084830181905290829060a490829084905af18015610425576131cd5750565b91908260409103126101d857602082516132ae816101c7565b92015161ffff811681036101d85790565b91908260409103126101d857602082516132d8816101c7565b92015190565b156132e557565b606460405162461bcd60e51b815260206004820152601560248201527f66656573206578636565642074686520707269636500000000000000000000006044820152fd5b6040938451947fd45573f60000000000000000000000000000000000000000000000000000000086528086600481305afa968715610425576101fb97600097889161352f575b5091613483916134296134899594996001600160a01b039a73716992d45bc60e9ead5f59206c0d049afbff429f8c8c1614613527575b6133b661ffff6133be9216886126f1565b612710900490565b9a8b936000958692818a859460606133e5610f0e610f0e868501516001600160a01b031690565b9101518351809a819482937f2a55205a0000000000000000000000000000000000000000000000000000000084526004840160209093929193604081019481520152565b03915afa8096859386986134f0575b50506134a2575b505061347e93508b7f00000000000000000000000070499adebb11efd915e3b69e700c33177862870786819f958d839761348f575b93925050506135be565b612819565b90611676565b926135be565b613498946135be565b8b8386388d613474565b90809294959350161515806134e7575b6134c1575b918392869261343f565b90945061347e9291506134df876134d88688612819565b11156132de565b9091386134b7565b508115156134b2565b8091929850613515939450903d10613520575b61350d8183610184565b8101906132bf565b919091953880613438565b503d613503565b5060006133a5565b61342998508391509161355e6134839361348996953d851161356c575b6135568183610184565b810190613295565b99909992949550509161336f565b503d61354c565b1561357a57565b606460405162461bcd60e51b815260206004820152601360248201527f6d73672e76616c756520213d20616d6f756e74000000000000000000000000006044820152fd5b909392919382156136d1576001600160a01b039180831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee036136c257508116300361366e57821692833b156101d857600060405180957f2e1a7d4d00000000000000000000000000000000000000000000000000000000825281838161364188600483019190602083019252565b03925af1938415610425576101fb9461365b575b506137b2565b806131da61366892610154565b38613655565b91909230838216146000146136b65750613689348414613573565b16803b156101d857600090600460405180948193630d0e30db60e41b83525af18015610425576131cd5750565b6101fb939192506137b2565b9091506101fb949293506136d8565b5050505050565b9291906001600160a01b0390811681831681811461376a573082036137035750506101fb931661382a565b9093919250604051937f23b872dd0000000000000000000000000000000000000000000000000000000060208601526024850152604484015260648301526064825260a082019282841067ffffffffffffffff85111761014f576101fb93604052166138f5565b505050505050565b3d156137ad573d9067ffffffffffffffff821161014f57604051916137a1601f8201601f191660200184610184565b82523d6000602084013e565b606090565b6000928380808086865af16137c5613772565b50156137d2575b50505050565b6001600160a01b0316803b156138265760405193630d0e30db60e41b85528460048186855af19384156104255761380e94613817575b5061382a565b388080806137cc565b61382090610154565b38613808565b8380fd5b6040517fa9059cbb0000000000000000000000000000000000000000000000000000000060208201526001600160a01b039290921660248301526044808301939093529181526101fb9161387f606483610184565b6138f5565b1561388b57565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b0316906040519061390c82610168565b6020928383527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656484840152803b15613983576000828192828761395e9796519301915af1613958613772565b906139c7565b8051908161396b57505050565b826101fb9361397e9383010191016115e0565b613884565b6064846040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b909190156139d3575090565b8151156139e35750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510613a29575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350613a06565b90613a4c82612826565b613a596040519182610184565b8281528092613a6a601f1991612826565b0190602036910137565b9691909294937fbde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe6135495613aad63ffffffff809916613a42565b938860009a5b89811080613cb9575b15613c2857613ae561065d82600052600080516020613cc5833981519152602052604060002090565b60808916158015613c0f575b613b08575b50600101976000190116968990613ab3565b6040808a1615908115613bf6575b50613b21575b613af6565b60208916158015613be9575b15613af65760048916158015613bc8575b15613af6576002808a1615908115613ba7575b5015613b1c5790915060019081891615908115613b97575b50613b77575b908a91613af6565b8a6001918d849e94613b8c848097168c6128fa565b5201169b9150613b6f565b613ba19150612c12565b38613b69565b9050610160820151613bb881610457565b613bc181610457565b1438613b51565b506001610160820151613bda81610457565b613be381610457565b14613b3e565b5085606082015114613b2d565b8201516001600160a01b03878116911614905038613b16565b5060208101516001600160a01b03888116911614613af1565b959750955096925050506000908210600014613cb257505b941690613c4c826128aa565b9460005b85811684811015613caa578691613ca282613c9161065d613c736001968a6128fa565b51600052600080516020613cc5833981519152602052604060002090565b613c9b828d6128fa565b528a6128fa565b500116613c50565b505093505050565b9050613c40565b508189161515613abc56febde2ebd6fd7bed2358dd7ed448613644a3349ac97dd3e0ae2ccd1f11b3ebe614a2646970667358221220c7316cbf917ca7c8e54b07205768587be270b352adaf6fcb5ca84b541ed2b3b664736f6c63430008120033