Source Code
Overview
MNT Balance
MNT Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
ZonicMarketplaceV1
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 500 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "./lib/OrderProcessorUpgradable.sol";
import "./lib/PersonalSignLib.sol";
import {
_revertWithUnsupportedCannotBuyYourOwnItem
} from './lib/OrderErrors.sol';
import {
OrderType,
ItemType
} from "./lib/OrderEnums.sol";
contract ZonicMarketplaceV1 is OrderProcessorUpgradable, ReentrancyGuardUpgradeable, PersonalSignLib {
event ZonicBasicOrderFulfilled(address offerer, address buyer, address token, uint256 identifier, address currency, uint256 totalPrice, uint256 creatorFee, uint256 marketplaceFee, address saleId);
event ZonicBasicOrderCanceled(address offerer, address token, uint256 identifier, address saleId);
address signerAddress;
address adminAddress;
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
function initialize(string memory signDomainName, string memory signVersion, uint256 _maxCreatorFeePercentage, uint256 _marketplaceFeePercentage, address _marketplaceFeePayoutAddress, address _signerAddress, address _adminAddress) public initializer {
__OrderProcessor_init(signDomainName, signVersion, _maxCreatorFeePercentage, _marketplaceFeePercentage, _marketplaceFeePayoutAddress);
__ReentrancyGuard_init();
signerAddress = _signerAddress;
adminAddress = _adminAddress;
}
function fulfillBasicOrder(
Listing calldata listing,
bytes calldata signature,
uint8 adminSignatureV,
bytes32 adminSignatureR,
bytes32 adminSignatureS,
uint32 adminSigExpiredAt
) external payable whenNotPaused nonReentrant {
require(__recoverAddress(abi.encodePacked(listing.saleId, "%", adminSigExpiredAt, "%", address(this), "%", block.chainid), adminSignatureV, adminSignatureR, adminSignatureS) == signerAddress, "Invalid admin Signature");
require(adminSigExpiredAt > block.timestamp, "Admin signature is expired");
// Offerer and buyer could not be the same address
if (listing.offerer == msg.sender)
_revertWithUnsupportedCannotBuyYourOwnItem();
uint256 marketplaceFee;
uint256 totalPrice;
uint256 totalCreatorFee;
(totalPrice, totalCreatorFee, marketplaceFee) = __validateOrderForFulfill(listing, signature);
// Mark Sale Id used
__markSaleIdUsed(listing.saleId);
// Send Event ahead of Transfer event
__emitZonicBasicOrderFulfilledEvent(listing, totalPrice, totalCreatorFee, marketplaceFee);
// -------------------
// -- Process Order --
// -------------------
// Transfer Offered Item
_transferOfferItems(listing);
// Transfer Payout
_transferPayout(listing, marketplaceFee);
}
function __emitZonicBasicOrderFulfilledEvent(
Listing calldata listing,
uint256 totalPrice,
uint256 totalCreatorFee,
uint256 marketplaceFee
) private {
emit ZonicBasicOrderFulfilled(
listing.offerer,
msg.sender,
listing.offers[0].token,
listing.offers[0].identifier,
listing.offererPayout.token,
totalPrice,
totalCreatorFee,
marketplaceFee,
listing.saleId);
}
function cancelBasicOrder(
Listing calldata listing,
bytes calldata signature
) external whenNotPaused nonReentrant {
// Check if caller is of offerer or admin
require(msg.sender == listing.offerer || msg.sender == adminAddress, "Caller is not offerer or admin");
__validateOrderForCancelation(listing, signature);
__markSaleIdUsed(listing.saleId);
emit ZonicBasicOrderCanceled(
listing.offerer,
listing.offers[0].token,
listing.offers[0].identifier,
listing.saleId);
}
/* Admin Functions */
function setSignerAddress(address _signerAddress) public onlyOwner {
signerAddress = _signerAddress;
}
function setAdminAddress(address _adminAddress) public onlyOwner {
adminAddress = _adminAddress;
}
function pause() public {
require(_msgSender() == owner() || _msgSender() == adminAddress, "Caller does not have permission");
_pause();
}
function unpause() public {
require(_msgSender() == owner() || _msgSender() == adminAddress, "Caller does not have permission");
_unpause();
}
/* Helper Methods */
function _transferOfferItems(
Listing memory listing
) internal {
for (uint i = 0; i < listing.offers.length; i++) {
_performTransfer(
listing.offerer,
msg.sender,
listing.offers[i].itemType,
listing.offers[i].token,
listing.offers[i].identifier,
listing.offers[i].amount
);
}
}
function _transferPayout(
Listing memory listing,
uint256 marketplaceFee
) internal {
// Transfer Offerer payout
_performTransfer(
msg.sender,
listing.offererPayout.recipient,
listing.offererPayout.itemType,
listing.offererPayout.token,
listing.offererPayout.identifier,
listing.offererPayout.amount
);
// Transfer Creator Payouts
for (uint i = 0; i < listing.creatorPayouts.length; i++)
_performTransfer(
msg.sender,
listing.creatorPayouts[i].recipient,
listing.creatorPayouts[i].itemType,
listing.creatorPayouts[i].token,
listing.creatorPayouts[i].identifier,
listing.creatorPayouts[i].amount
);
// Transfer Marketplace Fee
_performTransfer(
msg.sender,
marketplaceFeePayoutAddress,
listing.offererPayout.itemType,
listing.offererPayout.token,
listing.offererPayout.identifier,
marketplaceFee
);
}
function _performTransfer(
address sender,
address recipient,
uint8 itemType,
address tokenAddress,
uint256 identifier,
uint256 amount
) internal {
if (itemType == uint8(ItemType.COIN)) {
// Native Currency
require(sender == msg.sender, "Invalid sender");
require(tokenAddress == address(0), "Invalid address");
_transferEth(payable(recipient), amount);
} else if (itemType == uint8(ItemType.ERC20_TOKEN)) {
// ERC20
IERC20 tokenContract = IERC20(tokenAddress);
tokenContract.transferFrom(sender, recipient, amount);
} else if (itemType == uint8(ItemType.ERC721_TOKEN)) {
// ERC721
IERC721 tokenContract = IERC721(tokenAddress);
tokenContract.safeTransferFrom(sender, recipient, identifier);
require(tokenContract.ownerOf(identifier) == recipient, "Transfer Failed");
} else if (itemType == uint8(ItemType.ERC1155_TOKEN)) {
// ERC1155
IERC1155 tokenContract = IERC1155(tokenAddress);
tokenContract.safeTransferFrom(sender, recipient, identifier, amount, "");
}
}
function _transferEth(address payable to, uint256 amount) internal {
if (amount == 0)
return;
(bool sent,) = to.call{ value: amount }("");
require(sent, "Ether not sent");
}
/* Fail Safe Methods */
function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
function withdrawERC20Token(address tokenAddress) public onlyOwner {
IERC20 tokenContract = IERC20(tokenAddress);
tokenContract.transfer(msg.sender, tokenContract.balanceOf(address(this)));
}
function withdrawERC721Token(address tokenAddress, uint256 tokenId) public onlyOwner {
IERC721 tokenContract = IERC721(tokenAddress);
tokenContract.safeTransferFrom(address(this), msg.sender, tokenId);
}
function withdrawERC721Tokens(address tokenAddress, uint256[] memory tokenIds) public onlyOwner {
IERC721 tokenContract = IERC721(tokenAddress);
for (uint i = 0; i < tokenIds.length; i++)
tokenContract.safeTransferFrom(address(this), msg.sender, tokenIds[i]);
}
/* Storage Gap */
uint256[50] __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// 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;
uint256 private _status;
function __ReentrancyGuard_init() internal onlyInitializing {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal onlyInitializing {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/MathUpgradeable.sol";
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = MathUpgradeable.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, MathUpgradeable.log256(value) + 1);
}
}
/**
* @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] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../StringsUpgradeable.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSAUpgradeable {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV // Deprecated in v4.8
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
/// @solidity memory-safe-assembly
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
uint8 v = uint8((uint256(vs) >> 255) + 27);
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)
pragma solidity ^0.8.0;
import "./ECDSAUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*
* @custom:storage-size 52
*/
abstract contract EIP712Upgradeable is Initializable {
/* solhint-disable var-name-mixedcase */
bytes32 private _HASHED_NAME;
bytes32 private _HASHED_VERSION;
bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
__EIP712_init_unchained(name, version);
}
function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());
}
function _buildDomainSeparator(
bytes32 typeHash,
bytes32 nameHash,
bytes32 versionHash
) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);
}
/**
* @dev The hash of the name parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712NameHash() internal virtual view returns (bytes32) {
return _HASHED_NAME;
}
/**
* @dev The hash of the version parameter for the EIP712 domain.
*
* NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
* are a concern.
*/
function _EIP712VersionHash() internal virtual view returns (bytes32) {
return _HASHED_VERSION;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library MathUpgradeable {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface 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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.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);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// 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);
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
// keccak256("OfferItem(uint8 itemType,address token,uint256 identifier,uint256 amount)")
bytes32 constant OFFER_ITEM_TYPEHASH = 0x3d2811298909c55efd9f4f108efcfb0e7e2ec71cbbc7afc8b15862b50858ac8e;
// keccak256("Payout(uint8 itemType,address token,uint256 identifier,address recipient,uint256 amount)")
bytes32 constant PAYOUT_TYPEHASH = 0x2f640164aec5dd9f523d2a80beac36e83213daadafecd22ac297bb068187d193;
// keccak256("Listing(address offerer,OfferItem[] offers,Payout offererPayout,Payout[] creatorPayouts,uint8 orderType,uint32 listedAt,uint32 expiredAt,address saleId,uint8 version)OfferItem(uint8 itemType,address token,uint256 identifier,uint256 amount)Payout(uint8 itemType,address token,uint256 identifier,address recipient,uint256 amount)")
bytes32 constant LISTING_TYPEHASH = 0x0b27a7ffaa1672a8a16a672f5069c3a1e39bc0eabe3ec494cb9ea22c797b00e6;// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
enum OrderType {
FULL_OPEN,
PARTIAL_OPEN,
FULL_RESTRICTED,
PARTIAL_RESTRICTED,
CONTRACT
}
enum ItemType {
COIN,
ERC20_TOKEN,
ERC721_TOKEN,
ERC1155_TOKEN
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
function _revertMissingEther() pure {
revert("Missing Ether");
}
function _revertWithInvalidSignature() pure {
revert("Invalid Signature");
}
function _revertWithOrderNotStarted() pure {
revert("Order Not Started");
}
function _revertWithOrderExpired() pure {
revert("Order Expired");
}
function _revertWithDuplicatedSaleId() pure {
revert("Duplicate saleId");
}
function _revertWithInvalidOfferCount() pure {
revert("Invalid Offer Count");
}
function _revertWithUnsupportedListingOrderType() pure {
revert("Unsupported Listing Order Type");
}
function _revertWithUnsupportedOfferItemType() pure {
revert("Unsupported Offer Item Type");
}
function _revertWithUnsupportedPayoutItemType() pure {
revert("Unsupported Payout Item Type");
}
function _revertWithUnsupportedPayoutFormat() pure {
revert("Unsupported Payout Format");
}
function _revertWithUnsupportedCannotBuyYourOwnItem() pure {
revert("Cannot buy your own item");
}
function _revertWithUnsupportedCreatorFeeExceedAllowed() pure {
revert("Total creator fee exceeds the allowed rate");
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import {
OfferItem,
Payout,
Listing
} from "./OrderStructs.sol";
import {
OFFER_ITEM_TYPEHASH,
PAYOUT_TYPEHASH,
LISTING_TYPEHASH
} from "./OrderConstants.sol";
import {
_revertMissingEther,
_revertWithInvalidSignature,
_revertWithOrderNotStarted,
_revertWithOrderExpired,
_revertWithDuplicatedSaleId,
_revertWithUnsupportedListingOrderType,
_revertWithInvalidOfferCount,
_revertWithUnsupportedOfferItemType,
_revertWithUnsupportedPayoutItemType,
_revertWithUnsupportedPayoutFormat,
_revertWithUnsupportedCreatorFeeExceedAllowed
} from "./OrderErrors.sol";
import {
OrderType,
ItemType
} from "./OrderEnums.sol";
contract OrderProcessorUpgradable is OwnableUpgradeable, PausableUpgradeable, EIP712Upgradeable {
using ECDSAUpgradeable for bytes32;
uint256 public maxCreatorFeePercentage; // 10000 = 100%
uint256 public marketplaceFeePercentage; // 10000 = 100%
address public marketplaceFeePayoutAddress;
mapping(address => bool) private usedSaleIds;
mapping(address => bool) private usedOfferIds;
// Initializer
function __OrderProcessor_init(string memory name, string memory version, uint256 _maxCreatorFeePercentage, uint256 _marketplaceFeePercentage, address _marketplaceFeePayoutAddress) internal onlyInitializing {
__OrderProcessor_init_unchained(name, version, _maxCreatorFeePercentage, _marketplaceFeePercentage, _marketplaceFeePayoutAddress);
}
function __OrderProcessor_init_unchained(string memory name, string memory version, uint256 _maxCreatorFeePercentage, uint256 _marketplaceFeePercentage, address _marketplaceFeePayoutAddress) internal onlyInitializing {
__EIP712_init(name, version);
__Ownable_init();
__Pausable_init();
maxCreatorFeePercentage = _maxCreatorFeePercentage;
marketplaceFeePercentage = _marketplaceFeePercentage;
marketplaceFeePayoutAddress = _marketplaceFeePayoutAddress;
}
// Admin Functions
function setMaxCreatorFeePercentage(uint256 _maxCreatorFeePercentage) public onlyOwner {
require(_maxCreatorFeePercentage <= 1000, "Max creator fee could not exceed 30%");
maxCreatorFeePercentage = _maxCreatorFeePercentage;
}
function setMarketplaceFeePercentage(uint256 _marketplaceFeePercentage) public onlyOwner {
require(_marketplaceFeePercentage <= 1000, "Marketplace fee could not exceed 10%");
marketplaceFeePercentage = _marketplaceFeePercentage;
}
function setMarketplaceFeePayoutAddress(address _marketplaceFeePayoutAddress) public onlyOwner {
marketplaceFeePayoutAddress = _marketplaceFeePayoutAddress;
}
// Order Functions
function __validateOrderForFulfill(
Listing calldata listing,
bytes calldata signature
) internal view returns (uint256 totalPrice, uint256 totalCreatorFee, uint256 marketplaceFee) {
// Must started
if (block.timestamp < listing.listedAt)
_revertWithOrderNotStarted();
// Must not expired
if (listing.expiredAt < block.timestamp)
_revertWithOrderExpired();
// Must be coming with ETH
if (msg.value == 0)
_revertMissingEther();
// Signature must match the offerer address
if (__recoverAddressOfListing(listing, signature) != listing.offerer)
_revertWithInvalidSignature();
// Check Order Type
if (listing.orderType != uint8(OrderType.FULL_RESTRICTED))
_revertWithUnsupportedListingOrderType();
// Check Offer Item Type
for (uint i = 0; i < listing.offers.length; i++)
if (listing.offers[i].itemType != uint8(ItemType.ERC721_TOKEN))
_revertWithUnsupportedOfferItemType();
// Check Payout Item Type
if (listing.offererPayout.itemType != uint8(ItemType.COIN))
_revertWithUnsupportedPayoutItemType();
for (uint i = 0; i < listing.creatorPayouts.length; i++)
if (listing.creatorPayouts[i].itemType != uint8(ItemType.COIN))
_revertWithUnsupportedPayoutItemType();
// Check for Payout Format
if (listing.offererPayout.recipient != listing.offerer)
_revertWithUnsupportedPayoutFormat();
// Calculate ETH value for each part
uint256 offererEarning = listing.offererPayout.amount;
for (uint i = 0; i < listing.creatorPayouts.length; i++)
totalCreatorFee = totalCreatorFee + listing.creatorPayouts[i].amount;
totalPrice = (offererEarning + totalCreatorFee) * 10000 / (10000 - marketplaceFeePercentage);
// Total creator fee must not exceed maxCreatorFeePercentage
if (totalCreatorFee * 10000 / totalPrice > maxCreatorFeePercentage)
_revertWithUnsupportedCreatorFeeExceedAllowed();
// Check total ETH value
if (totalPrice != msg.value)
_revertMissingEther();
// Validate saleId
if (__isSaleIdUsed(listing.saleId))
_revertWithDuplicatedSaleId();
marketplaceFee = totalPrice - offererEarning - totalCreatorFee;
}
function __validateOrderForCancelation(
Listing calldata listing,
bytes calldata signature
) internal view {
// Signature must match the offerer address
if (__recoverAddressOfListing(listing, signature) != listing.offerer)
_revertWithInvalidSignature();
}
function __isSaleIdUsed(address saleId) internal view returns (bool) {
return usedSaleIds[saleId];
}
function __markSaleIdUsed(address saleId) internal {
usedSaleIds[saleId] = true;
}
function __encodeOfferItem(OfferItem calldata offerItem) private pure returns (bytes memory) {
return abi.encode(OFFER_ITEM_TYPEHASH, offerItem.itemType, offerItem.token, offerItem.identifier, offerItem.amount);
}
function __encodePayout(Payout calldata payout) private pure returns (bytes memory) {
return abi.encode(PAYOUT_TYPEHASH, payout.itemType, payout.token, payout.identifier, payout.recipient, payout.amount);
}
function __encodeListing(Listing calldata listing) private pure returns (bytes memory) {
bytes32[] memory encodedOffers = new bytes32[](listing.offers.length);
for (uint256 i = 0; i < listing.offers.length; i++)
encodedOffers[i] = keccak256(__encodeOfferItem(listing.offers[i]));
bytes32[] memory encodedCreatorPayouts = new bytes32[](listing.creatorPayouts.length);
for (uint256 i = 0; i < listing.creatorPayouts.length; i++)
encodedCreatorPayouts[i] = keccak256(__encodePayout(listing.creatorPayouts[i]));
return
abi.encode(
LISTING_TYPEHASH,
listing.offerer,
keccak256(abi.encodePacked(encodedOffers)),
keccak256(__encodePayout(listing.offererPayout)),
keccak256(abi.encodePacked(encodedCreatorPayouts)),
listing.orderType,
listing.listedAt,
listing.expiredAt,
listing.saleId,
listing.version
);
}
function __recoverAddressOfListing(
Listing calldata listing,
bytes calldata signature
) private view returns (address) {
return _hashTypedDataV4(keccak256(__encodeListing(listing))).recover(signature);
}
// Offer Functions
// Storage Gap
uint256[49] private __gap;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
struct OfferItem {
uint8 itemType;
address token;
uint256 identifier;
uint256 amount;
}
struct Payout {
uint8 itemType;
address token;
uint256 identifier;
address recipient;
uint256 amount;
}
struct Listing {
address offerer;
OfferItem[] offers;
Payout offererPayout;
Payout[] creatorPayouts;
uint8 orderType;
uint32 listedAt;
uint32 expiredAt;
address saleId;
uint8 version;
}// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
contract PersonalSignLib {
function __recoverAddress(bytes memory data, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
bytes32 msgHash = keccak256(data);
bytes32 messageDigest = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", msgHash));
return ecrecover(messageDigest, v, r, s);
}
}{
"libraries": {},
"optimizer": {
"enabled": true,
"runs": 500
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"offerer","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"identifier","type":"uint256"},{"indexed":false,"internalType":"address","name":"saleId","type":"address"}],"name":"ZonicBasicOrderCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"offerer","type":"address"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"identifier","type":"uint256"},{"indexed":false,"internalType":"address","name":"currency","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"creatorFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"marketplaceFee","type":"uint256"},{"indexed":false,"internalType":"address","name":"saleId","type":"address"}],"name":"ZonicBasicOrderFulfilled","type":"event"},{"inputs":[{"components":[{"internalType":"address","name":"offerer","type":"address"},{"components":[{"internalType":"uint8","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifier","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct OfferItem[]","name":"offers","type":"tuple[]"},{"components":[{"internalType":"uint8","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifier","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Payout","name":"offererPayout","type":"tuple"},{"components":[{"internalType":"uint8","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifier","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Payout[]","name":"creatorPayouts","type":"tuple[]"},{"internalType":"uint8","name":"orderType","type":"uint8"},{"internalType":"uint32","name":"listedAt","type":"uint32"},{"internalType":"uint32","name":"expiredAt","type":"uint32"},{"internalType":"address","name":"saleId","type":"address"},{"internalType":"uint8","name":"version","type":"uint8"}],"internalType":"struct Listing","name":"listing","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"cancelBasicOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"offerer","type":"address"},{"components":[{"internalType":"uint8","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifier","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct OfferItem[]","name":"offers","type":"tuple[]"},{"components":[{"internalType":"uint8","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifier","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Payout","name":"offererPayout","type":"tuple"},{"components":[{"internalType":"uint8","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifier","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct Payout[]","name":"creatorPayouts","type":"tuple[]"},{"internalType":"uint8","name":"orderType","type":"uint8"},{"internalType":"uint32","name":"listedAt","type":"uint32"},{"internalType":"uint32","name":"expiredAt","type":"uint32"},{"internalType":"address","name":"saleId","type":"address"},{"internalType":"uint8","name":"version","type":"uint8"}],"internalType":"struct Listing","name":"listing","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint8","name":"adminSignatureV","type":"uint8"},{"internalType":"bytes32","name":"adminSignatureR","type":"bytes32"},{"internalType":"bytes32","name":"adminSignatureS","type":"bytes32"},{"internalType":"uint32","name":"adminSigExpiredAt","type":"uint32"}],"name":"fulfillBasicOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"signDomainName","type":"string"},{"internalType":"string","name":"signVersion","type":"string"},{"internalType":"uint256","name":"_maxCreatorFeePercentage","type":"uint256"},{"internalType":"uint256","name":"_marketplaceFeePercentage","type":"uint256"},{"internalType":"address","name":"_marketplaceFeePayoutAddress","type":"address"},{"internalType":"address","name":"_signerAddress","type":"address"},{"internalType":"address","name":"_adminAddress","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"marketplaceFeePayoutAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketplaceFeePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxCreatorFeePercentage","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_adminAddress","type":"address"}],"name":"setAdminAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marketplaceFeePayoutAddress","type":"address"}],"name":"setMarketplaceFeePayoutAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_marketplaceFeePercentage","type":"uint256"}],"name":"setMarketplaceFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxCreatorFeePercentage","type":"uint256"}],"name":"setMaxCreatorFeePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signerAddress","type":"address"}],"name":"setSignerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"withdrawERC20Token","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdrawERC721Token","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"withdrawERC721Tokens","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60806040523480156200001157600080fd5b506200001c62000022565b620000e4565b600054610100900460ff16156200008f5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff9081161015620000e2576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b61324480620000f46000396000f3fe60806040526004361061013a5760003560e01c806344e03820116100bb5780638456cb591161007f578063a7aebf3611610059578063a7aebf3614610360578063eca63ff014610380578063f2fde38b146103a057600080fd5b80638456cb591461031a5780638da5cb5b1461032f578063a71c9b7f1461034d57600080fd5b806344e038201461028c5780634adadddf146102ac5780635c975abb146102c2578063715018a6146102e55780637a5dfd3f146102fa57600080fd5b80633aaed7b9116101025780633aaed7b9146102025780633af7627f146102225780633bdebbe1146102425780633ccfd60b146102625780633f4ba83a1461027757600080fd5b80630145d7161461013f578063046dc1661461017c5780630b00da251461019e57806318134a0c146101c25780632c1e816d146101e2575b600080fd5b34801561014b57600080fd5b5060cd5461015f906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561018857600080fd5b5061019c61019736600461289c565b6103c0565b005b3480156101aa57600080fd5b506101b460cb5481565b604051908152602001610173565b3480156101ce57600080fd5b5061019c6101dd3660046128c0565b6103eb565b3480156101ee57600080fd5b5061019c6101fd36600461289c565b61045b565b34801561020e57600080fd5b5061019c61021d3660046128d9565b610486565b34801561022e57600080fd5b5061019c61023d3660046128c0565b6104fb565b34801561024e57600080fd5b5061019c61025d36600461289c565b610566565b34801561026e57600080fd5b5061019c610656565b34801561028357600080fd5b5061019c610691565b34801561029857600080fd5b5061019c6102a73660046129bd565b610714565b3480156102b857600080fd5b506101b460cc5481565b3480156102ce57600080fd5b5060655460ff166040519015158152602001610173565b3480156102f157600080fd5b5061019c6107d7565b34801561030657600080fd5b5061019c610315366004612ac3565b6107e9565b34801561032657600080fd5b5061019c61099d565b34801561033b57600080fd5b506033546001600160a01b031661015f565b61019c61035b366004612b51565b610a1e565b34801561036c57600080fd5b5061019c61037b366004612c60565b610bfe565b34801561038c57600080fd5b5061019c61039b36600461289c565b610d64565b3480156103ac57600080fd5b5061019c6103bb36600461289c565b610d8e565b6103c8610e07565b61013380546001600160a01b0319166001600160a01b0392909216919091179055565b6103f3610e07565b6103e88111156104565760405162461bcd60e51b8152602060048201526024808201527f4d61782063726561746f722066656520636f756c64206e6f74206578636565646044820152632033302560e01b60648201526084015b60405180910390fd5b60cb55565b610463610e07565b61013480546001600160a01b0319166001600160a01b0392909216919091179055565b61048e610e07565b604051632142170760e11b81523060048201523360248201526044810182905282906001600160a01b038216906342842e0e90606401600060405180830381600087803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b50505050505050565b610503610e07565b6103e88111156105615760405162461bcd60e51b8152602060048201526024808201527f4d61726b6574706c6163652066656520636f756c64206e6f74206578636565646044820152632031302560e01b606482015260840161044d565b60cc55565b61056e610e07565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa1580156105be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e29190612d11565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af115801561062d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106519190612d2a565b505050565b61065e610e07565b6040514790339082156108fc029083906000818181858888f1935050505015801561068d573d6000803e3d6000fd5b5050565b6033546001600160a01b03163314806106be5750610134546001600160a01b0316336001600160a01b0316145b61070a5760405162461bcd60e51b815260206004820152601f60248201527f43616c6c657220646f6573206e6f742068617665207065726d697373696f6e00604482015260640161044d565b610712610e61565b565b61071c610e07565b8160005b82518110156107d157816001600160a01b03166342842e0e303386858151811061074c5761074c612d4c565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b1580156107a657600080fd5b505af11580156107ba573d6000803e3d6000fd5b5050505080806107c990612d78565b915050610720565b50505050565b6107df610e07565b6107126000610eb3565b6107f1610f05565b6107f9610f58565b610806602084018461289c565b6001600160a01b0316336001600160a01b031614806108305750610134546001600160a01b031633145b61087c5760405162461bcd60e51b815260206004820152601e60248201527f43616c6c6572206973206e6f74206f666665726572206f722061646d696e0000604482015260640161044d565b610887838383610fb3565b6108c061089c6101808501610160860161289c565b6001600160a01b0316600090815260ce60205260409020805460ff19166001179055565b7f880e12946e02965e33664201ca6e0558bef3bd1107e6d7624db838059e8c50af6108ee602085018561289c565b6108fb6020860186612d91565b600081811061090c5761090c612d4c565b9050608002016020016020810190610924919061289c565b6109316020870187612d91565b600081811061094257610942612d4c565b9050608002016040013586610160016020810190610960919061289c565b604080516001600160a01b0395861681529385166020850152830191909152909116606082015260800160405180910390a1610651600161010155565b6033546001600160a01b03163314806109ca5750610134546001600160a01b0316336001600160a01b0316145b610a165760405162461bcd60e51b815260206004820152601f60248201527f43616c6c657220646f6573206e6f742068617665207065726d697373696f6e00604482015260640161044d565b610712610ff2565b610a26610f05565b610a2e610f58565b610133546001600160a01b0316610ac6610a506101808a016101608b0161289c565b6040516bffffffffffffffffffffffff19606092831b81166020830152602560f81b603483018190526001600160e01b031960e088901b166035840152603983018190523090931b16603a820152604e81019190915246604f820152606f0160405160208183030381529060405286868661102f565b6001600160a01b031614610b1c5760405162461bcd60e51b815260206004820152601760248201527f496e76616c69642061646d696e205369676e6174757265000000000000000000604482015260640161044d565b428163ffffffff1611610b715760405162461bcd60e51b815260206004820152601a60248201527f41646d696e207369676e61747572652069732065787069726564000000000000604482015260640161044d565b33610b7f602089018961289c565b6001600160a01b031603610b9557610b956110f9565b6000806000610ba58a8a8a611141565b94509092509050610bc161089c6101808c016101608d0161289c565b610bcd8a83838661146d565b610bde610bd98b612f80565b611582565b610bf0610bea8b612f80565b8461163a565b5050506104f2600161010155565b600054610100900460ff1615808015610c1e5750600054600160ff909116105b80610c385750303b158015610c38575060005460ff166001145b610caa5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161044d565b6000805460ff191660011790558015610ccd576000805461ff0019166101001790555b610cda8888888888611768565b610ce26117a3565b61013380546001600160a01b038086166001600160a01b0319928316179092556101348054928516929091169190911790558015610d5a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b610d6c610e07565b60cd80546001600160a01b0319166001600160a01b0392909216919091179055565b610d96610e07565b6001600160a01b038116610dfb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161044d565b610e0481610eb3565b50565b6033546001600160a01b031633146107125760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161044d565b610e696117d2565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60655460ff16156107125760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161044d565b60026101015403610fab5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161044d565b600261010155565b610fc0602084018461289c565b6001600160a01b0316610fd4848484611824565b6001600160a01b03161461065157610651611888565b600161010155565b610ffa610f05565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610e963390565b6000808580519060200120905060008160405160200161107b91907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60408051601f1981840301815282825280516020918201206000845290830180835281905260ff8916918301919091526060820187905260808201869052915060019060a0016020604051602081039080840390855afa1580156110e3573d6000803e3d6000fd5b5050604051601f19015198975050505050505050565b60405162461bcd60e51b815260206004820152601860248201527f43616e6e6f742062757920796f7572206f776e206974656d0000000000000000604482015260640161044d565b600080806111576101408701610120880161306b565b63ffffffff1642101561116c5761116c6118d0565b4261117f6101608801610140890161306b565b63ffffffff16101561119357611193611918565b346000036111a3576111a3611950565b6111b0602087018761289c565b6001600160a01b03166111c4878787611824565b6001600160a01b0316146111da576111da611888565b60026111ee6101208801610100890161309c565b60ff16146111fe576111fe611988565b60005b61120e6020880188612d91565b905081101561126e5760026112266020890189612d91565b8381811061123657611236612d4c565b61124c926020608090920201908101915061309c565b60ff161461125c5761125c6119d0565b8061126681612d78565b915050611201565b506000611281606088016040890161309c565b60ff161461129157611291611a18565b60005b6112a160e08801886130b7565b90508110156113015760006112b960e08901896130b7565b838181106112c9576112c9612d4c565b6112df92602060a090920201908101915061309c565b60ff16146112ef576112ef611a18565b806112f981612d78565b915050611294565b5061130f602087018761289c565b6001600160a01b031661132860c0880160a0890161289c565b6001600160a01b03161461133e5761133e611a60565b60c086013560005b61135360e08901896130b7565b90508110156113a25761136960e08901896130b7565b8281811061137957611379612d4c565b905060a00201608001358461138e9190613100565b93508061139a81612d78565b915050611346565b5060cc546113b290612710613118565b6113bc8483613100565b6113c89061271061312f565b6113d2919061314e565b60cb54909450846113e58561271061312f565b6113ef919061314e565b11156113fd576113fd611aa8565b34841461140c5761140c611950565b61143f61142161018089016101608a0161289c565b6001600160a01b0316600090815260ce602052604090205460ff1690565b1561144c5761144c611b03565b826114578286613118565b6114619190613118565b91505093509350939050565b7f31d8f0f884ca359b1c76fda3fd0e25e5f67c2a5082158630f6f3900cb27de46761149b602086018661289c565b336114a96020880188612d91565b60008181106114ba576114ba612d4c565b90506080020160200160208101906114d2919061289c565b6114df6020890189612d91565b60008181106114f0576114f0612d4c565b90506080020160400135886040016020016020810190611510919061289c565b8888886115256101808e016101608f0161289c565b604080516001600160a01b039a8b168152988a1660208a0152968916968801969096526060870194909452918616608086015260a085015260c084015260e08301529091166101008201526101200160405180910390a150505050565b60005b81602001515181101561068d57611628826000015133846020015184815181106115b1576115b1612d4c565b602002602001015160000151856020015185815181106115d3576115d3612d4c565b602002602001015160200151866020015186815181106115f5576115f5612d4c565b6020026020010151604001518760200151878151811061161757611617612d4c565b602002602001015160600151611b4b565b8061163281612d78565b915050611585565b604080830151606081015181516020830151938301516080909301516116639433949091611b4b565b60005b82606001515181101561173857611726338460600151838151811061168d5761168d612d4c565b602002602001015160600151856060015184815181106116af576116af612d4c565b602002602001015160000151866060015185815181106116d1576116d1612d4c565b602002602001015160200151876060015186815181106116f3576116f3612d4c565b6020026020010151604001518860600151878151811061171557611715612d4c565b602002602001015160800151611b4b565b8061173081612d78565b915050611666565b5060cd5460408084015180516020820151919092015161068d9333936001600160a01b0390911692909186611b4b565b600054610100900460ff1661178f5760405162461bcd60e51b815260040161044d90613170565b61179c8585858585611e7c565b5050505050565b600054610100900460ff166117ca5760405162461bcd60e51b815260040161044d90613170565b610712611ee9565b60655460ff166107125760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161044d565b600061188083838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061187a925061186e9150889050611f10565b8051906020012061221b565b9061226f565b949350505050565b60405162461bcd60e51b815260206004820152601160248201527f496e76616c6964205369676e6174757265000000000000000000000000000000604482015260640161044d565b60405162461bcd60e51b815260206004820152601160248201527f4f72646572204e6f742053746172746564000000000000000000000000000000604482015260640161044d565b60405162461bcd60e51b815260206004820152600d60248201526c13dc99195c88115e1c1a5c9959609a1b604482015260640161044d565b60405162461bcd60e51b815260206004820152600d60248201526c26b4b9b9b4b7339022ba3432b960991b604482015260640161044d565b60405162461bcd60e51b815260206004820152601e60248201527f556e737570706f72746564204c697374696e67204f7264657220547970650000604482015260640161044d565b60405162461bcd60e51b815260206004820152601b60248201527f556e737570706f72746564204f66666572204974656d20547970650000000000604482015260640161044d565b60405162461bcd60e51b815260206004820152601c60248201527f556e737570706f72746564205061796f7574204974656d205479706500000000604482015260640161044d565b60405162461bcd60e51b815260206004820152601960248201527f556e737570706f72746564205061796f757420466f726d617400000000000000604482015260640161044d565b60405162461bcd60e51b815260206004820152602a60248201527f546f74616c2063726561746f722066656520657863656564732074686520616c6044820152696c6f776564207261746560b01b606482015260840161044d565b60405162461bcd60e51b815260206004820152601060248201527f4475706c69636174652073616c65496400000000000000000000000000000000604482015260640161044d565b60ff8416611c11576001600160a01b0386163314611bab5760405162461bcd60e51b815260206004820152600e60248201527f496e76616c69642073656e646572000000000000000000000000000000000000604482015260640161044d565b6001600160a01b03831615611c025760405162461bcd60e51b815260206004820152600f60248201527f496e76616c696420616464726573730000000000000000000000000000000000604482015260640161044d565b611c0c8582612293565b611e74565b60001960ff851601611ca2576040516323b872dd60e01b81526001600160a01b0387811660048301528681166024830152604482018390528491908216906323b872dd906064016020604051808303816000875af1158015611c77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9b9190612d2a565b5050611e74565b60011960ff851601611de457604051632142170760e11b81526001600160a01b0387811660048301528681166024830152604482018490528491908216906342842e0e90606401600060405180830381600087803b158015611d0357600080fd5b505af1158015611d17573d6000803e3d6000fd5b50506040516331a9108f60e11b8152600481018690526001600160a01b03898116935084169150636352211e90602401602060405180830381865afa158015611d64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8891906131bb565b6001600160a01b031614611dde5760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572204661696c65640000000000000000000000000000000000604482015260640161044d565b50611e74565b60021960ff851601611e7457604051637921219560e11b81526001600160a01b0387811660048301528681166024830152604482018490526064820183905260a06084830152600060a483015284919082169063f242432a9060c401600060405180830381600087803b158015611e5a57600080fd5b505af1158015611e6e573d6000803e3d6000fd5b50505050505b505050505050565b600054610100900460ff16611ea35760405162461bcd60e51b815260040161044d90613170565b611ead8585612342565b611eb5612373565b611ebd6123a2565b60cb9290925560cc5560cd80546001600160a01b0319166001600160a01b039092169190911790555050565b600054610100900460ff16610fea5760405162461bcd60e51b815260040161044d90613170565b60606000611f216020840184612d91565b905067ffffffffffffffff811115611f3b57611f3b612905565b604051908082528060200260200182016040528015611f64578160200160208202803683370190505b50905060005b611f776020850185612d91565b9050811015611fe157611fab611f906020860186612d91565b83818110611fa057611fa0612d4c565b9050608002016123d1565b80519060200120828281518110611fc457611fc4612d4c565b602090810291909101015280611fd981612d78565b915050611f6a565b506000611ff160e08501856130b7565b905067ffffffffffffffff81111561200b5761200b612905565b604051908082528060200260200182016040528015612034578160200160208202803683370190505b50905060005b61204760e08601866130b7565b90508110156120b15761207b61206060e08701876130b7565b8381811061207057612070612d4c565b905060a00201612463565b8051906020012082828151811061209457612094612d4c565b6020908102919091010152806120a981612d78565b91505061203a565b507f0b27a7ffaa1672a8a16a672f5069c3a1e39bc0eabe3ec494cb9ea22c797b00e66120e0602086018661289c565b836040516020016120f191906131d8565b6040516020818303038152906040528051906020012061211387604001612463565b805190602001208460405160200161212b91906131d8565b60408051601f1981840301815291905280516020909101206121556101208a016101008b0161309c565b6121676101408b016101208c0161306b565b6121796101608c016101408d0161306b565b61218b6101808d016101608e0161289c565b61219d6101a08e016101808f0161309c565b60408051602081019b909b526001600160a01b03998a16908b015260608a0197909752608089019590955260a088019390935260ff91821660c088015263ffffffff90811660e08801529091166101008601529216610120840152166101408201526101600160405160208183030381529060405292505050919050565b6000612269612228612500565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b92915050565b600080600061227e8585612580565b9150915061228b816125c5565b509392505050565b8060000361229f575050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146122ec576040519150601f19603f3d011682016040523d82523d6000602084013e6122f1565b606091505b50509050806106515760405162461bcd60e51b815260206004820152600e60248201527f4574686572206e6f742073656e74000000000000000000000000000000000000604482015260640161044d565b600054610100900460ff166123695760405162461bcd60e51b815260040161044d90613170565b61068d828261270f565b600054610100900460ff1661239a5760405162461bcd60e51b815260040161044d90613170565b610712612750565b600054610100900460ff166123c95760405162461bcd60e51b815260040161044d90613170565b610712612780565b60607f3d2811298909c55efd9f4f108efcfb0e7e2ec71cbbc7afc8b15862b50858ac8e612401602084018461309c565b612411604085016020860161289c565b60408051602081019490945260ff909216838301526001600160a01b031660608381019190915290840135608083015283013560a082015260c0015b6040516020818303038152906040529050919050565b60607f2f640164aec5dd9f523d2a80beac36e83213daadafecd22ac297bb068187d193612493602084018461309c565b6124a3604085016020860161289c565b60408501356124b8608087016060880161289c565b60408051602081019690965260ff909416938501939093526001600160a01b039182166060850152608084810191909152911660a083015283013560c082015260e00161244d565b600061257b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f61252f60975490565b6098546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b60008082516041036125b65760208301516040840151606085015160001a6125aa878285856127b3565b945094505050506125be565b506000905060025b9250929050565b60008160048111156125d9576125d9613086565b036125e15750565b60018160048111156125f5576125f5613086565b036126425760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161044d565b600281600481111561265657612656613086565b036126a35760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161044d565b60038160048111156126b7576126b7613086565b03610e045760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161044d565b600054610100900460ff166127365760405162461bcd60e51b815260040161044d90613170565b815160209283012081519190920120609791909155609855565b600054610100900460ff166127775760405162461bcd60e51b815260040161044d90613170565b61071233610eb3565b600054610100900460ff166127a75760405162461bcd60e51b815260040161044d90613170565b6065805460ff19169055565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156127ea575060009050600361286e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561283e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166128675760006001925092505061286e565b9150600090505b94509492505050565b6001600160a01b0381168114610e0457600080fd5b803561289781612877565b919050565b6000602082840312156128ae57600080fd5b81356128b981612877565b9392505050565b6000602082840312156128d257600080fd5b5035919050565b600080604083850312156128ec57600080fd5b82356128f781612877565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff8111828210171561293e5761293e612905565b60405290565b604051610120810167ffffffffffffffff8111828210171561293e5761293e612905565b604051601f8201601f1916810167ffffffffffffffff8111828210171561299157612991612905565b604052919050565b600067ffffffffffffffff8211156129b3576129b3612905565b5060051b60200190565b600080604083850312156129d057600080fd5b82356129db81612877565b915060208381013567ffffffffffffffff8111156129f857600080fd5b8401601f81018613612a0957600080fd5b8035612a1c612a1782612999565b612968565b81815260059190911b82018301908381019088831115612a3b57600080fd5b928401925b82841015612a5957833582529284019290840190612a40565b80955050505050509250929050565b60006101a08284031215612a7b57600080fd5b50919050565b60008083601f840112612a9357600080fd5b50813567ffffffffffffffff811115612aab57600080fd5b6020830191508360208285010111156125be57600080fd5b600080600060408486031215612ad857600080fd5b833567ffffffffffffffff80821115612af057600080fd5b612afc87838801612a68565b94506020860135915080821115612b1257600080fd5b50612b1f86828701612a81565b9497909650939450505050565b803560ff8116811461289757600080fd5b803563ffffffff8116811461289757600080fd5b600080600080600080600060c0888a031215612b6c57600080fd5b873567ffffffffffffffff80821115612b8457600080fd5b612b908b838c01612a68565b985060208a0135915080821115612ba657600080fd5b50612bb38a828b01612a81565b9097509550612bc6905060408901612b2c565b93506060880135925060808801359150612be260a08901612b3d565b905092959891949750929550565b600082601f830112612c0157600080fd5b813567ffffffffffffffff811115612c1b57612c1b612905565b612c2e601f8201601f1916602001612968565b818152846020838601011115612c4357600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600060e0888a031215612c7b57600080fd5b873567ffffffffffffffff80821115612c9357600080fd5b612c9f8b838c01612bf0565b985060208a0135915080821115612cb557600080fd5b50612cc28a828b01612bf0565b96505060408801359450606088013593506080880135612ce181612877565b925060a0880135612cf181612877565b915060c0880135612d0181612877565b8091505092959891949750929550565b600060208284031215612d2357600080fd5b5051919050565b600060208284031215612d3c57600080fd5b815180151581146128b957600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201612d8a57612d8a612d62565b5060010190565b6000808335601e19843603018112612da857600080fd5b83018035915067ffffffffffffffff821115612dc357600080fd5b6020019150600781901b36038213156125be57600080fd5b600082601f830112612dec57600080fd5b81356020612dfc612a1783612999565b82815260079290921b84018101918181019086841115612e1b57600080fd5b8286015b84811015612e7e5760808189031215612e385760008081fd5b612e4061291b565b612e4982612b2c565b815284820135612e5881612877565b818601526040828101359082015260608083013590820152835291830191608001612e1f565b509695505050505050565b600060a08284031215612e9b57600080fd5b60405160a0810181811067ffffffffffffffff82111715612ebe57612ebe612905565b604052905080612ecd83612b2c565b81526020830135612edd81612877565b6020820152604083810135908201526060830135612efa81612877565b6060820152608092830135920191909152919050565b600082601f830112612f2157600080fd5b81356020612f31612a1783612999565b82815260a09283028501820192828201919087851115612f5057600080fd5b8387015b85811015612f7357612f668982612e89565b8452928401928101612f54565b5090979650505050505050565b60006101a08236031215612f9357600080fd5b612f9b612944565b612fa48361288c565b8152602083013567ffffffffffffffff80821115612fc157600080fd5b612fcd36838701612ddb565b6020840152612fdf3660408701612e89565b604084015260e0850135915080821115612ff857600080fd5b5061300536828601612f10565b606083015250610100613019818501612b2c565b608083015261302b6101208501612b3d565b60a083015261303d6101408501612b3d565b60c083015261304f610160850161288c565b60e08301526130616101808501612b2c565b9082015292915050565b60006020828403121561307d57600080fd5b6128b982612b3d565b634e487b7160e01b600052602160045260246000fd5b6000602082840312156130ae57600080fd5b6128b982612b2c565b6000808335601e198436030181126130ce57600080fd5b83018035915067ffffffffffffffff8211156130e957600080fd5b602001915060a0810236038213156125be57600080fd5b6000821982111561311357613113612d62565b500190565b60008282101561312a5761312a612d62565b500390565b600081600019048311821515161561314957613149612d62565b500290565b60008261316b57634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000602082840312156131cd57600080fd5b81516128b981612877565b815160009082906020808601845b83811015613202578151855293820193908201906001016131e6565b5092969550505050505056fea2646970667358221220ec6ad56d9a956635b2383112ef6e3fefa176797ed839fca87f5973069fdaf20a64736f6c634300080d0033
Deployed Bytecode
0x60806040526004361061013a5760003560e01c806344e03820116100bb5780638456cb591161007f578063a7aebf3611610059578063a7aebf3614610360578063eca63ff014610380578063f2fde38b146103a057600080fd5b80638456cb591461031a5780638da5cb5b1461032f578063a71c9b7f1461034d57600080fd5b806344e038201461028c5780634adadddf146102ac5780635c975abb146102c2578063715018a6146102e55780637a5dfd3f146102fa57600080fd5b80633aaed7b9116101025780633aaed7b9146102025780633af7627f146102225780633bdebbe1146102425780633ccfd60b146102625780633f4ba83a1461027757600080fd5b80630145d7161461013f578063046dc1661461017c5780630b00da251461019e57806318134a0c146101c25780632c1e816d146101e2575b600080fd5b34801561014b57600080fd5b5060cd5461015f906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561018857600080fd5b5061019c61019736600461289c565b6103c0565b005b3480156101aa57600080fd5b506101b460cb5481565b604051908152602001610173565b3480156101ce57600080fd5b5061019c6101dd3660046128c0565b6103eb565b3480156101ee57600080fd5b5061019c6101fd36600461289c565b61045b565b34801561020e57600080fd5b5061019c61021d3660046128d9565b610486565b34801561022e57600080fd5b5061019c61023d3660046128c0565b6104fb565b34801561024e57600080fd5b5061019c61025d36600461289c565b610566565b34801561026e57600080fd5b5061019c610656565b34801561028357600080fd5b5061019c610691565b34801561029857600080fd5b5061019c6102a73660046129bd565b610714565b3480156102b857600080fd5b506101b460cc5481565b3480156102ce57600080fd5b5060655460ff166040519015158152602001610173565b3480156102f157600080fd5b5061019c6107d7565b34801561030657600080fd5b5061019c610315366004612ac3565b6107e9565b34801561032657600080fd5b5061019c61099d565b34801561033b57600080fd5b506033546001600160a01b031661015f565b61019c61035b366004612b51565b610a1e565b34801561036c57600080fd5b5061019c61037b366004612c60565b610bfe565b34801561038c57600080fd5b5061019c61039b36600461289c565b610d64565b3480156103ac57600080fd5b5061019c6103bb36600461289c565b610d8e565b6103c8610e07565b61013380546001600160a01b0319166001600160a01b0392909216919091179055565b6103f3610e07565b6103e88111156104565760405162461bcd60e51b8152602060048201526024808201527f4d61782063726561746f722066656520636f756c64206e6f74206578636565646044820152632033302560e01b60648201526084015b60405180910390fd5b60cb55565b610463610e07565b61013480546001600160a01b0319166001600160a01b0392909216919091179055565b61048e610e07565b604051632142170760e11b81523060048201523360248201526044810182905282906001600160a01b038216906342842e0e90606401600060405180830381600087803b1580156104de57600080fd5b505af11580156104f2573d6000803e3d6000fd5b50505050505050565b610503610e07565b6103e88111156105615760405162461bcd60e51b8152602060048201526024808201527f4d61726b6574706c6163652066656520636f756c64206e6f74206578636565646044820152632031302560e01b606482015260840161044d565b60cc55565b61056e610e07565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa1580156105be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e29190612d11565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af115801561062d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106519190612d2a565b505050565b61065e610e07565b6040514790339082156108fc029083906000818181858888f1935050505015801561068d573d6000803e3d6000fd5b5050565b6033546001600160a01b03163314806106be5750610134546001600160a01b0316336001600160a01b0316145b61070a5760405162461bcd60e51b815260206004820152601f60248201527f43616c6c657220646f6573206e6f742068617665207065726d697373696f6e00604482015260640161044d565b610712610e61565b565b61071c610e07565b8160005b82518110156107d157816001600160a01b03166342842e0e303386858151811061074c5761074c612d4c565b60209081029190910101516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b1580156107a657600080fd5b505af11580156107ba573d6000803e3d6000fd5b5050505080806107c990612d78565b915050610720565b50505050565b6107df610e07565b6107126000610eb3565b6107f1610f05565b6107f9610f58565b610806602084018461289c565b6001600160a01b0316336001600160a01b031614806108305750610134546001600160a01b031633145b61087c5760405162461bcd60e51b815260206004820152601e60248201527f43616c6c6572206973206e6f74206f666665726572206f722061646d696e0000604482015260640161044d565b610887838383610fb3565b6108c061089c6101808501610160860161289c565b6001600160a01b0316600090815260ce60205260409020805460ff19166001179055565b7f880e12946e02965e33664201ca6e0558bef3bd1107e6d7624db838059e8c50af6108ee602085018561289c565b6108fb6020860186612d91565b600081811061090c5761090c612d4c565b9050608002016020016020810190610924919061289c565b6109316020870187612d91565b600081811061094257610942612d4c565b9050608002016040013586610160016020810190610960919061289c565b604080516001600160a01b0395861681529385166020850152830191909152909116606082015260800160405180910390a1610651600161010155565b6033546001600160a01b03163314806109ca5750610134546001600160a01b0316336001600160a01b0316145b610a165760405162461bcd60e51b815260206004820152601f60248201527f43616c6c657220646f6573206e6f742068617665207065726d697373696f6e00604482015260640161044d565b610712610ff2565b610a26610f05565b610a2e610f58565b610133546001600160a01b0316610ac6610a506101808a016101608b0161289c565b6040516bffffffffffffffffffffffff19606092831b81166020830152602560f81b603483018190526001600160e01b031960e088901b166035840152603983018190523090931b16603a820152604e81019190915246604f820152606f0160405160208183030381529060405286868661102f565b6001600160a01b031614610b1c5760405162461bcd60e51b815260206004820152601760248201527f496e76616c69642061646d696e205369676e6174757265000000000000000000604482015260640161044d565b428163ffffffff1611610b715760405162461bcd60e51b815260206004820152601a60248201527f41646d696e207369676e61747572652069732065787069726564000000000000604482015260640161044d565b33610b7f602089018961289c565b6001600160a01b031603610b9557610b956110f9565b6000806000610ba58a8a8a611141565b94509092509050610bc161089c6101808c016101608d0161289c565b610bcd8a83838661146d565b610bde610bd98b612f80565b611582565b610bf0610bea8b612f80565b8461163a565b5050506104f2600161010155565b600054610100900460ff1615808015610c1e5750600054600160ff909116105b80610c385750303b158015610c38575060005460ff166001145b610caa5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161044d565b6000805460ff191660011790558015610ccd576000805461ff0019166101001790555b610cda8888888888611768565b610ce26117a3565b61013380546001600160a01b038086166001600160a01b0319928316179092556101348054928516929091169190911790558015610d5a576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050505050565b610d6c610e07565b60cd80546001600160a01b0319166001600160a01b0392909216919091179055565b610d96610e07565b6001600160a01b038116610dfb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161044d565b610e0481610eb3565b50565b6033546001600160a01b031633146107125760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161044d565b610e696117d2565b6065805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60655460ff16156107125760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a2070617573656400000000000000000000000000000000604482015260640161044d565b60026101015403610fab5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015260640161044d565b600261010155565b610fc0602084018461289c565b6001600160a01b0316610fd4848484611824565b6001600160a01b03161461065157610651611888565b600161010155565b610ffa610f05565b6065805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258610e963390565b6000808580519060200120905060008160405160200161107b91907f19457468657265756d205369676e6564204d6573736167653a0a3332000000008152601c810191909152603c0190565b60408051601f1981840301815282825280516020918201206000845290830180835281905260ff8916918301919091526060820187905260808201869052915060019060a0016020604051602081039080840390855afa1580156110e3573d6000803e3d6000fd5b5050604051601f19015198975050505050505050565b60405162461bcd60e51b815260206004820152601860248201527f43616e6e6f742062757920796f7572206f776e206974656d0000000000000000604482015260640161044d565b600080806111576101408701610120880161306b565b63ffffffff1642101561116c5761116c6118d0565b4261117f6101608801610140890161306b565b63ffffffff16101561119357611193611918565b346000036111a3576111a3611950565b6111b0602087018761289c565b6001600160a01b03166111c4878787611824565b6001600160a01b0316146111da576111da611888565b60026111ee6101208801610100890161309c565b60ff16146111fe576111fe611988565b60005b61120e6020880188612d91565b905081101561126e5760026112266020890189612d91565b8381811061123657611236612d4c565b61124c926020608090920201908101915061309c565b60ff161461125c5761125c6119d0565b8061126681612d78565b915050611201565b506000611281606088016040890161309c565b60ff161461129157611291611a18565b60005b6112a160e08801886130b7565b90508110156113015760006112b960e08901896130b7565b838181106112c9576112c9612d4c565b6112df92602060a090920201908101915061309c565b60ff16146112ef576112ef611a18565b806112f981612d78565b915050611294565b5061130f602087018761289c565b6001600160a01b031661132860c0880160a0890161289c565b6001600160a01b03161461133e5761133e611a60565b60c086013560005b61135360e08901896130b7565b90508110156113a25761136960e08901896130b7565b8281811061137957611379612d4c565b905060a00201608001358461138e9190613100565b93508061139a81612d78565b915050611346565b5060cc546113b290612710613118565b6113bc8483613100565b6113c89061271061312f565b6113d2919061314e565b60cb54909450846113e58561271061312f565b6113ef919061314e565b11156113fd576113fd611aa8565b34841461140c5761140c611950565b61143f61142161018089016101608a0161289c565b6001600160a01b0316600090815260ce602052604090205460ff1690565b1561144c5761144c611b03565b826114578286613118565b6114619190613118565b91505093509350939050565b7f31d8f0f884ca359b1c76fda3fd0e25e5f67c2a5082158630f6f3900cb27de46761149b602086018661289c565b336114a96020880188612d91565b60008181106114ba576114ba612d4c565b90506080020160200160208101906114d2919061289c565b6114df6020890189612d91565b60008181106114f0576114f0612d4c565b90506080020160400135886040016020016020810190611510919061289c565b8888886115256101808e016101608f0161289c565b604080516001600160a01b039a8b168152988a1660208a0152968916968801969096526060870194909452918616608086015260a085015260c084015260e08301529091166101008201526101200160405180910390a150505050565b60005b81602001515181101561068d57611628826000015133846020015184815181106115b1576115b1612d4c565b602002602001015160000151856020015185815181106115d3576115d3612d4c565b602002602001015160200151866020015186815181106115f5576115f5612d4c565b6020026020010151604001518760200151878151811061161757611617612d4c565b602002602001015160600151611b4b565b8061163281612d78565b915050611585565b604080830151606081015181516020830151938301516080909301516116639433949091611b4b565b60005b82606001515181101561173857611726338460600151838151811061168d5761168d612d4c565b602002602001015160600151856060015184815181106116af576116af612d4c565b602002602001015160000151866060015185815181106116d1576116d1612d4c565b602002602001015160200151876060015186815181106116f3576116f3612d4c565b6020026020010151604001518860600151878151811061171557611715612d4c565b602002602001015160800151611b4b565b8061173081612d78565b915050611666565b5060cd5460408084015180516020820151919092015161068d9333936001600160a01b0390911692909186611b4b565b600054610100900460ff1661178f5760405162461bcd60e51b815260040161044d90613170565b61179c8585858585611e7c565b5050505050565b600054610100900460ff166117ca5760405162461bcd60e51b815260040161044d90613170565b610712611ee9565b60655460ff166107125760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f7420706175736564000000000000000000000000604482015260640161044d565b600061188083838080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061187a925061186e9150889050611f10565b8051906020012061221b565b9061226f565b949350505050565b60405162461bcd60e51b815260206004820152601160248201527f496e76616c6964205369676e6174757265000000000000000000000000000000604482015260640161044d565b60405162461bcd60e51b815260206004820152601160248201527f4f72646572204e6f742053746172746564000000000000000000000000000000604482015260640161044d565b60405162461bcd60e51b815260206004820152600d60248201526c13dc99195c88115e1c1a5c9959609a1b604482015260640161044d565b60405162461bcd60e51b815260206004820152600d60248201526c26b4b9b9b4b7339022ba3432b960991b604482015260640161044d565b60405162461bcd60e51b815260206004820152601e60248201527f556e737570706f72746564204c697374696e67204f7264657220547970650000604482015260640161044d565b60405162461bcd60e51b815260206004820152601b60248201527f556e737570706f72746564204f66666572204974656d20547970650000000000604482015260640161044d565b60405162461bcd60e51b815260206004820152601c60248201527f556e737570706f72746564205061796f7574204974656d205479706500000000604482015260640161044d565b60405162461bcd60e51b815260206004820152601960248201527f556e737570706f72746564205061796f757420466f726d617400000000000000604482015260640161044d565b60405162461bcd60e51b815260206004820152602a60248201527f546f74616c2063726561746f722066656520657863656564732074686520616c6044820152696c6f776564207261746560b01b606482015260840161044d565b60405162461bcd60e51b815260206004820152601060248201527f4475706c69636174652073616c65496400000000000000000000000000000000604482015260640161044d565b60ff8416611c11576001600160a01b0386163314611bab5760405162461bcd60e51b815260206004820152600e60248201527f496e76616c69642073656e646572000000000000000000000000000000000000604482015260640161044d565b6001600160a01b03831615611c025760405162461bcd60e51b815260206004820152600f60248201527f496e76616c696420616464726573730000000000000000000000000000000000604482015260640161044d565b611c0c8582612293565b611e74565b60001960ff851601611ca2576040516323b872dd60e01b81526001600160a01b0387811660048301528681166024830152604482018390528491908216906323b872dd906064016020604051808303816000875af1158015611c77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c9b9190612d2a565b5050611e74565b60011960ff851601611de457604051632142170760e11b81526001600160a01b0387811660048301528681166024830152604482018490528491908216906342842e0e90606401600060405180830381600087803b158015611d0357600080fd5b505af1158015611d17573d6000803e3d6000fd5b50506040516331a9108f60e11b8152600481018690526001600160a01b03898116935084169150636352211e90602401602060405180830381865afa158015611d64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d8891906131bb565b6001600160a01b031614611dde5760405162461bcd60e51b815260206004820152600f60248201527f5472616e73666572204661696c65640000000000000000000000000000000000604482015260640161044d565b50611e74565b60021960ff851601611e7457604051637921219560e11b81526001600160a01b0387811660048301528681166024830152604482018490526064820183905260a06084830152600060a483015284919082169063f242432a9060c401600060405180830381600087803b158015611e5a57600080fd5b505af1158015611e6e573d6000803e3d6000fd5b50505050505b505050505050565b600054610100900460ff16611ea35760405162461bcd60e51b815260040161044d90613170565b611ead8585612342565b611eb5612373565b611ebd6123a2565b60cb9290925560cc5560cd80546001600160a01b0319166001600160a01b039092169190911790555050565b600054610100900460ff16610fea5760405162461bcd60e51b815260040161044d90613170565b60606000611f216020840184612d91565b905067ffffffffffffffff811115611f3b57611f3b612905565b604051908082528060200260200182016040528015611f64578160200160208202803683370190505b50905060005b611f776020850185612d91565b9050811015611fe157611fab611f906020860186612d91565b83818110611fa057611fa0612d4c565b9050608002016123d1565b80519060200120828281518110611fc457611fc4612d4c565b602090810291909101015280611fd981612d78565b915050611f6a565b506000611ff160e08501856130b7565b905067ffffffffffffffff81111561200b5761200b612905565b604051908082528060200260200182016040528015612034578160200160208202803683370190505b50905060005b61204760e08601866130b7565b90508110156120b15761207b61206060e08701876130b7565b8381811061207057612070612d4c565b905060a00201612463565b8051906020012082828151811061209457612094612d4c565b6020908102919091010152806120a981612d78565b91505061203a565b507f0b27a7ffaa1672a8a16a672f5069c3a1e39bc0eabe3ec494cb9ea22c797b00e66120e0602086018661289c565b836040516020016120f191906131d8565b6040516020818303038152906040528051906020012061211387604001612463565b805190602001208460405160200161212b91906131d8565b60408051601f1981840301815291905280516020909101206121556101208a016101008b0161309c565b6121676101408b016101208c0161306b565b6121796101608c016101408d0161306b565b61218b6101808d016101608e0161289c565b61219d6101a08e016101808f0161309c565b60408051602081019b909b526001600160a01b03998a16908b015260608a0197909752608089019590955260a088019390935260ff91821660c088015263ffffffff90811660e08801529091166101008601529216610120840152166101408201526101600160405160208183030381529060405292505050919050565b6000612269612228612500565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b92915050565b600080600061227e8585612580565b9150915061228b816125c5565b509392505050565b8060000361229f575050565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146122ec576040519150601f19603f3d011682016040523d82523d6000602084013e6122f1565b606091505b50509050806106515760405162461bcd60e51b815260206004820152600e60248201527f4574686572206e6f742073656e74000000000000000000000000000000000000604482015260640161044d565b600054610100900460ff166123695760405162461bcd60e51b815260040161044d90613170565b61068d828261270f565b600054610100900460ff1661239a5760405162461bcd60e51b815260040161044d90613170565b610712612750565b600054610100900460ff166123c95760405162461bcd60e51b815260040161044d90613170565b610712612780565b60607f3d2811298909c55efd9f4f108efcfb0e7e2ec71cbbc7afc8b15862b50858ac8e612401602084018461309c565b612411604085016020860161289c565b60408051602081019490945260ff909216838301526001600160a01b031660608381019190915290840135608083015283013560a082015260c0015b6040516020818303038152906040529050919050565b60607f2f640164aec5dd9f523d2a80beac36e83213daadafecd22ac297bb068187d193612493602084018461309c565b6124a3604085016020860161289c565b60408501356124b8608087016060880161289c565b60408051602081019690965260ff909416938501939093526001600160a01b039182166060850152608084810191909152911660a083015283013560c082015260e00161244d565b600061257b7f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f61252f60975490565b6098546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b60008082516041036125b65760208301516040840151606085015160001a6125aa878285856127b3565b945094505050506125be565b506000905060025b9250929050565b60008160048111156125d9576125d9613086565b036125e15750565b60018160048111156125f5576125f5613086565b036126425760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161044d565b600281600481111561265657612656613086565b036126a35760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161044d565b60038160048111156126b7576126b7613086565b03610e045760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161044d565b600054610100900460ff166127365760405162461bcd60e51b815260040161044d90613170565b815160209283012081519190920120609791909155609855565b600054610100900460ff166127775760405162461bcd60e51b815260040161044d90613170565b61071233610eb3565b600054610100900460ff166127a75760405162461bcd60e51b815260040161044d90613170565b6065805460ff19169055565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156127ea575060009050600361286e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa15801561283e573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166128675760006001925092505061286e565b9150600090505b94509492505050565b6001600160a01b0381168114610e0457600080fd5b803561289781612877565b919050565b6000602082840312156128ae57600080fd5b81356128b981612877565b9392505050565b6000602082840312156128d257600080fd5b5035919050565b600080604083850312156128ec57600080fd5b82356128f781612877565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff8111828210171561293e5761293e612905565b60405290565b604051610120810167ffffffffffffffff8111828210171561293e5761293e612905565b604051601f8201601f1916810167ffffffffffffffff8111828210171561299157612991612905565b604052919050565b600067ffffffffffffffff8211156129b3576129b3612905565b5060051b60200190565b600080604083850312156129d057600080fd5b82356129db81612877565b915060208381013567ffffffffffffffff8111156129f857600080fd5b8401601f81018613612a0957600080fd5b8035612a1c612a1782612999565b612968565b81815260059190911b82018301908381019088831115612a3b57600080fd5b928401925b82841015612a5957833582529284019290840190612a40565b80955050505050509250929050565b60006101a08284031215612a7b57600080fd5b50919050565b60008083601f840112612a9357600080fd5b50813567ffffffffffffffff811115612aab57600080fd5b6020830191508360208285010111156125be57600080fd5b600080600060408486031215612ad857600080fd5b833567ffffffffffffffff80821115612af057600080fd5b612afc87838801612a68565b94506020860135915080821115612b1257600080fd5b50612b1f86828701612a81565b9497909650939450505050565b803560ff8116811461289757600080fd5b803563ffffffff8116811461289757600080fd5b600080600080600080600060c0888a031215612b6c57600080fd5b873567ffffffffffffffff80821115612b8457600080fd5b612b908b838c01612a68565b985060208a0135915080821115612ba657600080fd5b50612bb38a828b01612a81565b9097509550612bc6905060408901612b2c565b93506060880135925060808801359150612be260a08901612b3d565b905092959891949750929550565b600082601f830112612c0157600080fd5b813567ffffffffffffffff811115612c1b57612c1b612905565b612c2e601f8201601f1916602001612968565b818152846020838601011115612c4357600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600080600060e0888a031215612c7b57600080fd5b873567ffffffffffffffff80821115612c9357600080fd5b612c9f8b838c01612bf0565b985060208a0135915080821115612cb557600080fd5b50612cc28a828b01612bf0565b96505060408801359450606088013593506080880135612ce181612877565b925060a0880135612cf181612877565b915060c0880135612d0181612877565b8091505092959891949750929550565b600060208284031215612d2357600080fd5b5051919050565b600060208284031215612d3c57600080fd5b815180151581146128b957600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201612d8a57612d8a612d62565b5060010190565b6000808335601e19843603018112612da857600080fd5b83018035915067ffffffffffffffff821115612dc357600080fd5b6020019150600781901b36038213156125be57600080fd5b600082601f830112612dec57600080fd5b81356020612dfc612a1783612999565b82815260079290921b84018101918181019086841115612e1b57600080fd5b8286015b84811015612e7e5760808189031215612e385760008081fd5b612e4061291b565b612e4982612b2c565b815284820135612e5881612877565b818601526040828101359082015260608083013590820152835291830191608001612e1f565b509695505050505050565b600060a08284031215612e9b57600080fd5b60405160a0810181811067ffffffffffffffff82111715612ebe57612ebe612905565b604052905080612ecd83612b2c565b81526020830135612edd81612877565b6020820152604083810135908201526060830135612efa81612877565b6060820152608092830135920191909152919050565b600082601f830112612f2157600080fd5b81356020612f31612a1783612999565b82815260a09283028501820192828201919087851115612f5057600080fd5b8387015b85811015612f7357612f668982612e89565b8452928401928101612f54565b5090979650505050505050565b60006101a08236031215612f9357600080fd5b612f9b612944565b612fa48361288c565b8152602083013567ffffffffffffffff80821115612fc157600080fd5b612fcd36838701612ddb565b6020840152612fdf3660408701612e89565b604084015260e0850135915080821115612ff857600080fd5b5061300536828601612f10565b606083015250610100613019818501612b2c565b608083015261302b6101208501612b3d565b60a083015261303d6101408501612b3d565b60c083015261304f610160850161288c565b60e08301526130616101808501612b2c565b9082015292915050565b60006020828403121561307d57600080fd5b6128b982612b3d565b634e487b7160e01b600052602160045260246000fd5b6000602082840312156130ae57600080fd5b6128b982612b2c565b6000808335601e198436030181126130ce57600080fd5b83018035915067ffffffffffffffff8211156130e957600080fd5b602001915060a0810236038213156125be57600080fd5b6000821982111561311357613113612d62565b500190565b60008282101561312a5761312a612d62565b500390565b600081600019048311821515161561314957613149612d62565b500290565b60008261316b57634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000602082840312156131cd57600080fd5b81516128b981612877565b815160009082906020808601845b83811015613202578151855293820193908201906001016131e6565b5092969550505050505056fea2646970667358221220ec6ad56d9a956635b2383112ef6e3fefa176797ed839fca87f5973069fdaf20a64736f6c634300080d0033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in MNT
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.