Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- HexToysMarketV2
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2023-09-30T03:32:36.410006Z
contracts/marketplace/HexToysMarketV2.sol
// Multiple Fixed Price Marketplace contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../signature/Signature.sol";
interface IPRC1155 {
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
function balanceOf(address account, uint256 id) external view returns (uint256);
function isApprovedForAll(address account, address operator) external view returns (bool);
}
interface IPRC721 {
function safeTransferFrom(address from, address to, uint256 tokenId) external;
function ownerOf(uint256 tokenId) external view returns (address);
function isApprovedForAll( address owner, address operator) external view returns (bool);
}
contract HexToysMarketV2 is OwnableUpgradeable, ERC1155HolderUpgradeable, Signature {
using SafeMath for uint256;
mapping (address => uint256) public nonce;
struct TrxEvent {
address buyer;
address seller;
string productType; // pair/auction
uint256 productId;
uint256 tokenId;
address collection;
uint256 amount;
uint256 price;
address tokenAddr;
}
uint256 public constant PERCENTS_DIVIDER = 1000;
uint256 public swapFee;
address public feeAddress;
address public signerAddress;
event Sold(TrxEvent soldEvent);
function initialize(address _feeAddress, address _signerAddress) public initializer {
__Ownable_init();
require(_feeAddress != address(0), "Invalid commonOwner");
feeAddress = _feeAddress;
signerAddress = _signerAddress;
swapFee = 21; // 2.1%
}
function setSignerAddress(address _signerAddress) external onlyOwner {
require(_signerAddress != address(0x0), "invalid address");
signerAddress = _signerAddress;
}
function setFeePercent(uint256 _swapFee) external onlyOwner {
require(_swapFee < 100, "invalid percent");
swapFee = _swapFee;
}
function setFeeAddress(address _address) external onlyOwner {
require(_address != address(0x0), "invalid address");
feeAddress = _address;
}
function buyNFT(address collection,
uint256 tokenId,
uint256 productId,
uint256 amount,
uint256 price,
address tokenAddr,
address seller,
uint256 nftType,
uint256[] memory _royaltyArray,
address[] memory _receiverArray,
bytes memory _signature
) external payable {
confirmSignature(
collection,
tokenId,
productId,
amount,
price,
tokenAddr,
msg.sender,
seller,
nonce[msg.sender],
_royaltyArray,
_receiverArray,
_signature,
signerAddress
);
// distribut token to owner, admin, royalty receivers
{
uint256 tokenAmount = price.mul(amount);
uint256 feeAmount = tokenAmount.mul(swapFee).div(PERCENTS_DIVIDER);
uint256 ownerAmount = tokenAmount.sub(feeAmount);
uint256 royaltyCount = _royaltyArray.length;
if (tokenAddr == address(0x0)) {
require(msg.value >= tokenAmount, "too small amount");
// send service fee
if (swapFee > 0) {
(bool result, ) = payable(feeAddress).call{ value: feeAmount}("");
require(result);
}
// send royalties
for (uint256 i = 0; i < royaltyCount; i++) {
uint256 royaltyAmount = tokenAmount.mul(_royaltyArray[i]).div(PERCENTS_DIVIDER);
if (royaltyAmount > 0) {
(bool result, ) = payable(_receiverArray[i]).call{value: royaltyAmount}("");
require(result);
ownerAmount = ownerAmount.sub(royaltyAmount);
}
}
// send coin to nft owner
(bool result1, ) = payable(seller).call{value: ownerAmount}("");
require(result1);
} else {
IERC20 governanceToken = IERC20(tokenAddr);
// send token from user to contract
require(governanceToken.transferFrom(msg.sender, address(this), tokenAmount), "in sufficiant token amount");
// send service fee
if (swapFee > 0) {
require(governanceToken.transfer(feeAddress, feeAmount), "send service fee failed");
}
// send royalties
for (uint256 i = 0; i < royaltyCount; i++) {
uint256 royaltyAmount = tokenAmount.mul(_royaltyArray[i]).div(PERCENTS_DIVIDER);
if (royaltyAmount > 0) {
require(governanceToken.transfer(_receiverArray[i], royaltyAmount), "send royality failed");
ownerAmount = ownerAmount.sub(royaltyAmount);
}
}
// transfer token to owner
require(governanceToken.transfer(seller, ownerAmount));
}
}
{
if (nftType == 0) {
// PRC721 transfer
IPRC721 nft = IPRC721(collection);
require(nft.isApprovedForAll(seller, address(this)), "Not approve nft to staker address");
require(nft.ownerOf(tokenId) == seller, "seller don't own nft");
nft.safeTransferFrom( seller, msg.sender, tokenId);
} else {
// PRC1155 transfer
IPRC1155 nft = IPRC1155(collection);
require(nft.isApprovedForAll(seller, address(this)), "Not approve nft to staker address");
uint256 nft_token_balance = nft.balanceOf(seller, tokenId);
require(nft_token_balance >= amount, "seller don't own enough balance");
nft.safeTransferFrom(seller, msg.sender, tokenId, amount, "");
}
}
{
nonce[msg.sender] = nonce[msg.sender].add(1);
TrxEvent memory soldEvent;
soldEvent.buyer = msg.sender;
soldEvent.seller = seller;
soldEvent.productType = "pair";
soldEvent.productId = productId;
soldEvent.tokenId = tokenId;
soldEvent.collection = collection;
soldEvent.amount = amount;
soldEvent.price = price;
soldEvent.tokenAddr = tokenAddr;
emit Sold(soldEvent);
}
}
function finalizeAuction(address collection,
uint256 tokenId,
uint256 productId,
uint256 price,
address tokenAddr,
address seller,
address bidder,
uint256[] memory _royaltyArray,
address[] memory _receiverArray,
bytes memory _signature) public {
require( msg.sender == seller || msg.sender == owner(), "only auction owner can finalize" );
confirmSignature(
collection,
tokenId,
productId,
1,
price,
tokenAddr,
bidder,
seller,
nonce[msg.sender],
_royaltyArray,
_receiverArray,
_signature,
signerAddress
);
// distribut token to owner, admin, royalty receivers
{
uint256 tokenAmount = price;
uint256 feeAmount = tokenAmount.mul(swapFee).div(PERCENTS_DIVIDER);
uint256 ownerAmount = tokenAmount.sub(feeAmount);
uint256 royaltyCount = _royaltyArray.length;
IERC20 governanceToken = IERC20(tokenAddr);
// send token from user to contract
require(governanceToken.transferFrom(bidder, address(this), tokenAmount), "in sufficiant token amount");
// send service fee
if (swapFee > 0) {
require(governanceToken.transfer(feeAddress, feeAmount), "send service fee failed");
}
// send royalties
for (uint256 i = 0; i < royaltyCount; i++) {
uint256 royaltyAmount = tokenAmount.mul(_royaltyArray[i]).div(PERCENTS_DIVIDER);
if (royaltyAmount > 0) {
require(governanceToken.transfer(_receiverArray[i], royaltyAmount), "send royality failed");
ownerAmount = ownerAmount.sub(royaltyAmount);
}
}
// transfer token to owner
require(governanceToken.transfer(seller, ownerAmount));
}
// PRC721 transfer
IPRC721 nft = IPRC721(collection);
require(nft.isApprovedForAll(seller, address(this)), "Not approve nft to staker address");
require(nft.ownerOf(tokenId) == seller, "seller don't own nft");
nft.safeTransferFrom( seller, bidder, tokenId);
nonce[msg.sender] = nonce[msg.sender].add(1);
TrxEvent memory soldEvent;
soldEvent.buyer = bidder;
soldEvent.seller = seller;
soldEvent.productType = "auction";
soldEvent.productId = productId;
soldEvent.tokenId = tokenId;
soldEvent.collection = collection;
soldEvent.amount = 1;
soldEvent.price = price;
soldEvent.tokenAddr = tokenAddr;
emit Sold(soldEvent);
}
}
@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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;
}
@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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]
* ```solidity
* 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;
}
}
@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165Upgradeable.sol";
/**
* @dev _Available since v3.1._
*/
interface IERC1155ReceiverUpgradeable is IERC165Upgradeable {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is
* called at the end of a `safeTransferFrom` after the balance has been updated.
*
* NOTE: To accept the transfer, this must return
* `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
* (i.e. 0xf23a6e61, or its own function selector).
*
* @param operator The address which initiated the transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param id The ID of the token being transferred
* @param value The amount of tokens being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function
* is called at the end of a `safeBatchTransferFrom` after the balances have
* been updated.
*
* NOTE: To accept the transfer(s), this must return
* `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
* (i.e. 0xbc197c81, or its own function selector).
*
* @param operator The address which initiated the batch transfer (i.e. msg.sender)
* @param from The address which previously owned the token
* @param ids An array containing ids of each token being transferred (order and length must match values array)
* @param values An array containing amounts of each token being transferred (order and length must match ids array)
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol)
pragma solidity ^0.8.0;
import "./ERC1155ReceiverUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";
/**
* Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens.
*
* IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
* stuck.
*
* @dev _Available since v3.1._
*/
contract ERC1155HolderUpgradeable is Initializable, ERC1155ReceiverUpgradeable {
function __ERC1155Holder_init() internal onlyInitializing {
}
function __ERC1155Holder_init_unchained() internal onlyInitializing {
}
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
function onERC1155BatchReceived(
address,
address,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual override returns (bytes4) {
return this.onERC1155BatchReceived.selector;
}
/**
* @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;
}
@openzeppelin/contracts-upgradeable/token/ERC1155/utils/ERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)
pragma solidity ^0.8.0;
import "../IERC1155ReceiverUpgradeable.sol";
import "../../../utils/introspection/ERC165Upgradeable.sol";
import "../../../proxy/utils/Initializable.sol";
/**
* @dev _Available since v3.1._
*/
abstract contract ERC1155ReceiverUpgradeable is Initializable, ERC165Upgradeable, IERC1155ReceiverUpgradeable {
function __ERC1155Receiver_init() internal onlyInitializing {
}
function __ERC1155Receiver_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
return interfaceId == type(IERC1155ReceiverUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @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;
}
@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [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://consensys.net/diligence/blog/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.8.0/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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(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);
}
}
}
@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// 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;
}
@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @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;
}
@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @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);
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
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 = Math.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 `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.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);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
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) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 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 256, 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 << 3) < value ? 1 : 0);
}
}
}
@openzeppelin/contracts/utils/math/SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
@openzeppelin/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
@openzeppelin/contracts/utils/structs/EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```solidity
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*
* [WARNING]
* ====
* Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
* unusable.
* See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
*
* In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
* array of EnumerableSet.
* ====
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping(bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
// Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastValue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastValue;
// Update the index for the moved value
set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex
}
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function _values(Set storage set) private view returns (bytes32[] memory) {
return set._values;
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
bytes32[] memory store = _values(set._inner);
bytes32[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(AddressSet storage set) internal view returns (address[] memory) {
bytes32[] memory store = _values(set._inner);
address[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
/**
* @dev Return the entire set in an array
*
* WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
* to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
* this function has an unbounded cost, and using it as part of a state-changing function may render the function
* uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
*/
function values(UintSet storage set) internal view returns (uint256[] memory) {
bytes32[] memory store = _values(set._inner);
uint256[] memory result;
/// @solidity memory-safe-assembly
assembly {
result := store
}
return result;
}
}
contracts/signature/Signature.sol
// InvestNFT token
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/utils/Strings.sol";
abstract contract Signature {
using Strings for uint256;
error InvalidSignature();
error InvalidSignatureLength();
function confirmSignature(
address collection,
uint256 tokenId,
uint256 productId,
uint256 amount,
uint256 price,
address tokenAddr,
address buyer,
address seller,
uint256 nonce,
uint256[] memory _royaltyArray,
address[] memory _receiverArray,
bytes memory signature_,
address signer
) internal pure {
// combine royalty array as string
bytes32 hashMessage = keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
keccak256(
abi.encodePacked(
collection,
tokenId,
productId,
amount,
price,
tokenAddr,
buyer,
seller,
nonce,
_royaltyArray,
_receiverArray
)
)
)
);
if (recoverSigner(hashMessage, signature_) != signer)
revert InvalidSignature();
}
function recoverSigner(
bytes32 ethSignedMessageHash_,
bytes memory signature_
) private pure returns (address) {
(bytes32 r, bytes32 s, uint8 v) = splitSignature(signature_);
return ecrecover(ethSignedMessageHash_, v, r, s);
}
function splitSignature(
bytes memory sig_
) private pure returns (bytes32 r, bytes32 s, uint8 v) {
if (sig_.length != 65) revert InvalidSignatureLength();
assembly {
r := mload(add(sig_, 32))
s := mload(add(sig_, 64))
v := byte(0, mload(add(sig_, 96)))
}
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"error","name":"InvalidSignature","inputs":[]},{"type":"error","name":"InvalidSignatureLength","inputs":[]},{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Sold","inputs":[{"type":"tuple","name":"soldEvent","internalType":"struct HexToysMarketV2.TrxEvent","indexed":false,"components":[{"type":"address","name":"buyer","internalType":"address"},{"type":"address","name":"seller","internalType":"address"},{"type":"string","name":"productType","internalType":"string"},{"type":"uint256","name":"productId","internalType":"uint256"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"collection","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"address","name":"tokenAddr","internalType":"address"}]}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PERCENTS_DIVIDER","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buyNFT","inputs":[{"type":"address","name":"collection","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"productId","internalType":"uint256"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"address","name":"tokenAddr","internalType":"address"},{"type":"address","name":"seller","internalType":"address"},{"type":"uint256","name":"nftType","internalType":"uint256"},{"type":"uint256[]","name":"_royaltyArray","internalType":"uint256[]"},{"type":"address[]","name":"_receiverArray","internalType":"address[]"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"feeAddress","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"finalizeAuction","inputs":[{"type":"address","name":"collection","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"uint256","name":"productId","internalType":"uint256"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"address","name":"tokenAddr","internalType":"address"},{"type":"address","name":"seller","internalType":"address"},{"type":"address","name":"bidder","internalType":"address"},{"type":"uint256[]","name":"_royaltyArray","internalType":"uint256[]"},{"type":"address[]","name":"_receiverArray","internalType":"address[]"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_feeAddress","internalType":"address"},{"type":"address","name":"_signerAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"nonce","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC1155BatchReceived","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"uint256[]","name":"","internalType":"uint256[]"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC1155Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFeeAddress","inputs":[{"type":"address","name":"_address","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFeePercent","inputs":[{"type":"uint256","name":"_swapFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setSignerAddress","inputs":[{"type":"address","name":"_signerAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"signerAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"swapFee","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b5061243d806100206000396000f3fe6080604052600436106100fe5760003560e01c80635b7633d0116100955780638705fcd4116100645780638705fcd4146102a15780638da5cb5b146102c1578063bc197c81146102df578063f23a6e6114610324578063f2fde38b1461035057600080fd5b80635b7633d01461021f57806370ae92d21461023f578063715018a61461026c5780637ce3489b1461028157600080fd5b80633b6d0756116100d15780633b6d07561461019e57806341275358146101b1578063485cc955146101e957806354cf2aeb1461020957600080fd5b806301c234a81461010357806301ffc9a71461012c578063046dc1661461015c57806320d0e8951461017e575b600080fd5b34801561010f57600080fd5b506101196103e881565b6040519081526020015b60405180910390f35b34801561013857600080fd5b5061014c610147366004611b19565b610370565b6040519015158152602001610123565b34801561016857600080fd5b5061017c610177366004611b68565b6103a7565b005b34801561018a57600080fd5b5061017c610199366004611d2f565b61041e565b61017c6101ac366004611e19565b610ae3565b3480156101bd57600080fd5b5060fd546101d1906001600160a01b031681565b6040516001600160a01b039091168152602001610123565b3480156101f557600080fd5b5061017c610204366004611f0e565b6114ee565b34801561021557600080fd5b5061011960fc5481565b34801561022b57600080fd5b5060fe546101d1906001600160a01b031681565b34801561024b57600080fd5b5061011961025a366004611b68565b60fb6020526000908152604090205481565b34801561027857600080fd5b5061017c611682565b34801561028d57600080fd5b5061017c61029c366004611f47565b611696565b3480156102ad57600080fd5b5061017c6102bc366004611b68565b6116e5565b3480156102cd57600080fd5b506033546001600160a01b03166101d1565b3480156102eb57600080fd5b5061030b6102fa366004611f60565b63bc197c8160e01b95945050505050565b6040516001600160e01b03199091168152602001610123565b34801561033057600080fd5b5061030b61033f36600461200e565b63f23a6e6160e01b95945050505050565b34801561035c57600080fd5b5061017c61036b366004611b68565b611757565b60006001600160e01b03198216630271189760e51b14806103a157506301ffc9a760e01b6001600160e01b03198316145b92915050565b6103af6117d0565b6001600160a01b0381166103fc5760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b60448201526064015b60405180910390fd5b60fe80546001600160a01b0319166001600160a01b0392909216919091179055565b336001600160a01b038616148061043f57506033546001600160a01b031633145b61048b5760405162461bcd60e51b815260206004820152601f60248201527f6f6e6c792061756374696f6e206f776e65722063616e2066696e616c697a650060448201526064016103f3565b33600090815260fb602052604090205460fe546104c8918c918c918c916001918d918d918c918e91908d908d908d906001600160a01b031661182a565b600087905060006104f06103e86104ea60fc54856118fd90919063ffffffff16565b90611910565b905060006104fe838361191c565b86516040516323b872dd60e01b8152919250908a906001600160a01b038216906323b872dd90610536908c9030908a90600401612077565b6020604051808303816000875af1158015610555573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610579919061209b565b6105c55760405162461bcd60e51b815260206004820152601a60248201527f696e2073756666696369616e7420746f6b656e20616d6f756e7400000000000060448201526064016103f3565b60fc541561068a5760fd5460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018690529082169063a9059cbb906044016020604051808303816000875af1158015610620573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610644919061209b565b61068a5760405162461bcd60e51b81526020600482015260176024820152761cd95b99081cd95c9d9a58d9481999594819985a5b1959604a1b60448201526064016103f3565b60005b828110156107d25760006106c96103e86104ea8c85815181106106b2576106b26120bd565b60200260200101518a6118fd90919063ffffffff16565b905080156107bf57826001600160a01b031663a9059cbb8a84815181106106f2576106f26120bd565b6020026020010151836040518363ffffffff1660e01b815260040161072c9291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af115801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f919061209b565b6107b25760405162461bcd60e51b81526020600482015260146024820152731cd95b99081c9bde585b1a5d1e4819985a5b195960621b60448201526064016103f3565b6107bc858261191c565b94505b50806107ca816120e9565b91505061068d565b5060405163a9059cbb60e01b81526001600160a01b038b811660048301526024820185905282169063a9059cbb906044016020604051808303816000875af1158015610822573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610846919061209b565b61084f57600080fd5b505060405163e985e9c560e01b81526001600160a01b0389811660048301523060248301528e94508416925063e985e9c59150604401602060405180830381865afa1580156108a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c6919061209b565b6108e25760405162461bcd60e51b81526004016103f390612102565b6040516331a9108f60e11b8152600481018b90526001600160a01b038088169190831690636352211e90602401602060405180830381865afa15801561092c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109509190612143565b6001600160a01b03161461099d5760405162461bcd60e51b81526020600482015260146024820152731cd95b1b195c88191bdb89dd081bdddb881b999d60621b60448201526064016103f3565b604051632142170760e11b81526001600160a01b038216906342842e0e906109cd90899089908f90600401612077565b600060405180830381600087803b1580156109e757600080fd5b505af11580156109fb573d6000803e3d6000fd5b505033600090815260fb6020526040902054610a1b925090506001611928565b33600090815260fb6020526040902055610a33611aa9565b6001600160a01b038087168252878116602080840191909152604080518082018252600781526630bab1ba34b7b760c91b9281019290925280840191909152606083018c9052608083018d90528d821660a0840152600160c084015260e083018b9052908916610100830152517f08c621668da99abcc3c6e10c4c29360acda822aed534f3e73785805ed4f266d890610acd9083906121a6565b60405180910390a1505050505050505050505050565b33600081815260fb602052604090205460fe54610b1d928e928e928e928e928e928e92918e918d908d908d906001600160a01b031661182a565b6000610b29888a6118fd565b90506000610b486103e86104ea60fc54856118fd90919063ffffffff16565b90506000610b56838361191c565b86519091506001600160a01b038a16610d5e5783341015610bac5760405162461bcd60e51b815260206004820152601060248201526f1d1bdbc81cdb585b1b08185b5bdd5b9d60821b60448201526064016103f3565b60fc5415610c165760fd546040516000916001600160a01b03169085908381818185875af1925050503d8060008114610c01576040519150601f19603f3d011682016040523d82523d6000602084013e610c06565b606091505b5050905080610c1457600080fd5b505b60005b81811015610cf7576000610c556103e86104ea8b8581518110610c3e57610c3e6120bd565b6020026020010151896118fd90919063ffffffff16565b90508015610ce4576000888381518110610c7157610c716120bd565b60200260200101516001600160a01b03168260405160006040518083038185875af1925050503d8060008114610cc3576040519150601f19603f3d011682016040523d82523d6000602084013e610cc8565b606091505b5050905080610cd657600080fd5b610ce0858361191c565b9450505b5080610cef816120e9565b915050610c19565b506000896001600160a01b03168360405160006040518083038185875af1925050503d8060008114610d45576040519150601f19603f3d011682016040523d82523d6000602084013e610d4a565b606091505b5050905080610d5857600080fd5b50611094565b6040516323b872dd60e01b81528a906001600160a01b038216906323b872dd90610d9090339030908a90600401612077565b6020604051808303816000875af1158015610daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd3919061209b565b610e1f5760405162461bcd60e51b815260206004820152601a60248201527f696e2073756666696369616e7420746f6b656e20616d6f756e7400000000000060448201526064016103f3565b60fc5415610ee45760fd5460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018690529082169063a9059cbb906044016020604051808303816000875af1158015610e7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9e919061209b565b610ee45760405162461bcd60e51b81526020600482015260176024820152761cd95b99081cd95c9d9a58d9481999594819985a5b1959604a1b60448201526064016103f3565b60005b82811015611015576000610f0c6103e86104ea8c85815181106106b2576106b26120bd565b9050801561100257826001600160a01b031663a9059cbb8a8481518110610f3557610f356120bd565b6020026020010151836040518363ffffffff1660e01b8152600401610f6f9291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af1158015610f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb2919061209b565b610ff55760405162461bcd60e51b81526020600482015260146024820152731cd95b99081c9bde585b1a5d1e4819985a5b195960621b60448201526064016103f3565b610fff858261191c565b94505b508061100d816120e9565b915050610ee7565b5060405163a9059cbb60e01b81526001600160a01b038b811660048301526024820185905282169063a9059cbb906044016020604051808303816000875af1158015611065573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611089919061209b565b61109257600080fd5b505b50505050836000036112525760405163e985e9c560e01b81526001600160a01b0386811660048301523060248301528c919082169063e985e9c590604401602060405180830381865afa1580156110ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611113919061209b565b61112f5760405162461bcd60e51b81526004016103f390612102565b6040516331a9108f60e11b8152600481018c90526001600160a01b038088169190831690636352211e90602401602060405180830381865afa158015611179573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119d9190612143565b6001600160a01b0316146111ea5760405162461bcd60e51b81526020600482015260146024820152731cd95b1b195c88191bdb89dd081bdddb881b999d60621b60448201526064016103f3565b806001600160a01b03166342842e0e87338e6040518463ffffffff1660e01b815260040161121a93929190612077565b600060405180830381600087803b15801561123457600080fd5b505af1158015611248573d6000803e3d6000fd5b5050505050611426565b60405163e985e9c560e01b81526001600160a01b0386811660048301523060248301528c919082169063e985e9c590604401602060405180830381865afa1580156112a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c5919061209b565b6112e15760405162461bcd60e51b81526004016103f390612102565b604051627eeac760e11b81526001600160a01b038781166004830152602482018d90526000919083169062fdd58e90604401602060405180830381865afa158015611330573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113549190612266565b9050898110156113a65760405162461bcd60e51b815260206004820152601f60248201527f73656c6c657220646f6e2774206f776e20656e6f7567682062616c616e63650060448201526064016103f3565b604051637921219560e11b81526001600160a01b038881166004830152336024830152604482018e9052606482018c905260a06084830152600060a483015283169063f242432a9060c401600060405180830381600087803b15801561140b57600080fd5b505af115801561141f573d6000803e3d6000fd5b5050505050505b33600090815260fb6020526040902054611441906001611928565b33600090815260fb6020526040902055611459611aa9565b3381526001600160a01b0386811660208084019190915260408051808201825260048152633830b4b960e11b9281019290925280840191909152606083018c9052608083018d90528d821660a084015260c083018b905260e083018a9052908816610100830152517f08c621668da99abcc3c6e10c4c29360acda822aed534f3e73785805ed4f266d890610acd9083906121a6565b600054610100900460ff161580801561150e5750600054600160ff909116105b806115285750303b158015611528575060005460ff166001145b61158b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103f3565b6000805460ff1916600117905580156115ae576000805461ff0019166101001790555b6115b6611934565b6001600160a01b0383166116025760405162461bcd60e51b815260206004820152601360248201527224b73b30b634b21031b7b6b6b7b727bbb732b960691b60448201526064016103f3565b60fd80546001600160a01b038086166001600160a01b03199283161790925560fe805492851692909116919091179055601560fc55801561167d576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b61168a6117d0565b6116946000611963565b565b61169e6117d0565b606481106116e05760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b60448201526064016103f3565b60fc55565b6116ed6117d0565b6001600160a01b0381166117355760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b60448201526064016103f3565b60fd80546001600160a01b0319166001600160a01b0392909216919091179055565b61175f6117d0565b6001600160a01b0381166117c45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103f3565b6117cd81611963565b50565b6033546001600160a01b031633146116945760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f3565b60008d8d8d8d8d8d8d8d8d8d8d6040516020016118519b9a999897969594939291906122bb565b60408051601f198184030181529082905280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000091830191909152603c820152605c01604051602081830303815290604052805190602001209050816001600160a01b03166118c682856119b5565b6001600160a01b0316146118ed57604051638baa579f60e01b815260040160405180910390fd5b5050505050505050505050505050565b6000611909828461235d565b9392505050565b60006119098284612374565b60006119098284612396565b600061190982846123a9565b600054610100900460ff1661195b5760405162461bcd60e51b81526004016103f3906123bc565b611694611a34565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806000806119c485611a64565b6040805160008152602081018083528b905260ff8316918101919091526060810184905260808101839052929550909350915060019060a0016020604051602081039080840390855afa158015611a1f573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b600054610100900460ff16611a5b5760405162461bcd60e51b81526004016103f3906123bc565b61169433611963565b60008060008351604114611a8b57604051634be6321b60e01b815260040160405180910390fd5b50505060208101516040820151606090920151909260009190911a90565b60405180610120016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160608152602001600081526020016000815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b031681525090565b600060208284031215611b2b57600080fd5b81356001600160e01b03198116811461190957600080fd5b6001600160a01b03811681146117cd57600080fd5b8035611b6381611b43565b919050565b600060208284031215611b7a57600080fd5b813561190981611b43565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611bc457611bc4611b85565b604052919050565b600067ffffffffffffffff821115611be657611be6611b85565b5060051b60200190565b600082601f830112611c0157600080fd5b81356020611c16611c1183611bcc565b611b9b565b82815260059290921b84018101918181019086841115611c3557600080fd5b8286015b84811015611c505780358352918301918301611c39565b509695505050505050565b600082601f830112611c6c57600080fd5b81356020611c7c611c1183611bcc565b82815260059290921b84018101918181019086841115611c9b57600080fd5b8286015b84811015611c50578035611cb281611b43565b8352918301918301611c9f565b600082601f830112611cd057600080fd5b813567ffffffffffffffff811115611cea57611cea611b85565b611cfd601f8201601f1916602001611b9b565b818152846020838601011115611d1257600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806000806000806000806101408b8d031215611d4f57600080fd5b611d588b611b58565b995060208b0135985060408b0135975060608b01359650611d7b60808c01611b58565b9550611d8960a08c01611b58565b9450611d9760c08c01611b58565b935060e08b013567ffffffffffffffff80821115611db457600080fd5b611dc08e838f01611bf0565b94506101008d0135915080821115611dd757600080fd5b611de38e838f01611c5b565b93506101208d0135915080821115611dfa57600080fd5b50611e078d828e01611cbf565b9150509295989b9194979a5092959850565b60008060008060008060008060008060006101608c8e031215611e3b57600080fd5b611e448c611b58565b9a5060208c0135995060408c0135985060608c0135975060808c01359650611e6e60a08d01611b58565b9550611e7c60c08d01611b58565b945060e08c0135935067ffffffffffffffff806101008e01351115611ea057600080fd5b611eb18e6101008f01358f01611bf0565b9350806101208e01351115611ec557600080fd5b611ed68e6101208f01358f01611c5b565b9250806101408e01351115611eea57600080fd5b50611efc8d6101408e01358e01611cbf565b90509295989b509295989b9093969950565b60008060408385031215611f2157600080fd5b8235611f2c81611b43565b91506020830135611f3c81611b43565b809150509250929050565b600060208284031215611f5957600080fd5b5035919050565b600080600080600060a08688031215611f7857600080fd5b8535611f8381611b43565b94506020860135611f9381611b43565b9350604086013567ffffffffffffffff80821115611fb057600080fd5b611fbc89838a01611bf0565b94506060880135915080821115611fd257600080fd5b611fde89838a01611bf0565b93506080880135915080821115611ff457600080fd5b5061200188828901611cbf565b9150509295509295909350565b600080600080600060a0868803121561202657600080fd5b853561203181611b43565b9450602086013561204181611b43565b93506040860135925060608601359150608086013567ffffffffffffffff81111561206b57600080fd5b61200188828901611cbf565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6000602082840312156120ad57600080fd5b8151801515811461190957600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016120fb576120fb6120d3565b5060010190565b60208082526021908201527f4e6f7420617070726f7665206e667420746f207374616b6572206164647265736040820152607360f81b606082015260800190565b60006020828403121561215557600080fd5b815161190981611b43565b6000815180845260005b818110156121865760208185018101518683018201520161216a565b506000602082860101526020601f19601f83011685010191505092915050565b602081526121c06020820183516001600160a01b03169052565b600060208301516121dc60408401826001600160a01b03169052565b5060408301516101208060608501526121f9610140850183612160565b915060608501516080850152608085015160a085015260a085015161222960c08601826001600160a01b03169052565b5060c085015160e085015260e085015161010081818701528087015191505061225c828601826001600160a01b03169052565b5090949350505050565b60006020828403121561227857600080fd5b5051919050565b60008151602080840160005b838110156122b05781516001600160a01b03168752958201959082019060010161228b565b509495945050505050565b60006bffffffffffffffffffffffff19808e60601b1683528c60148401528b60348401528a6054840152896074840152808960601b166094840152808860601b1660a8840152808760601b1660bc840152508460d083015260f082018451602080870160005b8381101561233d57815185529382019390820190600101612321565b5050505061234b818561227f565b9e9d5050505050505050505050505050565b80820281158282048414176103a1576103a16120d3565b60008261239157634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156103a1576103a16120d3565b808201808211156103a1576103a16120d3565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea264697066735822122050a9df6887e78ea0ee2178b05401e00f87cf6fa3d771837e85080e9579c47d0064736f6c63430008110033
Deployed ByteCode
0x6080604052600436106100fe5760003560e01c80635b7633d0116100955780638705fcd4116100645780638705fcd4146102a15780638da5cb5b146102c1578063bc197c81146102df578063f23a6e6114610324578063f2fde38b1461035057600080fd5b80635b7633d01461021f57806370ae92d21461023f578063715018a61461026c5780637ce3489b1461028157600080fd5b80633b6d0756116100d15780633b6d07561461019e57806341275358146101b1578063485cc955146101e957806354cf2aeb1461020957600080fd5b806301c234a81461010357806301ffc9a71461012c578063046dc1661461015c57806320d0e8951461017e575b600080fd5b34801561010f57600080fd5b506101196103e881565b6040519081526020015b60405180910390f35b34801561013857600080fd5b5061014c610147366004611b19565b610370565b6040519015158152602001610123565b34801561016857600080fd5b5061017c610177366004611b68565b6103a7565b005b34801561018a57600080fd5b5061017c610199366004611d2f565b61041e565b61017c6101ac366004611e19565b610ae3565b3480156101bd57600080fd5b5060fd546101d1906001600160a01b031681565b6040516001600160a01b039091168152602001610123565b3480156101f557600080fd5b5061017c610204366004611f0e565b6114ee565b34801561021557600080fd5b5061011960fc5481565b34801561022b57600080fd5b5060fe546101d1906001600160a01b031681565b34801561024b57600080fd5b5061011961025a366004611b68565b60fb6020526000908152604090205481565b34801561027857600080fd5b5061017c611682565b34801561028d57600080fd5b5061017c61029c366004611f47565b611696565b3480156102ad57600080fd5b5061017c6102bc366004611b68565b6116e5565b3480156102cd57600080fd5b506033546001600160a01b03166101d1565b3480156102eb57600080fd5b5061030b6102fa366004611f60565b63bc197c8160e01b95945050505050565b6040516001600160e01b03199091168152602001610123565b34801561033057600080fd5b5061030b61033f36600461200e565b63f23a6e6160e01b95945050505050565b34801561035c57600080fd5b5061017c61036b366004611b68565b611757565b60006001600160e01b03198216630271189760e51b14806103a157506301ffc9a760e01b6001600160e01b03198316145b92915050565b6103af6117d0565b6001600160a01b0381166103fc5760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b60448201526064015b60405180910390fd5b60fe80546001600160a01b0319166001600160a01b0392909216919091179055565b336001600160a01b038616148061043f57506033546001600160a01b031633145b61048b5760405162461bcd60e51b815260206004820152601f60248201527f6f6e6c792061756374696f6e206f776e65722063616e2066696e616c697a650060448201526064016103f3565b33600090815260fb602052604090205460fe546104c8918c918c918c916001918d918d918c918e91908d908d908d906001600160a01b031661182a565b600087905060006104f06103e86104ea60fc54856118fd90919063ffffffff16565b90611910565b905060006104fe838361191c565b86516040516323b872dd60e01b8152919250908a906001600160a01b038216906323b872dd90610536908c9030908a90600401612077565b6020604051808303816000875af1158015610555573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610579919061209b565b6105c55760405162461bcd60e51b815260206004820152601a60248201527f696e2073756666696369616e7420746f6b656e20616d6f756e7400000000000060448201526064016103f3565b60fc541561068a5760fd5460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018690529082169063a9059cbb906044016020604051808303816000875af1158015610620573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610644919061209b565b61068a5760405162461bcd60e51b81526020600482015260176024820152761cd95b99081cd95c9d9a58d9481999594819985a5b1959604a1b60448201526064016103f3565b60005b828110156107d25760006106c96103e86104ea8c85815181106106b2576106b26120bd565b60200260200101518a6118fd90919063ffffffff16565b905080156107bf57826001600160a01b031663a9059cbb8a84815181106106f2576106f26120bd565b6020026020010151836040518363ffffffff1660e01b815260040161072c9291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af115801561074b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076f919061209b565b6107b25760405162461bcd60e51b81526020600482015260146024820152731cd95b99081c9bde585b1a5d1e4819985a5b195960621b60448201526064016103f3565b6107bc858261191c565b94505b50806107ca816120e9565b91505061068d565b5060405163a9059cbb60e01b81526001600160a01b038b811660048301526024820185905282169063a9059cbb906044016020604051808303816000875af1158015610822573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610846919061209b565b61084f57600080fd5b505060405163e985e9c560e01b81526001600160a01b0389811660048301523060248301528e94508416925063e985e9c59150604401602060405180830381865afa1580156108a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c6919061209b565b6108e25760405162461bcd60e51b81526004016103f390612102565b6040516331a9108f60e11b8152600481018b90526001600160a01b038088169190831690636352211e90602401602060405180830381865afa15801561092c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109509190612143565b6001600160a01b03161461099d5760405162461bcd60e51b81526020600482015260146024820152731cd95b1b195c88191bdb89dd081bdddb881b999d60621b60448201526064016103f3565b604051632142170760e11b81526001600160a01b038216906342842e0e906109cd90899089908f90600401612077565b600060405180830381600087803b1580156109e757600080fd5b505af11580156109fb573d6000803e3d6000fd5b505033600090815260fb6020526040902054610a1b925090506001611928565b33600090815260fb6020526040902055610a33611aa9565b6001600160a01b038087168252878116602080840191909152604080518082018252600781526630bab1ba34b7b760c91b9281019290925280840191909152606083018c9052608083018d90528d821660a0840152600160c084015260e083018b9052908916610100830152517f08c621668da99abcc3c6e10c4c29360acda822aed534f3e73785805ed4f266d890610acd9083906121a6565b60405180910390a1505050505050505050505050565b33600081815260fb602052604090205460fe54610b1d928e928e928e928e928e928e92918e918d908d908d906001600160a01b031661182a565b6000610b29888a6118fd565b90506000610b486103e86104ea60fc54856118fd90919063ffffffff16565b90506000610b56838361191c565b86519091506001600160a01b038a16610d5e5783341015610bac5760405162461bcd60e51b815260206004820152601060248201526f1d1bdbc81cdb585b1b08185b5bdd5b9d60821b60448201526064016103f3565b60fc5415610c165760fd546040516000916001600160a01b03169085908381818185875af1925050503d8060008114610c01576040519150601f19603f3d011682016040523d82523d6000602084013e610c06565b606091505b5050905080610c1457600080fd5b505b60005b81811015610cf7576000610c556103e86104ea8b8581518110610c3e57610c3e6120bd565b6020026020010151896118fd90919063ffffffff16565b90508015610ce4576000888381518110610c7157610c716120bd565b60200260200101516001600160a01b03168260405160006040518083038185875af1925050503d8060008114610cc3576040519150601f19603f3d011682016040523d82523d6000602084013e610cc8565b606091505b5050905080610cd657600080fd5b610ce0858361191c565b9450505b5080610cef816120e9565b915050610c19565b506000896001600160a01b03168360405160006040518083038185875af1925050503d8060008114610d45576040519150601f19603f3d011682016040523d82523d6000602084013e610d4a565b606091505b5050905080610d5857600080fd5b50611094565b6040516323b872dd60e01b81528a906001600160a01b038216906323b872dd90610d9090339030908a90600401612077565b6020604051808303816000875af1158015610daf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd3919061209b565b610e1f5760405162461bcd60e51b815260206004820152601a60248201527f696e2073756666696369616e7420746f6b656e20616d6f756e7400000000000060448201526064016103f3565b60fc5415610ee45760fd5460405163a9059cbb60e01b81526001600160a01b039182166004820152602481018690529082169063a9059cbb906044016020604051808303816000875af1158015610e7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e9e919061209b565b610ee45760405162461bcd60e51b81526020600482015260176024820152761cd95b99081cd95c9d9a58d9481999594819985a5b1959604a1b60448201526064016103f3565b60005b82811015611015576000610f0c6103e86104ea8c85815181106106b2576106b26120bd565b9050801561100257826001600160a01b031663a9059cbb8a8481518110610f3557610f356120bd565b6020026020010151836040518363ffffffff1660e01b8152600401610f6f9291906001600160a01b03929092168252602082015260400190565b6020604051808303816000875af1158015610f8e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb2919061209b565b610ff55760405162461bcd60e51b81526020600482015260146024820152731cd95b99081c9bde585b1a5d1e4819985a5b195960621b60448201526064016103f3565b610fff858261191c565b94505b508061100d816120e9565b915050610ee7565b5060405163a9059cbb60e01b81526001600160a01b038b811660048301526024820185905282169063a9059cbb906044016020604051808303816000875af1158015611065573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611089919061209b565b61109257600080fd5b505b50505050836000036112525760405163e985e9c560e01b81526001600160a01b0386811660048301523060248301528c919082169063e985e9c590604401602060405180830381865afa1580156110ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611113919061209b565b61112f5760405162461bcd60e51b81526004016103f390612102565b6040516331a9108f60e11b8152600481018c90526001600160a01b038088169190831690636352211e90602401602060405180830381865afa158015611179573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061119d9190612143565b6001600160a01b0316146111ea5760405162461bcd60e51b81526020600482015260146024820152731cd95b1b195c88191bdb89dd081bdddb881b999d60621b60448201526064016103f3565b806001600160a01b03166342842e0e87338e6040518463ffffffff1660e01b815260040161121a93929190612077565b600060405180830381600087803b15801561123457600080fd5b505af1158015611248573d6000803e3d6000fd5b5050505050611426565b60405163e985e9c560e01b81526001600160a01b0386811660048301523060248301528c919082169063e985e9c590604401602060405180830381865afa1580156112a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c5919061209b565b6112e15760405162461bcd60e51b81526004016103f390612102565b604051627eeac760e11b81526001600160a01b038781166004830152602482018d90526000919083169062fdd58e90604401602060405180830381865afa158015611330573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113549190612266565b9050898110156113a65760405162461bcd60e51b815260206004820152601f60248201527f73656c6c657220646f6e2774206f776e20656e6f7567682062616c616e63650060448201526064016103f3565b604051637921219560e11b81526001600160a01b038881166004830152336024830152604482018e9052606482018c905260a06084830152600060a483015283169063f242432a9060c401600060405180830381600087803b15801561140b57600080fd5b505af115801561141f573d6000803e3d6000fd5b5050505050505b33600090815260fb6020526040902054611441906001611928565b33600090815260fb6020526040902055611459611aa9565b3381526001600160a01b0386811660208084019190915260408051808201825260048152633830b4b960e11b9281019290925280840191909152606083018c9052608083018d90528d821660a084015260c083018b905260e083018a9052908816610100830152517f08c621668da99abcc3c6e10c4c29360acda822aed534f3e73785805ed4f266d890610acd9083906121a6565b600054610100900460ff161580801561150e5750600054600160ff909116105b806115285750303b158015611528575060005460ff166001145b61158b5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016103f3565b6000805460ff1916600117905580156115ae576000805461ff0019166101001790555b6115b6611934565b6001600160a01b0383166116025760405162461bcd60e51b815260206004820152601360248201527224b73b30b634b21031b7b6b6b7b727bbb732b960691b60448201526064016103f3565b60fd80546001600160a01b038086166001600160a01b03199283161790925560fe805492851692909116919091179055601560fc55801561167d576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050565b61168a6117d0565b6116946000611963565b565b61169e6117d0565b606481106116e05760405162461bcd60e51b815260206004820152600f60248201526e1a5b9d985b1a59081c195c98d95b9d608a1b60448201526064016103f3565b60fc55565b6116ed6117d0565b6001600160a01b0381166117355760405162461bcd60e51b815260206004820152600f60248201526e696e76616c6964206164647265737360881b60448201526064016103f3565b60fd80546001600160a01b0319166001600160a01b0392909216919091179055565b61175f6117d0565b6001600160a01b0381166117c45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103f3565b6117cd81611963565b50565b6033546001600160a01b031633146116945760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016103f3565b60008d8d8d8d8d8d8d8d8d8d8d6040516020016118519b9a999897969594939291906122bb565b60408051601f198184030181529082905280516020918201207f19457468657265756d205369676e6564204d6573736167653a0a33320000000091830191909152603c820152605c01604051602081830303815290604052805190602001209050816001600160a01b03166118c682856119b5565b6001600160a01b0316146118ed57604051638baa579f60e01b815260040160405180910390fd5b5050505050505050505050505050565b6000611909828461235d565b9392505050565b60006119098284612374565b60006119098284612396565b600061190982846123a9565b600054610100900460ff1661195b5760405162461bcd60e51b81526004016103f3906123bc565b611694611a34565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000806000806119c485611a64565b6040805160008152602081018083528b905260ff8316918101919091526060810184905260808101839052929550909350915060019060a0016020604051602081039080840390855afa158015611a1f573d6000803e3d6000fd5b5050604051601f190151979650505050505050565b600054610100900460ff16611a5b5760405162461bcd60e51b81526004016103f3906123bc565b61169433611963565b60008060008351604114611a8b57604051634be6321b60e01b815260040160405180910390fd5b50505060208101516040820151606090920151909260009190911a90565b60405180610120016040528060006001600160a01b0316815260200160006001600160a01b0316815260200160608152602001600081526020016000815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b031681525090565b600060208284031215611b2b57600080fd5b81356001600160e01b03198116811461190957600080fd5b6001600160a01b03811681146117cd57600080fd5b8035611b6381611b43565b919050565b600060208284031215611b7a57600080fd5b813561190981611b43565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611bc457611bc4611b85565b604052919050565b600067ffffffffffffffff821115611be657611be6611b85565b5060051b60200190565b600082601f830112611c0157600080fd5b81356020611c16611c1183611bcc565b611b9b565b82815260059290921b84018101918181019086841115611c3557600080fd5b8286015b84811015611c505780358352918301918301611c39565b509695505050505050565b600082601f830112611c6c57600080fd5b81356020611c7c611c1183611bcc565b82815260059290921b84018101918181019086841115611c9b57600080fd5b8286015b84811015611c50578035611cb281611b43565b8352918301918301611c9f565b600082601f830112611cd057600080fd5b813567ffffffffffffffff811115611cea57611cea611b85565b611cfd601f8201601f1916602001611b9b565b818152846020838601011115611d1257600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000806000806000806000806101408b8d031215611d4f57600080fd5b611d588b611b58565b995060208b0135985060408b0135975060608b01359650611d7b60808c01611b58565b9550611d8960a08c01611b58565b9450611d9760c08c01611b58565b935060e08b013567ffffffffffffffff80821115611db457600080fd5b611dc08e838f01611bf0565b94506101008d0135915080821115611dd757600080fd5b611de38e838f01611c5b565b93506101208d0135915080821115611dfa57600080fd5b50611e078d828e01611cbf565b9150509295989b9194979a5092959850565b60008060008060008060008060008060006101608c8e031215611e3b57600080fd5b611e448c611b58565b9a5060208c0135995060408c0135985060608c0135975060808c01359650611e6e60a08d01611b58565b9550611e7c60c08d01611b58565b945060e08c0135935067ffffffffffffffff806101008e01351115611ea057600080fd5b611eb18e6101008f01358f01611bf0565b9350806101208e01351115611ec557600080fd5b611ed68e6101208f01358f01611c5b565b9250806101408e01351115611eea57600080fd5b50611efc8d6101408e01358e01611cbf565b90509295989b509295989b9093969950565b60008060408385031215611f2157600080fd5b8235611f2c81611b43565b91506020830135611f3c81611b43565b809150509250929050565b600060208284031215611f5957600080fd5b5035919050565b600080600080600060a08688031215611f7857600080fd5b8535611f8381611b43565b94506020860135611f9381611b43565b9350604086013567ffffffffffffffff80821115611fb057600080fd5b611fbc89838a01611bf0565b94506060880135915080821115611fd257600080fd5b611fde89838a01611bf0565b93506080880135915080821115611ff457600080fd5b5061200188828901611cbf565b9150509295509295909350565b600080600080600060a0868803121561202657600080fd5b853561203181611b43565b9450602086013561204181611b43565b93506040860135925060608601359150608086013567ffffffffffffffff81111561206b57600080fd5b61200188828901611cbf565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6000602082840312156120ad57600080fd5b8151801515811461190957600080fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016120fb576120fb6120d3565b5060010190565b60208082526021908201527f4e6f7420617070726f7665206e667420746f207374616b6572206164647265736040820152607360f81b606082015260800190565b60006020828403121561215557600080fd5b815161190981611b43565b6000815180845260005b818110156121865760208185018101518683018201520161216a565b506000602082860101526020601f19601f83011685010191505092915050565b602081526121c06020820183516001600160a01b03169052565b600060208301516121dc60408401826001600160a01b03169052565b5060408301516101208060608501526121f9610140850183612160565b915060608501516080850152608085015160a085015260a085015161222960c08601826001600160a01b03169052565b5060c085015160e085015260e085015161010081818701528087015191505061225c828601826001600160a01b03169052565b5090949350505050565b60006020828403121561227857600080fd5b5051919050565b60008151602080840160005b838110156122b05781516001600160a01b03168752958201959082019060010161228b565b509495945050505050565b60006bffffffffffffffffffffffff19808e60601b1683528c60148401528b60348401528a6054840152896074840152808960601b166094840152808860601b1660a8840152808760601b1660bc840152508460d083015260f082018451602080870160005b8381101561233d57815185529382019390820190600101612321565b5050505061234b818561227f565b9e9d5050505050505050505050505050565b80820281158282048414176103a1576103a16120d3565b60008261239157634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156103a1576103a16120d3565b808201808211156103a1576103a16120d3565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b60608201526080019056fea264697066735822122050a9df6887e78ea0ee2178b05401e00f87cf6fa3d771837e85080e9579c47d0064736f6c63430008110033