- Contract name:
- ShopAP
- Optimization enabled
- true
- Compiler version
- v0.8.2+commit.661d1103
- Optimization runs
- 999999
- Verified at
- 2023-12-14 09:02:37.691825Z
contracts/ShopAP.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
import "./libraries/TransferHelper.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "./OwnerOperator.sol";
import "./interfaces/ICollection.sol";
contract ShopAP is ERC721HolderUpgradeable, OwnerOperator {
using CountersUpgradeable for CountersUpgradeable.Counter;
using SafeMathUpgradeable for uint256;
event CreateSellOrder(
uint256 indexed _orderId,
address indexed _seller,
uint256 _tokenId,
uint256 _price,
address _currency,
address _tokenAddress,
string _type
);
event Buy(
uint256 indexed _orderId,
address indexed _buyer,
address indexed seller,
uint256 _tokenId,
uint256 _price,
address _currency,
address _tokenAddress
);
event CancelSellOrder(
uint256 indexed _orderId,
address indexed _seller,
uint256 _tokenId,
uint256 _price,
address _currency,
address _tokenAddress
);
event UpdateSellOrder(
uint256 indexed _orderId,
address indexed _seller,
uint256 _tokenId,
uint256 _oldPrice,
uint256 _newPrice,
address _currency,
address _tokenAddress
);
event AcceptOffer(
address indexed _seller,
address indexed _buyer,
uint256 _tokenId,
uint256 _amount,
uint256 _price,
address _tokenAddress,
address _currency
);
event Bid(
address indexed owner,
address indexed winner,
address _tokenAddress,
uint256 _tokenId,
uint256 _price,
address _currency
);
event adminStatics(
address collectionArr,
uint256 tokenId,
string nameToken,
address adminAddr,
uint256 fee,
uint256 revenue
);
event earningStatics(
address collectionArr,
uint256 tokenId,
string nameToken,
address[] earner,
uint256[] fee,
uint256[] revenue
);
struct Order {
address tokenAddress;
uint256 tokenId;
address owner;
uint256 price;
address currency;
string sellType;
}
struct UserBid {
address userAddress;
uint256 price;
uint256 bidId;
}
struct SavedData {
address owner;
uint256 tokenId;
}
// orderID => order
mapping(uint256 => Order) public orders;
CountersUpgradeable.Counter private _orderIdCounter;
// addmin
address private _adminAddress;
// creator
// contract address => tokenId => Creator
mapping(address => address) private _creatorOf;
mapping(address => mapping(uint256 => uint256)) public IsSelling;
// percent fee of admin and creator
uint256 private _adminFee;
uint256 private _creatorFee;
UserBid userbid;
uint256[] SellingId;
mapping(address => bool) public TokenAddress;
mapping(address => bool) public CurrencyAddress;
mapping(address => bool) public isCollection;
mapping(address => mapping(uint256 => SavedData)) public sellData;
mapping(address => mapping(uint256 => SavedData)) public buyData;
mapping(address => mapping(uint256 => SavedData)) public cancelData;
uint256 DECIMAL = 10 ** 5;
function setTokenAddress(address _tokenaddress) public onlyOperator {
TokenAddress[_tokenaddress] = true;
}
function setCollectionAddress(address _colletionAddress) public onlyOperator {
isCollection[_colletionAddress] = true;
TokenAddress[_colletionAddress] = true;
}
function setCurrencyAddress(address _currencyaddress) public onlyOperator {
CurrencyAddress[_currencyaddress] = true;
}
function checkTokenAddress(address _tokenaddress) public view returns (bool) {
return TokenAddress[_tokenaddress];
}
function checkCurrencyAddress(address _currencyaddress) public view returns (bool) {
return CurrencyAddress[_currencyaddress];
}
function getAdminAdress() external view returns (address) {
return _adminAddress;
}
function getAdminFee() external view returns (uint256) {
return _adminFee;
}
function sell(
address _tokenAddress,
uint256 _tokenId,
uint256 _price,
address _currency,
string memory _type
) public returns (uint256 orderId) {
require(msg.sender == IERC721Upgradeable(_tokenAddress).ownerOf(_tokenId), "You are not the owner of NFT");
require(
checkTokenAddress(_tokenAddress) == true && checkCurrencyAddress(_currency) == true,
"Your Token or Currency is not allowed"
);
require(
keccak256(abi.encodePacked((_type))) == keccak256(abi.encodePacked(("adil"))) ||
keccak256(abi.encodePacked((_type))) == keccak256(abi.encodePacked(("merah"))),
"Type of sell invalid"
);
// create order
_orderIdCounter.increment();
orderId = _orderIdCounter.current();
Order memory order = Order(_tokenAddress, _tokenId, msg.sender, _price, _currency, _type);
orders[orderId] = order;
sellData[_tokenAddress][orderId] = SavedData({owner: msg.sender, tokenId: _tokenId});
IERC721Upgradeable(_tokenAddress).safeTransferFrom(msg.sender, address(this), _tokenId);
IsSelling[_tokenAddress][_tokenId] = orderId;
SellingId.push(_tokenId);
emit CreateSellOrder(
orderId,
order.owner,
order.tokenId,
order.price,
order.currency,
order.tokenAddress,
_type
);
}
function sellBatch(
address _tokenAddress,
uint256[] memory tokenIds,
uint256 _price,
address _currency,
string memory _type
) public {
for (uint256 i = 0; i < tokenIds.length; i++) {
sell(_tokenAddress, tokenIds[i], _price, _currency, _type);
}
}
function transferTo(address _TokenAddress, address _adddressTo, uint256 _TokenId) public onlyOperator {
IERC721Upgradeable(_TokenAddress).safeTransferFrom(address(this), _adddressTo, _TokenId);
}
function buyUsingMERAH(address _TokenAddress, address _adddressTo, uint256 _TokenId) public onlyOperator {
IERC721Upgradeable(_TokenAddress).safeTransferFrom(address(this), _adddressTo, _TokenId);
uint256 _orderId;
_orderId = IsSelling[_TokenAddress][_TokenId];
buyData[_TokenAddress][_orderId] = SavedData({owner: _adddressTo, tokenId: _TokenId});
delete IsSelling[_TokenAddress][_TokenId];
delete orders[_orderId];
}
function checktoken(address _tokenAddress, uint256 _tokenId) external view returns (uint256) {
return IsSelling[_tokenAddress][_tokenId];
}
function buyNative(uint256 _orderId) external payable {
// check order status
require(orders[_orderId].owner != address(0), "Order does not exist or is deleted");
require(msg.value == orders[_orderId].price, "Buyer did not send correct ADIL amount");
require(
orders[_orderId].currency == address(0),
"Order requires being paid by erc20 currency, use buy() instead"
);
require(_adminAddress != address(0), "AdminFee is Unused or Mising AdminAddress");
require(
checkTokenAddress(orders[_orderId].tokenAddress) == true &&
checkCurrencyAddress(orders[_orderId].currency) == true,
"Your Token or Currency is not allowed"
);
uint256 adminFee;
uint256 totalFeeEarning;
if (_adminFee != 0) {
adminFee = orders[_orderId].price.mul(_adminFee).div(100).div(DECIMAL);
TransferHelper.safeTransferETH(_adminAddress, adminFee);
emit adminStatics(
orders[_orderId].tokenAddress,
orders[_orderId].tokenId,
"ADIL",
_adminAddress,
_adminFee,
adminFee
);
}
if (isCollection[orders[_orderId].tokenAddress]) {
totalFeeEarning = payForEarning(
orders[_orderId].price,
orders[_orderId].tokenAddress,
orders[_orderId].currency,
orders[_orderId].tokenId
);
TransferHelper.safeTransferETH(orders[_orderId].owner, orders[_orderId].price - adminFee - totalFeeEarning);
}
buyData[orders[_orderId].tokenAddress][_orderId] = SavedData({
owner: msg.sender,
tokenId: orders[_orderId].tokenId
});
IERC721Upgradeable(orders[_orderId].tokenAddress).safeTransferFrom(
address(this),
msg.sender,
orders[_orderId].tokenId
);
emit Buy(
_orderId,
msg.sender,
orders[_orderId].owner,
orders[_orderId].tokenId,
orders[_orderId].price,
orders[_orderId].currency,
orders[_orderId].tokenAddress
);
delete IsSelling[orders[_orderId].tokenAddress][orders[_orderId].tokenId];
delete orders[_orderId];
}
function cancelSell(uint256 _orderId, address _tokenAddress) public {
require(orders[_orderId].owner != address(0), "Order does not exist");
require(orders[_orderId].owner == msg.sender, "Msg sender is not order 's owner");
require(
checkTokenAddress(orders[_orderId].tokenAddress) == true &&
checkCurrencyAddress(orders[_orderId].currency) == true,
"Your Token or Currency is not allowed"
);
cancelData[orders[_orderId].tokenAddress][_orderId] = SavedData({
owner: msg.sender,
tokenId: orders[_orderId].tokenId
});
IERC721Upgradeable(_tokenAddress).safeTransferFrom(address(this), msg.sender, orders[_orderId].tokenId);
emit CancelSellOrder(
_orderId,
orders[_orderId].owner,
orders[_orderId].tokenId,
orders[_orderId].price,
orders[_orderId].currency,
orders[_orderId].tokenAddress
);
delete IsSelling[orders[_orderId].tokenAddress][orders[_orderId].tokenId];
delete orders[_orderId];
}
function cancelSellBatch(address _tokenAddress, uint256[] memory _orderIds) public {
for (uint256 i = 0; i < _orderIds.length; i++) {
cancelSell(_orderIds[i], _tokenAddress);
}
}
// set address of admin
function setAdminAddress(address _admin) external onlyOperator {
_adminAddress = _admin;
}
// set admin fee
function setAdminFee(uint256 _fee) external onlyOperator {
_adminFee = _fee;
}
function updateOrder(uint256 _orderId, uint256 _newPrice) external {
require(orders[_orderId].owner != address(0), "Order does not exist");
require(orders[_orderId].owner == msg.sender, "Msg sender is not order 's owner");
require(
checkTokenAddress(orders[_orderId].tokenAddress) == true &&
checkCurrencyAddress(orders[_orderId].currency) == true,
"Your Token or Currency is not allowed"
);
uint256 oldPrice = orders[_orderId].price;
orders[_orderId].price = _newPrice;
emit UpdateSellOrder(
_orderId,
orders[_orderId].owner,
orders[_orderId].tokenId,
oldPrice,
orders[_orderId].price,
orders[_orderId].currency,
orders[_orderId].tokenAddress
);
}
function payForEarning(
uint256 _price,
address _tokenAddress,
address _currency,
uint256 _tokenId
) private returns (uint256) {
uint256 earnersLen;
uint256 ratesEarningLen;
(earnersLen, ratesEarningLen) = ICollection(_tokenAddress).getLenEarnersAndRates();
address[] memory earners = new address[](earnersLen);
uint256[] memory ratesEarning = new uint256[](ratesEarningLen);
(earners, ratesEarning) = ICollection(_tokenAddress).getEarnersAndRates();
uint256 totalFeeEarning = 0;
uint256[] memory revenue = new uint256[](ratesEarningLen);
if (_currency == 0x0000000000000000000000000000000000000000) {
for (uint256 i = 0; i < earners.length; i++) {
revenue[i] = _price.mul(ratesEarning[i]).div(1000000);
totalFeeEarning += revenue[i];
TransferHelper.safeTransferETH(earners[i], revenue[i]);
}
emit earningStatics(_tokenAddress, _tokenId, "ADIL", earners, ratesEarning, revenue);
} else {
for (uint256 i = 0; i < earners.length; i++) {
revenue[i] = _price.mul(ratesEarning[i]).div(1000000);
totalFeeEarning += revenue[i];
TransferHelper.safeTransferFrom(_currency, msg.sender, earners[i], revenue[i]);
}
emit earningStatics(
_tokenAddress,
_tokenId,
ERC20Upgradeable(_currency).name(),
earners,
ratesEarning,
revenue
);
}
return totalFeeEarning;
}
}
@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 {Initializable} from "../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/ERC20/ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.0;
import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import {Initializable} from "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address to, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/
function _transfer(address from, address to, uint256 amount) internal virtual {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
/**
* @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[45] private __gap;
}
@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.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 IERC20Upgradeable {
/**
* @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-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20Upgradeable.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721ReceiverUpgradeable {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165Upgradeable.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/utils/ERC721Holder.sol)
pragma solidity ^0.8.0;
import "../IERC721ReceiverUpgradeable.sol";
import {Initializable} from "../../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC721Receiver} interface.
*
* Accepts all token transfers.
* Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
*/
contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
function __ERC721Holder_init() internal onlyInitializing {
}
function __ERC721Holder_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC721Receiver-onERC721Received}.
*
* Always returns `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {
return this.onERC721Received.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/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 (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
import {Initializable} from "../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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
/**
* @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/CountersUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library CountersUpgradeable {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
@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-upgradeable/utils/math/SafeMathUpgradeable.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 SafeMathUpgradeable {
/**
* @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;
}
}
}
contracts/OwnerOperator.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
abstract contract OwnerOperator is OwnableUpgradeable {
mapping(address => bool) public operators;
function initialize() public initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
modifier operatorOrOwner() {
require(operators[msg.sender] || owner() == msg.sender, "OwnerOperator: !operator, !owner");
_;
}
modifier onlyOperator() {
require(operators[msg.sender], "OwnerOperator: !operator");
_;
}
function addOperator(address operator) external virtual onlyOwner {
require(operator != address(0), "OwnerOperator: operator is the zero address");
operators[operator] = true;
}
function removeOperator(address operator) external virtual onlyOwner {
require(operator != address(0), "OwnerOperator: operator is the zero address");
operators[operator] = false;
}
}
contracts/interfaces/ICollection.sol
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
interface ICollection {
function getEarnersAndRates() external view returns (address[] memory, uint256[] memory);
function getLenEarnersAndRates() external view returns (uint256, uint256);
}
contracts/libraries/TransferHelper.sol
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(address token, address to, uint256 value) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
"TransferHelper::safeApprove: approve failed"
);
}
function safeTransfer(address token, address to, uint256 value) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
"TransferHelper::safeTransfer: transfer failed"
);
}
function safeTransferFrom(address token, address from, address to, uint256 value) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
"TransferHelper::transferFrom: transferFrom failed"
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, "TransferHelper::safeTransferETH: ETH transfer failed");
}
}
Contract ABI
[{"type":"event","name":"AcceptOffer","inputs":[{"type":"address","name":"_seller","internalType":"address","indexed":true},{"type":"address","name":"_buyer","internalType":"address","indexed":true},{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false},{"type":"uint256","name":"_price","internalType":"uint256","indexed":false},{"type":"address","name":"_tokenAddress","internalType":"address","indexed":false},{"type":"address","name":"_currency","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Bid","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"winner","internalType":"address","indexed":true},{"type":"address","name":"_tokenAddress","internalType":"address","indexed":false},{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_price","internalType":"uint256","indexed":false},{"type":"address","name":"_currency","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"Buy","inputs":[{"type":"uint256","name":"_orderId","internalType":"uint256","indexed":true},{"type":"address","name":"_buyer","internalType":"address","indexed":true},{"type":"address","name":"seller","internalType":"address","indexed":true},{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_price","internalType":"uint256","indexed":false},{"type":"address","name":"_currency","internalType":"address","indexed":false},{"type":"address","name":"_tokenAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"CancelSellOrder","inputs":[{"type":"uint256","name":"_orderId","internalType":"uint256","indexed":true},{"type":"address","name":"_seller","internalType":"address","indexed":true},{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_price","internalType":"uint256","indexed":false},{"type":"address","name":"_currency","internalType":"address","indexed":false},{"type":"address","name":"_tokenAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"CreateSellOrder","inputs":[{"type":"uint256","name":"_orderId","internalType":"uint256","indexed":true},{"type":"address","name":"_seller","internalType":"address","indexed":true},{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_price","internalType":"uint256","indexed":false},{"type":"address","name":"_currency","internalType":"address","indexed":false},{"type":"address","name":"_tokenAddress","internalType":"address","indexed":false},{"type":"string","name":"_type","internalType":"string","indexed":false}],"anonymous":false},{"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":"UpdateSellOrder","inputs":[{"type":"uint256","name":"_orderId","internalType":"uint256","indexed":true},{"type":"address","name":"_seller","internalType":"address","indexed":true},{"type":"uint256","name":"_tokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"_oldPrice","internalType":"uint256","indexed":false},{"type":"uint256","name":"_newPrice","internalType":"uint256","indexed":false},{"type":"address","name":"_currency","internalType":"address","indexed":false},{"type":"address","name":"_tokenAddress","internalType":"address","indexed":false}],"anonymous":false},{"type":"event","name":"adminStatics","inputs":[{"type":"address","name":"collectionArr","internalType":"address","indexed":false},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"string","name":"nameToken","internalType":"string","indexed":false},{"type":"address","name":"adminAddr","internalType":"address","indexed":false},{"type":"uint256","name":"fee","internalType":"uint256","indexed":false},{"type":"uint256","name":"revenue","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"earningStatics","inputs":[{"type":"address","name":"collectionArr","internalType":"address","indexed":false},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":false},{"type":"string","name":"nameToken","internalType":"string","indexed":false},{"type":"address[]","name":"earner","internalType":"address[]","indexed":false},{"type":"uint256[]","name":"fee","internalType":"uint256[]","indexed":false},{"type":"uint256[]","name":"revenue","internalType":"uint256[]","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"CurrencyAddress","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"IsSelling","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"TokenAddress","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"addOperator","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}],"name":"buyData","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"buyNative","inputs":[{"type":"uint256","name":"_orderId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"buyUsingMERAH","inputs":[{"type":"address","name":"_TokenAddress","internalType":"address"},{"type":"address","name":"_adddressTo","internalType":"address"},{"type":"uint256","name":"_TokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}],"name":"cancelData","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelSell","inputs":[{"type":"uint256","name":"_orderId","internalType":"uint256"},{"type":"address","name":"_tokenAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelSellBatch","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256[]","name":"_orderIds","internalType":"uint256[]"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"checkCurrencyAddress","inputs":[{"type":"address","name":"_currencyaddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"checkTokenAddress","inputs":[{"type":"address","name":"_tokenaddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"checktoken","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getAdminAdress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getAdminFee","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isCollection","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"onERC721Received","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"operators","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"tokenAddress","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"},{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"price","internalType":"uint256"},{"type":"address","name":"currency","internalType":"address"},{"type":"string","name":"sellType","internalType":"string"}],"name":"orders","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"removeOperator","inputs":[{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"orderId","internalType":"uint256"}],"name":"sell","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"address","name":"_currency","internalType":"address"},{"type":"string","name":"_type","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"sellBatch","inputs":[{"type":"address","name":"_tokenAddress","internalType":"address"},{"type":"uint256[]","name":"tokenIds","internalType":"uint256[]"},{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"address","name":"_currency","internalType":"address"},{"type":"string","name":"_type","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}],"name":"sellData","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAdminAddress","inputs":[{"type":"address","name":"_admin","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setAdminFee","inputs":[{"type":"uint256","name":"_fee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCollectionAddress","inputs":[{"type":"address","name":"_colletionAddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCurrencyAddress","inputs":[{"type":"address","name":"_currencyaddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setTokenAddress","inputs":[{"type":"address","name":"_tokenaddress","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferTo","inputs":[{"type":"address","name":"_TokenAddress","internalType":"address"},{"type":"address","name":"_adddressTo","internalType":"address"},{"type":"uint256","name":"_TokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateOrder","inputs":[{"type":"uint256","name":"_orderId","internalType":"uint256"},{"type":"uint256","name":"_newPrice","internalType":"uint256"}]}]
Deployed ByteCode
0x6080604052600436106102195760003560e01c80638da5cb5b1161011d578063a6904aa5116100b0578063b502daeb1161007f578063ba45b71911610064578063ba45b71914610844578063d148d23b14610857578063f2fde38b1461087757610219565b8063b502daeb146107cc578063b6fa23f2146107ec57610219565b8063a6904aa51461073a578063a85c38ef1461075a578063ac8a584a1461078c578063adbfdd70146107ac57610219565b80639e54bf71116100ec5780639e54bf71146106445780639f1a156c1461067c578063a2916227146106c2578063a5f2a1521461071a57610219565b80638da5cb5b146105a95780639687492a146105d45780639870d7fe146106045780639c78aee81461062457610219565b80634931bb92116101b0578063715018a61161017f578063796b89ec11610164578063796b89ec146105545780638129fc1c146105745780638beb60b61461058957610219565b8063715018a6146104ef578063722b60291461050457610219565b80634931bb92146104395780634a66b3df14610459578063587b71a61461049f5780635fa15ebb146104bf57610219565b806326a4e8d2116101ec57806326a4e8d21461038c5780632a905ccc146103ae5780632c1e816d146103cd5780633ef7fec7146103ed57610219565b80630755b1c71461021e57806313e7c9d8146102a7578063150b7a02146102e75780631a124d711461035c575b600080fd5b34801561022a57600080fd5b50610276610239366004613987565b60a76020908152600092835260408084209091529082529020805460019091015473ffffffffffffffffffffffffffffffffffffffff9091169082565b6040805173ffffffffffffffffffffffffffffffffffffffff90931683526020830191909152015b60405180910390f35b3480156102b357600080fd5b506102d76102c23660046137b2565b60976020526000908152604090205460ff1681565b604051901515815260200161029e565b3480156102f357600080fd5b5061032b61030236600461382a565b7f150b7a0200000000000000000000000000000000000000000000000000000000949350505050565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200161029e565b34801561036857600080fd5b506102d76103773660046137b2565b60a46020526000908152604090205460ff1681565b34801561039857600080fd5b506103ac6103a73660046137b2565b610897565b005b3480156103ba57600080fd5b50609d545b60405190815260200161029e565b3480156103d957600080fd5b506103ac6103e83660046137b2565b610964565b3480156103f957600080fd5b50609a5473ffffffffffffffffffffffffffffffffffffffff165b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200161029e565b34801561044557600080fd5b506103ac6104543660046137ea565b610a24565b34801561046557600080fd5b506102d76104743660046137b2565b73ffffffffffffffffffffffffffffffffffffffff16600090815260a4602052604090205460ff1690565b3480156104ab57600080fd5b506103ac6104ba366004613bac565b610c00565b3480156104cb57600080fd5b506102d76104da3660046137b2565b60a56020526000908152604090205460ff1681565b3480156104fb57600080fd5b506103ac610ec4565b34801561051057600080fd5b506103bf61051f366004613987565b73ffffffffffffffffffffffffffffffffffffffff919091166000908152609c60209081526040808320938352929052205490565b34801561056057600080fd5b506103ac61056f3660046137b2565b610ed8565b34801561058057600080fd5b506103ac610fa0565b34801561059557600080fd5b506103ac6105a4366004613b65565b61113a565b3480156105b557600080fd5b5060655473ffffffffffffffffffffffffffffffffffffffff16610414565b3480156105e057600080fd5b506102d76105ef3660046137b2565b60a36020526000908152604090205460ff1681565b34801561061057600080fd5b506103ac61061f3660046137b2565b6111b8565b34801561063057600080fd5b506103ac61063f3660046138f5565b6112b2565b34801561065057600080fd5b506103bf61065f366004613987565b609c60209081526000928352604080842090915290825290205481565b34801561068857600080fd5b506102d76106973660046137b2565b73ffffffffffffffffffffffffffffffffffffffff16600090815260a3602052604090205460ff1690565b3480156106ce57600080fd5b506102766106dd366004613987565b60a86020908152600092835260408084209091529082529020805460019091015473ffffffffffffffffffffffffffffffffffffffff9091169082565b34801561072657600080fd5b506103ac6107353660046137ea565b61131e565b34801561074657600080fd5b506103ac6107553660046137b2565b61142a565b34801561076657600080fd5b5061077a610775366004613b65565b61150a565b60405161029e96959493929190613cd5565b34801561079857600080fd5b506103ac6107a73660046137b2565b6115e6565b3480156107b857600080fd5b506103ac6107c7366004613b7d565b6116dd565b3480156107d857600080fd5b506103bf6107e73660046139b2565b611b37565b3480156107f857600080fd5b50610276610807366004613987565b60a66020908152600092835260408084209091529082529020805460019091015473ffffffffffffffffffffffffffffffffffffffff9091169082565b6103ac610852366004613b65565b612137565b34801561086357600080fd5b506103ac6108723660046138a7565b6128d3565b34801561088357600080fd5b506103ac6108923660046137b2565b612940565b3360009081526097602052604090205460ff16610915576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4f776e65724f70657261746f723a20216f70657261746f72000000000000000060448201526064015b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff16600090815260a36020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b3360009081526097602052604090205460ff166109dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4f776e65724f70657261746f723a20216f70657261746f720000000000000000604482015260640161090c565b609a80547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b3360009081526097602052604090205460ff16610a9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4f776e65724f70657261746f723a20216f70657261746f720000000000000000604482015260640161090c565b6040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152604482018390528416906342842e0e90606401600060405180830381600087803b158015610b1357600080fd5b505af1158015610b27573d6000803e3d6000fd5b5050505073ffffffffffffffffffffffffffffffffffffffff8381166000818152609c602090815260408083208684528252808320805482518084018452898816815280850189815296865260a7855283862082875285528386209051815498167fffffffffffffffffffffffff0000000000000000000000000000000000000000988916178155955160019687015590849055609890925282208054851681559283018290556002830180548516905560038301829055600483018054909416909355610bf860058301826135bf565b505050505050565b60008281526098602052604090206002015473ffffffffffffffffffffffffffffffffffffffff16610c8e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7264657220646f6573206e6f74206578697374000000000000000000000000604482015260640161090c565b60008281526098602052604090206002015473ffffffffffffffffffffffffffffffffffffffff163314610d1e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4d73672073656e646572206973206e6f74206f72646572202773206f776e6572604482015260640161090c565b60008281526098602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260a390915290205460ff1615156001148015610d9d575060008281526098602090815260408083206004015473ffffffffffffffffffffffffffffffffffffffff16835260a490915290205460ff1615156001145b610e29576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f596f757220546f6b656e206f722043757272656e6379206973206e6f7420616c60448201527f6c6f776564000000000000000000000000000000000000000000000000000000606482015260840161090c565b600082815260986020908152604091829020600381018054908590556002820154600183015460048401549354865191825294810183905294850186905273ffffffffffffffffffffffffffffffffffffffff928316606086015292821660808501529291169084907f6d1b2d95d9b5089c8adae070090fd2dde13c784e7ba3b57ef219dce142cc52709060a00160405180910390a3505050565b610ecc6129f4565b610ed66000612a75565b565b3360009081526097602052604090205460ff16610f51576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4f776e65724f70657261746f723a20216f70657261746f720000000000000000604482015260640161090c565b73ffffffffffffffffffffffffffffffffffffffff16600090815260a46020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b600054610100900460ff1615808015610fc05750600054600160ff909116105b80610fda5750303b158015610fda575060005460ff166001145b611066576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161090c565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156110c457600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6110cc612aec565b6110d4612b83565b801561113757600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b3360009081526097602052604090205460ff166111b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4f776e65724f70657261746f723a20216f70657261746f720000000000000000604482015260640161090c565b609d55565b6111c06129f4565b73ffffffffffffffffffffffffffffffffffffffff8116611263576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f4f776e65724f70657261746f723a206f70657261746f7220697320746865207a60448201527f65726f2061646472657373000000000000000000000000000000000000000000606482015260840161090c565b73ffffffffffffffffffffffffffffffffffffffff16600090815260976020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055565b60005b8451811015610bf85761130b868683815181106112fb577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151868686611b37565b5080611316816140ed565b9150506112b5565b3360009081526097602052604090205460ff16611397576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4f776e65724f70657261746f723a20216f70657261746f720000000000000000604482015260640161090c565b6040517f42842e0e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff8381166024830152604482018390528416906342842e0e90606401600060405180830381600087803b15801561140d57600080fd5b505af1158015611421573d6000803e3d6000fd5b50505050505050565b3360009081526097602052604090205460ff166114a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4f776e65724f70657261746f723a20216f70657261746f720000000000000000604482015260640161090c565b73ffffffffffffffffffffffffffffffffffffffff16600090815260a560209081526040808320805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00918216811790925560a3909352922080549091169091179055565b60986020526000908152604090208054600182015460028301546003840154600485015460058601805473ffffffffffffffffffffffffffffffffffffffff968716979596948516959394909216929161156390614099565b80601f016020809104026020016040519081016040528092919081815260200182805461158f90614099565b80156115dc5780601f106115b1576101008083540402835291602001916115dc565b820191906000526020600020905b8154815290600101906020018083116115bf57829003601f168201915b5050505050905086565b6115ee6129f4565b73ffffffffffffffffffffffffffffffffffffffff8116611691576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f4f776e65724f70657261746f723a206f70657261746f7220697320746865207a60448201527f65726f2061646472657373000000000000000000000000000000000000000000606482015260840161090c565b73ffffffffffffffffffffffffffffffffffffffff16600090815260976020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00169055565b60008281526098602052604090206002015473ffffffffffffffffffffffffffffffffffffffff1661176b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f4f7264657220646f6573206e6f74206578697374000000000000000000000000604482015260640161090c565b60008281526098602052604090206002015473ffffffffffffffffffffffffffffffffffffffff1633146117fb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4d73672073656e646572206973206e6f74206f72646572202773206f776e6572604482015260640161090c565b60008281526098602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260a390915290205460ff161515600114801561187a575060008281526098602090815260408083206004015473ffffffffffffffffffffffffffffffffffffffff16835260a490915290205460ff1615156001145b611906576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f596f757220546f6b656e206f722043757272656e6379206973206e6f7420616c60448201527f6c6f776564000000000000000000000000000000000000000000000000000000606482015260840161090c565b6040805180820182523380825260008581526098602081815285832060018082018054848901908152925473ffffffffffffffffffffffffffffffffffffffff908116875260a885528987208c8852855295899020975188547fffffffffffffffffffffffff000000000000000000000000000000000000000016908716178855915196019590955552915492517f42842e0e000000000000000000000000000000000000000000000000000000008152306004820152602481019190915260448101929092528216906342842e0e90606401600060405180830381600087803b1580156119f357600080fd5b505af1158015611a07573d6000803e3d6000fd5b5050506000838152609860209081526040918290206002810154600182015460038301546004840154935486519283529482015273ffffffffffffffffffffffffffffffffffffffff92831681860152928216606084015292519216925084917fa2b96082ec456d01f350420a13d8bb79e3c1b9db557aa581c27ba50c58b8b5069181900360800190a36000828152609860208181526040808420805473ffffffffffffffffffffffffffffffffffffffff168552609c835281852060018201805487529084529185208590558685529290915281547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168355908390556002820180548216905560038201839055600482018054909116905590611b3160058301826135bf565b50505050565b6040517f6352211e0000000000000000000000000000000000000000000000000000000081526004810185905260009073ffffffffffffffffffffffffffffffffffffffff871690636352211e9060240160206040518083038186803b158015611ba057600080fd5b505afa158015611bb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611bd891906137ce565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611c6c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f596f7520617265206e6f7420746865206f776e6572206f66204e465400000000604482015260640161090c565b73ffffffffffffffffffffffffffffffffffffffff8616600090815260a3602052604090205460ff1615156001148015611cd0575073ffffffffffffffffffffffffffffffffffffffff8316600090815260a4602052604090205460ff1615156001145b611d5c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f596f757220546f6b656e206f722043757272656e6379206973206e6f7420616c60448201527f6c6f776564000000000000000000000000000000000000000000000000000000606482015260840161090c565b6040517f6164696c0000000000000000000000000000000000000000000000000000000060208201526024016040516020818303038152906040528051906020012082604051602001611daf9190613cb9565b604051602081830303815290604052805190602001201480611e3757506040517f6d6572616800000000000000000000000000000000000000000000000000000060208201526025016040516020818303038152906040528051906020012082604051602001611e1f9190613cb9565b60405160208183030381529060405280519060200120145b611e9d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f54797065206f662073656c6c20696e76616c6964000000000000000000000000604482015260640161090c565b611eab609980546001019055565b506099546040805160c08101825273ffffffffffffffffffffffffffffffffffffffff8881168252602080830189815233848601908152606085018a81528985166080870190815260a087018a815260008a81526098875298909820875181547fffffffffffffffffffffffff00000000000000000000000000000000000000009081169189169190911782559451600182015592516002840180548616918816919091179055905160038301555160048201805490931694169390931790559251805192938493611f8392600585019201906135fb565b50506040805180820182523380825260208083018b815273ffffffffffffffffffffffffffffffffffffffff8d8116600081815260a685528781208b825290945292869020945185547fffffffffffffffffffffffff00000000000000000000000000000000000000001691161784555160019093019290925591517f42842e0e00000000000000000000000000000000000000000000000000000000815260048101929092523060248301526044820189905291506342842e0e90606401600060405180830381600087803b15801561205c57600080fd5b505af1158015612070573d6000803e3d6000fd5b50505073ffffffffffffffffffffffffffffffffffffffff8089166000908152609c602090815260408083208b8452825280832087905560a2805460018101825593527faaf4f58de99300cfadc4585755f376d5fa747d5bc561d5bd9d710de1f91bf42d9092018a90558482015190850151606086015160808701518751945193909516955087947f734cb3360db0c44980db1672068196c1880e4802a340aa4aaf3469bc0d6eeb8594612125948b90613ebf565b60405180910390a35095945050505050565b60008181526098602052604090206002015473ffffffffffffffffffffffffffffffffffffffff166121eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f4f7264657220646f6573206e6f74206578697374206f722069732064656c657460448201527f6564000000000000000000000000000000000000000000000000000000000000606482015260840161090c565b600081815260986020526040902060030154341461228b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f427579657220646964206e6f742073656e6420636f7272656374204144494c2060448201527f616d6f756e740000000000000000000000000000000000000000000000000000606482015260840161090c565b60008181526098602052604090206004015473ffffffffffffffffffffffffffffffffffffffff1615612340576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603e60248201527f4f72646572207265717569726573206265696e6720706169642062792065726360448201527f32302063757272656e63792c2075736520627579282920696e73746561640000606482015260840161090c565b609a5473ffffffffffffffffffffffffffffffffffffffff166123e5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f41646d696e46656520697320556e75736564206f72204d6973696e672041646d60448201527f696e416464726573730000000000000000000000000000000000000000000000606482015260840161090c565b60008181526098602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260a390915290205460ff1615156001148015612464575060008181526098602090815260408083206004015473ffffffffffffffffffffffffffffffffffffffff16835260a490915290205460ff1615156001145b6124f0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f596f757220546f6b656e206f722043757272656e6379206973206e6f7420616c60448201527f6c6f776564000000000000000000000000000000000000000000000000000000606482015260840161090c565b600080609d546000146125c75760a954609d5460008581526098602052604090206003015461252f929161252991606491839190612c23565b90612c36565b609a549092506125559073ffffffffffffffffffffffffffffffffffffffff1683612c42565b600083815260986020526040908190208054600190910154609a54609d5493517f372cd38608aab20876dff382c36d9d55e0cbf3ee5cd829dbadd7e467d0573a7b946125be9473ffffffffffffffffffffffffffffffffffffffff908116949316918890613daa565b60405180910390a15b60008381526098602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260a590915290205460ff161561269a5760008381526098602052604090206003810154815460048301546001909301546126459373ffffffffffffffffffffffffffffffffffffffff928316921690612d4c565b6000848152609860205260409020600281015460039091015491925061269a9173ffffffffffffffffffffffffffffffffffffffff90911690839061268b908690614056565b6126959190614056565b612c42565b6040805180820182523380825260008681526098602081815285832060018082018054848901908152835473ffffffffffffffffffffffffffffffffffffffff908116885260a786528a88208e89528652968a9020985189547fffffffffffffffffffffffff00000000000000000000000000000000000000001690881617895551979091019690965591905254925493517f42842e0e000000000000000000000000000000000000000000000000000000008152306004820152602481019290925260448201939093529116906342842e0e90606401600060405180830381600087803b15801561278b57600080fd5b505af115801561279f573d6000803e3d6000fd5b5050506000848152609860209081526040918290206002810154600182015460038301546004840154935486519283529482015273ffffffffffffffffffffffffffffffffffffffff928316818601529282166060840152925192169250339186917f31d0856aaeeb5c244e76b84841b6126287ffff3729c4ba6d2eac3bfee5bd826b919081900360800190a46000838152609860208181526040808420805473ffffffffffffffffffffffffffffffffffffffff168552609c835281852060018201805487529084529185208590558785529290915281547fffffffffffffffffffffffff000000000000000000000000000000000000000090811683559083905560028201805482169055600382018390556004820180549091169055906128cc60058301826135bf565b5050505050565b60005b815181101561293b5761292982828151811061291b577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151846116dd565b80612933816140ed565b9150506128d6565b505050565b6129486129f4565b73ffffffffffffffffffffffffffffffffffffffff81166129eb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161090c565b61113781612a75565b60655473ffffffffffffffffffffffffffffffffffffffff163314610ed6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161090c565b6065805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16610ed6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161090c565b600054610100900460ff16612c1a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e67000000000000000000000000000000000000000000606482015260840161090c565b610ed633612a75565b6000612c2f8284614019565b9392505050565b6000612c2f8284613fe0565b6040805160008082526020820190925273ffffffffffffffffffffffffffffffffffffffff8416908390604051612c799190613cb9565b60006040518083038185875af1925050503d8060008114612cb6576040519150601f19603f3d011682016040523d82523d6000602084013e612cbb565b606091505b505090508061293b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603460248201527f5472616e7366657248656c7065723a3a736166655472616e736665724554483a60448201527f20455448207472616e73666572206661696c6564000000000000000000000000606482015260840161090c565b60008060008573ffffffffffffffffffffffffffffffffffffffff16636e0856cc6040518163ffffffff1660e01b8152600401604080518083038186803b158015612d9657600080fd5b505afa158015612daa573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612dce9190613bcd565b909250905060008267ffffffffffffffff811115612e15577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015612e3e578160200160208202803683370190505b50905060008267ffffffffffffffff811115612e83577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015612eac578160200160208202803683370190505b5090508773ffffffffffffffffffffffffffffffffffffffff1663ec2972f86040518163ffffffff1660e01b815260040160006040518083038186803b158015612ef557600080fd5b505afa158015612f09573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201604052612f4f9190810190613a19565b90925090506000808467ffffffffffffffff811115612f97577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051908082528060200260200182016040528015612fc0578160200160208202803683370190505b50905073ffffffffffffffffffffffffffffffffffffffff89166131b85760005b845181101561317357613044620f424061252986848151811061302d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200260200101518f612c2390919063ffffffff16565b82828151811061307d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010181815250508181815181106130c2577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151836130d59190613fc8565b9250613161858281518110613113577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151838381518110613154577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151612c42565b8061316b816140ed565b915050612fe1565b507f500a3bc9002597727593979b03e34049b145223063cf479a195c6bd1b56b5b348a898686856040516131ab959493929190613e26565b60405180910390a161341a565b60005b845181101561333857613207620f424061252986848151811061302d577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b828281518110613240577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b602002602001018181525050818181518110613285577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151836132989190613fc8565b92506133268a338784815181106132d8577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151858581518110613319577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6020026020010151613428565b80613330816140ed565b9150506131bb565b507f500a3bc9002597727593979b03e34049b145223063cf479a195c6bd1b56b5b348a898b73ffffffffffffffffffffffffffffffffffffffff166306fdde036040518163ffffffff1660e01b815260040160006040518083038186803b1580156133a257600080fd5b505afa1580156133b6573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526133fc9190810190613af2565b87878660405161341196959493929190613d2e565b60405180910390a15b509998505050505050505050565b6040805173ffffffffffffffffffffffffffffffffffffffff85811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905291516000928392908816916134c79190613cb9565b6000604051808303816000865af19150503d8060008114613504576040519150601f19603f3d011682016040523d82523d6000602084013e613509565b606091505b50915091508180156135335750805115806135335750808060200190518101906135339190613ad2565b610bf8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a20747260448201527f616e7366657246726f6d206661696c6564000000000000000000000000000000606482015260840161090c565b5080546135cb90614099565b6000825580601f106135dd5750611137565b601f016020900490600052602060002090810190611137919061367f565b82805461360790614099565b90600052602060002090601f016020900481019282613629576000855561366f565b82601f1061364257805160ff191683800117855561366f565b8280016001018555821561366f579182015b8281111561366f578251825591602001919060010190613654565b5061367b92915061367f565b5090565b5b8082111561367b5760008155600101613680565b60006136a76136a284613f82565b613f0f565b90508281528383830111156136bb57600080fd5b828260208301376000602084830101529392505050565b600082601f8301126136e2578081fd5b813560206136f26136a283613f5e565b828152818101908583018385028701840188101561370e578586fd5b855b8581101561372c57813584529284019290840190600101613710565b5090979650505050505050565b600082601f830112613749578081fd5b815160206137596136a283613f5e565b8281528181019085830183850287018401881015613775578586fd5b855b8581101561372c57815184529284019290840190600101613777565b600082601f8301126137a3578081fd5b612c2f83833560208501613694565b6000602082840312156137c3578081fd5b8135612c2f81614184565b6000602082840312156137df578081fd5b8151612c2f81614184565b6000806000606084860312156137fe578182fd5b833561380981614184565b9250602084013561381981614184565b929592945050506040919091013590565b6000806000806080858703121561383f578081fd5b843561384a81614184565b9350602085013561385a81614184565b925060408501359150606085013567ffffffffffffffff81111561387c578182fd5b8501601f8101871361388c578182fd5b61389b87823560208401613694565b91505092959194509250565b600080604083850312156138b9578182fd5b82356138c481614184565b9150602083013567ffffffffffffffff8111156138df578182fd5b6138eb858286016136d2565b9150509250929050565b600080600080600060a0868803121561390c578283fd5b853561391781614184565b9450602086013567ffffffffffffffff80821115613933578485fd5b61393f89838a016136d2565b9550604088013594506060880135915061395882614184565b9092506080870135908082111561396d578283fd5b5061397a88828901613793565b9150509295509295909350565b60008060408385031215613999578182fd5b82356139a481614184565b946020939093013593505050565b600080600080600060a086880312156139c9578283fd5b85356139d481614184565b9450602086013593506040860135925060608601356139f281614184565b9150608086013567ffffffffffffffff811115613a0d578182fd5b61397a88828901613793565b60008060408385031215613a2b578182fd5b825167ffffffffffffffff80821115613a42578384fd5b818501915085601f830112613a55578384fd5b81516020613a656136a283613f5e565b82815281810190858301838502870184018b1015613a81578889fd5b8896505b84871015613aac578051613a9881614184565b835260019690960195918301918301613a85565b5091880151919650909350505080821115613ac5578283fd5b506138eb85828601613739565b600060208284031215613ae3578081fd5b81518015158114612c2f578182fd5b600060208284031215613b03578081fd5b815167ffffffffffffffff811115613b19578182fd5b8201601f81018413613b29578182fd5b8051613b376136a282613f82565b818152856020838501011115613b4b578384fd5b613b5c82602083016020860161406d565b95945050505050565b600060208284031215613b76578081fd5b5035919050565b60008060408385031215613b8f578182fd5b823591506020830135613ba181614184565b809150509250929050565b60008060408385031215613bbe578182fd5b50508035926020909101359150565b60008060408385031215613bdf578182fd5b505080516020909101519092909150565b6000815180845260208085019450808401835b83811015613c3557815173ffffffffffffffffffffffffffffffffffffffff1687529582019590820190600101613c03565b509495945050505050565b6000815180845260208085019450808401835b83811015613c3557815187529582019590820190600101613c53565b60008151808452613c8781602086016020860161406d565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60008251613ccb81846020870161406d565b9190910192915050565b600073ffffffffffffffffffffffffffffffffffffffff8089168352876020840152808716604084015285606084015280851660808401525060c060a0830152613d2260c0830184613c6f565b98975050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff8816825286602083015260c06040830152613d6360c0830187613c6f565b8281036060840152613d758187613bf0565b90508281036080840152613d898186613c40565b905082810360a0840152613d9d8185613c40565b9998505050505050505050565b600073ffffffffffffffffffffffffffffffffffffffff808816835286602084015260c06040840152613e0a60c08401600481527f4144494c00000000000000000000000000000000000000000000000000000000602082015260400190565b9516606083015250608081019290925260a09091015292915050565b600073ffffffffffffffffffffffffffffffffffffffff8716825285602083015260c06040830152613e8560c08301600481527f4144494c00000000000000000000000000000000000000000000000000000000602082015260400190565b8281036060840152613e978187613bf0565b90508281036080840152613eab8186613c40565b905082810360a0840152613d228185613c40565b600086825285602083015273ffffffffffffffffffffffffffffffffffffffff808616604084015280851660608401525060a06080830152613f0460a0830184613c6f565b979650505050505050565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715613f5657613f56614155565b604052919050565b600067ffffffffffffffff821115613f7857613f78614155565b5060209081020190565b600067ffffffffffffffff821115613f9c57613f9c614155565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b60008219821115613fdb57613fdb614126565b500190565b600082614014577f4e487b710000000000000000000000000000000000000000000000000000000081526012600452602481fd5b500490565b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff048311821515161561405157614051614126565b500290565b60008282101561406857614068614126565b500390565b60005b83811015614088578181015183820152602001614070565b83811115611b315750506000910152565b6002810460018216806140ad57607f821691505b602082108114156140e7577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561411f5761411f614126565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461113757600080fdfea2646970667358221220b7dff9c5ea10bda590dbb1fc36d7825f221fa5b21ab3897bb0045d793930412b64736f6c63430008020033