Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- OffersLogic
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 1000
- EVM Version
- default
- Verified at
- 2023-08-01T22:09:27.725928Z
contracts/marketplace/offers/OffersLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/// @author thirdweb
import "./OffersStorage.sol";
// ====== External imports ======
import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
// ====== Internal imports ======
import "@thirdweb-dev/contracts/extension/plugin/ERC2771ContextConsumer.sol";
import "@thirdweb-dev/contracts/extension/interface/IPlatformFee.sol";
import "@thirdweb-dev/contracts/extension/plugin/ReentrancyGuardLogic.sol";
import "@thirdweb-dev/contracts/extension/plugin/PermissionsEnumerableLogic.sol";
import { CurrencyTransferLib } from "@thirdweb-dev/contracts/lib/CurrencyTransferLib.sol";
import "../../Constants.sol";
/**
* @author thirdweb.com
*/
contract OffersLogic is IOffers, ReentrancyGuardLogic, ERC2771ContextConsumer, Constants {
/*///////////////////////////////////////////////////////////////
Constants / Immutables
//////////////////////////////////////////////////////////////*/
/// @dev Can create offer for only assets from NFT contracts with asset role, when offers 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;
/*///////////////////////////////////////////////////////////////
Modifiers
//////////////////////////////////////////////////////////////*/
modifier onlyAssetRole(address _asset) {
require(PermissionsLogic(address(this)).hasRoleWithSwitch(ASSET_ROLE, _asset), "!ASSET_ROLE");
_;
}
/// @dev Checks whether caller is a offer creator.
modifier onlyOfferor(uint256 _offerId) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
require(data.offers[_offerId].offeror == _msgSender(), "!Offeror");
_;
}
/// @dev Checks whether an auction exists.
modifier onlyExistingOffer(uint256 _offerId) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
require(data.offers[_offerId].status == IOffers.Status.CREATED, "Marketplace: invalid offer.");
_;
}
/*///////////////////////////////////////////////////////////////
Constructor logic
//////////////////////////////////////////////////////////////*/
constructor() {}
/*///////////////////////////////////////////////////////////////
External functions
//////////////////////////////////////////////////////////////*/
function makeOffer(OfferParams memory _params)
external
onlyAssetRole(_params.assetContract)
returns (uint256 _offerId)
{
_offerId = _getNextOfferId();
address _offeror = _msgSender();
TokenType _tokenType = _getTokenType(_params.assetContract);
_validateNewOffer(_params, _tokenType);
Offer memory _offer = Offer({
offerId: _offerId,
offeror: _offeror,
assetContract: _params.assetContract,
tokenId: _params.tokenId,
tokenType: _tokenType,
quantity: _params.quantity,
currency: _params.currency,
totalPrice: _params.totalPrice,
expirationTimestamp: _params.expirationTimestamp,
status: IOffers.Status.CREATED
});
OffersStorage.Data storage data = OffersStorage.offersStorage();
data.offers[_offerId] = _offer;
emit NewOffer(_offeror, _offerId, _params.assetContract, _params.tokenId, _offer);
}
function cancelOffer(uint256 _offerId) external onlyExistingOffer(_offerId) onlyOfferor(_offerId) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
data.offers[_offerId].status = IOffers.Status.CANCELLED;
Offer memory offer = data.offers[_offerId];
emit CancelledOffer(_msgSender(), _offerId, offer.assetContract, offer.tokenId);
}
function acceptOffer(uint256 _offerId) external nonReentrant onlyExistingOffer(_offerId) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
Offer memory _targetOffer = data.offers[_offerId];
require(_targetOffer.expirationTimestamp > block.timestamp, "EXPIRED");
require(
_validateERC20BalAndAllowance(_targetOffer.offeror, _targetOffer.currency, _targetOffer.totalPrice),
"Marketplace: insufficient currency balance."
);
_validateOwnershipAndApproval(
_msgSender(),
_targetOffer.assetContract,
_targetOffer.tokenId,
_targetOffer.quantity,
_targetOffer.tokenType
);
data.offers[_offerId].status = IOffers.Status.COMPLETED;
_payout(_targetOffer.offeror, _msgSender(), _targetOffer.currency, _targetOffer.totalPrice, _targetOffer);
_transferOfferTokens(_msgSender(), _targetOffer.offeror, _targetOffer.quantity, _targetOffer);
emit AcceptedOffer(
_msgSender(),
_targetOffer.offerId,
_targetOffer.assetContract,
_targetOffer.tokenId,
_targetOffer.offeror,
_targetOffer.quantity,
_targetOffer.totalPrice,
_targetOffer.currency
);
emit AcceptedOfferor(
_targetOffer.offeror,
_targetOffer.offerId,
_targetOffer.assetContract,
_targetOffer.tokenId,
_msgSender(),
_targetOffer.quantity,
_targetOffer.totalPrice,
_targetOffer.currency
);
}
/*///////////////////////////////////////////////////////////////
View functions
//////////////////////////////////////////////////////////////*/
/// @dev Returns total number of offers
function totalOffers() public view returns (uint256) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
return data.totalOffers;
}
/// @dev Returns existing offer with the given uid.
function getOffer(uint256 _offerId) external view returns (Offer memory _offer) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
_offer = data.offers[_offerId];
}
/// @dev Returns all existing offers within the specified range.
function getAllOffers(uint256 _startId, uint256 _endId) external view returns (Offer[] memory _allOffers) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
require(_startId <= _endId && _endId < data.totalOffers, "invalid range");
_allOffers = new Offer[](_endId - _startId + 1);
for (uint256 i = _startId; i <= _endId; i += 1) {
_allOffers[i - _startId] = data.offers[i];
}
}
/// @dev Returns offers within the specified range, where offeror has sufficient balance.
function getAllValidOffers(uint256 _startId, uint256 _endId) external view returns (Offer[] memory _validOffers) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
require(_startId <= _endId && _endId < data.totalOffers, "invalid range");
Offer[] memory _offers = new Offer[](_endId - _startId + 1);
uint256 _offerCount;
for (uint256 i = _startId; i <= _endId; i += 1) {
uint256 j = i - _startId;
_offers[j] = data.offers[i];
if (_validateExistingOffer(_offers[j])) {
_offerCount += 1;
}
}
_validOffers = new Offer[](_offerCount);
uint256 index = 0;
uint256 count = _offers.length;
for (uint256 i = 0; i < count; i += 1) {
if (_validateExistingOffer(_offers[i])) {
_validOffers[index++] = _offers[i];
}
}
}
/*///////////////////////////////////////////////////////////////
Internal functions
//////////////////////////////////////////////////////////////*/
/// @dev Returns the next offer Id.
function _getNextOfferId() internal returns (uint256 id) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
id = data.totalOffers;
data.totalOffers += 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: token must be ERC1155 or ERC721.");
}
}
/// @dev Checks whether the auction creator owns and has approved marketplace to transfer auctioned tokens.
function _validateNewOffer(OfferParams memory _params, TokenType _tokenType) internal view {
require(_params.totalPrice > 0, "zero price.");
require(_params.quantity > 0, "Marketplace: wanted zero tokens.");
require(_params.quantity == 1 || _tokenType == TokenType.ERC1155, "Marketplace: wanted invalid quantity.");
require(
_params.expirationTimestamp + 60 minutes > block.timestamp,
"Marketplace: invalid expiration timestamp."
);
require(
_validateERC20BalAndAllowance(_msgSender(), _params.currency, _params.totalPrice),
"Marketplace: insufficient currency balance."
);
}
/// @dev Checks whether the offer exists, is active, and if the offeror has sufficient balance.
function _validateExistingOffer(Offer memory _targetOffer) internal view returns (bool isValid) {
isValid =
_targetOffer.expirationTimestamp > block.timestamp &&
_targetOffer.status == IOffers.Status.CREATED &&
_validateERC20BalAndAllowance(_targetOffer.offeror, _targetOffer.currency, _targetOffer.totalPrice);
}
/// @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 {
address market = address(this);
bool isValid;
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));
}
require(isValid, "Marketplace: not owner or approved tokens.");
}
/// @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 returns (bool isValid) {
isValid =
IERC20(_currency).balanceOf(_tokenOwner) >= _amount &&
IERC20(_currency).allowance(_tokenOwner, address(this)) >= _amount;
}
/// @dev Transfers tokens.
function _transferOfferTokens(
address _from,
address _to,
uint256 _quantity,
Offer memory _offer
) internal {
if (_offer.tokenType == TokenType.ERC1155) {
IERC1155(_offer.assetContract).safeTransferFrom(_from, _to, _offer.tokenId, _quantity, "");
} else if (_offer.tokenType == TokenType.ERC721) {
IERC721(_offer.assetContract).safeTransferFrom(_from, _to, _offer.tokenId, "");
}
}
/// @dev Pays out stakeholders in a sale.
function _payout(
address _payer,
address _payee,
address _currencyToUse,
uint256 _totalPayoutAmount,
Offer memory _offer
) internal {
(address platformFeeRecipient, uint16 platformFeeBps) = IPlatformFee(address(this)).getPlatformFeeInfo();
if(_currencyToUse == HOC_DIME_ADDRESS)
platformFeeBps = 0;
uint256 platformFeeCut = (_totalPayoutAmount * platformFeeBps) / MAX_BPS;
uint256 royaltyCut;
address royaltyRecipient;
// Distribute royalties. See Sushiswap's https://github.com/sushiswap/shoyu/blob/master/contracts/base/BaseExchange.sol#L296
try IERC2981(_offer.assetContract).royaltyInfo(_offer.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 {}
if(platformFeeCut > 0) {
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
platformFeeRecipient,
platformFeeCut,
address(0)
);
}
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
royaltyRecipient,
royaltyCut,
address(0)
);
CurrencyTransferLib.transferCurrencyWithWrapper(
_currencyToUse,
_payer,
_payee,
_totalPayoutAmount - (platformFeeCut + royaltyCut),
address(0)
);
}
function validateOffer(uint256 _offerId) external onlyExistingOffer(_offerId) view returns (bool isValid) {
OffersStorage.Data storage data = OffersStorage.offersStorage();
Offer memory offer = data.offers[_offerId];
isValid = _validateExistingOffer(offer);
}
uint8 constant FILTER_CREATOR = 0x80;
uint8 constant FILTER_ASSET_CONTRACT = 0x40;
uint8 constant FILTER_TOKEN_ID = 0x20;
uint8 constant FILTER_OFFEROR = 0x10;
uint8 constant FILTER_OWNER = 0x08;
uint8 constant FILTER_ONLY_VALID_TIME = 0x04;
uint8 constant FILTER_ONLY_COMPLETED = 0x02;
uint8 constant FILTER_ONLY_CREATED = 0x01;
function selectOffers(
uint256 _startId,
uint8 _filterFlags,
address _filterCreator,
address _filterAssetContract,
uint256 _filterTokenId,
address _filterOfferor,
address _filterOwner,
uint32 _maxScannedItems,
uint32 _maxOutputItems)
external
view
returns (Offer[] memory _offers, uint256 _nextStartId, uint256 blockTimeStamp)
{
blockTimeStamp = block.timestamp;
OffersStorage.Data storage data = OffersStorage.offersStorage();
uint256 totalItems = data.totalOffers;
uint256[] memory matchedItems = new uint256[](_maxOutputItems);
uint32 matchedItemsCount = 0;
while (_startId < totalItems && _maxScannedItems > 0 && _maxOutputItems > 0) {
Offer memory item = data.offers[_startId];
if ((_filterFlags & FILTER_CREATOR) == 0 || item.offeror == _filterCreator) {
if ((_filterFlags & FILTER_ASSET_CONTRACT) == 0 || item.assetContract == _filterAssetContract) {
if ((_filterFlags & FILTER_TOKEN_ID) == 0 || item.tokenId == _filterTokenId) {
if ((_filterFlags & FILTER_OFFEROR) == 0 || item.offeror == _filterOfferor) {
if ((_filterFlags & FILTER_ONLY_CREATED) == 0 || item.status == IOffers.Status.CREATED) {
if ((_filterFlags & FILTER_ONLY_COMPLETED) == 0 || item.status == IOffers.Status.COMPLETED) {
if ((_filterFlags & FILTER_ONLY_VALID_TIME) == 0 || item.expirationTimestamp > block.timestamp) {
if ((_filterFlags & FILTER_OWNER) != 0) {
if(item.tokenType == TokenType.ERC721) {
try IERC721(item.assetContract).ownerOf(item.tokenId) returns (address owner) {
if(owner != _filterOwner)
continue;
}
catch {
continue;
}
}
if(item.tokenType == TokenType.ERC1155) {
try IERC1155(item.assetContract).balanceOf(_filterOwner, item.tokenId) returns (uint256 balance) {
if(balance == 0)
continue;
}
catch {
continue;
}
}
}
matchedItems[matchedItemsCount] = _startId;
unchecked { ++matchedItemsCount; --_maxOutputItems; }
}
}
}
}
}
}
}
unchecked { ++_startId; --_maxScannedItems; }
}
_nextStartId = _startId < totalItems ? _startId : 0;
_offers = new Offer[](matchedItemsCount);
for (uint32 i = 0; i < matchedItemsCount; ) {
_offers[i] = data.offers[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/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/interfaces/IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(
uint256 tokenId,
uint256 salePrice
) external view returns (address receiver, uint256 royaltyAmount);
}
@openzeppelin/contracts/token/ERC1155/IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC1155/IERC1155.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[EIP].
*
* _Available since v3.1._
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the amount of tokens of token type `id` owned by `account`.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the caller.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `amount`.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* Emits a {TransferBatch} event.
*
* Requirements:
*
* - `ids` and `amounts` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata amounts,
bytes calldata data
) external;
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
@thirdweb-dev/contracts/eip/interface/IERC20.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
@thirdweb-dev/contracts/extension/interface/IPermissions.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IPermissions {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
@thirdweb-dev/contracts/extension/interface/IPermissionsEnumerable.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./IPermissions.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IPermissionsEnumerable is IPermissions {
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* [forum post](https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296)
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) external view returns (address);
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
@thirdweb-dev/contracts/extension/interface/IPlatformFee.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* Thirdweb's `PlatformFee` is a contract extension to be used with any base contract. It exposes functions for setting and reading
* the recipient of platform fee and the platform fee basis points, and lets the inheriting contract perform conditional logic
* that uses information about platform fees, if desired.
*/
interface IPlatformFee {
/// @dev Fee type variants: percentage fee and flat fee
enum PlatformFeeType {
Bps,
Flat
}
/// @dev Returns the platform fee bps and recipient.
function getPlatformFeeInfo() external view returns (address, uint16);
/// @dev Lets a module admin update the fees on primary sales.
function setPlatformFeeInfo(address _platformFeeRecipient, uint256 _platformFeeBps) external;
/// @dev Emitted when fee on primary sales is updated.
event PlatformFeeInfoUpdated(address indexed platformFeeRecipient, uint256 platformFeeBps);
/// @dev Emitted when the flat platform fee is updated.
event FlatPlatformFeeUpdated(address platformFeeRecipient, uint256 flatFee);
/// @dev Emitted when the platform fee type is updated.
event PlatformFeeTypeUpdated(PlatformFeeType feeType);
}
@thirdweb-dev/contracts/extension/plugin/ERC2771ContextConsumer.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./ERC2771ContextLogic.sol";
interface IERC2771Context {
function isTrustedForwarder(address forwarder) external view returns (bool);
}
/**
* @dev Context variant with ERC2771 support.
*/
abstract contract ERC2771ContextConsumer {
function _msgSender() public view virtual returns (address sender) {
if (IERC2771Context(address(this)).isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
assembly {
sender := shr(96, calldataload(sub(calldatasize(), 20)))
}
} else {
return msg.sender;
}
}
function _msgData() public view virtual returns (bytes calldata) {
if (IERC2771Context(address(this)).isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 20];
} else {
return msg.data;
}
}
}
@thirdweb-dev/contracts/extension/plugin/ERC2771ContextLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./ERC2771ContextStorage.sol";
/**
* @dev Context variant with ERC2771 support.
*/
abstract contract ERC2771ContextLogic {
constructor(address[] memory trustedForwarder) {
ERC2771ContextStorage.Data storage data = ERC2771ContextStorage.erc2771ContextStorage();
for (uint256 i = 0; i < trustedForwarder.length; i++) {
data._trustedForwarder[trustedForwarder[i]] = true;
}
}
function isTrustedForwarder(address forwarder) public view virtual returns (bool) {
ERC2771ContextStorage.Data storage data = ERC2771ContextStorage.erc2771ContextStorage();
return data._trustedForwarder[forwarder];
}
function _msgSender() internal view virtual returns (address sender) {
if (isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
assembly {
sender := shr(96, calldataload(sub(calldatasize(), 20)))
}
} else {
return msg.sender;
}
}
function _msgData() internal view virtual returns (bytes calldata) {
if (isTrustedForwarder(msg.sender)) {
return msg.data[:msg.data.length - 20];
} else {
return msg.data;
}
}
}
@thirdweb-dev/contracts/extension/plugin/ERC2771ContextStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
library ERC2771ContextStorage {
bytes32 public constant ERC2771_CONTEXT_STORAGE_POSITION = keccak256("erc2771.context.storage");
struct Data {
mapping(address => bool) _trustedForwarder;
}
function erc2771ContextStorage() internal pure returns (Data storage erc2771ContextData) {
bytes32 position = ERC2771_CONTEXT_STORAGE_POSITION;
assembly {
erc2771ContextData.slot := position
}
}
}
@thirdweb-dev/contracts/extension/plugin/PermissionsEnumerableLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./PermissionsEnumerableStorage.sol";
import "./PermissionsLogic.sol";
/**
* @author thirdweb.com
*
* @title PermissionsEnumerable
* @dev This contracts provides extending-contracts with role-based access control mechanisms.
* Also provides interfaces to view all members with a given role, and total count of members.
*/
contract PermissionsEnumerableLogic is IPermissionsEnumerable, PermissionsLogic {
/**
* @notice Returns the role-member from a list of members for a role,
* at a given index.
* @dev Returns `member` who has `role`, at `index` of role-members list.
* See struct {RoleMembers}, and mapping {roleMembers}
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param index Index in list of current members for the role.
*
* @return member Address of account that has `role`
*/
function getRoleMember(bytes32 role, uint256 index) external view override returns (address member) {
PermissionsEnumerableStorage.Data storage data = PermissionsEnumerableStorage.permissionsEnumerableStorage();
uint256 currentIndex = data.roleMembers[role].index;
uint256 check;
for (uint256 i = 0; i < currentIndex; i += 1) {
if (data.roleMembers[role].members[i] != address(0)) {
if (check == index) {
member = data.roleMembers[role].members[i];
return member;
}
check += 1;
} else if (hasRole(role, address(0)) && i == data.roleMembers[role].indexOf[address(0)]) {
check += 1;
}
}
}
/**
* @notice Returns total number of accounts that have a role.
* @dev Returns `count` of accounts that have `role`.
* See struct {RoleMembers}, and mapping {roleMembers}
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
*
* @return count Total number of accounts that have `role`
*/
function getRoleMemberCount(bytes32 role) external view override returns (uint256 count) {
PermissionsEnumerableStorage.Data storage data = PermissionsEnumerableStorage.permissionsEnumerableStorage();
uint256 currentIndex = data.roleMembers[role].index;
for (uint256 i = 0; i < currentIndex; i += 1) {
if (data.roleMembers[role].members[i] != address(0)) {
count += 1;
}
}
if (hasRole(role, address(0))) {
count += 1;
}
}
/// @dev Revokes `role` from `account`, and removes `account` from {roleMembers}
/// See {_removeMember}
function _revokeRole(bytes32 role, address account) internal override {
super._revokeRole(role, account);
_removeMember(role, account);
}
/// @dev Grants `role` to `account`, and adds `account` to {roleMembers}
/// See {_addMember}
function _setupRole(bytes32 role, address account) internal override {
super._setupRole(role, account);
_addMember(role, account);
}
/// @dev adds `account` to {roleMembers}, for `role`
function _addMember(bytes32 role, address account) internal {
PermissionsEnumerableStorage.Data storage data = PermissionsEnumerableStorage.permissionsEnumerableStorage();
uint256 idx = data.roleMembers[role].index;
data.roleMembers[role].index += 1;
data.roleMembers[role].members[idx] = account;
data.roleMembers[role].indexOf[account] = idx;
}
/// @dev removes `account` from {roleMembers}, for `role`
function _removeMember(bytes32 role, address account) internal {
PermissionsEnumerableStorage.Data storage data = PermissionsEnumerableStorage.permissionsEnumerableStorage();
uint256 idx = data.roleMembers[role].indexOf[account];
delete data.roleMembers[role].members[idx];
delete data.roleMembers[role].indexOf[account];
}
}
@thirdweb-dev/contracts/extension/plugin/PermissionsEnumerableStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "../../extension/interface/IPermissionsEnumerable.sol";
/**
* @author thirdweb.com
*/
library PermissionsEnumerableStorage {
bytes32 public constant PERMISSIONS_ENUMERABLE_STORAGE_POSITION = keccak256("permissions.enumerable.storage");
/**
* @notice A data structure to store data of members for a given role.
*
* @param index Current index in the list of accounts that have a role.
* @param members map from index => address of account that has a role
* @param indexOf map from address => index which the account has.
*/
struct RoleMembers {
uint256 index;
mapping(uint256 => address) members;
mapping(address => uint256) indexOf;
}
struct Data {
/// @dev map from keccak256 hash of a role to its members' data. See {RoleMembers}.
mapping(bytes32 => RoleMembers) roleMembers;
}
function permissionsEnumerableStorage() internal pure returns (Data storage permissionsEnumerableData) {
bytes32 position = PERMISSIONS_ENUMERABLE_STORAGE_POSITION;
assembly {
permissionsEnumerableData.slot := position
}
}
}
@thirdweb-dev/contracts/extension/plugin/PermissionsLogic.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "../../extension/interface/IPermissions.sol";
import "./PermissionsStorage.sol";
import "../../lib/TWStrings.sol";
/**
* @author thirdweb.com
*
* @title Permissions
* @dev This contracts provides extending-contracts with role-based access control mechanisms
*/
contract PermissionsLogic is IPermissions {
/// @dev Default admin role for all roles. Only accounts with this role can grant/revoke other roles.
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/// @dev Modifier that checks if an account has the specified role; reverts otherwise.
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @notice Checks whether an account has a particular role.
* @dev Returns `true` if `account` has been granted `role`.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account for which the role is being checked.
*/
function hasRole(bytes32 role, address account) public view override returns (bool) {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
return data._hasRole[role][account];
}
/**
* @notice Checks whether an account has a particular role;
* role restrictions can be swtiched on and off.
*
* @dev Returns `true` if `account` has been granted `role`.
* Role restrictions can be swtiched on and off:
* - If address(0) has ROLE, then the ROLE restrictions
* don't apply.
* - If address(0) does not have ROLE, then the ROLE
* restrictions will apply.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account for which the role is being checked.
*/
function hasRoleWithSwitch(bytes32 role, address account) public view returns (bool) {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
if (!data._hasRole[role][address(0)]) {
return data._hasRole[role][account];
}
return true;
}
/**
* @notice Returns the admin role that controls the specified role.
* @dev See {grantRole} and {revokeRole}.
* To change a role's admin, use {_setRoleAdmin}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
*/
function getRoleAdmin(bytes32 role) external view override returns (bytes32) {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
return data._getRoleAdmin[role];
}
/**
* @notice Grants a role to an account, if not previously granted.
* @dev Caller must have admin role for the `role`.
* Emits {RoleGranted Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account to which the role is being granted.
*/
function grantRole(bytes32 role, address account) public virtual override {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
_checkRole(data._getRoleAdmin[role], _msgSender());
if (data._hasRole[role][account]) {
revert("Can only grant to non holders");
}
_setupRole(role, account);
}
/**
* @notice Revokes role from an account.
* @dev Caller must have admin role for the `role`.
* Emits {RoleRevoked Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account from which the role is being revoked.
*/
function revokeRole(bytes32 role, address account) public virtual override {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
_checkRole(data._getRoleAdmin[role], _msgSender());
_revokeRole(role, account);
}
/**
* @notice Revokes role from the account.
* @dev Caller must have the `role`, with caller being the same as `account`.
* Emits {RoleRevoked Event}.
*
* @param role keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE")
* @param account Address of the account from which the role is being revoked.
*/
function renounceRole(bytes32 role, address account) public virtual override {
if (_msgSender() != account) {
revert("Can only renounce for self");
}
_revokeRole(role, account);
}
/// @dev Sets `adminRole` as `role`'s admin role.
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
bytes32 previousAdminRole = data._getRoleAdmin[role];
data._getRoleAdmin[role] = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/// @dev Sets up `role` for `account`
function _setupRole(bytes32 role, address account) internal virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
data._hasRole[role][account] = true;
emit RoleGranted(role, account, _msgSender());
}
/// @dev Revokes `role` from `account`
function _revokeRole(bytes32 role, address account) internal virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
_checkRole(role, account);
delete data._hasRole[role][account];
emit RoleRevoked(role, account, _msgSender());
}
/// @dev Checks `role` for `account`. Reverts with a message including the required role.
function _checkRole(bytes32 role, address account) internal view virtual {
PermissionsStorage.Data storage data = PermissionsStorage.permissionsStorage();
if (!data._hasRole[role][account]) {
revert(
string(
abi.encodePacked(
"Permissions: account ",
TWStrings.toHexString(uint160(account), 20),
" is missing role ",
TWStrings.toHexString(uint256(role), 32)
)
)
);
}
}
/// @dev Checks `role` for `account`. Reverts with a message including the required role.
function _checkRoleWithSwitch(bytes32 role, address account) internal view virtual {
if (!hasRoleWithSwitch(role, account)) {
revert(
string(
abi.encodePacked(
"Permissions: account ",
TWStrings.toHexString(uint160(account), 20),
" is missing role ",
TWStrings.toHexString(uint256(role), 32)
)
)
);
}
}
function _msgSender() internal view virtual returns (address sender) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
@thirdweb-dev/contracts/extension/plugin/PermissionsStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @author thirdweb.com
*/
library PermissionsStorage {
bytes32 public constant PERMISSIONS_STORAGE_POSITION = keccak256("permissions.storage");
struct Data {
/// @dev Map from keccak256 hash of a role => a map from address => whether address has role.
mapping(bytes32 => mapping(address => bool)) _hasRole;
/// @dev Map from keccak256 hash of a role to role admin. See {getRoleAdmin}.
mapping(bytes32 => bytes32) _getRoleAdmin;
}
function permissionsStorage() internal pure returns (Data storage permissionsData) {
bytes32 position = PERMISSIONS_STORAGE_POSITION;
assembly {
permissionsData.slot := position
}
}
}
@thirdweb-dev/contracts/extension/plugin/ReentrancyGuardLogic.sol
// SPDX-License-Identifier: Apache 2.0
pragma solidity ^0.8.0;
/// @author thirdweb
import "./ReentrancyGuardStorage.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardLogic {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
function __ReentrancyGuard_init() internal {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal {
ReentrancyGuardStorage.Data storage data = ReentrancyGuardStorage.reentrancyGuardStorage();
data._status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
ReentrancyGuardStorage.Data storage data = ReentrancyGuardStorage.reentrancyGuardStorage();
// On the first call to nonReentrant, _notEntered will be true
require(data._status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
data._status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
data._status = _NOT_ENTERED;
}
}
@thirdweb-dev/contracts/lib/CurrencyTransferLib.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
/// @author thirdweb
// Helper interfaces
import { IWETH } from "../interfaces/IWETH.sol";
import "../openzeppelin-presets/token/ERC20/utils/SafeERC20.sol";
library CurrencyTransferLib {
using SafeERC20 for IERC20;
/// @dev The address interpreted as native token of the chain.
address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
/// @dev Transfers a given amount of currency.
function transferCurrency(
address _currency,
address _from,
address _to,
uint256 _amount
) internal {
if (_amount == 0) {
return;
}
if (_currency == NATIVE_TOKEN) {
safeTransferNativeToken(_to, _amount);
} else {
safeTransferERC20(_currency, _from, _to, _amount);
}
}
/// @dev Transfers a given amount of currency. (With native token wrapping)
function transferCurrencyWithWrapper(
address _currency,
address _from,
address _to,
uint256 _amount,
address _nativeTokenWrapper
) internal {
if (_amount == 0) {
return;
}
if (_currency == NATIVE_TOKEN) {
if (_from == address(this)) {
// withdraw from weth then transfer withdrawn native token to recipient
IWETH(_nativeTokenWrapper).withdraw(_amount);
safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
} else if (_to == address(this)) {
// store native currency in weth
require(_amount == msg.value, "msg.value != amount");
IWETH(_nativeTokenWrapper).deposit{ value: _amount }();
} else {
safeTransferNativeTokenWithWrapper(_to, _amount, _nativeTokenWrapper);
}
} else {
safeTransferERC20(_currency, _from, _to, _amount);
}
}
/// @dev Transfer `amount` of ERC20 token from `from` to `to`.
function safeTransferERC20(
address _currency,
address _from,
address _to,
uint256 _amount
) internal {
if (_from == _to) {
return;
}
if (_from == address(this)) {
IERC20(_currency).safeTransfer(_to, _amount);
} else {
IERC20(_currency).safeTransferFrom(_from, _to, _amount);
}
}
/// @dev Transfers `amount` of native token to `to`.
function safeTransferNativeToken(address to, uint256 value) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
require(success, "native token transfer failed");
}
/// @dev Transfers `amount` of native token to `to`. (With native token wrapping)
function safeTransferNativeTokenWithWrapper(
address to,
uint256 value,
address _nativeTokenWrapper
) internal {
// solhint-disable avoid-low-level-calls
// slither-disable-next-line low-level-calls
(bool success, ) = to.call{ value: value }("");
if (!success) {
IWETH(_nativeTokenWrapper).deposit{ value: value }();
IERC20(_nativeTokenWrapper).safeTransfer(to, value);
}
}
}
@thirdweb-dev/contracts/lib/TWAddress.sol
// SPDX-License-Identifier: Apache 2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev Collection of functions related to the address type
*/
library TWAddress {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* [EIP1884](https://eips.ethereum.org/EIPS/eip-1884) increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
@thirdweb-dev/contracts/lib/TWStrings.sol
// SPDX-License-Identifier: Apache 2.0
pragma solidity ^0.8.0;
/// @author thirdweb
/**
* @dev String operations.
*/
library TWStrings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
@thirdweb-dev/contracts/openzeppelin-presets/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../../../../eip/interface/IERC20.sol";
import "../../../../lib/TWAddress.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using TWAddress for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contracts/Constants.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.11;
contract Constants {
address internal constant HOC_DIME_ADDRESS = 0x716992D45Bc60E9Ead5f59206c0d049afbFf429F; // TODO: Mainnet
}
contracts/marketplace/IMarketplace.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/// @author thirdweb
/**
* @author thirdweb.com
*
* The `DirectListings` extension smart contract lets you buy and sell NFTs (ERC-721 or ERC-1155) for a fixed price.
*/
interface IDirectListings {
enum TokenType {
ERC721,
ERC1155
}
enum Status {
UNSET,
CREATED,
COMPLETED,
CANCELLED
}
/**
* @notice The parameters a seller sets when creating or updating a listing.
*
* @param assetContract The address of the smart contract of the NFTs being listed.
* @param tokenId The tokenId of the NFTs being listed.
* @param quantity The quantity of NFTs being listed. This must be non-zero, and is expected to
* be `1` for ERC-721 NFTs.
* @param currency The currency in which the price must be paid when buying the listed NFTs.
* @param pricePerToken The price to pay per unit of NFTs listed.
* @param startTimestamp The UNIX timestamp at and after which NFTs can be bought from the listing.
* @param endTimestamp The UNIX timestamp at and after which NFTs cannot be bought from the listing.
* @param reserved Whether the listing is reserved to be bought from a specific set of buyers.
*/
struct ListingParameters {
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 pricePerToken;
uint128 startTimestamp;
uint128 endTimestamp;
bool reserved;
}
/**
* @notice The information stored for a listing.
*
* @param listingId The unique ID of the listing.
* @param listingCreator The creator of the listing.
* @param assetContract The address of the smart contract of the NFTs being listed.
* @param tokenId The tokenId of the NFTs being listed.
* @param quantity The quantity of NFTs being listed. This must be non-zero, and is expected to
* be `1` for ERC-721 NFTs.
* @param currency The currency in which the price must be paid when buying the listed NFTs.
* @param pricePerToken The price to pay per unit of NFTs listed.
* @param startTimestamp The UNIX timestamp at and after which NFTs can be bought from the listing.
* @param endTimestamp The UNIX timestamp at and after which NFTs cannot be bought from the listing.
* @param reserved Whether the listing is reserved to be bought from a specific set of buyers.
* @param tokenType The type of token listed (ERC-721 or ERC-1155)
*/
struct Listing {
uint256 listingId;
address listingCreator;
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 pricePerToken;
uint128 startTimestamp;
uint128 endTimestamp;
bool reserved;
TokenType tokenType;
Status status;
}
/// @notice Emitted when a new listing is created.
event NewListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
Listing listing
);
/// @notice Emitted when a listing is updated.
event UpdatedListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
Listing listing
);
/// @notice Emitted when a listing is cancelled.
event CancelledListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId
);
/// @notice Emitted when a buyer is approved to buy from a reserved listing.
event BuyerApprovedForListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
address buyer,
bool approved
);
/// @notice Emitted when a currency is approved as a form of payment for the listing.
event CurrencyApprovedForListing(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
uint256 pricePerToken,
address currency
);
/// @notice Emitted when NFTs are bought from a listing.
event NewSale(
address indexed listingCreator,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
address buyer,
uint256 quantityBought,
uint256 totalPricePaid,
address currency
);
/// @notice Emitted when NFTs are bought from a listing (indexed by buyer).
event NewPurchase(
address indexed buyer,
uint256 listingId,
address indexed assetContract,
uint256 indexed tokenId,
address listingCreator,
uint256 quantityBought,
uint256 totalPricePaid,
address currency
);
/**
* @notice List NFTs (ERC721 or ERC1155) for sale at a fixed price.
*
* @param _params The parameters of a listing a seller sets when creating a listing.
*
* @return listingId The unique integer ID of the listing.
*/
function createListing(ListingParameters memory _params) external returns (uint256 listingId);
/**
* @notice Update parameters of a listing of NFTs.
*
* @param _listingId The ID of the listing to update.
* @param _params The parameters of a listing a seller sets when updating a listing.
*/
function updateListing(uint256 _listingId, ListingParameters memory _params) external;
/**
* @notice Cancel a listing.
*
* @param _listingId The ID of the listing to cancel.
*/
function cancelListing(uint256 _listingId) external;
/**
* @notice Approve a buyer to buy from a reserved listing.
*
* @param _listingId The ID of the listing to update.
* @param _buyer The address of the buyer to approve to buy from the listing.
* @param _toApprove Whether to approve the buyer to buy from the listing.
*/
function approveBuyerForListing(
uint256 _listingId,
address _buyer,
bool _toApprove
) external;
/**
* @notice Approve a currency as a form of payment for the listing.
*
* @param _listingId The ID of the listing to update.
* @param _currency The address of the currency to approve as a form of payment for the listing.
* @param _pricePerTokenInCurrency The price per token for the currency to approve.
*/
function approveCurrencyForListing(
uint256 _listingId,
address _currency,
uint256 _pricePerTokenInCurrency
) external;
/**
* @notice Buy NFTs from a listing.
*
* @param _listingId The ID of the listing to update.
* @param _buyFor The recipient of the NFTs being bought.
* @param _quantity The quantity of NFTs to buy from the listing.
* @param _currency The currency to use to pay for NFTs.
* @param _expectedTotalPrice The expected total price to pay for the NFTs being bought.
*/
function buyFromListing(
uint256 _listingId,
address _buyFor,
uint256 _quantity,
address _currency,
uint256 _expectedTotalPrice
) external payable;
/**
* @notice Returns the total number of listings created.
* @dev At any point, the return value is the ID of the next listing created.
*/
function totalListings() external view returns (uint256);
/// @notice Returns all listings between the start and end Id (both inclusive) provided.
function getAllListings(uint256 _startId, uint256 _endId) external view returns (Listing[] memory listings);
/**
* @notice Returns all valid listings between the start and end Id (both inclusive) provided.
* A valid listing is where the listing creator still owns and has approved Marketplace
* to transfer the listed NFTs.
*/
function getAllValidListings(uint256 _startId, uint256 _endId) external view returns (Listing[] memory listings);
/**
* @notice Returns a listing at the provided listing ID.
*
* @param _listingId The ID of the listing to fetch.
*/
function getListing(uint256 _listingId) external view returns (Listing memory listing);
}
/**
* The `EnglishAuctions` extension smart contract lets you sell NFTs (ERC-721 or ERC-1155) in an english auction.
*/
interface IEnglishAuctions {
enum TokenType {
ERC721,
ERC1155
}
enum Status {
UNSET,
CREATED,
COMPLETED,
CANCELLED
}
/**
* @notice The parameters a seller sets when creating an auction listing.
*
* @param assetContract The address of the smart contract of the NFTs being auctioned.
* @param tokenId The tokenId of the NFTs being auctioned.
* @param quantity The quantity of NFTs being auctioned. This must be non-zero, and is expected to
* be `1` for ERC-721 NFTs.
* @param currency The currency in which the bid must be made when bidding for the auctioned NFTs.
* @param minimumBidAmount The minimum bid amount for the auction.
* @param buyoutBidAmount The total bid amount for which the bidder can directly purchase the auctioned items and close the auction as a result.
* @param timeBufferInSeconds This is a buffer e.g. x seconds. If a new winning bid is made less than x seconds before expirationTimestamp, the
* expirationTimestamp is increased by x seconds.
* @param bidBufferBps This is a buffer in basis points e.g. x%. To be considered as a new winning bid, a bid must be at least x% greater than
* the current winning bid.
* @param startTimestamp The timestamp at and after which bids can be made to the auction
* @param endTimestamp The timestamp at and after which bids cannot be made to the auction.
*/
struct AuctionParameters {
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 minimumBidAmount;
uint256 buyoutBidAmount;
uint64 timeBufferInSeconds;
uint64 bidBufferBps;
uint64 startTimestamp;
uint64 endTimestamp;
}
/**
* @notice The information stored for an auction.
*
* @param auctionId The unique ID of the auction.
* @param auctionCreator The creator of the auction.
* @param assetContract The address of the smart contract of the NFTs being auctioned.
* @param tokenId The tokenId of the NFTs being auctioned.
* @param quantity The quantity of NFTs being auctioned. This must be non-zero, and is expected to
* be `1` for ERC-721 NFTs.
* @param currency The currency in which the bid must be made when bidding for the auctioned NFTs.
* @param minimumBidAmount The minimum bid amount for the auction.
* @param buyoutBidAmount The total bid amount for which the bidder can directly purchase the auctioned items and close the auction as a result.
* @param timeBufferInSeconds This is a buffer e.g. x seconds. If a new winning bid is made less than x seconds before expirationTimestamp, the
* expirationTimestamp is increased by x seconds.
* @param bidBufferBps This is a buffer in basis points e.g. x%. To be considered as a new winning bid, a bid must be at least x% greater than
* the current winning bid.
* @param startTimestamp The timestamp at and after which bids can be made to the auction
* @param endTimestamp The timestamp at and after which bids cannot be made to the auction.
* @param tokenType The type of NFTs auctioned (ERC-721 or ERC-1155)
*/
struct Auction {
uint256 auctionId;
address auctionCreator;
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 minimumBidAmount;
uint256 buyoutBidAmount;
uint64 timeBufferInSeconds;
uint64 bidBufferBps;
uint64 startTimestamp;
uint64 endTimestamp;
TokenType tokenType;
Status status;
}
/**
* @notice The information stored for a bid made in an auction.
*
* @param auctionId The unique ID of the auction.
* @param bidder The address of the bidder.
* @param bidAmount The total bid amount (in the currency specified by the auction).
*/
struct Bid {
uint256 auctionId;
address bidder;
uint256 bidAmount;
}
struct AuctionPayoutStatus {
bool paidOutAuctionTokens;
bool paidOutBidAmount;
}
/// @dev Emitted when a new auction is created.
event NewAuction(
address indexed auctionCreator,
uint256 auctionId,
address indexed assetContract,
uint256 indexed tokenId,
Auction auction
);
/// @dev Emitted when a new bid is made in an auction.
event NewBid(
address indexed bidder,
uint256 auctionId,
address indexed assetContract,
uint256 indexed tokenId,
uint256 bidAmount,
Auction auction
);
/// @notice Emitted when a auction is cancelled.
event CancelledAuction(
address indexed auctionCreator,
uint256 auctionId,
address indexed assetContract,
uint256 indexed tokenId
);
/// @dev Emitted when an auction is closed.
event AuctionClosed(
address indexed winningBidder,
uint256 auctionId,
address indexed assetContract,
uint256 indexed tokenId,
address closer,
uint256 winningAmount,
address currency
);
/**
* @notice Put up NFTs (ERC721 or ERC1155) for an english auction.
*
* @param _params The parameters of an auction a seller sets when creating an auction.
*
* @return auctionId The unique integer ID of the auction.
*/
function createAuction(AuctionParameters memory _params) external returns (uint256 auctionId);
/**
* @notice Cancel an auction.
*
* @param _auctionId The ID of the auction to cancel.
*/
function cancelAuction(uint256 _auctionId) external;
/**
* @notice Distribute the winning bid amount to the auction creator.
*
* @param _auctionId The ID of an auction.
*/
function collectAuctionPayout(uint256 _auctionId) external;
/**
* @notice Distribute the auctioned NFTs to the winning bidder.
*
* @param _auctionId The ID of an auction.
*/
function collectAuctionTokens(uint256 _auctionId) external;
/**
* @notice Distribute the winning bid amount and the auctioned NFTs.
*
* @param _auctionId The ID of an auction.
*/
function collectAuction(uint256 _auctionId) external;
/**
* @notice Bid in an active auction.
*
* @param _auctionId The ID of the auction to bid in.
* @param _bidAmount The bid amount in the currency specified by the auction.
*/
function bidInAuction(uint256 _auctionId, uint256 _bidAmount) external payable;
/**
* @notice Returns whether a given bid amount would make for a winning bid in an auction.
*
* @param _auctionId The ID of an auction.
* @param _bidAmount The bid amount to check.
*/
function isNewWinningBid(uint256 _auctionId, uint256 _bidAmount) external view returns (bool);
/// @notice Returns the auction of the provided auction ID.
function getAuction(uint256 _auctionId) external view returns (Auction memory auction);
/// @notice Returns all non-cancelled auctions.
function getAllAuctions(uint256 _startId, uint256 _endId) external view returns (Auction[] memory auctions);
/// @notice Returns all active auctions.
function getAllValidAuctions(uint256 _startId, uint256 _endId) external view returns (Auction[] memory auctions);
/// @notice Returns the winning bid of an active auction.
function getWinningBid(uint256 _auctionId)
external
view
returns (
address bidder,
address currency,
uint256 bidAmount
);
/// @notice Returns whether an auction is active.
function isAuctionExpired(uint256 _auctionId) external view returns (bool);
}
/**
* The `Offers` extension smart contract lets you make and accept offers made for NFTs (ERC-721 or ERC-1155).
*/
interface IOffers {
enum TokenType {
ERC721,
ERC1155,
ERC20
}
enum Status {
UNSET,
CREATED,
COMPLETED,
CANCELLED
}
/**
* @notice The parameters an offeror sets when making an offer for NFTs.
*
* @param assetContract The contract of the NFTs for which the offer is being made.
* @param tokenId The tokenId of the NFT for which the offer is being made.
* @param quantity The quantity of NFTs wanted.
* @param currency The currency offered for the NFTs.
* @param totalPrice The total offer amount for the NFTs.
* @param expirationTimestamp The timestamp at and after which the offer cannot be accepted.
*/
struct OfferParams {
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 totalPrice;
uint256 expirationTimestamp;
}
/**
* @notice The information stored for the offer made.
*
* @param offerId The ID of the offer.
* @param offeror The address of the offeror.
* @param assetContract The contract of the NFTs for which the offer is being made.
* @param tokenId The tokenId of the NFT for which the offer is being made.
* @param quantity The quantity of NFTs wanted.
* @param currency The currency offered for the NFTs.
* @param totalPrice The total offer amount for the NFTs.
* @param expirationTimestamp The timestamp at and after which the offer cannot be accepted.
* @param tokenType The type of token (ERC-721 or ERC-1155) the offer is made for.
*/
struct Offer {
uint256 offerId;
address offeror;
address assetContract;
uint256 tokenId;
uint256 quantity;
address currency;
uint256 totalPrice;
uint256 expirationTimestamp;
TokenType tokenType;
Status status;
}
/// @dev Emitted when a new offer is created.
event NewOffer(
address indexed offeror,
uint256 offerId,
address indexed assetContract,
uint256 indexed tokenId,
Offer offer
);
/// @dev Emitted when an offer is cancelled.
event CancelledOffer(
address indexed offeror,
uint256 offerId,
address indexed assetContract,
uint256 indexed tokenId
);
/// @dev Emitted when an offer is accepted.
event AcceptedOffer(
address indexed seller,
uint256 offerId,
address indexed assetContract,
uint256 indexed tokenId,
address offeror,
uint256 quantityBought,
uint256 totalPricePaid,
address currency
);
/// @dev Emitted when an offer is accepted.
event AcceptedOfferor(
address indexed offeror,
uint256 offerId,
address indexed assetContract,
uint256 indexed tokenId,
address seller,
uint256 quantityBought,
uint256 totalPricePaid,
address currency
);
/**
* @notice Make an offer for NFTs (ERC-721 or ERC-1155)
*
* @param _params The parameters of an offer.
*
* @return offerId The unique integer ID assigned to the offer.
*/
function makeOffer(OfferParams memory _params) external returns (uint256 offerId);
/**
* @notice Cancel an offer.
*
* @param _offerId The ID of the offer to cancel.
*/
function cancelOffer(uint256 _offerId) external;
/**
* @notice Accept an offer.
*
* @param _offerId The ID of the offer to accept.
*/
function acceptOffer(uint256 _offerId) external;
/// @notice Returns an offer for the given offer ID.
function getOffer(uint256 _offerId) external view returns (Offer memory offer);
/// @notice Returns all active (i.e. non-expired or cancelled) offers.
function getAllOffers(uint256 _startId, uint256 _endId) external view returns (Offer[] memory offers);
/// @notice Returns all valid offers. An offer is valid if the offeror owns and has approved Marketplace to transfer the offer amount of currency.
function getAllValidOffers(uint256 _startId, uint256 _endId) external view returns (Offer[] memory offers);
}
contracts/marketplace/offers/OffersStorage.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.11;
/// @author thirdweb
import { IOffers } from "../IMarketplace.sol";
/**
* @author thirdweb.com
*/
library OffersStorage {
bytes32 public constant OFFERS_STORAGE_POSITION = keccak256("offers.storage");
struct Data {
uint256 totalOffers;
mapping(uint256 => IOffers.Offer) offers;
}
function offersStorage() internal pure returns (Data storage offersData) {
bytes32 position = OFFERS_STORAGE_POSITION;
assembly {
offersData.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":"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":"acceptOffer","inputs":[{"type":"uint256","name":"_offerId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelOffer","inputs":[{"type":"uint256","name":"_offerId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_allOffers","internalType":"struct IOffers.Offer[]","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getAllOffers","inputs":[{"type":"uint256","name":"_startId","internalType":"uint256"},{"type":"uint256","name":"_endId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_validOffers","internalType":"struct IOffers.Offer[]","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getAllValidOffers","inputs":[{"type":"uint256","name":"_startId","internalType":"uint256"},{"type":"uint256","name":"_endId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple","name":"_offer","internalType":"struct IOffers.Offer","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint8"},{"type":"uint8"}]}],"name":"getOffer","inputs":[{"type":"uint256","name":"_offerId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"_offerId","internalType":"uint256"}],"name":"makeOffer","inputs":[{"type":"tuple","name":"_params","internalType":"struct IOffers.OfferParams","components":[{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"}]}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"_offers","internalType":"struct IOffers.Offer[]","components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint8"},{"type":"uint8"}]},{"type":"uint256","name":"_nextStartId","internalType":"uint256"},{"type":"uint256","name":"blockTimeStamp","internalType":"uint256"}],"name":"selectOffers","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":"address","name":"_filterOfferor","internalType":"address"},{"type":"address","name":"_filterOwner","internalType":"address"},{"type":"uint32","name":"_maxScannedItems","internalType":"uint32"},{"type":"uint32","name":"_maxOutputItems","internalType":"uint32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalOffers","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"isValid","internalType":"bool"}],"name":"validateOffer","inputs":[{"type":"uint256","name":"_offerId","internalType":"uint256"}]},{"type":"event","name":"AcceptedOffer","inputs":[{"type":"address","name":"seller","indexed":true},{"type":"uint256","name":"offerId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"address","name":"offeror","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":"AcceptedOfferor","inputs":[{"type":"address","name":"offeror","indexed":true},{"type":"uint256","name":"offerId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"address","name":"seller","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":"CancelledOffer","inputs":[{"type":"address","name":"offeror","indexed":true},{"type":"uint256","name":"offerId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true}],"anonymous":false},{"type":"event","name":"NewOffer","inputs":[{"type":"address","name":"offeror","indexed":true},{"type":"uint256","name":"offerId","indexed":false},{"type":"address","name":"assetContract","indexed":true},{"type":"uint256","name":"tokenId","indexed":true},{"type":"tuple","name":"offer","indexed":false,"components":[{"type":"uint256"},{"type":"address"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"address"},{"type":"uint256"},{"type":"uint256"},{"type":"uint8"},{"type":"uint8"}]}],"anonymous":false}]
Contract Creation Code
0x6080806040523461001657612b7d908161001c8239f35b600080fdfe6080604052600436101561001257600080fd5b60003560e01c8063016767fa146100c75780630a5894a3146100c2578063119df25f146100bd5780634579268a146100b85780638b49d47e146100b357806391940b3e146100ae578063a9fd8ed1146100a9578063c1edcfbe146100a4578063c815729d1461009f578063cbd69d6b1461009a5763ef706adf1461009557600080fd5b610b26565b610a99565b61070a565b610631565b6105f4565b610481565b6103e4565b610393565b61028e565b610207565b61018c565b634e487b7160e01b600052604160045260246000fd5b60c0810190811067ffffffffffffffff8211176100fe57604052565b6100cc565b67ffffffffffffffff81116100fe57604052565b6040810190811067ffffffffffffffff8211176100fe57604052565b90601f8019910116810190811067ffffffffffffffff8211176100fe57604052565b60405190610140820182811067ffffffffffffffff8211176100fe57604052565b6001600160a01b0381160361018757565b600080fd5b346101875760c0366003190112610187576102036101f36040516101af816100e2565b6004356101bb81610176565b8152602435602082015260443560408201526064356101d981610176565b6060820152608435608082015260a43560a0820152610d11565b6040519081529081906020820190565b0390f35b346101875760203660031901126101875760043580600052600080516020612b28833981519152908160205260ff60086040600020015460081c16600481101561027e57600161025791146110c7565b600052602052602061027461026f6040600020611112565b61183e565b6040519015158152f35b6102ba565b600091031261018757565b346101875760003660031901126101875760206102a9610c11565b6001600160a01b0360405191168152f35b634e487b7160e01b600052602160045260246000fd5b6003111561027e57565b90600382101561027e5752565b6004111561027e57565b90600482101561027e5752565b805182526020808201516001600160a01b03169083015261039191906040818101516001600160a01b031690830152606081015160608301526080810151608083015261035b60a082015160a08401906001600160a01b03169052565b60c081015160c083015260e081015160e083015261038261010080830151908401906102da565b610120809101519101906102f1565b565b34610187576020366003190112610187576103ac611320565b50600435600052600080516020612b288339815191526020526101406103d56040600020611112565b6103e260405180926102fe565bf35b346101875760003660031901126101875760406103ff610ca8565b919082825193849260208452816020850152848401376000828201840152601f01601f19168101030190f35b90815180825260208080930193019160005b82811061044b575050505090565b90919293826101408261046160019489516102fe565b0195019392910161043d565b90602061047e92818152019061042b565b90565b346101875760403660031901126101875760243560043581811115806105ca575b6104ab9061137e565b6104c56104c06104bb8385610c9b565b6113c9565b61140b565b90600090805b8481111561054d57836104dd8461140b565b81516000805b8281106104f85760405180610203868261046d565b8061050f610509610518938861145b565b5161183e565b61051d576113c9565b6104e3565b61054761052a828861145b565b519361053581611485565b94610540828961145b565b528661145b565b506113c9565b6105a261050961055d8484610c9b565b61058661058185600052600080516020612b28833981519152602052604060002090565b611112565b610590828961145b565b5261059b818861145b565b508661145b565b6105b5575b6105b0906113c9565b6104cb565b916105c26105b0916113c9565b9290506105a7565b507fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca95482106104a2565b346101875760003660031901126101875760207fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca954604051908152f35b3461018757604080600319360112610187576004356024359182821115806106e0575b61065d9061137e565b8183038381116106db576001908181018091116106db5761067d9061140b565b92805b8581111561069557835180610203878261046d565b6106ce846000838152600080516020612b28833981519152602052206106c46106be8585610c9b565b91611112565b610540828961145b565b5082810180911115610680575b610c85565b507fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca9548310610654565b34610187576020366003190112610187576004357fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f6002815414610a1f576002905580600052600080516020612b2883398151915260205260ff60086040600020015460081c16600481101561027e57600114610786906110c7565b6107a781600052600080516020612b28833981519152602052604060002090565b6107b090611112565b60e081015142106107c090611264565b602081019182516107d7906001600160a01b031690565b9260a083019384516107ef906001600160a01b031690565b9060c085019182519061080192611bd3565b61080a906112af565b610812610c11565b906040850190815161082a906001600160a01b031690565b94606087019384519660808901978851906101008b01519261084b846102d0565b6108549461192b565b61087590600052600080516020612b28833981519152602052604060002090565b600801805461ff00191661020017905583516001600160a01b031686610899610c11565b89516001600160a01b03168451916108b094611f23565b6108b8610c11565b845187906001600160a01b03168751906108d193611ce0565b6108d9610c11565b93865183516108ee906001600160a01b031690565b958551918351610904906001600160a01b031690565b9089518651918d5161091c906001600160a01b031690565b604080519283526001600160a01b03958616602084015282019290925260608101929092528216608082015290978816918816907f31ee722dd5481cc30d4c84372f2191d02befbafed3a623224f133e60fe67bd419060a090a4516001600160a01b0316955191516001600160a01b0316925196610998610c11565b955191519051604080519485526001600160a01b039788166020860152840192909252606083015293909316608084015281169216907f2438a194ea7eefe8c8d8df3ad7b412b2e7b77f17ff0739e8c7f1965caf3f628c9060a090a4610a1d60017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b005b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b610104359063ffffffff8216820361018757565b610a8f6040929594939560608352606083019061042b565b9460208201520152565b34610187576101203660031901126101875760243560ff8116810361018757604435610ac481610176565b60643590610ad182610176565b60a435610add81610176565b60c435610ae981610176565b60e4359163ffffffff831683036101875761020395610b1795610b0a610a63565b95608435926004356126b6565b60409391935193849384610a77565b3461018757602036600319011261018757600435600090808252600080516020612b288339815191528060205260ff600860408520015460081c16600481101561027e576001610b7691146110c7565b8183526020526001600160a01b038060016040852001541690610b97610c11565b1603610ba957610ba6906111e4565b80f35b606460405162461bcd60e51b815260206004820152600860248201527f214f666665726f720000000000000000000000000000000000000000000000006044820152fd5b90816020910312610187575180151581036101875790565b6040513d6000823e3d90fd5b60405163572b6c0560e01b8152336004820152602081602481305afa908115610c8057600091610c52575b5015610c4e5736601319013560601c90565b3390565b610c73915060203d8111610c79575b610c6b8183610133565b810190610bed565b38610c3c565b503d610c61565b610c05565b634e487b7160e01b600052601160045260246000fd5b919082039182116106db57565b60405163572b6c0560e01b8152336004820152602081602481305afa908115610c8057600091610cf3575b5015610cec576013193601903682116106db5760009190565b6000903690565b610d0b915060203d8111610c7957610c6b8183610133565b38610cd3565b6001600160a01b03815116604051907fa32fa5b30000000000000000000000000000000000000000000000000000000082527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae660048301526024820152602081604481305afa908115610c8057600091610dd9575b5015610d955761047e90610f87565b606460405162461bcd60e51b815260206004820152600b60248201527f2141535345545f524f4c450000000000000000000000000000000000000000006044820152fd5b610df1915060203d8111610c7957610c6b8183610133565b38610d86565b600382101561027e5752565b600482101561027e5752565b90600381101561027e5760ff80198354169116179055565b90600481101561027e5761ff0082549160081b169061ff001916179055565b9061012060086103919383518155610e97610e6b60208601516001600160a01b031690565b60018301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b610eda610eae60408601516001600160a01b031690565b60028301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b6060840151600382015560808401516004820155610f31610f0560a08601516001600160a01b031690565b60058301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60c0840151600682015560e084015160078201550191610f5f610100820151610f59816102d0565b84610e0f565b015190610f6b826102e7565b610e27565b9081526101608101929161039191602001906102fe565b90610f90611494565b91610f99610c11565b81516001600160a01b0316610fad906114c8565b91610fb8838261176c565b80516001600160a01b0316906020810193845160408301516060840151610fe5906001600160a01b031690565b60808501519160a086015193610ff9610155565b8c81526001600160a01b038a166020820152976001600160a01b03166040890152606088015260808701526001600160a01b031660a086015260c085015260e084015261104a906101008401610df7565b60016101208301528161107487600052600080516020612b28833981519152602052604060002090565b9061107e91610e46565b51925160405190936001600160a01b0390811693169181906110a1908883610f70565b037fe5f7d2ca9b939cd61d1b80107f4733d6552e26d08e899e8b27d99b4bb01466da91a4565b156110ce57565b606460405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574706c6163653a20696e76616c6964206f666665722e00000000006044820152fd5b9061039160ff6008611122610155565b948054865261114e61113e60018301546001600160a01b031690565b6001600160a01b03166020880152565b61117561116560028301546001600160a01b031690565b6001600160a01b03166040880152565b60038101546060870152600481015460808701526111b06111a060058301546001600160a01b031690565b6001600160a01b031660a0880152565b600681015460c0870152600781015460e087015201546111d68282166101008701610df7565b60081c166101208401610e03565b80600052600080516020612b2883398151915260205261121860406000206008810161030061ff0019825416179055611112565b611220610c11565b917f656fae5ac58099f1303c3dd53bbc9e4b0f000700d538d81ef7f5716ab1a34b9060206001600160a01b03606081604087015116950151956040519485521692a4565b1561126b57565b606460405162461bcd60e51b815260206004820152600760248201527f45585049524544000000000000000000000000000000000000000000000000006044820152fd5b156112b657565b608460405162461bcd60e51b815260206004820152602b60248201527f4d61726b6574706c6163653a20696e73756666696369656e742063757272656e60448201527f63792062616c616e63652e0000000000000000000000000000000000000000006064820152fd5b60405190610140820182811067ffffffffffffffff8211176100fe57604052816101206000918281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e0820152826101008201520152565b1561138557565b606460405162461bcd60e51b815260206004820152600d60248201527f696e76616c69642072616e6765000000000000000000000000000000000000006044820152fd5b90600182018092116106db57565b90610e1082018092116106db57565b919082018092116106db57565b67ffffffffffffffff81116100fe5760051b60200190565b90611415826113f3565b6114226040519182610133565b8281528092611433601f19916113f3565b019060005b82811061144457505050565b60209061144f611320565b82828501015201611438565b805182101561146f5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b60001981146106db5760010190565b7fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca99081549160018301908184116106db5755565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082527fd9b67a260000000000000000000000000000000000000000000000000000000060048301526020926001600160a01b0316918381602481865afa908115610c8057600091611622575b501561154757505050600190565b6040519081527f80ac58cd000000000000000000000000000000000000000000000000000000006004820152908290829060249082905afa918215610c8057600092611605575b50501561159a57600090565b60405162461bcd60e51b815260206004820152602d60248201527f4d61726b6574706c6163653a20746f6b656e206d75737420626520455243313160448201527f3535206f72204552433732312e000000000000000000000000000000000000006064820152608490fd5b61161b9250803d10610c7957610c6b8183610133565b388061158e565b6116399150843d8611610c7957610c6b8183610133565b38611539565b1561164657565b606460405162461bcd60e51b815260206004820152602060248201527f4d61726b6574706c6163653a2077616e746564207a65726f20746f6b656e732e6044820152fd5b1561169157565b608460405162461bcd60e51b815260206004820152602560248201527f4d61726b6574706c6163653a2077616e74656420696e76616c6964207175616e60448201527f746974792e0000000000000000000000000000000000000000000000000000006064820152fd5b1561170257565b608460405162461bcd60e51b815260206004820152602a60248201527f4d61726b6574706c6163653a20696e76616c69642065787069726174696f6e2060448201527f74696d657374616d702e000000000000000000000000000000000000000000006064820152fd5b9060808201918251156117fa57610391926117a66117e1936001604085016117968151151561163f565b51149081156117e6575b5061168a565b6117bd6117b660a08401516113d7565b42106116fb565b6117d960606117ca610c11565b9301516001600160a01b031690565b905191611bd3565b6112af565b600191506117f3816102d0565b14386117a0565b606460405162461bcd60e51b815260206004820152600b60248201527f7a65726f2070726963652e0000000000000000000000000000000000000000006044820152fd5b60e08101514210908161187c575b81611855575090565b61047e91506001600160a01b039060c0826020830151169260a08301511691015191611bd3565b9050610120810151600481101561027e576001149061184c565b90816020910312610187575161047e81610176565b90816020910312610187575190565b156118c157565b608460405162461bcd60e51b815260206004820152602a60248201527f4d61726b6574706c6163653a206e6f74206f776e6572206f7220617070726f7660448201527f656420746f6b656e732e000000000000000000000000000000000000000000006064820152fd5b92919360009061193a816102d0565b60018103611a36575050604051627eeac760e11b81526001600160a01b0384811660048301526024820195909552931692602091908281604481885afa908115610c8057600091611a09575b501015918261199c575b505061039191506118ba565b60405163e985e9c560e01b81526001600160a01b0391909116600482015230602482015290929091508290829060449082905afa908115610c8057610391926000926119ec575b50503880611990565b611a029250803d10610c7957610c6b8183610133565b38806119e3565b611a299150833d8511611a2f575b611a218183610133565b8101906118ab565b38611986565b503d611a17565b909391949250611a45816102d0565b15611a5657505061039191506118ba565b6040516331a9108f60e11b8152600481018390526001600160a01b03948516949293919260209182816024818a5afa908115610c80578491611bb6575b508116848216149485611ab2575b505050505061039191503880611990565b6040517f081812fc0000000000000000000000000000000000000000000000000000000081526004810191909152939450919290918282602481895afa918215610c80578492611b87575b50163014928315611b1b575b50505061039191503880808080611aa1565b60405163e985e9c560e01b81526001600160a01b0391909116600482015230602482015291939092508290829060449082905afa918215610c80576103919392611b6a575b5050388080611b09565b611b809250803d10610c7957610c6b8183610133565b3880611b60565b611ba8919250833d8511611baf575b611ba08183610133565b810190611896565b9038611afd565b503d611b96565b611bcd9150833d8511611baf57611ba08183610133565b38611a93565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038281166004830152929092169290916020908181602481885afa8015610c80578391600091611cc3575b5010159283611c3d575b505050905090565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015230602482015291939092508290829060449082905afa918215610c8057600092611ca6575b5050101580388080611c35565b611cbc9250803d10611a2f57611a218183610133565b3880611c99565b611cda9150833d8511611a2f57611a218183610133565b38611c2b565b9192610100810160018151611cf4816102d0565b611cfd816102d0565b03611dc757506060611d2b611d1f611d1f60408501516001600160a01b031690565b6001600160a01b031690565b91015191813b156101875760008094611da3604051978896879586947ff242432a00000000000000000000000000000000000000000000000000000000865260048601929060c094926001600160a01b0380921685521660208401526040830152606082015260a06080820152600060a08201520190565b03925af18015610c8057611db45750565b80611dc161039192610103565b80610283565b9091935051611dd5816102d0565b611dde816102d0565b15611de857505050565b6060611e04611d1f611d1f60408501516001600160a01b031690565b91015190803b15610187576040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b03938416600482015293909216602484015260448301526080606483015260006084830181905290829060a490829084905af18015610c8057611db45750565b91908260409103126101875760208251611e9581610176565b92015161ffff811681036101875790565b818102929181159184041417156106db57565b91908260409103126101875760208251611ed281610176565b92015190565b15611edf57565b606460405162461bcd60e51b815260206004820152601560248201527f66656573206578636565642074686520707269636500000000000000000000006044820152fd5b909192936040948551957fd45573f60000000000000000000000000000000000000000000000000000000087528087600481305afa8015610c80576103919761205c9461205693612025936000938491612106575b50918a6001600160a01b039373716992d45bc60e9ead5f59206c0d049afbff429f858316146120fe575b611fb361ffff611fbb92168a611ea6565b612710900490565b80956000978589968c88976060611fe1611d1f611d1f868501516001600160a01b031690565b91015183518096819482937f2a55205a0000000000000000000000000000000000000000000000000000000084526004840160209093929193604081019481520152565b03915afa87928392826120cb575b5050612074575b505061205195508b82612062575b92915050612184565b6113e6565b90610c9b565b92612184565b61206b93612184565b8a84388b612048565b9250929450929481161515806120c2575b612096575b8492879492879261203a565b85965061205194506120b6896120af88859697956113e6565b1115611ed8565b9195819392945061208a565b50811515612085565b80919294506120ef9350903d106120f7575b6120e78183610133565b810190611eb9565b913880612033565b503d6120dd565b506000611fa2565b9050816121299294503d8511612132575b6121218183610133565b810190611e7c565b92909238611f78565b503d612117565b1561214057565b606460405162461bcd60e51b815260206004820152601360248201527f6d73672e76616c756520213d20616d6f756e74000000000000000000000000006044820152fd5b908315612281576001600160a01b039180831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee03612275575081163003612229575090600091823b15612225576040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101839052928360248183805af1928315610c805761039193612212575b5061239e565b80611dc161221f92610103565b3861220c565b8280fd5b8116300361226b575061223d348214612139565b60003b1561018757600060049160405192838092630d0e30db60e41b8252845af18015610c8057611db45750565b906103919161239e565b61039194939250612287565b50505050565b92916001600160a01b03918216828216818114612356573082036122f057505060405163a9059cbb60e01b60208201526001600160a01b0390911660248201526044810192909252610391926122ea83606481015b03601f198101855284610133565b16612562565b90939150604051937f23b872dd0000000000000000000000000000000000000000000000000000000060208601526024850152604484015260648301526064825260a082019282841067ffffffffffffffff8511176100fe576103919360405216612562565b505050505050565b3d15612399573d9067ffffffffffffffff82116100fe576040519161238d601f8201601f191660200184610133565b82523d6000602084013e565b606090565b60008080808086865af16123b061235e565b50156123bb57505050565b803b156124ee57604051630d0e30db60e41b8152818160048187845af18015610c80576124df575b5060405163a9059cbb60e01b60208083019182526001600160a01b0390941660248301526044820194909452919261241e83606481016122dc565b6040519261242b84610117565b8484527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656485850152823b1561249b579180916124769493519082805af161247061235e565b90612609565b8051908161248357505050565b8261039193612496938301019101610bed565b6124f1565b6064856040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b6124e890610103565b386123e3565b80fd5b156124f857565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b0316906040519061257982610117565b6020928383527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656484840152803b156125c557600082819282876124769796519301915af161247061235e565b6064846040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b90919015612615575090565b8151156126255750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b82851061266b575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350612648565b9061268e826113f3565b61269b6040519182610133565b82815280926126ac601f19916113f3565b0190602036910137565b959390919296989442917fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca954986126f263ffffffff8c16612684565b976000995b8b81108e81612b17575b5080612b08575b15612a655761273161058182600052600080516020612b28833981519152602052604060002090565b60808816158015612a4c575b612766575b509b9c6000190163ffffffff169b6001019a8c8e828e5b505050509a9c9b9c6126f7565b60408816158015612a33575b61277c575b612742565b60208816158015612a26575b156127425760108816158015612a0d575b1561274257600188161580156129ec575b15612742576002808916159081156129cb575b501561277757600488161580156129be575b15612777579a8c9d9b6008899e939e16612813575b508c6127f663ffffffff83168d61145b565b5260010163ffffffff169a6000190163ffffffff169c9b90612742565b909150610100810151612825816102d0565b61282e816102d0565b15612911575b6001610100820151612845816102d0565b61284e816102d0565b1461285c575b908d916127e4565b60209b9e9d919b816060612883611d1f611d1f60406128b89701516001600160a01b031690565b910151604051627eeac760e11b81526001600160a01b038e166004820152602481019190915292839190829081906044820190565b03915afa600091816128f0575b506128d457508c8e828e612759565b9d9a909c9d156128e4578c612854565b999c9b8c8e828e612759565b61290a91925060203d602011611a2f57611a218183610133565b90386128c5565b61295b9b9e9d919b6020612935611d1f611d1f60408601516001600160a01b031690565b60608401519060405180809581946331a9108f60e11b8352600483019190602083019252565b03915afa6000918161299d575b506129785750508c8e828e612759565b9d9e9b919d6001600160a01b03808c16911603156128345750999c9b8c8e828e612759565b6129b791925060203d602011611baf57611ba08183610133565b9038612968565b508660e0820151116127cf565b90506101208201516129dc816102e7565b6129e5816102e7565b14386127bd565b5060016101208201516129fe816102e7565b612a07816102e7565b146127aa565b5060208101516001600160a01b03878116911614612799565b5084606082015114612788565b5060408101516001600160a01b03858116911614612772565b5060208101516001600160a01b038a811691161461273d565b97509a505050509750505063ffffffff9192936000908210600014612b0157505b921691612a928361140b565b9460005b63ffffffff811685811015612af85763ffffffff91612af082612adf610581612ac16001968b61145b565b51600052600080516020612b28833981519152602052604060002090565b612ae9828d61145b565b528a61145b565b500116612a96565b50509250929050565b9050612a86565b5063ffffffff8d161515612708565b63ffffffff91501615158e61270156fee4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624caaa2646970667358221220e27da20838eb9e74efa6a1314c2beacfc202a7f94e8ff343b9de0d3dbc396aa964736f6c63430008120033
Deployed ByteCode
0x6080604052600436101561001257600080fd5b60003560e01c8063016767fa146100c75780630a5894a3146100c2578063119df25f146100bd5780634579268a146100b85780638b49d47e146100b357806391940b3e146100ae578063a9fd8ed1146100a9578063c1edcfbe146100a4578063c815729d1461009f578063cbd69d6b1461009a5763ef706adf1461009557600080fd5b610b26565b610a99565b61070a565b610631565b6105f4565b610481565b6103e4565b610393565b61028e565b610207565b61018c565b634e487b7160e01b600052604160045260246000fd5b60c0810190811067ffffffffffffffff8211176100fe57604052565b6100cc565b67ffffffffffffffff81116100fe57604052565b6040810190811067ffffffffffffffff8211176100fe57604052565b90601f8019910116810190811067ffffffffffffffff8211176100fe57604052565b60405190610140820182811067ffffffffffffffff8211176100fe57604052565b6001600160a01b0381160361018757565b600080fd5b346101875760c0366003190112610187576102036101f36040516101af816100e2565b6004356101bb81610176565b8152602435602082015260443560408201526064356101d981610176565b6060820152608435608082015260a43560a0820152610d11565b6040519081529081906020820190565b0390f35b346101875760203660031901126101875760043580600052600080516020612b28833981519152908160205260ff60086040600020015460081c16600481101561027e57600161025791146110c7565b600052602052602061027461026f6040600020611112565b61183e565b6040519015158152f35b6102ba565b600091031261018757565b346101875760003660031901126101875760206102a9610c11565b6001600160a01b0360405191168152f35b634e487b7160e01b600052602160045260246000fd5b6003111561027e57565b90600382101561027e5752565b6004111561027e57565b90600482101561027e5752565b805182526020808201516001600160a01b03169083015261039191906040818101516001600160a01b031690830152606081015160608301526080810151608083015261035b60a082015160a08401906001600160a01b03169052565b60c081015160c083015260e081015160e083015261038261010080830151908401906102da565b610120809101519101906102f1565b565b34610187576020366003190112610187576103ac611320565b50600435600052600080516020612b288339815191526020526101406103d56040600020611112565b6103e260405180926102fe565bf35b346101875760003660031901126101875760406103ff610ca8565b919082825193849260208452816020850152848401376000828201840152601f01601f19168101030190f35b90815180825260208080930193019160005b82811061044b575050505090565b90919293826101408261046160019489516102fe565b0195019392910161043d565b90602061047e92818152019061042b565b90565b346101875760403660031901126101875760243560043581811115806105ca575b6104ab9061137e565b6104c56104c06104bb8385610c9b565b6113c9565b61140b565b90600090805b8481111561054d57836104dd8461140b565b81516000805b8281106104f85760405180610203868261046d565b8061050f610509610518938861145b565b5161183e565b61051d576113c9565b6104e3565b61054761052a828861145b565b519361053581611485565b94610540828961145b565b528661145b565b506113c9565b6105a261050961055d8484610c9b565b61058661058185600052600080516020612b28833981519152602052604060002090565b611112565b610590828961145b565b5261059b818861145b565b508661145b565b6105b5575b6105b0906113c9565b6104cb565b916105c26105b0916113c9565b9290506105a7565b507fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca95482106104a2565b346101875760003660031901126101875760207fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca954604051908152f35b3461018757604080600319360112610187576004356024359182821115806106e0575b61065d9061137e565b8183038381116106db576001908181018091116106db5761067d9061140b565b92805b8581111561069557835180610203878261046d565b6106ce846000838152600080516020612b28833981519152602052206106c46106be8585610c9b565b91611112565b610540828961145b565b5082810180911115610680575b610c85565b507fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca9548310610654565b34610187576020366003190112610187576004357fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f6002815414610a1f576002905580600052600080516020612b2883398151915260205260ff60086040600020015460081c16600481101561027e57600114610786906110c7565b6107a781600052600080516020612b28833981519152602052604060002090565b6107b090611112565b60e081015142106107c090611264565b602081019182516107d7906001600160a01b031690565b9260a083019384516107ef906001600160a01b031690565b9060c085019182519061080192611bd3565b61080a906112af565b610812610c11565b906040850190815161082a906001600160a01b031690565b94606087019384519660808901978851906101008b01519261084b846102d0565b6108549461192b565b61087590600052600080516020612b28833981519152602052604060002090565b600801805461ff00191661020017905583516001600160a01b031686610899610c11565b89516001600160a01b03168451916108b094611f23565b6108b8610c11565b845187906001600160a01b03168751906108d193611ce0565b6108d9610c11565b93865183516108ee906001600160a01b031690565b958551918351610904906001600160a01b031690565b9089518651918d5161091c906001600160a01b031690565b604080519283526001600160a01b03958616602084015282019290925260608101929092528216608082015290978816918816907f31ee722dd5481cc30d4c84372f2191d02befbafed3a623224f133e60fe67bd419060a090a4516001600160a01b0316955191516001600160a01b0316925196610998610c11565b955191519051604080519485526001600160a01b039788166020860152840192909252606083015293909316608084015281169216907f2438a194ea7eefe8c8d8df3ad7b412b2e7b77f17ff0739e8c7f1965caf3f628c9060a090a4610a1d60017fbbf78d3411d42a81effd97bb8c69faae4e77e75cec462245c1001191a0634c6f55565b005b606460405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152fd5b610104359063ffffffff8216820361018757565b610a8f6040929594939560608352606083019061042b565b9460208201520152565b34610187576101203660031901126101875760243560ff8116810361018757604435610ac481610176565b60643590610ad182610176565b60a435610add81610176565b60c435610ae981610176565b60e4359163ffffffff831683036101875761020395610b1795610b0a610a63565b95608435926004356126b6565b60409391935193849384610a77565b3461018757602036600319011261018757600435600090808252600080516020612b288339815191528060205260ff600860408520015460081c16600481101561027e576001610b7691146110c7565b8183526020526001600160a01b038060016040852001541690610b97610c11565b1603610ba957610ba6906111e4565b80f35b606460405162461bcd60e51b815260206004820152600860248201527f214f666665726f720000000000000000000000000000000000000000000000006044820152fd5b90816020910312610187575180151581036101875790565b6040513d6000823e3d90fd5b60405163572b6c0560e01b8152336004820152602081602481305afa908115610c8057600091610c52575b5015610c4e5736601319013560601c90565b3390565b610c73915060203d8111610c79575b610c6b8183610133565b810190610bed565b38610c3c565b503d610c61565b610c05565b634e487b7160e01b600052601160045260246000fd5b919082039182116106db57565b60405163572b6c0560e01b8152336004820152602081602481305afa908115610c8057600091610cf3575b5015610cec576013193601903682116106db5760009190565b6000903690565b610d0b915060203d8111610c7957610c6b8183610133565b38610cd3565b6001600160a01b03815116604051907fa32fa5b30000000000000000000000000000000000000000000000000000000082527f86d5cf0a6bdc8d859ba3bdc97043337c82a0e609035f378e419298b6a3e00ae660048301526024820152602081604481305afa908115610c8057600091610dd9575b5015610d955761047e90610f87565b606460405162461bcd60e51b815260206004820152600b60248201527f2141535345545f524f4c450000000000000000000000000000000000000000006044820152fd5b610df1915060203d8111610c7957610c6b8183610133565b38610d86565b600382101561027e5752565b600482101561027e5752565b90600381101561027e5760ff80198354169116179055565b90600481101561027e5761ff0082549160081b169061ff001916179055565b9061012060086103919383518155610e97610e6b60208601516001600160a01b031690565b60018301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b610eda610eae60408601516001600160a01b031690565b60028301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b6060840151600382015560808401516004820155610f31610f0560a08601516001600160a01b031690565b60058301906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b60c0840151600682015560e084015160078201550191610f5f610100820151610f59816102d0565b84610e0f565b015190610f6b826102e7565b610e27565b9081526101608101929161039191602001906102fe565b90610f90611494565b91610f99610c11565b81516001600160a01b0316610fad906114c8565b91610fb8838261176c565b80516001600160a01b0316906020810193845160408301516060840151610fe5906001600160a01b031690565b60808501519160a086015193610ff9610155565b8c81526001600160a01b038a166020820152976001600160a01b03166040890152606088015260808701526001600160a01b031660a086015260c085015260e084015261104a906101008401610df7565b60016101208301528161107487600052600080516020612b28833981519152602052604060002090565b9061107e91610e46565b51925160405190936001600160a01b0390811693169181906110a1908883610f70565b037fe5f7d2ca9b939cd61d1b80107f4733d6552e26d08e899e8b27d99b4bb01466da91a4565b156110ce57565b606460405162461bcd60e51b815260206004820152601b60248201527f4d61726b6574706c6163653a20696e76616c6964206f666665722e00000000006044820152fd5b9061039160ff6008611122610155565b948054865261114e61113e60018301546001600160a01b031690565b6001600160a01b03166020880152565b61117561116560028301546001600160a01b031690565b6001600160a01b03166040880152565b60038101546060870152600481015460808701526111b06111a060058301546001600160a01b031690565b6001600160a01b031660a0880152565b600681015460c0870152600781015460e087015201546111d68282166101008701610df7565b60081c166101208401610e03565b80600052600080516020612b2883398151915260205261121860406000206008810161030061ff0019825416179055611112565b611220610c11565b917f656fae5ac58099f1303c3dd53bbc9e4b0f000700d538d81ef7f5716ab1a34b9060206001600160a01b03606081604087015116950151956040519485521692a4565b1561126b57565b606460405162461bcd60e51b815260206004820152600760248201527f45585049524544000000000000000000000000000000000000000000000000006044820152fd5b156112b657565b608460405162461bcd60e51b815260206004820152602b60248201527f4d61726b6574706c6163653a20696e73756666696369656e742063757272656e60448201527f63792062616c616e63652e0000000000000000000000000000000000000000006064820152fd5b60405190610140820182811067ffffffffffffffff8211176100fe57604052816101206000918281528260208201528260408201528260608201528260808201528260a08201528260c08201528260e0820152826101008201520152565b1561138557565b606460405162461bcd60e51b815260206004820152600d60248201527f696e76616c69642072616e6765000000000000000000000000000000000000006044820152fd5b90600182018092116106db57565b90610e1082018092116106db57565b919082018092116106db57565b67ffffffffffffffff81116100fe5760051b60200190565b90611415826113f3565b6114226040519182610133565b8281528092611433601f19916113f3565b019060005b82811061144457505050565b60209061144f611320565b82828501015201611438565b805182101561146f5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b60001981146106db5760010190565b7fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca99081549160018301908184116106db5755565b6040517f01ffc9a7000000000000000000000000000000000000000000000000000000008082527fd9b67a260000000000000000000000000000000000000000000000000000000060048301526020926001600160a01b0316918381602481865afa908115610c8057600091611622575b501561154757505050600190565b6040519081527f80ac58cd000000000000000000000000000000000000000000000000000000006004820152908290829060249082905afa918215610c8057600092611605575b50501561159a57600090565b60405162461bcd60e51b815260206004820152602d60248201527f4d61726b6574706c6163653a20746f6b656e206d75737420626520455243313160448201527f3535206f72204552433732312e000000000000000000000000000000000000006064820152608490fd5b61161b9250803d10610c7957610c6b8183610133565b388061158e565b6116399150843d8611610c7957610c6b8183610133565b38611539565b1561164657565b606460405162461bcd60e51b815260206004820152602060248201527f4d61726b6574706c6163653a2077616e746564207a65726f20746f6b656e732e6044820152fd5b1561169157565b608460405162461bcd60e51b815260206004820152602560248201527f4d61726b6574706c6163653a2077616e74656420696e76616c6964207175616e60448201527f746974792e0000000000000000000000000000000000000000000000000000006064820152fd5b1561170257565b608460405162461bcd60e51b815260206004820152602a60248201527f4d61726b6574706c6163653a20696e76616c69642065787069726174696f6e2060448201527f74696d657374616d702e000000000000000000000000000000000000000000006064820152fd5b9060808201918251156117fa57610391926117a66117e1936001604085016117968151151561163f565b51149081156117e6575b5061168a565b6117bd6117b660a08401516113d7565b42106116fb565b6117d960606117ca610c11565b9301516001600160a01b031690565b905191611bd3565b6112af565b600191506117f3816102d0565b14386117a0565b606460405162461bcd60e51b815260206004820152600b60248201527f7a65726f2070726963652e0000000000000000000000000000000000000000006044820152fd5b60e08101514210908161187c575b81611855575090565b61047e91506001600160a01b039060c0826020830151169260a08301511691015191611bd3565b9050610120810151600481101561027e576001149061184c565b90816020910312610187575161047e81610176565b90816020910312610187575190565b156118c157565b608460405162461bcd60e51b815260206004820152602a60248201527f4d61726b6574706c6163653a206e6f74206f776e6572206f7220617070726f7660448201527f656420746f6b656e732e000000000000000000000000000000000000000000006064820152fd5b92919360009061193a816102d0565b60018103611a36575050604051627eeac760e11b81526001600160a01b0384811660048301526024820195909552931692602091908281604481885afa908115610c8057600091611a09575b501015918261199c575b505061039191506118ba565b60405163e985e9c560e01b81526001600160a01b0391909116600482015230602482015290929091508290829060449082905afa908115610c8057610391926000926119ec575b50503880611990565b611a029250803d10610c7957610c6b8183610133565b38806119e3565b611a299150833d8511611a2f575b611a218183610133565b8101906118ab565b38611986565b503d611a17565b909391949250611a45816102d0565b15611a5657505061039191506118ba565b6040516331a9108f60e11b8152600481018390526001600160a01b03948516949293919260209182816024818a5afa908115610c80578491611bb6575b508116848216149485611ab2575b505050505061039191503880611990565b6040517f081812fc0000000000000000000000000000000000000000000000000000000081526004810191909152939450919290918282602481895afa918215610c80578492611b87575b50163014928315611b1b575b50505061039191503880808080611aa1565b60405163e985e9c560e01b81526001600160a01b0391909116600482015230602482015291939092508290829060449082905afa918215610c80576103919392611b6a575b5050388080611b09565b611b809250803d10610c7957610c6b8183610133565b3880611b60565b611ba8919250833d8511611baf575b611ba08183610133565b810190611896565b9038611afd565b503d611b96565b611bcd9150833d8511611baf57611ba08183610133565b38611a93565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b038281166004830152929092169290916020908181602481885afa8015610c80578391600091611cc3575b5010159283611c3d575b505050905090565b6040517fdd62ed3e0000000000000000000000000000000000000000000000000000000081526001600160a01b0391909116600482015230602482015291939092508290829060449082905afa918215610c8057600092611ca6575b5050101580388080611c35565b611cbc9250803d10611a2f57611a218183610133565b3880611c99565b611cda9150833d8511611a2f57611a218183610133565b38611c2b565b9192610100810160018151611cf4816102d0565b611cfd816102d0565b03611dc757506060611d2b611d1f611d1f60408501516001600160a01b031690565b6001600160a01b031690565b91015191813b156101875760008094611da3604051978896879586947ff242432a00000000000000000000000000000000000000000000000000000000865260048601929060c094926001600160a01b0380921685521660208401526040830152606082015260a06080820152600060a08201520190565b03925af18015610c8057611db45750565b80611dc161039192610103565b80610283565b9091935051611dd5816102d0565b611dde816102d0565b15611de857505050565b6060611e04611d1f611d1f60408501516001600160a01b031690565b91015190803b15610187576040517fb88d4fde0000000000000000000000000000000000000000000000000000000081526001600160a01b03938416600482015293909216602484015260448301526080606483015260006084830181905290829060a490829084905af18015610c8057611db45750565b91908260409103126101875760208251611e9581610176565b92015161ffff811681036101875790565b818102929181159184041417156106db57565b91908260409103126101875760208251611ed281610176565b92015190565b15611edf57565b606460405162461bcd60e51b815260206004820152601560248201527f66656573206578636565642074686520707269636500000000000000000000006044820152fd5b909192936040948551957fd45573f60000000000000000000000000000000000000000000000000000000087528087600481305afa8015610c80576103919761205c9461205693612025936000938491612106575b50918a6001600160a01b039373716992d45bc60e9ead5f59206c0d049afbff429f858316146120fe575b611fb361ffff611fbb92168a611ea6565b612710900490565b80956000978589968c88976060611fe1611d1f611d1f868501516001600160a01b031690565b91015183518096819482937f2a55205a0000000000000000000000000000000000000000000000000000000084526004840160209093929193604081019481520152565b03915afa87928392826120cb575b5050612074575b505061205195508b82612062575b92915050612184565b6113e6565b90610c9b565b92612184565b61206b93612184565b8a84388b612048565b9250929450929481161515806120c2575b612096575b8492879492879261203a565b85965061205194506120b6896120af88859697956113e6565b1115611ed8565b9195819392945061208a565b50811515612085565b80919294506120ef9350903d106120f7575b6120e78183610133565b810190611eb9565b913880612033565b503d6120dd565b506000611fa2565b9050816121299294503d8511612132575b6121218183610133565b810190611e7c565b92909238611f78565b503d612117565b1561214057565b606460405162461bcd60e51b815260206004820152601360248201527f6d73672e76616c756520213d20616d6f756e74000000000000000000000000006044820152fd5b908315612281576001600160a01b039180831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee03612275575081163003612229575090600091823b15612225576040517f2e1a7d4d00000000000000000000000000000000000000000000000000000000815260048101839052928360248183805af1928315610c805761039193612212575b5061239e565b80611dc161221f92610103565b3861220c565b8280fd5b8116300361226b575061223d348214612139565b60003b1561018757600060049160405192838092630d0e30db60e41b8252845af18015610c8057611db45750565b906103919161239e565b61039194939250612287565b50505050565b92916001600160a01b03918216828216818114612356573082036122f057505060405163a9059cbb60e01b60208201526001600160a01b0390911660248201526044810192909252610391926122ea83606481015b03601f198101855284610133565b16612562565b90939150604051937f23b872dd0000000000000000000000000000000000000000000000000000000060208601526024850152604484015260648301526064825260a082019282841067ffffffffffffffff8511176100fe576103919360405216612562565b505050505050565b3d15612399573d9067ffffffffffffffff82116100fe576040519161238d601f8201601f191660200184610133565b82523d6000602084013e565b606090565b60008080808086865af16123b061235e565b50156123bb57505050565b803b156124ee57604051630d0e30db60e41b8152818160048187845af18015610c80576124df575b5060405163a9059cbb60e01b60208083019182526001600160a01b0390941660248301526044820194909452919261241e83606481016122dc565b6040519261242b84610117565b8484527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656485850152823b1561249b579180916124769493519082805af161247061235e565b90612609565b8051908161248357505050565b8261039193612496938301019101610bed565b6124f1565b6064856040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b6124e890610103565b386123e3565b80fd5b156124f857565b608460405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b6001600160a01b0316906040519061257982610117565b6020928383527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656484840152803b156125c557600082819282876124769796519301915af161247061235e565b6064846040519062461bcd60e51b82526004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152fd5b90919015612615575090565b8151156126255750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b82851061266b575050604492506000838284010152601f80199101168101030190fd5b8481018201518686016044015293810193859350612648565b9061268e826113f3565b61269b6040519182610133565b82815280926126ac601f19916113f3565b0190602036910137565b959390919296989442917fe4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624ca954986126f263ffffffff8c16612684565b976000995b8b81108e81612b17575b5080612b08575b15612a655761273161058182600052600080516020612b28833981519152602052604060002090565b60808816158015612a4c575b612766575b509b9c6000190163ffffffff169b6001019a8c8e828e5b505050509a9c9b9c6126f7565b60408816158015612a33575b61277c575b612742565b60208816158015612a26575b156127425760108816158015612a0d575b1561274257600188161580156129ec575b15612742576002808916159081156129cb575b501561277757600488161580156129be575b15612777579a8c9d9b6008899e939e16612813575b508c6127f663ffffffff83168d61145b565b5260010163ffffffff169a6000190163ffffffff169c9b90612742565b909150610100810151612825816102d0565b61282e816102d0565b15612911575b6001610100820151612845816102d0565b61284e816102d0565b1461285c575b908d916127e4565b60209b9e9d919b816060612883611d1f611d1f60406128b89701516001600160a01b031690565b910151604051627eeac760e11b81526001600160a01b038e166004820152602481019190915292839190829081906044820190565b03915afa600091816128f0575b506128d457508c8e828e612759565b9d9a909c9d156128e4578c612854565b999c9b8c8e828e612759565b61290a91925060203d602011611a2f57611a218183610133565b90386128c5565b61295b9b9e9d919b6020612935611d1f611d1f60408601516001600160a01b031690565b60608401519060405180809581946331a9108f60e11b8352600483019190602083019252565b03915afa6000918161299d575b506129785750508c8e828e612759565b9d9e9b919d6001600160a01b03808c16911603156128345750999c9b8c8e828e612759565b6129b791925060203d602011611baf57611ba08183610133565b9038612968565b508660e0820151116127cf565b90506101208201516129dc816102e7565b6129e5816102e7565b14386127bd565b5060016101208201516129fe816102e7565b612a07816102e7565b146127aa565b5060208101516001600160a01b03878116911614612799565b5084606082015114612788565b5060408101516001600160a01b03858116911614612772565b5060208101516001600160a01b038a811691161461273d565b97509a505050509750505063ffffffff9192936000908210600014612b0157505b921691612a928361140b565b9460005b63ffffffff811685811015612af85763ffffffff91612af082612adf610581612ac16001968b61145b565b51600052600080516020612b28833981519152602052604060002090565b612ae9828d61145b565b528a61145b565b500116612a96565b50509250929050565b9050612a86565b5063ffffffff8d161515612708565b63ffffffff91501615158e61270156fee4435c80c9874d455ad2136af47d67165644bb851fd208179d93e973f0624caaa2646970667358221220e27da20838eb9e74efa6a1314c2beacfc202a7f94e8ff343b9de0d3dbc396aa964736f6c63430008120033