Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- AssetFactory
- Optimization enabled
- true
- Compiler version
- v0.8.20+commit.a1b79de6
- Optimization runs
- 200
- EVM Version
- paris
- Verified at
- 2023-10-31T12:47:00.055866Z
contracts/AssetFactory.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Asset} from "./Asset.sol";
import "./Structs.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract AssetFactory is Ownable {
event AssetCreated(address indexed _creator, address _asset, uint256 _timestamp);
// Guid => Asset map
mapping(string => Asset) public AssetGuidMap;
// Type => Guid => Asset map
// We can use this map to return like active assets for a specific type
mapping(string => mapping(string => Asset)) public AssetTypeGuidMap;
// Type => Count map. Used for name and symbol string generation
mapping(string => uint256) public AssetTypeCountMap;
constructor()
Ownable(msg.sender)
{
}
function CreateNewAsset(string memory type_, string memory guid_, uint256 share_count_, uint256 share_price_)
external onlyOwner
returns (address)
{
// TODO: Check that Guid is not already used
AssetTypeCountMap[type_]++;
// Create name and symbol
uint256 typeCount = AssetTypeCountMap[type_];
string memory typeCountStr = ToString(typeCount);
string memory name_ = string(abi.encodePacked("PSS ", type_, " ", typeCountStr));
string memory symbol_ = string(abi.encodePacked("Pss", type_, typeCountStr));
// Crerate Asset
Asset newAsset = new Asset(name_, symbol_, type_, guid_, share_count_, share_price_);
// Process new asset for maps
AssetGuidMap[guid_] = newAsset;
AssetTypeGuidMap[type_][guid_] = newAsset;
// Emit Events
emit AssetCreated(msg.sender, address(newAsset), block.timestamp);
// Return contract address of new asset. User can add his NFT Asset to MetaMask with Contract Address + TokenId
return address(newAsset);
}
function LockAsset(string memory guid_) external onlyOwner {
AssetGuidMap[guid_].Lock();
}
function UnlockAsset(string memory guid_) external onlyOwner {
AssetGuidMap[guid_].Unlock();
}
function IsAssetLocked(string memory guid_) external view returns (bool) {
return AssetGuidMap[guid_].IsLocked();
}
function SetEarlySellPenaltyPercentage(string memory guid_, uint256 percentage) external onlyOwner {
AssetGuidMap[guid_].SetEarlySellPenaltyPercentage(percentage);
}
function BuyShare(string memory guid_, uint256 share_count_) public
{
AssetGuidMap[guid_].BuyShare(msg.sender, share_count_);
}
function SellShare(string memory guid_, uint256 share_count_) public
{
AssetGuidMap[guid_].SellShare(msg.sender, share_count_);
}
// Pure functions
function ToString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp > 0) {
temp /= 10;
digits++;
}
bytes memory buffer = new bytes(digits);
while (value > 0) {
buffer[--digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
}
contracts/Structs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
enum AssetStatus
{
Active,
Closing,
Closed
}
struct AssetDataStruct
{
string AssetType;
string AssetGuid;
uint256 TotalShareCount;
uint256 PerSharePrice; // In StableCoin for e.g. USDT
bool IsLocked;
AssetStatus Status;
uint256 TokenId;
uint256 StartTimestamp;
uint256 ClosingTimestamp;
uint256 ClosedTimestamp;
uint256 EarlySellPenaltyPercentage;
uint256 BuyableShareCount;
}
struct TokenDataStruct
{
uint256 TokenId;
uint256 ShareCount;
uint256 ProfitEarned;
uint256 ProfitClaimed;
}
struct ProfitDataStruct
{
uint256 ProfitPerShare;
uint256 TotalInvestorShares;
uint256 DistributionTimestamp;
}
struct AssetMoneyPoolStruct
{
uint256 MoneyInvested;
uint256 MoneyUsed;
uint256 MoneyInInvestmentPool;
uint256 MoneyCutForPenalty;
uint256 MoneyInProfitPool;
}
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.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.
*
* The initial owner is set to the address provided by the deployer. 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 Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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 {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_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);
}
}
@openzeppelin/contracts/interfaces/draft-IERC6093.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
@openzeppelin/contracts/token/ERC20/ERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.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}.
*
* 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.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => 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.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual 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 returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual 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 `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` 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 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
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 `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` 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.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` 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.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @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/token/ERC721/ERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.20;
import {IERC721} from "./IERC721.sol";
import {IERC721Receiver} from "./IERC721Receiver.sol";
import {IERC721Metadata} from "./extensions/IERC721Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {Strings} from "../../utils/Strings.sol";
import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol";
import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors {
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
mapping(uint256 tokenId => address) private _owners;
mapping(address owner => uint256) private _balances;
mapping(uint256 tokenId => address) private _tokenApprovals;
mapping(address owner => mapping(address operator => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual returns (uint256) {
if (owner == address(0)) {
revert ERC721InvalidOwner(address(0));
}
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual returns (address) {
return _requireOwned(tokenId);
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual returns (string memory) {
_requireOwned(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual {
_approve(to, tokenId, _msgSender());
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual returns (address) {
_requireOwned(tokenId);
return _getApproved(tokenId);
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
// Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists
// (from != 0). Therefore, it is not needed to verify that the return value is not 0 here.
address previousOwner = _update(to, tokenId, _msgSender());
if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual {
transferFrom(from, to, tokenId);
_checkOnERC721Received(from, to, tokenId, data);
}
/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*
* IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
* core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances
* consistent with ownership. The invariant to preserve is that for any address `a` the value returned by
* `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`.
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted.
*/
function _getApproved(uint256 tokenId) internal view virtual returns (address) {
return _tokenApprovals[tokenId];
}
/**
* @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in
* particular (ignoring whether it is owned by `owner`).
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) {
return
spender != address(0) &&
(owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender);
}
/**
* @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner.
* Reverts if `spender` does not have approval from the provided `owner` for the given token or for all its assets
* the `spender` for the specific `tokenId`.
*
* WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this
* assumption.
*/
function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual {
if (!_isAuthorized(owner, spender, tokenId)) {
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else {
revert ERC721InsufficientApproval(spender, tokenId);
}
}
}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that
* a uint256 would ever overflow from increments when these increments are bounded to uint128 values.
*
* WARNING: Increasing an account's balance using this function tends to be paired with an override of the
* {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership
* remain consistent with one another.
*/
function _increaseBalance(address account, uint128 value) internal virtual {
unchecked {
_balances[account] += value;
}
}
/**
* @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner
* (or `to`) is the zero address. Returns the owner of the `tokenId` before the update.
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that
* `auth` is either the owner of the token, or approved to operate on the token (by the owner).
*
* Emits a {Transfer} event.
*
* NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}.
*/
function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) {
address from = _ownerOf(tokenId);
// Perform (optional) operator check
if (auth != address(0)) {
_checkAuthorized(from, auth, tokenId);
}
// Execute the update
if (from != address(0)) {
// Clear approval. No need to re-authorize or emit the Approval event
_approve(address(0), tokenId, address(0), false);
unchecked {
_balances[from] -= 1;
}
}
if (to != address(0)) {
unchecked {
_balances[to] += 1;
}
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
return from;
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner != address(0)) {
revert ERC721InvalidSender(address(0));
}
}
/**
* @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
_mint(to, tokenId);
_checkOnERC721Received(address(0), to, tokenId, data);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal {
address previousOwner = _update(address(0), tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal {
if (to == address(0)) {
revert ERC721InvalidReceiver(address(0));
}
address previousOwner = _update(to, tokenId, address(0));
if (previousOwner == address(0)) {
revert ERC721NonexistentToken(tokenId);
} else if (previousOwner != from) {
revert ERC721IncorrectOwner(from, tokenId, previousOwner);
}
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients
* are aware of the ERC721 standard to prevent tokens from being forever locked.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is like {safeTransferFrom} in the sense that it invokes
* {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `tokenId` token must exist and be owned by `from`.
* - `to` cannot be the zero address.
* - `from` cannot be the zero address.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId) internal {
_safeTransfer(from, to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {
_transfer(from, to, tokenId);
_checkOnERC721Received(from, to, tokenId, data);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is
* either the owner of the token, or approved to operate on all tokens held by this owner.
*
* Emits an {Approval} event.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address to, uint256 tokenId, address auth) internal {
_approve(to, tokenId, auth, true);
}
/**
* @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not
* emitted in the context of transfers.
*/
function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual {
// Avoid reading the owner unless necessary
if (emitEvent || auth != address(0)) {
address owner = _requireOwned(tokenId);
// We do not use _isAuthorized because single-token approvals should not be able to call approve
if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) {
revert ERC721InvalidApprover(auth);
}
if (emitEvent) {
emit Approval(owner, to, tokenId);
}
}
_tokenApprovals[tokenId] = to;
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Requirements:
* - operator can't be the address zero.
*
* Emits an {ApprovalForAll} event.
*/
function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {
if (operator == address(0)) {
revert ERC721InvalidOperator(operator);
}
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned).
* Returns the owner.
*
* Overrides to ownership logic should be done to {_ownerOf}.
*/
function _requireOwned(uint256 tokenId) internal view returns (address) {
address owner = _ownerOf(tokenId);
if (owner == address(0)) {
revert ERC721NonexistentToken(tokenId);
}
return owner;
}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target address. This will revert if the
* recipient doesn't accept the token transfer. The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param data bytes optional data to send along with the call
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory data) private {
if (to.code.length > 0) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
if (retval != IERC721Receiver.onERC721Received.selector) {
revert ERC721InvalidReceiver(to);
}
} catch (bytes memory reason) {
if (reason.length == 0) {
revert ERC721InvalidReceiver(to);
} else {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
}
}
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* 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/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.20;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be
* reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.20;
import {IERC721} from "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)
pragma solidity ^0.8.20;
import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant HEX_DIGITS = "0123456789abcdef";
uint8 private constant ADDRESS_LENGTH = 20;
/**
* @dev The `value` string doesn't fit in the specified `length`.
*/
error StringsInsufficientHexLength(uint256 value, uint256 length);
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `int256` to its ASCII `string` decimal representation.
*/
function toStringSigned(int256 value) internal pure returns (string memory) {
return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
uint256 localValue = value;
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_DIGITS[localValue & 0xf];
localValue >>= 4;
}
if (localValue != 0) {
revert StringsInsufficientHexLength(value, length);
}
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
* representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
}
}
@openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Muldiv operation overflow.
*/
error MathOverflowedMulDiv();
enum Rounding {
Floor, // Toward negative infinity
Ceil, // Toward positive infinity
Trunc, // Toward zero
Expand // Away from zero
}
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*/
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.
*/
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.
*/
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.
*/
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.
*/
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 largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds towards infinity instead
* of rounding towards zero.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
if (b == 0) {
// Guarantee the same behavior as in a regular Solidity division.
return a / b;
}
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
* denominator == 0.
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
* Uniswap Labs also under MIT license.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0 = x * y; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
if (denominator <= prod1) {
revert MathOverflowedMulDiv();
}
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator.
// Always >= 1. See https://cs.stackexchange.com/q/138556/92363.
uint256 twos = denominator & (0 - denominator);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
// works in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
* towards zero.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
}
}
/**
* @dev Return the log in base 2 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 10 of a positive value rounded towards zero.
* Returns 0 if given 0.
*/
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10 ** 64) {
value /= 10 ** 64;
result += 64;
}
if (value >= 10 ** 32) {
value /= 10 ** 32;
result += 32;
}
if (value >= 10 ** 16) {
value /= 10 ** 16;
result += 16;
}
if (value >= 10 ** 8) {
value /= 10 ** 8;
result += 8;
}
if (value >= 10 ** 4) {
value /= 10 ** 4;
result += 4;
}
if (value >= 10 ** 2) {
value /= 10 ** 2;
result += 2;
}
if (value >= 10 ** 1) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
}
}
/**
* @dev Return the log in base 256 of a positive value rounded towards zero.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
/**
* @dev Return the log in base 256, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
}
}
/**
* @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
*/
function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
return uint8(rounding) % 2 == 1;
}
}
@openzeppelin/contracts/utils/math/SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}
contracts/Asset.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./Structs.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract Asset is Ownable, ERC721
{
// Events
event EarlySellPenaltyPercentageChanged(address User, uint256 OldPercentage, uint256 NewPercentage, uint256 TimeStamp);
event UserEnabledTokenCreated(address User, uint256 TokenId, uint256 TimeStamp);
event MoneyInvested(address User, uint256 Amount, uint256 ShareCount, uint256 TimeStamp);
event MoneyUnInvested(address User, uint256 Amount, uint256 ShareCount, uint256 TimeStamp);
event MoneyCutForPenalty(address User, uint256 Amount, uint256 ShareCount, uint256 PenaltyPercentage, uint256 TimeStamp);
event TokenShareCountChanged(address User, uint256 OldShareCount, uint256 NewShareCount, uint256 TimeStamp);
AssetDataStruct public AssetData;
AssetMoneyPoolStruct public AssetMoneyPool;
ProfitDataStruct[] public DistributedProfits;
mapping(address user => TokenDataStruct) public TokenIdTokenDataMap;
// We must create an empty TokenData for user and add to TokenIdTokenDataMap
// and set user to true in UserEnabledMap map.
// TokenData has TokenId value.
mapping(address user => bool) public UserEnabledMap;
address public StableCoinAddress = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
constructor(
string memory name_,
string memory symbol_,
string memory asset_type_,
string memory asset_guid_,
uint256 share_count_,
uint256 share_price_
) payable ERC721(name_, symbol_) Ownable(msg.sender) {
AssetData = AssetDataStruct(
asset_type_,
asset_guid_,
share_count_,
share_price_,
false,
AssetStatus.Active,
0,
block.timestamp,
0,
0,
5,
share_count_
); // TODO: How should I set 5%? wei? gwei?
AssetMoneyPool = AssetMoneyPoolStruct(0, 0, 0, 0, 0);
// Initial NFT for PSS. PSS owns first NFT and owns all shares initially
uint256 tokenId = Mint(address(this));
TokenIdTokenDataMap[address(this)] = TokenDataStruct(tokenId, share_count_, 0, 0);
}
function Mint(address addr_) internal returns (uint256) {
AssetData.TokenId += 1;
_mint(addr_, AssetData.TokenId);
return AssetData.TokenId;
}
function Lock() public onlyOwner {
AssetData.IsLocked = true;
}
function Unlock() public onlyOwner {
AssetData.IsLocked = false;
}
function IsLocked() public view returns (bool) {
return AssetData.IsLocked;
}
function SetEarlySellPenaltyPercentage(uint256 percentage) external onlyOwner {
require(percentage <= 10, "Early sell penatly percentage cannot be greater than 10%");
uint256 oldPercentage = AssetData.EarlySellPenaltyPercentage;
AssetData.EarlySellPenaltyPercentage = percentage;
emit EarlySellPenaltyPercentageChanged(msg.sender, oldPercentage, AssetData.EarlySellPenaltyPercentage, block.timestamp);
}
function EnableUser() public
{
require(!UserEnabledMap[msg.sender], "User already enabled for that asset");
// If user is not already enabled, enable it.
// Mint NFT/Token for the user
// Create an emtpy (all zero) TokenDataStruct and assign TokenId from Minted NFT
// TokenDataStruct into TokenIdTokenDataMap map for that user
uint256 tokenId = Mint(msg.sender);
TokenIdTokenDataMap[msg.sender] = TokenDataStruct(tokenId, 0, 0, 0);
UserEnabledMap[msg.sender] = true;
emit UserEnabledTokenCreated(msg.sender, tokenId, block.timestamp);
}
function BuyShare(address user, uint256 share_count_) public onlyOwner
{
require(UserEnabledMap[user], "User is not enabled for that asset");
require(AssetData.BuyableShareCount >= share_count_, "There is not enough share to buy");
uint256 amount = share_count_ * AssetData.PerSharePrice;
// User must Allow with the amount to Assets's contract address
// When user wnats to buy share, WebApp knows required USDT/Stable Coin.
// Should check user's allowance to Asset's address and if it is less than required amount,
// should enable Approve button and send approve request for the whole required amount.
// If share price is 5$ and user wants to buy 100 shares, allowence should be 500$.
// This should be done on WebApp before calling BuyShare method.
// Get the payment with stable coin (USDT for example)
// We should then transfer amount from user adres to Asset address
ERC20 usdt = ERC20(StableCoinAddress);
// Check that user has enough USDT and allowence for buy share transaction
uint256 allowance = usdt.allowance(user, msg.sender);
uint256 balance = usdt.balanceOf(user);
require(balance >= amount, "Your Stable Coin balance is not enough");
require(allowance >= amount, "Given Stable Coin spending allowance is not enough");
usdt.transferFrom(user, address(this), amount);
// Now assign shares from PSS/Asset to User
uint256 old_share_count = TokenIdTokenDataMap[user].ShareCount;
TokenIdTokenDataMap[user].ShareCount += share_count_;
TokenIdTokenDataMap[address(this)].ShareCount -= share_count_;
// Adjust buyable share count
AssetData.BuyableShareCount -= share_count_;
// Update AssetMoneyPool
AssetMoneyPool.MoneyInInvestmentPool += amount;
AssetMoneyPool.MoneyInvested += amount;
emit MoneyInvested(user, amount, share_count_, block.timestamp);
emit TokenShareCountChanged(user, old_share_count, TokenIdTokenDataMap[user].ShareCount, block.timestamp);
}
function SellShare(address user, uint256 share_count_) public onlyOwner
{
require(UserEnabledMap[user], "User is not enabled for that asset");
require(TokenIdTokenDataMap[user].ShareCount >= share_count_, "User does not have enough shares to sell");
// Amount befofe early sell amount
uint256 amount = share_count_ * AssetData.PerSharePrice;
// If EarlySellPenaltyPercentage is 5, it means 5%. We will multiply with 5 and divide by 100.
uint256 penalty_amount = 0;
if (AssetData.EarlySellPenaltyPercentage > 0)
{
penalty_amount = (amount * AssetData.EarlySellPenaltyPercentage) / 100;
}
// Net pay to user. If there is no penalty will be same with amount.
uint256 payment = amount - penalty_amount;
// Get the payment with stable coin (USDT for example)
// We should then transfer amount from user adres to Asset address
IERC20 usdt = IERC20(StableCoinAddress);
uint256 balance = usdt.balanceOf(address(this));
require(balance >= payment && AssetMoneyPool.MoneyInInvestmentPool >= payment,
"There is not enough Stable Coin int the PSS Investment Pool");
usdt.transfer(msg.sender, payment);
// Now assign shares from PSS/Asset to User
uint256 old_share_count = TokenIdTokenDataMap[user].ShareCount;
TokenIdTokenDataMap[user].ShareCount -= share_count_;
TokenIdTokenDataMap[address(this)].ShareCount += share_count_;
// Adjust buyable share count
AssetData.BuyableShareCount += share_count_;
// Update AssetMoneyPool
AssetMoneyPool.MoneyInInvestmentPool -= payment;
AssetMoneyPool.MoneyInvested -= payment;
AssetMoneyPool.MoneyCutForPenalty += penalty_amount;
emit MoneyUnInvested(user, amount, share_count_, block.timestamp);
emit TokenShareCountChanged(user, old_share_count, TokenIdTokenDataMap[user].ShareCount, block.timestamp);
if (penalty_amount > 0)
{
emit MoneyCutForPenalty(user, penalty_amount, share_count_, AssetData.EarlySellPenaltyPercentage, block.timestamp);
}
}
}
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":200,"enabled":true},"libraries":{},"evmVersion":"paris"}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"event","name":"AssetCreated","inputs":[{"type":"address","name":"_creator","internalType":"address","indexed":true},{"type":"address","name":"_asset","internalType":"address","indexed":false},{"type":"uint256","name":"_timestamp","internalType":"uint256","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":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract Asset"}],"name":"AssetGuidMap","inputs":[{"type":"string","name":"","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"AssetTypeCountMap","inputs":[{"type":"string","name":"","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract Asset"}],"name":"AssetTypeGuidMap","inputs":[{"type":"string","name":"","internalType":"string"},{"type":"string","name":"","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"BuyShare","inputs":[{"type":"string","name":"guid_","internalType":"string"},{"type":"uint256","name":"share_count_","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"CreateNewAsset","inputs":[{"type":"string","name":"type_","internalType":"string"},{"type":"string","name":"guid_","internalType":"string"},{"type":"uint256","name":"share_count_","internalType":"uint256"},{"type":"uint256","name":"share_price_","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"IsAssetLocked","inputs":[{"type":"string","name":"guid_","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"LockAsset","inputs":[{"type":"string","name":"guid_","internalType":"string"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"SellShare","inputs":[{"type":"string","name":"guid_","internalType":"string"},{"type":"uint256","name":"share_count_","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"SetEarlySellPenaltyPercentage","inputs":[{"type":"string","name":"guid_","internalType":"string"},{"type":"uint256","name":"percentage","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"UnlockAsset","inputs":[{"type":"string","name":"guid_","internalType":"string"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50338061003757604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b61004081610046565b50610096565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6138cc806100a56000396000f3fe60806040523480156200001157600080fd5b5060043610620000e05760003560e01c8063600a0cc41162000097578063bc9a56b9116200006e578063bc9a56b91462000255578063d37898a3146200026c578063eda74d291462000283578063f2fde38b146200029a57600080fd5b8063600a0cc41462000202578063715018a614620002395780638da5cb5b146200024357600080fd5b806321f3498a14620000e557806334eea10414620001115780633bff12e2146200014e578063485614e014620001bb5780634d8ad26414620001d45780634ffdd20a14620001eb575b600080fd5b620000fc620000f636600462000a15565b620002b1565b60405190151581526020015b60405180910390f35b6200013f6200012236600462000a15565b805160208183018101805160038252928201919093012091525481565b60405190815260200162000108565b620001a26200015f36600462000a4e565b815160208184018101805160028252928201948201949094209190935281518083018401805192815290840192909301919091209152546001600160a01b031681565b6040516001600160a01b03909116815260200162000108565b620001d2620001cc36600462000ab9565b62000341565b005b620001a2620001e536600462000b02565b620003d2565b620001d2620001fc36600462000a15565b620005c7565b620001a26200021336600462000a15565b80516020818301810180516001825292820191909301209152546001600160a01b031681565b620001d26200064f565b6000546001600160a01b0316620001a2565b620001d26200026636600462000ab9565b62000667565b620001d26200027d36600462000ab9565b620006b9565b620001d26200029436600462000a15565b6200070b565b620001d2620002ab36600462000b7d565b62000777565b6000600182604051620002c5919062000bd5565b90815260408051602092819003830181205463caa30f5560e01b825291516001600160a01b039092169263caa30f55926004808401938290030181865afa15801562000315573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200033b919062000bf3565b92915050565b6200034b620007bf565b6001826040516200035d919062000bd5565b90815260405190819003602001812054632678307b60e11b82526001600160a01b031690634cf060f6906200039a90849060040190815260200190565b600060405180830381600087803b158015620003b557600080fd5b505af1158015620003ca573d6000803e3d6000fd5b505050505050565b6000620003de620007bf565b600385604051620003f0919062000bd5565b90815260405190819003602001902080549060006200040f8362000c2d565b9190505550600060038660405162000428919062000bd5565b908152602001604051809103902054905060006200044682620007ee565b9050600087826040516020016200045f92919062000c49565b6040516020818303038152906040529050600088836040516020016200048792919062000c99565b6040516020818303038152906040529050600082828b8b8b8b604051620004ae906200095c565b620004bf9695949392919062000d0c565b604051809103906000f080158015620004dc573d6000803e3d6000fd5b5090508060018a604051620004f2919062000bd5565b908152602001604051809103902060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508060028b60405162000537919062000bd5565b90815260200160405180910390208a60405162000555919062000bd5565b908152604080516020928190038301812080546001600160a01b0319166001600160a01b039586161790559284168352429183019190915233917f927e1c3a34f637ab867910098dc4d90fbc0be75b5d5633dc3bdbf1993c9c33d4910160405180910390a29998505050505050505050565b620005d1620007bf565b600181604051620005e3919062000bd5565b90815260408051918290036020018220546346620e3960e01b835290516001600160a01b03909116916346620e3991600480830192600092919082900301818387803b1580156200063357600080fd5b505af115801562000648573d6000803e3d6000fd5b5050505050565b62000659620007bf565b6200066560006200090c565b565b60018260405162000679919062000bd5565b90815260405190819003602001812054633d19048d60e21b8252336004830152602482018390526001600160a01b03169063f4641234906044016200039a565b600182604051620006cb919062000bd5565b9081526040519081900360200181205463622cb44960e11b8252336004830152602482018390526001600160a01b03169063c4596892906044016200039a565b62000715620007bf565b60018160405162000727919062000bd5565b9081526040805191829003602001822054633871ffff60e11b835290516001600160a01b03909116916370e3fffe91600480830192600092919082900301818387803b1580156200063357600080fd5b62000781620007bf565b6001600160a01b038116620007b157604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620007bc816200090c565b50565b6000546001600160a01b03163314620006655760405163118cdaa760e01b8152336004820152602401620007a8565b606081600003620008165750506040805180820190915260018152600360fc1b602082015290565b8160005b811562000845576200082e600a8362000d8d565b9150806200083c8162000c2d565b9150506200081a565b60008167ffffffffffffffff8111156200086357620008636200096a565b6040519080825280601f01601f1916602001820160405280156200088e576020820181803683370190505b5090505b84156200090457620008a6600a8662000da4565b620008b390603062000dbb565b60f81b81620008c28462000dd1565b93508381518110620008d857620008d862000deb565b60200101906001600160f81b031916908160001a905350620008fc600a8662000d8d565b945062000892565b949350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b612a958062000e0283390190565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200099257600080fd5b813567ffffffffffffffff80821115620009b057620009b06200096a565b604051601f8301601f19908116603f01168101908282118183101715620009db57620009db6200096a565b81604052838152866020858801011115620009f557600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121562000a2857600080fd5b813567ffffffffffffffff81111562000a4057600080fd5b620009048482850162000980565b6000806040838503121562000a6257600080fd5b823567ffffffffffffffff8082111562000a7b57600080fd5b62000a898683870162000980565b9350602085013591508082111562000aa057600080fd5b5062000aaf8582860162000980565b9150509250929050565b6000806040838503121562000acd57600080fd5b823567ffffffffffffffff81111562000ae557600080fd5b62000af38582860162000980565b95602094909401359450505050565b6000806000806080858703121562000b1957600080fd5b843567ffffffffffffffff8082111562000b3257600080fd5b62000b408883890162000980565b9550602087013591508082111562000b5757600080fd5b5062000b668782880162000980565b949794965050505060408301359260600135919050565b60006020828403121562000b9057600080fd5b81356001600160a01b038116811462000ba857600080fd5b9392505050565b60005b8381101562000bcc57818101518382015260200162000bb2565b50506000910152565b6000825162000be981846020870162000baf565b9190910192915050565b60006020828403121562000c0657600080fd5b8151801515811462000ba857600080fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000c425762000c4262000c17565b5060010190565b6302829a9960e51b81526000835162000c6a81600485016020880162000baf565b600160fd1b600491840191820152835162000c8d81600584016020880162000baf565b01600501949350505050565b6250737360e81b81526000835162000cb981600385016020880162000baf565b83519083019062000cd281600384016020880162000baf565b01600301949350505050565b6000815180845262000cf881602086016020860162000baf565b601f01601f19169290920160200192915050565b60c08152600062000d2160c083018962000cde565b828103602084015262000d35818962000cde565b9050828103604084015262000d4b818862000cde565b9050828103606084015262000d61818762000cde565b6080840195909552505060a00152949350505050565b634e487b7160e01b600052601260045260246000fd5b60008262000d9f5762000d9f62000d77565b500490565b60008262000db65762000db662000d77565b500690565b808201808211156200033b576200033b62000c17565b60008162000de35762000de362000c17565b506000190190565b634e487b7160e01b600052603260045260246000fdfe60806040819052601a80546001600160a01b03191673dac17f958d2ee523a2206206994597c13d831ec717905562002a95388190039081908339810160408190526200004b91620007a0565b858533806200007557604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000808162000284565b5060016200008f8382620008f9565b5060026200009e8282620008f9565b50505060405180610180016040528085815260200184815260200183815260200182815260200160001515815260200160006002811115620000e457620000e4620009c5565b8152600060208201819052426040830152606082018190526080820152600560a082015260c00183905280516007908190620001219082620008f9565b5060208201516001820190620001389082620008f9565b50604082015160028083019190915560608301516003830155608083015160048301805491151560ff1983168117825560a086015193919261ff001990911661ffff199091161790610100908490811115620001985762000198620009c5565b021790555060c0820151600582015560e0820151600682015561010082015160078201556101208201516008820155610140820151600982015561016090910151600a909101556040805160a08101825260008082526020820181905291810182905260608101829052608001819052601281905560138190556014819055601581905560168190556200022c30620002d4565b60408051608081018252918252602080830195865260008383018181526060850182815230835260189093529290209251835594516001830155516002820155925160039093019290925550620009fd945050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000600160076005016000828254620002ee9190620009db565b9091555050600c54620003039083906200030b565b5050600c5490565b6001600160a01b0382166200033757604051633250574960e11b8152600060048201526024016200006c565b6000620003468383836200037a565b90506001600160a01b0381161562000375576040516339e3563760e11b8152600060048201526024016200006c565b505050565b6000828152600360205260408120546001600160a01b0390811690831615620003aa57620003aa81848662000479565b6001600160a01b03811615620003ea57620003c96000858180620004e3565b6001600160a01b038116600090815260046020526040902080546000190190555b6001600160a01b038516156200041a576001600160a01b0385166000908152600460205260409020805460010190555b60008481526003602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6200048683838362000611565b62000375576001600160a01b038316620004b757604051637e27328960e01b8152600481018290526024016200006c565b60405163177e802f60e01b81526001600160a01b0383166004820152602481018290526044016200006c565b8080620004f857506001600160a01b03821615155b15620005e15760006200050b846200069a565b90506001600160a01b03831615801590620005385750826001600160a01b0316816001600160a01b031614155b80156200056b57506001600160a01b0380821660009081526006602090815260408083209387168352929052205460ff16155b15620005965760405163a9fbf51f60e01b81526001600160a01b03841660048201526024016200006c565b8115620005df5783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260056020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03831615801590620006925750826001600160a01b0316846001600160a01b031614806200066d57506001600160a01b0380851660009081526006602090815260408083209387168352929052205460ff165b806200069257506000828152600560205260409020546001600160a01b038481169116145b949350505050565b6000818152600360205260408120546001600160a01b031680620006d557604051637e27328960e01b8152600481018490526024016200006c565b92915050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200070357600080fd5b81516001600160401b0380821115620007205762000720620006db565b604051601f8301601f19908116603f011681019082821181831017156200074b576200074b620006db565b816040528381526020925086838588010111156200076857600080fd5b600091505b838210156200078c57858201830151818301840152908201906200076d565b600093810190920192909252949350505050565b60008060008060008060c08789031215620007ba57600080fd5b86516001600160401b0380821115620007d257600080fd5b620007e08a838b01620006f1565b97506020890151915080821115620007f757600080fd5b620008058a838b01620006f1565b965060408901519150808211156200081c57600080fd5b6200082a8a838b01620006f1565b955060608901519150808211156200084157600080fd5b506200085089828a01620006f1565b9350506080870151915060a087015190509295509295509295565b600181811c908216806200088057607f821691505b602082108103620008a157634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200037557600081815260208120601f850160051c81016020861015620008d05750805b601f850160051c820191505b81811015620008f157828155600101620008dc565b505050505050565b81516001600160401b03811115620009155762000915620006db565b6200092d816200092684546200086b565b84620008a7565b602080601f8311600181146200096557600084156200094c5750858301515b600019600386901b1c1916600185901b178555620008f1565b600085815260208120601f198616915b82811015620009965788860151825594840194600190910190840162000975565b5085821015620009b55787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052602160045260246000fd5b80820180821115620006d557634e487b7160e01b600052601160045260246000fd5b6120888062000a0d6000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80638566ac8711610104578063caa30f55116100a2578063f24d05d311610071578063f24d05d31461042e578063f2fde38b1461044e578063f464123414610461578063f895290a1461047457600080fd5b8063caa30f55146103b3578063da53e0e1146103be578063e985e9c5146103c6578063f1609481146103d957600080fd5b8063a22cb465116100de578063a22cb46514610367578063b88d4fde1461037a578063c45968921461038d578063c87b56dd146103a057600080fd5b80638566ac871461033b5780638da5cb5b1461034e57806395d89b411461035f57600080fd5b806346620e39116101715780636352211e1161014b5780636352211e146102f757806370a082311461030a57806370e3fffe1461032b578063715018a61461033357600080fd5b806346620e39146102b95780634cf060f6146102c157806361b69b45146102d457600080fd5b8063095ea7b3116101ad578063095ea7b31461023c57806323b872dd1461025157806342842e0e1461026457806343977d611461027757600080fd5b806301ffc9a7146101d457806306fdde03146101fc578063081812fc14610211575b600080fd5b6101e76101e2366004611b43565b6104a2565b60405190151581526020015b60405180910390f35b6102046104f4565b6040516101f39190611bb0565b61022461021f366004611bc3565b610586565b6040516001600160a01b0390911681526020016101f3565b61024f61024a366004611bf8565b6105af565b005b61024f61025f366004611c22565b6105be565b61024f610272366004611c22565b61064e565b601254601354601454601554601654610291949392919085565b604080519586526020860194909452928401919091526060830152608082015260a0016101f3565b61024f61066e565b61024f6102cf366004611bc3565b610685565b6101e76102e2366004611c5e565b60196020526000908152604090205460ff1681565b610224610305366004611bc3565b61074e565b61031d610318366004611c5e565b610759565b6040519081526020016101f3565b61024f6107a1565b61024f6107b5565b601a54610224906001600160a01b031681565b6000546001600160a01b0316610224565b6102046107c9565b61024f610375366004611c87565b6107d8565b61024f610388366004611cd4565b6107e3565b61024f61039b366004611bf8565b6107fa565b6102046103ae366004611bc3565b610c27565b600b5460ff166101e7565b61024f610c9c565b6101e76103d4366004611db0565b610db7565b61040e6103e7366004611c5e565b60186020526000908152604090208054600182015460028301546003909301549192909184565b6040805194855260208501939093529183015260608201526080016101f3565b610436610de5565b6040516101f39c9b9a99989796959493929190611de3565b61024f61045c366004611c5e565b610f4d565b61024f61046f366004611bf8565b610f8b565b610487610482366004611bc3565b6113a3565b604080519384526020840192909252908201526060016101f3565b60006001600160e01b031982166380ac58cd60e01b14806104d357506001600160e01b03198216635b5e139f60e01b145b806104ee57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606001805461050390611e7c565b80601f016020809104026020016040519081016040528092919081815260200182805461052f90611e7c565b801561057c5780601f106105515761010080835404028352916020019161057c565b820191906000526020600020905b81548152906001019060200180831161055f57829003601f168201915b5050505050905090565b6000610591826113d6565b506000828152600560205260409020546001600160a01b03166104ee565b6105ba82823361140f565b5050565b6001600160a01b0382166105ed57604051633250574960e11b8152600060048201526024015b60405180910390fd5b60006105fa83833361141c565b9050836001600160a01b0316816001600160a01b031614610648576040516364283d7b60e01b81526001600160a01b03808616600483015260248201849052821660448201526064016105e4565b50505050565b610669838383604051806020016040528060008152506107e3565b505050565b610676611515565b600b805460ff19166001179055565b61068d611515565b600a8111156107045760405162461bcd60e51b815260206004820152603860248201527f4561726c792073656c6c2070656e61746c792070657263656e7461676520636160448201527f6e6e6f742062652067726561746572207468616e20313025000000000000000060648201526084016105e4565b60108054908290556040517fc9db72790e7a4fae748689bbc442c8fee430ddce97247b20d6a61cfb9d22c5b390610742903390849086904290611eb6565b60405180910390a15050565b60006104ee826113d6565b60006001600160a01b038216610785576040516322718ad960e21b8152600060048201526024016105e4565b506001600160a01b031660009081526004602052604090205490565b6107a9611515565b600b805460ff19169055565b6107bd611515565b6107c76000611542565b565b60606002805461050390611e7c565b6105ba338383611592565b6107ee8484846105be565b61064884848484611631565b610802611515565b6001600160a01b03821660009081526019602052604090205460ff1661083a5760405162461bcd60e51b81526004016105e490611edc565b6001600160a01b0382166000908152601860205260409020600101548111156108b65760405162461bcd60e51b815260206004820152602860248201527f5573657220646f6573206e6f74206861766520656e6f75676820736861726573604482015267081d1bc81cd95b1b60c21b60648201526084016105e4565b600a546000906108c69083611f34565b601054909150600090156108f1576010546064906108e49084611f34565b6108ee9190611f4b565b90505b60006108fd8284611f6d565b601a546040516370a0823160e01b81523060048201529192506001600160a01b03169060009082906370a0823190602401602060405180830381865afa15801561094b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096f9190611f80565b905082811015801561098357506014548311155b6109f55760405162461bcd60e51b815260206004820152603b60248201527f5468657265206973206e6f7420656e6f75676820537461626c6520436f696e2060448201527f696e74207468652050535320496e766573746d656e7420506f6f6c000000000060648201526084016105e4565b60405163a9059cbb60e01b8152336004820152602481018490526001600160a01b0383169063a9059cbb906044016020604051808303816000875af1158015610a42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a669190611f99565b506001600160a01b0387166000908152601860205260408120600101805491889190610a928385611f6d565b90915550503060009081526018602052604081206001018054899290610ab9908490611fb6565b909155505060118054889190600090610ad3908490611fb6565b909155505060148054859190600090610aed908490611f6d565b909155505060128054859190600090610b07908490611f6d565b909155505060158054869190600090610b21908490611fb6565b90915550506040517f4ef968d41cbdfb30786af634ab3e7193102b5ff159c6f57673e03e6d4bb9fd9e90610b5c908a9089908b904290611eb6565b60405180910390a16001600160a01b038816600090815260186020526040908190206001015490517fe82d4bc383be0bd7683df6ae65751941587961fcd446d3a638dd6753c03bbe8a91610bb5918b9185914290611eb6565b60405180910390a18415610c1d57601054604080516001600160a01b038b168152602081018890528082018a90526060810192909252426080830152517f4d4fe222cf9e14cea33b3a3fc7781f71406ce9dd36e6b057c4ed8b515a27312b9181900360a00190a15b5050505050505050565b6060610c32826113d6565b506000610c4a60408051602081019091526000815290565b90506000815111610c6a5760405180602001604052806000815250610c95565b80610c748461175a565b604051602001610c85929190611fc9565b6040516020818303038152906040525b9392505050565b3360009081526019602052604090205460ff1615610d085760405162461bcd60e51b815260206004820152602360248201527f5573657220616c726561647920656e61626c656420666f7220746861742061736044820152621cd95d60ea1b60648201526084016105e4565b6000610d13336117ed565b60408051608081018252828152600060208083018281528385018381526060808601858152338087526018865288872097518855935160018089019190915592516002880155516003909601959095556019835292859020805460ff191690931790925583519182528101849052428184015291519293507fa29911e5e92282c7acfdd6b641bd27d42b45009f5d4911aa4e26482867c5030592918290030190a150565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b600780548190610df490611e7c565b80601f0160208091040260200160405190810160405280929190818152602001828054610e2090611e7c565b8015610e6d5780601f10610e4257610100808354040283529160200191610e6d565b820191906000526020600020905b815481529060010190602001808311610e5057829003601f168201915b505050505090806001018054610e8290611e7c565b80601f0160208091040260200160405190810160405280929190818152602001828054610eae90611e7c565b8015610efb5780601f10610ed057610100808354040283529160200191610efb565b820191906000526020600020905b815481529060010190602001808311610ede57829003601f168201915b50505050600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a909a01549899969895975060ff80861697610100909604169593949293919290918c565b610f55611515565b6001600160a01b038116610f7f57604051631e4fbdf760e01b8152600060048201526024016105e4565b610f8881611542565b50565b610f93611515565b6001600160a01b03821660009081526019602052604090205460ff16610fcb5760405162461bcd60e51b81526004016105e490611edc565b60115481111561101d5760405162461bcd60e51b815260206004820181905260248201527f5468657265206973206e6f7420656e6f75676820736861726520746f2062757960448201526064016105e4565b600a5460009061102d9083611f34565b601a54604051636eb1769f60e11b81526001600160a01b038681166004830152336024830152929350911690600090829063dd62ed3e90604401602060405180830381865afa158015611084573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a89190611f80565b6040516370a0823160e01b81526001600160a01b0387811660048301529192506000918416906370a0823190602401602060405180830381865afa1580156110f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111189190611f80565b9050838110156111795760405162461bcd60e51b815260206004820152602660248201527f596f757220537461626c6520436f696e2062616c616e6365206973206e6f74206044820152650cadcdeeaced60d31b60648201526084016105e4565b838210156111e45760405162461bcd60e51b815260206004820152603260248201527f476976656e20537461626c6520436f696e207370656e64696e6720616c6c6f776044820152710c2dcc6ca40d2e640dcdee840cadcdeeaced60731b60648201526084016105e4565b6040516323b872dd60e01b81526001600160a01b038781166004830152306024830152604482018690528416906323b872dd906064016020604051808303816000875af1158015611239573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125d9190611f99565b506001600160a01b03861660009081526018602052604081206001018054918791906112898385611fb6565b909155505030600090815260186020526040812060010180548892906112b0908490611f6d565b9091555050601180548791906000906112ca908490611f6d565b9091555050601480548691906000906112e4908490611fb6565b9091555050601280548691906000906112fe908490611fb6565b90915550506040517f9b0f5993334341f62f796be2fd6c71be5d0babbabe83223152d22ae5d2e827e09061133990899088908a904290611eb6565b60405180910390a16001600160a01b038716600090815260186020526040908190206001015490517fe82d4bc383be0bd7683df6ae65751941587961fcd446d3a638dd6753c03bbe8a91611392918a9185914290611eb6565b60405180910390a150505050505050565b601781815481106113b357600080fd5b600091825260209091206003909102018054600182015460029092015490925083565b6000818152600360205260408120546001600160a01b0316806104ee57604051637e27328960e01b8152600481018490526024016105e4565b6106698383836001611820565b6000828152600360205260408120546001600160a01b039081169083161561144957611449818486611926565b6001600160a01b0381161561148757611466600085600080611820565b6001600160a01b038116600090815260046020526040902080546000190190555b6001600160a01b038516156114b6576001600160a01b0385166000908152600460205260409020805460010190555b60008481526003602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6000546001600160a01b031633146107c75760405163118cdaa760e01b81523360048201526024016105e4565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0382166115c457604051630b61174360e31b81526001600160a01b03831660048201526024016105e4565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b1561064857604051630a85bd0160e11b81526001600160a01b0384169063150b7a0290611673903390889087908790600401611ff8565b6020604051808303816000875af19250505080156116ae575060408051601f3d908101601f191682019092526116ab91810190612035565b60015b611717573d8080156116dc576040519150601f19603f3d011682016040523d82523d6000602084013e6116e1565b606091505b50805160000361170f57604051633250574960e11b81526001600160a01b03851660048201526024016105e4565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b1461175357604051633250574960e11b81526001600160a01b03851660048201526024016105e4565b5050505050565b606060006117678361198a565b600101905060008167ffffffffffffffff81111561178757611787611cbe565b6040519080825280601f01601f1916602001820160405280156117b1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846117bb57509392505050565b60006001600760050160008282546118059190611fb6565b9091555050600c54611818908390611a62565b5050600c5490565b808061183457506001600160a01b03821615155b156118f6576000611844846113d6565b90506001600160a01b038316158015906118705750826001600160a01b0316816001600160a01b031614155b801561188357506118818184610db7565b155b156118ac5760405163a9fbf51f60e01b81526001600160a01b03841660048201526024016105e4565b81156118f45783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260056020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b611931838383611ac7565b610669576001600160a01b03831661195f57604051637e27328960e01b8152600481018290526024016105e4565b60405163177e802f60e01b81526001600160a01b0383166004820152602481018290526044016105e4565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106119c95772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106119f5576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611a1357662386f26fc10000830492506010015b6305f5e1008310611a2b576305f5e100830492506008015b6127108310611a3f57612710830492506004015b60648310611a51576064830492506002015b600a83106104ee5760010192915050565b6001600160a01b038216611a8c57604051633250574960e11b8152600060048201526024016105e4565b6000611a9a8383600061141c565b90506001600160a01b03811615610669576040516339e3563760e11b8152600060048201526024016105e4565b60006001600160a01b03831615801590611b255750826001600160a01b0316846001600160a01b03161480611b015750611b018484610db7565b80611b2557506000828152600560205260409020546001600160a01b038481169116145b949350505050565b6001600160e01b031981168114610f8857600080fd5b600060208284031215611b5557600080fd5b8135610c9581611b2d565b60005b83811015611b7b578181015183820152602001611b63565b50506000910152565b60008151808452611b9c816020860160208601611b60565b601f01601f19169290920160200192915050565b602081526000610c956020830184611b84565b600060208284031215611bd557600080fd5b5035919050565b80356001600160a01b0381168114611bf357600080fd5b919050565b60008060408385031215611c0b57600080fd5b611c1483611bdc565b946020939093013593505050565b600080600060608486031215611c3757600080fd5b611c4084611bdc565b9250611c4e60208501611bdc565b9150604084013590509250925092565b600060208284031215611c7057600080fd5b610c9582611bdc565b8015158114610f8857600080fd5b60008060408385031215611c9a57600080fd5b611ca383611bdc565b91506020830135611cb381611c79565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215611cea57600080fd5b611cf385611bdc565b9350611d0160208601611bdc565b925060408501359150606085013567ffffffffffffffff80821115611d2557600080fd5b818701915087601f830112611d3957600080fd5b813581811115611d4b57611d4b611cbe565b604051601f8201601f19908116603f01168101908382118183101715611d7357611d73611cbe565b816040528281528a6020848701011115611d8c57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215611dc357600080fd5b611dcc83611bdc565b9150611dda60208401611bdc565b90509250929050565b61018081526000611df861018083018f611b84565b8281036020840152611e0a818f611b84565b9150508b60408301528a6060830152891515608083015260038910611e3f57634e487b7160e01b600052602160045260246000fd5b60a082019890985260c081019690965260e08601949094526101008501929092526101208401526101408301526101609091015295945050505050565b600181811c90821680611e9057607f821691505b602082108103611eb057634e487b7160e01b600052602260045260246000fd5b50919050565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b60208082526022908201527f55736572206973206e6f7420656e61626c656420666f72207468617420617373604082015261195d60f21b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176104ee576104ee611f1e565b600082611f6857634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156104ee576104ee611f1e565b600060208284031215611f9257600080fd5b5051919050565b600060208284031215611fab57600080fd5b8151610c9581611c79565b808201808211156104ee576104ee611f1e565b60008351611fdb818460208801611b60565b835190830190611fef818360208801611b60565b01949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061202b90830184611b84565b9695505050505050565b60006020828403121561204757600080fd5b8151610c9581611b2d56fea2646970667358221220802949df22f44d7ac49f4ab9e1a32b244f6311950c023a7a325024dd6f92eb1364736f6c63430008140033a2646970667358221220baf2d86db7029701fa46eb357254ef0ed16b61932ca74641e8cd70d461f4a2a364736f6c63430008140033
Deployed ByteCode
0x60806040523480156200001157600080fd5b5060043610620000e05760003560e01c8063600a0cc41162000097578063bc9a56b9116200006e578063bc9a56b91462000255578063d37898a3146200026c578063eda74d291462000283578063f2fde38b146200029a57600080fd5b8063600a0cc41462000202578063715018a614620002395780638da5cb5b146200024357600080fd5b806321f3498a14620000e557806334eea10414620001115780633bff12e2146200014e578063485614e014620001bb5780634d8ad26414620001d45780634ffdd20a14620001eb575b600080fd5b620000fc620000f636600462000a15565b620002b1565b60405190151581526020015b60405180910390f35b6200013f6200012236600462000a15565b805160208183018101805160038252928201919093012091525481565b60405190815260200162000108565b620001a26200015f36600462000a4e565b815160208184018101805160028252928201948201949094209190935281518083018401805192815290840192909301919091209152546001600160a01b031681565b6040516001600160a01b03909116815260200162000108565b620001d2620001cc36600462000ab9565b62000341565b005b620001a2620001e536600462000b02565b620003d2565b620001d2620001fc36600462000a15565b620005c7565b620001a26200021336600462000a15565b80516020818301810180516001825292820191909301209152546001600160a01b031681565b620001d26200064f565b6000546001600160a01b0316620001a2565b620001d26200026636600462000ab9565b62000667565b620001d26200027d36600462000ab9565b620006b9565b620001d26200029436600462000a15565b6200070b565b620001d2620002ab36600462000b7d565b62000777565b6000600182604051620002c5919062000bd5565b90815260408051602092819003830181205463caa30f5560e01b825291516001600160a01b039092169263caa30f55926004808401938290030181865afa15801562000315573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200033b919062000bf3565b92915050565b6200034b620007bf565b6001826040516200035d919062000bd5565b90815260405190819003602001812054632678307b60e11b82526001600160a01b031690634cf060f6906200039a90849060040190815260200190565b600060405180830381600087803b158015620003b557600080fd5b505af1158015620003ca573d6000803e3d6000fd5b505050505050565b6000620003de620007bf565b600385604051620003f0919062000bd5565b90815260405190819003602001902080549060006200040f8362000c2d565b9190505550600060038660405162000428919062000bd5565b908152602001604051809103902054905060006200044682620007ee565b9050600087826040516020016200045f92919062000c49565b6040516020818303038152906040529050600088836040516020016200048792919062000c99565b6040516020818303038152906040529050600082828b8b8b8b604051620004ae906200095c565b620004bf9695949392919062000d0c565b604051809103906000f080158015620004dc573d6000803e3d6000fd5b5090508060018a604051620004f2919062000bd5565b908152602001604051809103902060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508060028b60405162000537919062000bd5565b90815260200160405180910390208a60405162000555919062000bd5565b908152604080516020928190038301812080546001600160a01b0319166001600160a01b039586161790559284168352429183019190915233917f927e1c3a34f637ab867910098dc4d90fbc0be75b5d5633dc3bdbf1993c9c33d4910160405180910390a29998505050505050505050565b620005d1620007bf565b600181604051620005e3919062000bd5565b90815260408051918290036020018220546346620e3960e01b835290516001600160a01b03909116916346620e3991600480830192600092919082900301818387803b1580156200063357600080fd5b505af115801562000648573d6000803e3d6000fd5b5050505050565b62000659620007bf565b6200066560006200090c565b565b60018260405162000679919062000bd5565b90815260405190819003602001812054633d19048d60e21b8252336004830152602482018390526001600160a01b03169063f4641234906044016200039a565b600182604051620006cb919062000bd5565b9081526040519081900360200181205463622cb44960e11b8252336004830152602482018390526001600160a01b03169063c4596892906044016200039a565b62000715620007bf565b60018160405162000727919062000bd5565b9081526040805191829003602001822054633871ffff60e11b835290516001600160a01b03909116916370e3fffe91600480830192600092919082900301818387803b1580156200063357600080fd5b62000781620007bf565b6001600160a01b038116620007b157604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620007bc816200090c565b50565b6000546001600160a01b03163314620006655760405163118cdaa760e01b8152336004820152602401620007a8565b606081600003620008165750506040805180820190915260018152600360fc1b602082015290565b8160005b811562000845576200082e600a8362000d8d565b9150806200083c8162000c2d565b9150506200081a565b60008167ffffffffffffffff8111156200086357620008636200096a565b6040519080825280601f01601f1916602001820160405280156200088e576020820181803683370190505b5090505b84156200090457620008a6600a8662000da4565b620008b390603062000dbb565b60f81b81620008c28462000dd1565b93508381518110620008d857620008d862000deb565b60200101906001600160f81b031916908160001a905350620008fc600a8662000d8d565b945062000892565b949350505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b612a958062000e0283390190565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200099257600080fd5b813567ffffffffffffffff80821115620009b057620009b06200096a565b604051601f8301601f19908116603f01168101908282118183101715620009db57620009db6200096a565b81604052838152866020858801011115620009f557600080fd5b836020870160208301376000602085830101528094505050505092915050565b60006020828403121562000a2857600080fd5b813567ffffffffffffffff81111562000a4057600080fd5b620009048482850162000980565b6000806040838503121562000a6257600080fd5b823567ffffffffffffffff8082111562000a7b57600080fd5b62000a898683870162000980565b9350602085013591508082111562000aa057600080fd5b5062000aaf8582860162000980565b9150509250929050565b6000806040838503121562000acd57600080fd5b823567ffffffffffffffff81111562000ae557600080fd5b62000af38582860162000980565b95602094909401359450505050565b6000806000806080858703121562000b1957600080fd5b843567ffffffffffffffff8082111562000b3257600080fd5b62000b408883890162000980565b9550602087013591508082111562000b5757600080fd5b5062000b668782880162000980565b949794965050505060408301359260600135919050565b60006020828403121562000b9057600080fd5b81356001600160a01b038116811462000ba857600080fd5b9392505050565b60005b8381101562000bcc57818101518382015260200162000bb2565b50506000910152565b6000825162000be981846020870162000baf565b9190910192915050565b60006020828403121562000c0657600080fd5b8151801515811462000ba857600080fd5b634e487b7160e01b600052601160045260246000fd5b60006001820162000c425762000c4262000c17565b5060010190565b6302829a9960e51b81526000835162000c6a81600485016020880162000baf565b600160fd1b600491840191820152835162000c8d81600584016020880162000baf565b01600501949350505050565b6250737360e81b81526000835162000cb981600385016020880162000baf565b83519083019062000cd281600384016020880162000baf565b01600301949350505050565b6000815180845262000cf881602086016020860162000baf565b601f01601f19169290920160200192915050565b60c08152600062000d2160c083018962000cde565b828103602084015262000d35818962000cde565b9050828103604084015262000d4b818862000cde565b9050828103606084015262000d61818762000cde565b6080840195909552505060a00152949350505050565b634e487b7160e01b600052601260045260246000fd5b60008262000d9f5762000d9f62000d77565b500490565b60008262000db65762000db662000d77565b500690565b808201808211156200033b576200033b62000c17565b60008162000de35762000de362000c17565b506000190190565b634e487b7160e01b600052603260045260246000fdfe60806040819052601a80546001600160a01b03191673dac17f958d2ee523a2206206994597c13d831ec717905562002a95388190039081908339810160408190526200004b91620007a0565b858533806200007557604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b620000808162000284565b5060016200008f8382620008f9565b5060026200009e8282620008f9565b50505060405180610180016040528085815260200184815260200183815260200182815260200160001515815260200160006002811115620000e457620000e4620009c5565b8152600060208201819052426040830152606082018190526080820152600560a082015260c00183905280516007908190620001219082620008f9565b5060208201516001820190620001389082620008f9565b50604082015160028083019190915560608301516003830155608083015160048301805491151560ff1983168117825560a086015193919261ff001990911661ffff199091161790610100908490811115620001985762000198620009c5565b021790555060c0820151600582015560e0820151600682015561010082015160078201556101208201516008820155610140820151600982015561016090910151600a909101556040805160a08101825260008082526020820181905291810182905260608101829052608001819052601281905560138190556014819055601581905560168190556200022c30620002d4565b60408051608081018252918252602080830195865260008383018181526060850182815230835260189093529290209251835594516001830155516002820155925160039093019290925550620009fd945050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000600160076005016000828254620002ee9190620009db565b9091555050600c54620003039083906200030b565b5050600c5490565b6001600160a01b0382166200033757604051633250574960e11b8152600060048201526024016200006c565b6000620003468383836200037a565b90506001600160a01b0381161562000375576040516339e3563760e11b8152600060048201526024016200006c565b505050565b6000828152600360205260408120546001600160a01b0390811690831615620003aa57620003aa81848662000479565b6001600160a01b03811615620003ea57620003c96000858180620004e3565b6001600160a01b038116600090815260046020526040902080546000190190555b6001600160a01b038516156200041a576001600160a01b0385166000908152600460205260409020805460010190555b60008481526003602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6200048683838362000611565b62000375576001600160a01b038316620004b757604051637e27328960e01b8152600481018290526024016200006c565b60405163177e802f60e01b81526001600160a01b0383166004820152602481018290526044016200006c565b8080620004f857506001600160a01b03821615155b15620005e15760006200050b846200069a565b90506001600160a01b03831615801590620005385750826001600160a01b0316816001600160a01b031614155b80156200056b57506001600160a01b0380821660009081526006602090815260408083209387168352929052205460ff16155b15620005965760405163a9fbf51f60e01b81526001600160a01b03841660048201526024016200006c565b8115620005df5783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260056020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b03831615801590620006925750826001600160a01b0316846001600160a01b031614806200066d57506001600160a01b0380851660009081526006602090815260408083209387168352929052205460ff165b806200069257506000828152600560205260409020546001600160a01b038481169116145b949350505050565b6000818152600360205260408120546001600160a01b031680620006d557604051637e27328960e01b8152600481018490526024016200006c565b92915050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200070357600080fd5b81516001600160401b0380821115620007205762000720620006db565b604051601f8301601f19908116603f011681019082821181831017156200074b576200074b620006db565b816040528381526020925086838588010111156200076857600080fd5b600091505b838210156200078c57858201830151818301840152908201906200076d565b600093810190920192909252949350505050565b60008060008060008060c08789031215620007ba57600080fd5b86516001600160401b0380821115620007d257600080fd5b620007e08a838b01620006f1565b97506020890151915080821115620007f757600080fd5b620008058a838b01620006f1565b965060408901519150808211156200081c57600080fd5b6200082a8a838b01620006f1565b955060608901519150808211156200084157600080fd5b506200085089828a01620006f1565b9350506080870151915060a087015190509295509295509295565b600181811c908216806200088057607f821691505b602082108103620008a157634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200037557600081815260208120601f850160051c81016020861015620008d05750805b601f850160051c820191505b81811015620008f157828155600101620008dc565b505050505050565b81516001600160401b03811115620009155762000915620006db565b6200092d816200092684546200086b565b84620008a7565b602080601f8311600181146200096557600084156200094c5750858301515b600019600386901b1c1916600185901b178555620008f1565b600085815260208120601f198616915b82811015620009965788860151825594840194600190910190840162000975565b5085821015620009b55787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052602160045260246000fd5b80820180821115620006d557634e487b7160e01b600052601160045260246000fd5b6120888062000a0d6000396000f3fe608060405234801561001057600080fd5b50600436106101cf5760003560e01c80638566ac8711610104578063caa30f55116100a2578063f24d05d311610071578063f24d05d31461042e578063f2fde38b1461044e578063f464123414610461578063f895290a1461047457600080fd5b8063caa30f55146103b3578063da53e0e1146103be578063e985e9c5146103c6578063f1609481146103d957600080fd5b8063a22cb465116100de578063a22cb46514610367578063b88d4fde1461037a578063c45968921461038d578063c87b56dd146103a057600080fd5b80638566ac871461033b5780638da5cb5b1461034e57806395d89b411461035f57600080fd5b806346620e39116101715780636352211e1161014b5780636352211e146102f757806370a082311461030a57806370e3fffe1461032b578063715018a61461033357600080fd5b806346620e39146102b95780634cf060f6146102c157806361b69b45146102d457600080fd5b8063095ea7b3116101ad578063095ea7b31461023c57806323b872dd1461025157806342842e0e1461026457806343977d611461027757600080fd5b806301ffc9a7146101d457806306fdde03146101fc578063081812fc14610211575b600080fd5b6101e76101e2366004611b43565b6104a2565b60405190151581526020015b60405180910390f35b6102046104f4565b6040516101f39190611bb0565b61022461021f366004611bc3565b610586565b6040516001600160a01b0390911681526020016101f3565b61024f61024a366004611bf8565b6105af565b005b61024f61025f366004611c22565b6105be565b61024f610272366004611c22565b61064e565b601254601354601454601554601654610291949392919085565b604080519586526020860194909452928401919091526060830152608082015260a0016101f3565b61024f61066e565b61024f6102cf366004611bc3565b610685565b6101e76102e2366004611c5e565b60196020526000908152604090205460ff1681565b610224610305366004611bc3565b61074e565b61031d610318366004611c5e565b610759565b6040519081526020016101f3565b61024f6107a1565b61024f6107b5565b601a54610224906001600160a01b031681565b6000546001600160a01b0316610224565b6102046107c9565b61024f610375366004611c87565b6107d8565b61024f610388366004611cd4565b6107e3565b61024f61039b366004611bf8565b6107fa565b6102046103ae366004611bc3565b610c27565b600b5460ff166101e7565b61024f610c9c565b6101e76103d4366004611db0565b610db7565b61040e6103e7366004611c5e565b60186020526000908152604090208054600182015460028301546003909301549192909184565b6040805194855260208501939093529183015260608201526080016101f3565b610436610de5565b6040516101f39c9b9a99989796959493929190611de3565b61024f61045c366004611c5e565b610f4d565b61024f61046f366004611bf8565b610f8b565b610487610482366004611bc3565b6113a3565b604080519384526020840192909252908201526060016101f3565b60006001600160e01b031982166380ac58cd60e01b14806104d357506001600160e01b03198216635b5e139f60e01b145b806104ee57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606001805461050390611e7c565b80601f016020809104026020016040519081016040528092919081815260200182805461052f90611e7c565b801561057c5780601f106105515761010080835404028352916020019161057c565b820191906000526020600020905b81548152906001019060200180831161055f57829003601f168201915b5050505050905090565b6000610591826113d6565b506000828152600560205260409020546001600160a01b03166104ee565b6105ba82823361140f565b5050565b6001600160a01b0382166105ed57604051633250574960e11b8152600060048201526024015b60405180910390fd5b60006105fa83833361141c565b9050836001600160a01b0316816001600160a01b031614610648576040516364283d7b60e01b81526001600160a01b03808616600483015260248201849052821660448201526064016105e4565b50505050565b610669838383604051806020016040528060008152506107e3565b505050565b610676611515565b600b805460ff19166001179055565b61068d611515565b600a8111156107045760405162461bcd60e51b815260206004820152603860248201527f4561726c792073656c6c2070656e61746c792070657263656e7461676520636160448201527f6e6e6f742062652067726561746572207468616e20313025000000000000000060648201526084016105e4565b60108054908290556040517fc9db72790e7a4fae748689bbc442c8fee430ddce97247b20d6a61cfb9d22c5b390610742903390849086904290611eb6565b60405180910390a15050565b60006104ee826113d6565b60006001600160a01b038216610785576040516322718ad960e21b8152600060048201526024016105e4565b506001600160a01b031660009081526004602052604090205490565b6107a9611515565b600b805460ff19169055565b6107bd611515565b6107c76000611542565b565b60606002805461050390611e7c565b6105ba338383611592565b6107ee8484846105be565b61064884848484611631565b610802611515565b6001600160a01b03821660009081526019602052604090205460ff1661083a5760405162461bcd60e51b81526004016105e490611edc565b6001600160a01b0382166000908152601860205260409020600101548111156108b65760405162461bcd60e51b815260206004820152602860248201527f5573657220646f6573206e6f74206861766520656e6f75676820736861726573604482015267081d1bc81cd95b1b60c21b60648201526084016105e4565b600a546000906108c69083611f34565b601054909150600090156108f1576010546064906108e49084611f34565b6108ee9190611f4b565b90505b60006108fd8284611f6d565b601a546040516370a0823160e01b81523060048201529192506001600160a01b03169060009082906370a0823190602401602060405180830381865afa15801561094b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061096f9190611f80565b905082811015801561098357506014548311155b6109f55760405162461bcd60e51b815260206004820152603b60248201527f5468657265206973206e6f7420656e6f75676820537461626c6520436f696e2060448201527f696e74207468652050535320496e766573746d656e7420506f6f6c000000000060648201526084016105e4565b60405163a9059cbb60e01b8152336004820152602481018490526001600160a01b0383169063a9059cbb906044016020604051808303816000875af1158015610a42573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a669190611f99565b506001600160a01b0387166000908152601860205260408120600101805491889190610a928385611f6d565b90915550503060009081526018602052604081206001018054899290610ab9908490611fb6565b909155505060118054889190600090610ad3908490611fb6565b909155505060148054859190600090610aed908490611f6d565b909155505060128054859190600090610b07908490611f6d565b909155505060158054869190600090610b21908490611fb6565b90915550506040517f4ef968d41cbdfb30786af634ab3e7193102b5ff159c6f57673e03e6d4bb9fd9e90610b5c908a9089908b904290611eb6565b60405180910390a16001600160a01b038816600090815260186020526040908190206001015490517fe82d4bc383be0bd7683df6ae65751941587961fcd446d3a638dd6753c03bbe8a91610bb5918b9185914290611eb6565b60405180910390a18415610c1d57601054604080516001600160a01b038b168152602081018890528082018a90526060810192909252426080830152517f4d4fe222cf9e14cea33b3a3fc7781f71406ce9dd36e6b057c4ed8b515a27312b9181900360a00190a15b5050505050505050565b6060610c32826113d6565b506000610c4a60408051602081019091526000815290565b90506000815111610c6a5760405180602001604052806000815250610c95565b80610c748461175a565b604051602001610c85929190611fc9565b6040516020818303038152906040525b9392505050565b3360009081526019602052604090205460ff1615610d085760405162461bcd60e51b815260206004820152602360248201527f5573657220616c726561647920656e61626c656420666f7220746861742061736044820152621cd95d60ea1b60648201526084016105e4565b6000610d13336117ed565b60408051608081018252828152600060208083018281528385018381526060808601858152338087526018865288872097518855935160018089019190915592516002880155516003909601959095556019835292859020805460ff191690931790925583519182528101849052428184015291519293507fa29911e5e92282c7acfdd6b641bd27d42b45009f5d4911aa4e26482867c5030592918290030190a150565b6001600160a01b03918216600090815260066020908152604080832093909416825291909152205460ff1690565b600780548190610df490611e7c565b80601f0160208091040260200160405190810160405280929190818152602001828054610e2090611e7c565b8015610e6d5780601f10610e4257610100808354040283529160200191610e6d565b820191906000526020600020905b815481529060010190602001808311610e5057829003601f168201915b505050505090806001018054610e8290611e7c565b80601f0160208091040260200160405190810160405280929190818152602001828054610eae90611e7c565b8015610efb5780601f10610ed057610100808354040283529160200191610efb565b820191906000526020600020905b815481529060010190602001808311610ede57829003601f168201915b50505050600283015460038401546004850154600586015460068701546007880154600889015460098a0154600a909a01549899969895975060ff80861697610100909604169593949293919290918c565b610f55611515565b6001600160a01b038116610f7f57604051631e4fbdf760e01b8152600060048201526024016105e4565b610f8881611542565b50565b610f93611515565b6001600160a01b03821660009081526019602052604090205460ff16610fcb5760405162461bcd60e51b81526004016105e490611edc565b60115481111561101d5760405162461bcd60e51b815260206004820181905260248201527f5468657265206973206e6f7420656e6f75676820736861726520746f2062757960448201526064016105e4565b600a5460009061102d9083611f34565b601a54604051636eb1769f60e11b81526001600160a01b038681166004830152336024830152929350911690600090829063dd62ed3e90604401602060405180830381865afa158015611084573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a89190611f80565b6040516370a0823160e01b81526001600160a01b0387811660048301529192506000918416906370a0823190602401602060405180830381865afa1580156110f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111189190611f80565b9050838110156111795760405162461bcd60e51b815260206004820152602660248201527f596f757220537461626c6520436f696e2062616c616e6365206973206e6f74206044820152650cadcdeeaced60d31b60648201526084016105e4565b838210156111e45760405162461bcd60e51b815260206004820152603260248201527f476976656e20537461626c6520436f696e207370656e64696e6720616c6c6f776044820152710c2dcc6ca40d2e640dcdee840cadcdeeaced60731b60648201526084016105e4565b6040516323b872dd60e01b81526001600160a01b038781166004830152306024830152604482018690528416906323b872dd906064016020604051808303816000875af1158015611239573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061125d9190611f99565b506001600160a01b03861660009081526018602052604081206001018054918791906112898385611fb6565b909155505030600090815260186020526040812060010180548892906112b0908490611f6d565b9091555050601180548791906000906112ca908490611f6d565b9091555050601480548691906000906112e4908490611fb6565b9091555050601280548691906000906112fe908490611fb6565b90915550506040517f9b0f5993334341f62f796be2fd6c71be5d0babbabe83223152d22ae5d2e827e09061133990899088908a904290611eb6565b60405180910390a16001600160a01b038716600090815260186020526040908190206001015490517fe82d4bc383be0bd7683df6ae65751941587961fcd446d3a638dd6753c03bbe8a91611392918a9185914290611eb6565b60405180910390a150505050505050565b601781815481106113b357600080fd5b600091825260209091206003909102018054600182015460029092015490925083565b6000818152600360205260408120546001600160a01b0316806104ee57604051637e27328960e01b8152600481018490526024016105e4565b6106698383836001611820565b6000828152600360205260408120546001600160a01b039081169083161561144957611449818486611926565b6001600160a01b0381161561148757611466600085600080611820565b6001600160a01b038116600090815260046020526040902080546000190190555b6001600160a01b038516156114b6576001600160a01b0385166000908152600460205260409020805460010190555b60008481526003602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b6000546001600160a01b031633146107c75760405163118cdaa760e01b81523360048201526024016105e4565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0382166115c457604051630b61174360e31b81526001600160a01b03831660048201526024016105e4565b6001600160a01b03838116600081815260066020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0383163b1561064857604051630a85bd0160e11b81526001600160a01b0384169063150b7a0290611673903390889087908790600401611ff8565b6020604051808303816000875af19250505080156116ae575060408051601f3d908101601f191682019092526116ab91810190612035565b60015b611717573d8080156116dc576040519150601f19603f3d011682016040523d82523d6000602084013e6116e1565b606091505b50805160000361170f57604051633250574960e11b81526001600160a01b03851660048201526024016105e4565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b1461175357604051633250574960e11b81526001600160a01b03851660048201526024016105e4565b5050505050565b606060006117678361198a565b600101905060008167ffffffffffffffff81111561178757611787611cbe565b6040519080825280601f01601f1916602001820160405280156117b1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a85049450846117bb57509392505050565b60006001600760050160008282546118059190611fb6565b9091555050600c54611818908390611a62565b5050600c5490565b808061183457506001600160a01b03821615155b156118f6576000611844846113d6565b90506001600160a01b038316158015906118705750826001600160a01b0316816001600160a01b031614155b801561188357506118818184610db7565b155b156118ac5760405163a9fbf51f60e01b81526001600160a01b03841660048201526024016105e4565b81156118f45783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b5050600090815260056020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b611931838383611ac7565b610669576001600160a01b03831661195f57604051637e27328960e01b8152600481018290526024016105e4565b60405163177e802f60e01b81526001600160a01b0383166004820152602481018290526044016105e4565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106119c95772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106119f5576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc100008310611a1357662386f26fc10000830492506010015b6305f5e1008310611a2b576305f5e100830492506008015b6127108310611a3f57612710830492506004015b60648310611a51576064830492506002015b600a83106104ee5760010192915050565b6001600160a01b038216611a8c57604051633250574960e11b8152600060048201526024016105e4565b6000611a9a8383600061141c565b90506001600160a01b03811615610669576040516339e3563760e11b8152600060048201526024016105e4565b60006001600160a01b03831615801590611b255750826001600160a01b0316846001600160a01b03161480611b015750611b018484610db7565b80611b2557506000828152600560205260409020546001600160a01b038481169116145b949350505050565b6001600160e01b031981168114610f8857600080fd5b600060208284031215611b5557600080fd5b8135610c9581611b2d565b60005b83811015611b7b578181015183820152602001611b63565b50506000910152565b60008151808452611b9c816020860160208601611b60565b601f01601f19169290920160200192915050565b602081526000610c956020830184611b84565b600060208284031215611bd557600080fd5b5035919050565b80356001600160a01b0381168114611bf357600080fd5b919050565b60008060408385031215611c0b57600080fd5b611c1483611bdc565b946020939093013593505050565b600080600060608486031215611c3757600080fd5b611c4084611bdc565b9250611c4e60208501611bdc565b9150604084013590509250925092565b600060208284031215611c7057600080fd5b610c9582611bdc565b8015158114610f8857600080fd5b60008060408385031215611c9a57600080fd5b611ca383611bdc565b91506020830135611cb381611c79565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215611cea57600080fd5b611cf385611bdc565b9350611d0160208601611bdc565b925060408501359150606085013567ffffffffffffffff80821115611d2557600080fd5b818701915087601f830112611d3957600080fd5b813581811115611d4b57611d4b611cbe565b604051601f8201601f19908116603f01168101908382118183101715611d7357611d73611cbe565b816040528281528a6020848701011115611d8c57600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b60008060408385031215611dc357600080fd5b611dcc83611bdc565b9150611dda60208401611bdc565b90509250929050565b61018081526000611df861018083018f611b84565b8281036020840152611e0a818f611b84565b9150508b60408301528a6060830152891515608083015260038910611e3f57634e487b7160e01b600052602160045260246000fd5b60a082019890985260c081019690965260e08601949094526101008501929092526101208401526101408301526101609091015295945050505050565b600181811c90821680611e9057607f821691505b602082108103611eb057634e487b7160e01b600052602260045260246000fd5b50919050565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b60208082526022908201527f55736572206973206e6f7420656e61626c656420666f72207468617420617373604082015261195d60f21b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176104ee576104ee611f1e565b600082611f6857634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156104ee576104ee611f1e565b600060208284031215611f9257600080fd5b5051919050565b600060208284031215611fab57600080fd5b8151610c9581611c79565b808201808211156104ee576104ee611f1e565b60008351611fdb818460208801611b60565b835190830190611fef818360208801611b60565b01949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061202b90830184611b84565b9695505050505050565b60006020828403121561204757600080fd5b8151610c9581611b2d56fea2646970667358221220802949df22f44d7ac49f4ab9e1a32b244f6311950c023a7a325024dd6f92eb1364736f6c63430008140033a2646970667358221220baf2d86db7029701fa46eb357254ef0ed16b61932ca74641e8cd70d461f4a2a364736f6c63430008140033