Token Planck
Overview ERC-721
Total Supply:
1,000,000 PLK
Holders:
280 addresses
Transfers:
-
Profile Summary
Contract:
[ Download CSV Export ]
[ Download CSV Export ]
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
TheSpace
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; import "./HarbergerMarket.sol"; /** * @notice _The Space_ is a pixel space owned by a decentralized autonomous organization (DAO), where members can tokenize, own, trade and color pixels. * Pixels are tokenized as ERC721 tokens and traded under Harberger tax, while members receive dividend based on the share of pixels they own. * Trading logic of Harberger tax is defined in [`IHarbergerMarket`](./IHarbergerMarket.md). * * #### Trading * * - User needs to call `approve` on currency contract before starting. If there is not sufficient allowance for taxing, the corresponding assets are defaulted. * - User buy land: call [`bid` function](./IHarbergerMarket.md) on `HarbergerMarket` contract. * - User set land price: call [`setPrice` function](./IHarbergerMarket.md) on `HarbergerMarket` contract. * */ contract TheSpace is HarbergerMarket { /** * @notice Color data of each token. * */ mapping(uint256 => uint256) public pixelColor; /** * @notice Emitted when the color of a pixel is updated. */ event Color(uint256 indexed pixelId, uint256 indexed color, address indexed owner); constructor( address currencyAddress_, address aclManager_, address marketAdmin_, address treasuryAdmin_ ) HarbergerMarket("Planck", "PLK", currencyAddress_, aclManager_, marketAdmin_, treasuryAdmin_) {} /** * @notice Bid pixel, then set price and color. */ function setPixel( uint256 tokenId_, uint256 bid_, uint256 price_, uint256 color_ ) external { bid(tokenId_, bid_); setPrice(tokenId_, price_); setColor(tokenId_, color_); } /** * @notice Get pixel info. */ function getPixel(uint256 tokenId_) external view returns ( uint256 tokenId, uint256 price, uint256 lastTaxCollection, uint256 ubi, address owner, uint256 color ) { return ( tokenId_, tokenRecord[tokenId_].price, tokenRecord[tokenId_].lastTaxCollection, ubiAvailable(tokenId_), getOwner(tokenId_), pixelColor[tokenId_] ); } /** * @notice Set color for a pixel. * * @dev Emits {Color} event. */ function setColor(uint256 tokenId, uint256 color) public { if (!_isApprovedOrOwner(msg.sender, tokenId)) revert Unauthorized(); pixelColor[tokenId] = color; emit Color(tokenId, color, ownerOf(tokenId)); } /** * @notice Get color for a pixel. * */ function getColor(uint256 tokenId) public view returns (uint256) { return pixelColor[tokenId]; } /** * @notice Get owned tokens for a user. * * @dev offset based pagination */ function getTokensByOwner( address owner, uint256 limit, uint256 offset ) external view returns (uint256[] memory) { if (limit == 0) { return new uint256[](0); } uint256 total = balanceOf(owner); if (offset >= total) { return new uint256[](0); } uint256 left = total - offset; uint256 pageSize = left > limit ? limit : left; uint256[] memory tokens = new uint256[](pageSize); for (uint256 i = 0; i < pageSize; i++) { uint256 tokenIndex = i + offset; tokens[i] = tokenOfOwnerByIndex(owner, tokenIndex); } return tokens; } }
//SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/utils/Multicall.sol"; import "./IHarbergerMarket.sol"; import "./ACLManager.sol"; /** * @dev Market place with Harberger tax. Market attaches one ERC20 contract as currency. */ contract HarbergerMarket is ERC721Enumerable, IHarbergerMarket, Multicall, ACLManager { /** * Global setup total supply and currency address */ /** * @dev Total possible NFTs */ uint256 private _totalSupply = 1000000; /** * @dev ERC20 token used as currency */ ERC20 public currency; /** * State variables for each token */ /** * @dev Record of each token. * @param price Current price. * @param lastTaxCollection Block number of last tax collection. * @param ubiWithdrawn Amount of UBI been withdrawn. * */ struct TokenRecord { uint256 price; uint256 lastTaxCollection; uint256 ubiWithdrawn; } /** * @dev Record for all tokens (tokenId => TokenRecord). */ mapping(uint256 => TokenRecord) public tokenRecord; /** * Tax related global states. */ /** * @dev Global state of tax and treasury. * @param accumulatedUBI Total amount of currency allocated for UBI. * @param accumulatedTreasury Total amount of currency allocated for treasury. * @param treasuryWithdrawn Total amount of treasury been withdrawn. * */ struct TreasuryRecord { uint256 accumulatedUBI; uint256 accumulatedTreasury; uint256 treasuryWithdrawn; } TreasuryRecord public treasuryRecord; /** * @dev Tax configuration of market. */ mapping(ConfigOptions => uint256) public taxConfig; /** * @dev Create Property contract, setup attached currency contract, setup tax rate */ constructor( string memory propertyName_, string memory propertySymbol_, address currencyAddress_, address aclManager_, address marketAdmin_, address treasuryAdmin_ ) ERC721(propertyName_, propertySymbol_) ACLManager(aclManager_, marketAdmin_, treasuryAdmin_) { // initialize currency contract currency = ERC20(currencyAddress_); // default config taxConfig[ConfigOptions.taxRate] = 75; taxConfig[ConfigOptions.treasuryShare] = 500; taxConfig[ConfigOptions.mintTax] = 1000000000000000000; } /** * Override functions */ /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId_) public view virtual override(AccessControl, ERC721Enumerable, IERC165) returns (bool) { return interfaceId_ == type(IHarbergerMarket).interfaceId || super.supportsInterface(interfaceId_); } /** * @dev See {IERC721-transferFrom}. Override to collect tax before transfer. */ function transferFrom( address from_, address to_, uint256 tokenId_ ) public override(ERC721, IERC721) { if (!_isApprovedOrOwner(_msgSender(), tokenId_)) revert Unauthorized(); bool success = _collectTax(tokenId_); if (success) { // proceed with transfer if success _transfer(from_, to_, tokenId_); } else { // default token if not successful _burn(tokenId_); } } /** * @dev See {IERC721-safeTransferFrom}. Override to collect tax before transfer. */ function safeTransferFrom( address from_, address to_, uint256 tokenId_, bytes memory data_ ) public override(ERC721, IERC721) { if (!_isApprovedOrOwner(_msgSender(), tokenId_)) revert Unauthorized(); bool success = _collectTax(tokenId_); if (success) { // proceed with transfer if success _safeTransfer(from_, to_, tokenId_, data_); } else { // default token if not successful _burn(tokenId_); } } /** * @dev See {IERC20-totalSupply}. Always return total possible amount of supply, instead of current token in circulation. */ function totalSupply() public view override returns (uint256) { return _totalSupply; } /** * Admin only */ /// @inheritdoc IHarbergerMarket function setTaxConfig(ConfigOptions option_, uint256 value_) external onlyRole(MARKET_ADMIN) { taxConfig[option_] = value_; emit Config(option_, value_); } /// @inheritdoc IHarbergerMarket function withdrawTreasury(address to) external onlyRole(TREASURY_ADMIN) { uint256 amount = treasuryRecord.accumulatedTreasury - treasuryRecord.treasuryWithdrawn; treasuryRecord.treasuryWithdrawn = treasuryRecord.accumulatedTreasury; currency.transfer(to, amount); } /** * Read and write of token state */ /// @inheritdoc IHarbergerMarket function getPrice(uint256 tokenId_) public view returns (uint256 price) { return _exists(tokenId_) ? _getPrice(tokenId_) : taxConfig[ConfigOptions.mintTax]; } function _getPrice(uint256 tokenId_) internal view returns (uint256 price) { return tokenRecord[tokenId_].price; } /// @inheritdoc IHarbergerMarket function setPrice(uint256 tokenId_, uint256 price_) public { if (!_isApprovedOrOwner(msg.sender, tokenId_)) revert Unauthorized(); if (price_ == _getPrice(tokenId_)) return; bool success = settleTax(tokenId_); if (success) _setPrice(tokenId_, price_); } /// @inheritdoc IHarbergerMarket function getOwner(uint256 tokenId_) public view returns (address owner) { return _exists(tokenId_) ? ownerOf(tokenId_) : address(0); } /// @inheritdoc IHarbergerMarket function bid(uint256 tokenId_, uint256 price_) public { uint256 mintTax = taxConfig[ConfigOptions.mintTax]; if (_exists(tokenId_)) { // skip if already own address owner = ownerOf(tokenId_); if (owner == msg.sender) return; // check price uint256 askPrice = _getPrice(tokenId_); // clear tax bool success = _collectTax(tokenId_); // process with transfer if (success) { // revert if price too low if (price_ < askPrice) revert PriceTooLow(); // if tax fully paid, owner get paid normally currency.transferFrom(msg.sender, owner, askPrice); } else { // if tax not fully paid, token is treated as defaulted and mint tax is collected if (price_ < mintTax) revert PriceTooLow(); currency.transferFrom(msg.sender, address(this), mintTax); _recordTax(tokenId_, msg.sender, mintTax); } _safeTransfer(owner, msg.sender, tokenId_, ""); emit Bid(tokenId_, owner, msg.sender, askPrice); } else { if (tokenId_ > _totalSupply || tokenId_ < 1) revert InvalidTokenId(1, _totalSupply); // if token does not exists yet, or token is defaulted if (price_ < mintTax) revert PriceTooLow(); currency.transferFrom(msg.sender, address(this), mintTax); _recordTax(tokenId_, msg.sender, mintTax); _safeMint(msg.sender, tokenId_); // equal to bidding from address 0 with price 0 emit Bid(tokenId_, address(0), msg.sender, 0); // initialize price _setPrice(tokenId_, price_, msg.sender); } } /** * Tax & UBI */ /// @inheritdoc IHarbergerMarket function getTax(uint256 tokenId_) public view returns (uint256) { if (!_exists(tokenId_)) revert TokenNotExists(); return _getTax(tokenId_); } function _getTax(uint256 tokenId_) internal view returns (uint256) { // `1000` for every `1000` blocks, `10000` for conversion from bps return (getPrice(tokenId_) * taxConfig[ConfigOptions.taxRate] * (block.number - tokenRecord[tokenId_].lastTaxCollection)) / (1000 * 10000); } /// @inheritdoc IHarbergerMarket function evaluateOwnership(uint256 tokenId_) public view returns (uint256 collectable, bool shouldDefault) { uint256 tax = getTax(tokenId_); if (tax > 0) { // calculate collectable amount address taxpayer = ownerOf(tokenId_); uint256 allowance = currency.allowance(taxpayer, address(this)); uint256 balance = currency.balanceOf(taxpayer); uint256 available = allowance < balance ? allowance : balance; if (available >= tax) { // can pay tax fully and do not need to be defaulted return (tax, false); } else { // cannot pay tax fully and need to be defaulted return (available, true); } } else { // not tax needed return (0, false); } } /** * @dev Collect outstanding tax for a given token, put token on tax sale if obligation not met. * * Emits a {Tax} event and a {Price} event (when properties are put on tax sale). */ function _collectTax(uint256 tokenId_) private returns (bool success) { (uint256 collectable, bool shouldDefault) = evaluateOwnership(tokenId_); if (collectable > 0) { // collect and record tax address owner = ownerOf(tokenId_); currency.transferFrom(owner, address(this), collectable); _recordTax(tokenId_, owner, collectable); } return !shouldDefault; } /// @inheritdoc IHarbergerMarket function settleTax(uint256 tokenId_) public returns (bool success) { success = _collectTax(tokenId_); if (!success) _burn(tokenId_); } /** * @dev Update tax record and emit Tax event. */ function _recordTax( uint256 tokenId_, address taxpayer, uint256 amount ) private { uint256 treasuryShare = taxConfig[ConfigOptions.treasuryShare]; // update accumulated ubi treasuryRecord.accumulatedUBI += (amount * (10000 - treasuryShare)) / 10000; // update accumulated treasury treasuryRecord.accumulatedTreasury += (amount * treasuryShare) / 10000; // update tax record tokenRecord[tokenId_].lastTaxCollection = block.number; emit Tax(tokenId_, taxpayer, amount); } /// @inheritdoc IHarbergerMarket function ubiAvailable(uint256 tokenId_) public view returns (uint256) { return treasuryRecord.accumulatedUBI / _totalSupply - tokenRecord[tokenId_].ubiWithdrawn; } /** * @dev Withdraw UBI on given token. */ function withdrawUbi(uint256 tokenId_) external { uint256 ubi = ubiAvailable(tokenId_); if (ubi > 0) { tokenRecord[tokenId_].ubiWithdrawn += ubi; address recipient = ownerOf(tokenId_); currency.transfer(recipient, ubi); emit UBI(tokenId_, recipient, ubi); } } /** * @dev Internel function to set price for a token. */ function _setPrice(uint256 tokenId_, uint256 price_) internal { _setPrice(tokenId_, price_, ownerOf(tokenId_)); } function _setPrice( uint256 tokenId_, uint256 price_, address owner ) internal { // update price in tax record tokenRecord[tokenId_].price = price_; // emit events emit Price(tokenId_, price_, owner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20.sol"; import "./extensions/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * 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 override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom( address sender, address recipient, uint256 amount ) public virtual override returns (bool) { uint256 currentAllowance = _allowances[sender][_msgSender()]; if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance"); unchecked { _approve(sender, _msgSender(), currentAllowance - amount); } } _transfer(sender, recipient, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { uint256 currentAllowance = _allowances[_msgSender()][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(_msgSender(), spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ function _transfer( address sender, address recipient, uint256 amount ) internal virtual { require(sender != address(0), "ERC20: transfer from the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(sender, recipient, amount); uint256 senderBalance = _balances[sender]; require(senderBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[sender] = senderBalance - amount; } _balances[recipient] += amount; emit Transfer(sender, recipient, amount); _afterTokenTransfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual override { super._beforeTokenTransfer(from, to, tokenId); if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Multicall.sol) pragma solidity ^0.8.0; import "./Address.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ abstract contract Multicall { /** * @dev Receives and executes a batch of function calls on this contract. */ function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionDelegateCall(address(this), data[i]); } return results; } }
//SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; /** * @notice ERC721-compatible contract that allows token to be traded under Harberger tax. * @dev Market attaches one ERC20 contract as currency. */ interface IHarbergerMarket is IERC721 { /** * Error types */ /** * @dev Price too low to bid the given token. */ error PriceTooLow(); /** * @dev Sender is not authorized for given operation. */ error Unauthorized(); /** * @dev The give token does not exist and needs to be minted first via bidding. */ error TokenNotExists(); /** * @dev Token id is out of range. * @param min Lower range of possible token id. * @param max Higher range of possible token id. */ error InvalidTokenId(uint256 min, uint256 max); /** * Event types */ /** * @notice A token updated price. * @param tokenId Id of token that updated price. * @param price New price after update. * @param owner Token owner during price update. */ event Price(uint256 indexed tokenId, uint256 price, address indexed owner); /** * @notice Global configuration for tax is updated. * @param option Field of config been updated. * @param value New value after update. */ event Config(ConfigOptions indexed option, uint256 value); /** * @notice Tax is collected for a token. * @param tokenId Id of token that has been taxed. * @param taxpayer user address who has paid the tax. * @param amount Amount of tax been collected. */ event Tax(uint256 indexed tokenId, address indexed taxpayer, uint256 amount); /** * @notice UBI (universal basic income) is withdrawn for a token. * @param tokenId Id of token that UBI has been withdrawn for. * @param recipient user address who got this withdrawn UBI. * @param amount Amount of UBI withdrawn. */ event UBI(uint256 indexed tokenId, address indexed recipient, uint256 amount); /** * @notice A token has been succefully bid. * @param tokenId Id of token that has been bid. * @param from Original owner before bid. * @param to New owner after bid. * @param amount Amount of currency used for bidding. */ event Bid(uint256 indexed tokenId, address indexed from, address indexed to, uint256 amount); /** * @dev Options for global tax configuration. * @param taxRate: Tax rate in bps every 1000 blocks * @param treasuryShare: Share to treasury in bps. * @param mintTax: Tax to mint a token. It should be non-zero to prevent attacker constantly mint, default and mint token again. */ enum ConfigOptions { taxRate, treasuryShare, mintTax } /** * Configuration / Admin */ /** * @notice Update current tax configuration. * @dev ADMIN_ROLE only. * @param option_ Field of config been updated. * @param value_ New value after update. */ function setTaxConfig(ConfigOptions option_, uint256 value_) external; /** * @notice Withdraw all available treasury. * @dev TREASURY_ROLE only. */ function withdrawTreasury(address to) external; /** * Trading */ /** * @notice Returns the current price of a token by id. * @param tokenId_ Id of token been queried. * @return price Current price. */ function getPrice(uint256 tokenId_) external view returns (uint256 price); /** * @notice Set the current price of a token with id. Triggers tax settle first, price is succefully updated after tax is successfully collected. * @dev Only token owner or approved operator. Throw `Unauthorized` or `ERC721: operator query for nonexistent token` error. Emits a {Price} event if update is successful. * @param tokenId_ Id of token been updated. * @param price_ New price to be updated. */ function setPrice(uint256 tokenId_, uint256 price_) external; /** * @notice Returns the current owner of an Harberger property with token id. * @dev If token does not exisit, return address(0) and user can bid the token as usual. * @param tokenId_ Id of token been queried. * @return owner Current owner address. */ function getOwner(uint256 tokenId_) external view returns (address owner); /** * @notice Purchase property with bid higher than current price. If bid price is higher than ask price, only ask price will be deducted. * @dev Clear tax for owner before transfer. * @param tokenId_ Id of token been bid. * @param price_ Bid price. */ function bid(uint256 tokenId_, uint256 price_) external; /** * Tax & UBI */ /** * @notice Calculate outstanding tax for a token. * @param tokenId_ Id of token been queried. * @return amount Current amount of tax that needs to be paid. */ function getTax(uint256 tokenId_) external view returns (uint256 amount); /** * @notice Calculate amount of tax that can be collected, and determine if token should be defaulted. * @param tokenId_ Id of token been queried. * @return collectable Amount of currency that can be collected, considering balance and allowance. * @return shouldDefault Whether current token should be defaulted. */ function evaluateOwnership(uint256 tokenId_) external view returns (uint256 collectable, bool shouldDefault); /** * @notice Collect outstanding tax of a token and default it if needed. * @dev Anyone can trigger this function. It could be desirable for the developer team to trigger it once a while to make sure all tokens meet their tax obligation. * @param tokenId_ Id of token been settled. * @return success Whether tax is fully collected without token been defaulted. */ function settleTax(uint256 tokenId_) external returns (bool success); /** * @notice Amount of UBI available for withdraw on given token. * @param tokenId_ Id of token been queried. * @param amount Amount of UBI available to be collected */ function ubiAvailable(uint256 tokenId_) external view returns (uint256 amount); /** * @notice Withdraw all UBI on given token. * @param tokenId_ Id of token been withdrawn. */ function withdrawUbi(uint256 tokenId_) external; }
//SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.11; import "@openzeppelin/contracts/access/AccessControl.sol"; /** * @notice Access Control List Manager for HarbergerMarket contract. * @dev There are 3 roles: * - DEFAULT_ADMIN_ROLE: default admin in OpenZeppelin AccessControl module, responsible for assigning and revoking roles of other addresses * - MARKET_ADMIN: responsible for updating tax related configuration, e.g. tax rate and treasury rate. * - TREASURY_ADMIN: responsible for withdrawing treasury from contract. */ contract ACLManager is AccessControl { bytes32 public constant TREASURY_ADMIN = keccak256("TREASURY_ADMIN"); bytes32 public constant MARKET_ADMIN = keccak256("MARKET_ADMIN"); constructor( address aclManager_, address marketAdmin_, address treasuryAdmin_ ) { require(aclManager_ != address(0), "zero address"); // default admin to control other roles _setupRole(DEFAULT_ADMIN_ROLE, aclManager_); _setupRole(MARKET_ADMIN, marketAdmin_); _setupRole(TREASURY_ADMIN, treasuryAdmin_); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ 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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.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}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => 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 override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(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 overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @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. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - 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, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * 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 virtual { _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); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @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 virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), 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 virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * 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 * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * 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 Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns 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); /** * @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; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./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); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
{ "remappings": [ "@openzeppelin/=lib/openzeppelin-contracts/", "ds-test/=lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "src/=src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london" }
[{"inputs":[{"internalType":"address","name":"currencyAddress_","type":"address"},{"internalType":"address","name":"aclManager_","type":"address"},{"internalType":"address","name":"marketAdmin_","type":"address"},{"internalType":"address","name":"treasuryAdmin_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"min","type":"uint256"},{"internalType":"uint256","name":"max","type":"uint256"}],"name":"InvalidTokenId","type":"error"},{"inputs":[],"name":"PriceTooLow","type":"error"},{"inputs":[],"name":"TokenNotExists","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Bid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"pixelId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"color","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"Color","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum IHarbergerMarket.ConfigOptions","name":"option","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Config","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"Price","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"taxpayer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Tax","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"UBI","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MARKET_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TREASURY_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"uint256","name":"price_","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currency","outputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"evaluateOwnership","outputs":[{"internalType":"uint256","name":"collectable","type":"uint256"},{"internalType":"bool","name":"shouldDefault","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getColor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"getOwner","outputs":[{"internalType":"address","name":"owner","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"getPixel","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"lastTaxCollection","type":"uint256"},{"internalType":"uint256","name":"ubi","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"color","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"getTax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"limit","type":"uint256"},{"internalType":"uint256","name":"offset","type":"uint256"}],"name":"getTokensByOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"pixelColor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"color","type":"uint256"}],"name":"setColor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"uint256","name":"bid_","type":"uint256"},{"internalType":"uint256","name":"price_","type":"uint256"},{"internalType":"uint256","name":"color_","type":"uint256"}],"name":"setPixel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"},{"internalType":"uint256","name":"price_","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum IHarbergerMarket.ConfigOptions","name":"option_","type":"uint8"},{"internalType":"uint256","name":"value_","type":"uint256"}],"name":"setTaxConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"settleTax","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId_","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum IHarbergerMarket.ConfigOptions","name":"","type":"uint8"}],"name":"taxConfig","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenRecord","outputs":[{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"lastTaxCollection","type":"uint256"},{"internalType":"uint256","name":"ubiWithdrawn","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from_","type":"address"},{"internalType":"address","name":"to_","type":"address"},{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryRecord","outputs":[{"internalType":"uint256","name":"accumulatedUBI","type":"uint256"},{"internalType":"uint256","name":"accumulatedTreasury","type":"uint256"},{"internalType":"uint256","name":"treasuryWithdrawn","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"ubiAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"}],"name":"withdrawTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId_","type":"uint256"}],"name":"withdrawUbi","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
6080604052620f4240600b553480156200001857600080fd5b5060405162003856380380620038568339810160408190526200003b9162000387565b60405180604001604052806006815260200165506c616e636b60d01b81525060405180604001604052806003815260200162504c4b60e81b815250858585858282828888816000908051906020019062000097929190620002c4565b508051620000ad906001906020840190620002c4565b5050506001600160a01b038316620000fa5760405162461bcd60e51b815260206004820152600c60248201526b7a65726f206164647265737360a01b604482015260640160405180910390fd5b6200010760008462000210565b620001337f07f0a275418c306f0387154a78b34319faf760726ea38247d69f21825e8947a68362000210565b6200015f7f27f406f19fd1b378cfb619bc553f0cd86d17e85e38ecad46997fb68ad17b73078262000210565b5050600c80546001600160a01b0319166001600160a01b039690961695909517909455505060116020525050604b7f4ad3b33220dddc71b994a52d72c06b10862965f7d926534c05c00fb7e819e7b75550506101f47f17bc176d2408558f6e4111feebc3cab4e16b63e967be91cde721f4c8a488b55255505060026000525050670de0b6b3a76400007f08037d7b151cc412d25674a4e66b334d9ae9d2e5517a7feaae5cdb828bf1c6285562000420565b6200021c828262000220565b5050565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff166200021c576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620002803390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b828054620002d290620003e4565b90600052602060002090601f016020900481019282620002f6576000855562000341565b82601f106200031157805160ff191683800117855562000341565b8280016001018555821562000341579182015b828111156200034157825182559160200191906001019062000324565b506200034f92915062000353565b5090565b5b808211156200034f576000815560010162000354565b80516001600160a01b03811681146200038257600080fd5b919050565b600080600080608085870312156200039e57600080fd5b620003a9856200036a565b9350620003b9602086016200036a565b9250620003c9604086016200036a565b9150620003d9606086016200036a565b905092959194509250565b600181811c90821680620003f957607f821691505b6020821081036200041a57634e487b7160e01b600052602260045260246000fd5b50919050565b61342680620004306000396000f3fe608060405234801561001057600080fd5b506004361061028a5760003560e01c80638ec8c5041161015c578063cf3a421f116100ce578063e985e9c511610087578063e985e9c51461069f578063ecaf822a146106db578063ee1ef07e146106ee578063f7d9757714610701578063f86c9e9a14610714578063ff1644d81461072757600080fd5b8063cf3a421f146105fe578063d547741f14610626578063e26c523c14610639578063e5a6b10f14610659578063e75722301461066c578063e7d6fbbf1461067f57600080fd5b8063a314fb1611610120578063a314fb1614610535578063ac9650d81461055c578063b4f80eb91461057c578063b88d4fde146105c5578063c41a360a146105d8578063c87b56dd146105eb57600080fd5b80638ec8c504146104ec57806391d14854146104ff57806395d89b4114610512578063a217fddf1461051a578063a22cb4651461052257600080fd5b80632f2ff15d11610200578063598647f8116101b9578063598647f81461043d5780635d474404146104505780636352211e1461047f57806370a0823114610492578063769ac726146104a557806380057b9a146104cc57600080fd5b80632f2ff15d146103b15780632f745c59146103c457806336568abe146103d757806342842e0e146103ea5780634d7c7dc7146103fd5780634f6ccce71461042a57600080fd5b806310ac4e741161025257806310ac4e741461032d57806318160ddd146103405780631d8d0f481461034857806323b872dd14610368578063242d81cd1461037b578063248a9ca31461038e57600080fd5b806301ffc9a71461028f57806306fdde03146102b7578063081812fc146102cc578063095ea7b3146102f7578063099da37f1461030c575b600080fd5b6102a261029d366004612bc3565b61073a565b60405190151581526020015b60405180910390f35b6102bf610765565b6040516102ae9190612c38565b6102df6102da366004612c4b565b6107f7565b6040516001600160a01b0390911681526020016102ae565b61030a610305366004612c7b565b610884565b005b61031f61031a366004612c4b565b610999565b6040519081526020016102ae565b61031f61033b366004612c4b565b6109c9565b600b5461031f565b61031f610356366004612c4b565b60126020526000908152604090205481565b61030a610376366004612ca5565b6109f5565b61030a610389366004612ce1565b610a4d565b61031f61039c366004612c4b565b6000908152600a602052604090206001015490565b61030a6103bf366004612d03565b610ac8565b61031f6103d2366004612c7b565b610aee565b61030a6103e5366004612d03565b610b84565b61030a6103f8366004612ca5565b610c02565b600e54600f5460105461040f92919083565b604080519384526020840192909252908201526060016102ae565b61031f610438366004612c4b565b610c1d565b61030a61044b366004612ce1565b610cb0565b61040f61045e366004612c4b565b600d6020526000908152604090208054600182015460029092015490919083565b6102df61048d366004612c4b565b61100f565b61031f6104a0366004612d2f565b611086565b61031f7f27f406f19fd1b378cfb619bc553f0cd86d17e85e38ecad46997fb68ad17b730781565b61031f6104da366004612c4b565b60009081526012602052604090205490565b6102a26104fa366004612c4b565b61110d565b6102a261050d366004612d03565b61112d565b6102bf611158565b61031f600081565b61030a610530366004612d58565b611167565b61031f7f07f0a275418c306f0387154a78b34319faf760726ea38247d69f21825e8947a681565b61056f61056a366004612d8f565b611172565b6040516102ae9190612e04565b61058f61058a366004612c4b565b611267565b6040805196875260208701959095529385019290925260608401526001600160a01b0316608083015260a082015260c0016102ae565b61030a6105d3366004612e7c565b6112be565b6102df6105e6366004612c4b565b611318565b6102bf6105f9366004612c4b565b611337565b61061161060c366004612c4b565b61140f565b604080519283529015156020830152016102ae565b61030a610634366004612d03565b611563565b61064c610647366004612f58565b611589565b6040516102ae9190612f8b565b600c546102df906001600160a01b031681565b61031f61067a366004612c4b565b611699565b61031f61068d366004612fde565b60116020526000908152604090205481565b6102a26106ad366004612ff9565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61030a6106e9366004613023565b6116ed565b61030a6106fc366004612c4b565b61179b565b61030a61070f366004612ce1565b6118a3565b61030a610722366004612d2f565b6118ff565b61030a61073536600461303f565b6119bb565b60006001600160e01b03198216632f0ca06b60e01b148061075f575061075f826119d9565b92915050565b60606000805461077490613071565b80601f01602080910402602001604051908101604052809291908181526020018280546107a090613071565b80156107ed5780601f106107c2576101008083540402835291602001916107ed565b820191906000526020600020905b8154815290600101906020018083116107d057829003601f168201915b5050505050905090565b6000610802826119fe565b6108685760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b60648201526084015b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061088f8261100f565b9050806001600160a01b0316836001600160a01b0316036108fc5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b606482015260840161085f565b336001600160a01b0382161480610918575061091881336106ad565b61098a5760405162461bcd60e51b815260206004820152603860248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760448201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606482015260840161085f565b6109948383611a1b565b505050565b60006109a4826119fe565b6109c057604051626f708760e21b815260040160405180910390fd5b61075f82611a89565b6000818152600d6020526040812060020154600b54600e546109eb91906130d7565b61075f91906130eb565b6109ff3382611afc565b610a1b576040516282b42960e81b815260040160405180910390fd5b6000610a2682611be6565b90508015610a3e57610a39848484611c98565b610a47565b610a4782611e3f565b50505050565b610a573383611afc565b610a73576040516282b42960e81b815260040160405180910390fd5b6000828152601260205260409020819055610a8d8261100f565b6001600160a01b031681837f8da7074ffa2c919782faaf9705c7edfe7f814551a91b91aed83ee2ef5ac6af2760405160405180910390a45050565b6000828152600a6020526040902060010154610ae48133611ee6565b6109948383611f4a565b6000610af983611086565b8210610b5b5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b606482015260840161085f565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6001600160a01b0381163314610bf45760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161085f565b610bfe8282611fd0565b5050565b610994838383604051806020016040528060008152506112be565b6000610c2860085490565b8210610c8b5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b606482015260840161085f565b60088281548110610c9e57610c9e613102565b90600052602060002001549050919050565b600260005260116020527f08037d7b151cc412d25674a4e66b334d9ae9d2e5517a7feaae5cdb828bf1c62854610ce5836119fe565b15610ee1576000610cf58461100f565b9050336001600160a01b03821603610d0d5750505050565b6000848152600d602052604081205490610d2686611be6565b90508015610dcc5781851015610d4f57604051636dddf41160e11b815260040160405180910390fd5b600c546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90610d839033908790879060040161312e565b6020604051808303816000875af1158015610da2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dc69190613152565b50610e70565b83851015610ded57604051636dddf41160e11b815260040160405180910390fd5b600c546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90610e219033903090899060040161312e565b6020604051808303816000875af1158015610e40573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e649190613152565b50610e70863386612037565b610e8b8333886040518060200160405280600081525061212c565b336001600160a01b0316836001600160a01b0316877ff828f9266a867e728bd505090b4db2d33e1935c90d43a9fe0a6906eaf30bc48b85604051610ed191815260200190565b60405180910390a4505050505050565b600b54831180610ef15750600183105b15610f1d57600b5460405163168a450960e21b815260016004820152602481019190915260440161085f565b80821015610f3e57604051636dddf41160e11b815260040160405180910390fd5b600c546040516323b872dd60e01b81526001600160a01b03909116906323b872dd90610f729033903090869060040161312e565b6020604051808303816000875af1158015610f91573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb59190613152565b50610fc1833383612037565b610fcb338461215f565b6040516000808252339185907ff828f9266a867e728bd505090b4db2d33e1935c90d43a9fe0a6906eaf30bc48b9060200160405180910390a4610994838333612179565b6000818152600260205260408120546001600160a01b03168061075f5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b606482015260840161085f565b60006001600160a01b0382166110f15760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b606482015260840161085f565b506001600160a01b031660009081526003602052604090205490565b600061111882611be6565b9050806111285761112882611e3f565b919050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b60606001805461077490613071565b610bfe3383836121c9565b60608167ffffffffffffffff81111561118d5761118d612e66565b6040519080825280602002602001820160405280156111c057816020015b60608152602001906001900390816111ab5790505b50905060005b8281101561126057611230308585848181106111e4576111e4613102565b90506020028101906111f6919061316f565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061228f92505050565b82828151811061124257611242613102565b60200260200101819052508080611258906131bd565b9150506111c6565b5092915050565b6000818152600d602052604081208054600190910154829182918291829182918891611292836109c9565b61129b8b611318565b60009b8c5260126020526040909b2054939b929a91995097509550909350915050565b6112c83383611afc565b6112e4576040516282b42960e81b815260040160405180910390fd5b60006112ef83611be6565b90508015611308576113038585858561212c565b611311565b61131183611e3f565b5050505050565b6000611323826119fe565b61132e57600061075f565b61075f8261100f565b6060611342826119fe565b6113a65760405162461bcd60e51b815260206004820152602f60248201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60448201526e3732bc34b9ba32b73a103a37b5b2b760891b606482015260840161085f565b60006113bd60408051602081019091526000815290565b905060008151116113dd5760405180602001604052806000815250611408565b806113e7846122b4565b6040516020016113f89291906131d6565b6040516020818303038152906040525b9392505050565b600080600061141d84610999565b905080156115575760006114308561100f565b600c54604051636eb1769f60e11b81526001600160a01b0380841660048301523060248301529293506000929091169063dd62ed3e90604401602060405180830381865afa158015611486573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114aa9190613205565b600c546040516370a0823160e01b81526001600160a01b038581166004830152929350600092909116906370a0823190602401602060405180830381865afa1580156114fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151e9190613205565b9050600081831061152f5781611531565b825b90508481106115495750929660009650945050505050565b976001975095505050505050565b50600093849350915050565b6000828152600a602052604090206001015461157f8133611ee6565b6109948383611fd0565b6060826000036115a85750604080516000815260208101909152611408565b60006115b385611086565b90508083106115d2575050604080516000815260208101909152611408565b60006115de84836130eb565b905060008582116115ef57816115f1565b855b905060008167ffffffffffffffff81111561160e5761160e612e66565b604051908082528060200260200182016040528015611637578160200160208202803683370190505b50905060005b8281101561168d576000611651888361321e565b905061165d8a82610aee565b83838151811061166f5761166f613102565b60209081029190910101525080611685816131bd565b91505061163d565b50979650505050505050565b60006116a4826119fe565b6116d957600260005260116020527f08037d7b151cc412d25674a4e66b334d9ae9d2e5517a7feaae5cdb828bf1c6285461075f565b6000828152600d602052604090205461075f565b7f07f0a275418c306f0387154a78b34319faf760726ea38247d69f21825e8947a66117188133611ee6565b816011600085600281111561172f5761172f613118565b600281111561174057611740613118565b815260208101919091526040016000205582600281111561176357611763613118565b6040518381527f90e64b63a2c952a97e60fcb9bdb464e5e76d2920683504331028687f0cd6643b9060200160405180910390a2505050565b60006117a6826109c9565b90508015610bfe576000828152600d6020526040812060020180548392906117cf90849061321e565b90915550600090506117e08361100f565b600c5460405163a9059cbb60e01b81526001600160a01b0380841660048301526024820186905292935091169063a9059cbb906044016020604051808303816000875af1158015611835573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118599190613152565b50806001600160a01b0316837fa760fe80056c46d089c37a35d9dbe762141a463ae0eb8235522d27ab9595286d8460405161189691815260200190565b60405180910390a3505050565b6118ad3383611afc565b6118c9576040516282b42960e81b815260040160405180910390fd5b6000828152600d602052604090205481036118e2575050565b60006118ed8361110d565b905080156109945761099483836123b5565b7f27f406f19fd1b378cfb619bc553f0cd86d17e85e38ecad46997fb68ad17b730761192a8133611ee6565b601054600f5460009161193c916130eb565b600f54601055600c5460405163a9059cbb60e01b81526001600160a01b0386811660048301526024820184905292935091169063a9059cbb906044016020604051808303816000875af1158015611997573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a479190613152565b6119c58484610cb0565b6119cf84836118a3565b610a478482610a4d565b60006001600160e01b03198216637965db0b60e01b148061075f575061075f826123c8565b6000908152600260205260409020546001600160a01b0316151590565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611a508261100f565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000818152600d60205260408120600101546298968090611aaa90436130eb565b6000805260116020527f4ad3b33220dddc71b994a52d72c06b10862965f7d926534c05c00fb7e819e7b754611ade85611699565b611ae89190613236565b611af29190613236565b61075f91906130d7565b6000611b07826119fe565b611b685760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b606482015260840161085f565b6000611b738361100f565b9050806001600160a01b0316846001600160a01b03161480611bae5750836001600160a01b0316611ba3846107f7565b6001600160a01b0316145b80611bde57506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b949350505050565b6000806000611bf48461140f565b90925090508115611c90576000611c0a8561100f565b600c546040516323b872dd60e01b81529192506001600160a01b0316906323b872dd90611c3f9084903090889060040161312e565b6020604051808303816000875af1158015611c5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c829190613152565b50611c8e858285612037565b505b159392505050565b826001600160a01b0316611cab8261100f565b6001600160a01b031614611d0f5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b606482015260840161085f565b6001600160a01b038216611d715760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b606482015260840161085f565b611d7c8383836123ed565b611d87600082611a1b565b6001600160a01b0383166000908152600360205260408120805460019290611db09084906130eb565b90915550506001600160a01b0382166000908152600360205260408120805460019290611dde90849061321e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611e4a8261100f565b9050611e58816000846123ed565b611e63600083611a1b565b6001600160a01b0381166000908152600360205260408120805460019290611e8c9084906130eb565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b611ef0828261112d565b610bfe57611f08816001600160a01b031660146124a5565b611f138360206124a5565b604051602001611f24929190613255565b60408051601f198184030181529082905262461bcd60e51b825261085f91600401612c38565b611f54828261112d565b610bfe576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055611f8c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611fda828261112d565b15610bfe576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600160005260116020527f17bc176d2408558f6e4111feebc3cab4e16b63e967be91cde721f4c8a488b5525461271061207082826130eb565b61207a9084613236565b61208491906130d7565b600e805460009061209690849061321e565b9091555061271090506120a98284613236565b6120b391906130d7565b600f80546000906120c590849061321e565b90915550506000848152600d60205260409081902043600190910155516001600160a01b0384169085907fc5790222911f43ca7d78c4f5ef5cb5a21d7fda4d923d433b80e7db9c295de88a9061211e9086815260200190565b60405180910390a350505050565b612137848484611c98565b61214384848484612641565b610a475760405162461bcd60e51b815260040161085f906132ca565b610bfe828260405180602001604052806000815250612742565b6000838152600d602052604090819020839055516001600160a01b0382169084907f75a0543aefc16d03b25751bdf0b5a2fbbec05c6436fd60b038d40f5b7d1def83906118969086815260200190565b816001600160a01b0316836001600160a01b03160361222a5760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604482015260640161085f565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319101611896565b606061140883836040518060600160405280602781526020016133ca60279139612775565b6060816000036122db5750506040805180820190915260018152600360fc1b602082015290565b8160005b811561230557806122ef816131bd565b91506122fe9050600a836130d7565b91506122df565b60008167ffffffffffffffff81111561232057612320612e66565b6040519080825280601f01601f19166020018201604052801561234a576020820181803683370190505b5090505b8415611bde5761235f6001836130eb565b915061236c600a8661331c565b61237790603061321e565b60f81b81838151811061238c5761238c613102565b60200101906001600160f81b031916908160001a9053506123ae600a866130d7565b945061234e565b610bfe82826123c38561100f565b612179565b60006001600160e01b0319821663780e9d6360e01b148061075f575061075f82612852565b6001600160a01b0383166124485761244381600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b61246b565b816001600160a01b0316836001600160a01b03161461246b5761246b83826128a2565b6001600160a01b038216612482576109948161293f565b826001600160a01b0316826001600160a01b0316146109945761099482826129ee565b606060006124b4836002613236565b6124bf90600261321e565b67ffffffffffffffff8111156124d7576124d7612e66565b6040519080825280601f01601f191660200182016040528015612501576020820181803683370190505b509050600360fc1b8160008151811061251c5761251c613102565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061254b5761254b613102565b60200101906001600160f81b031916908160001a905350600061256f846002613236565b61257a90600161321e565b90505b60018111156125f2576f181899199a1a9b1b9c1cb0b131b232b360811b85600f16601081106125ae576125ae613102565b1a60f81b8282815181106125c4576125c4613102565b60200101906001600160f81b031916908160001a90535060049490941c936125eb81613330565b905061257d565b5083156114085760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161085f565b60006001600160a01b0384163b1561273757604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612685903390899088908890600401613347565b6020604051808303816000875af19250505080156126c0575060408051601f3d908101601f191682019092526126bd9181019061337a565b60015b61271d573d8080156126ee576040519150601f19603f3d011682016040523d82523d6000602084013e6126f3565b606091505b5080516000036127155760405162461bcd60e51b815260040161085f906132ca565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611bde565b506001949350505050565b61274c8383612a32565b6127596000848484612641565b6109945760405162461bcd60e51b815260040161085f906132ca565b60606001600160a01b0384163b6127dd5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b606482015260840161085f565b600080856001600160a01b0316856040516127f89190613397565b600060405180830381855af49150503d8060008114612833576040519150601f19603f3d011682016040523d82523d6000602084013e612838565b606091505b5091509150612848828286612b71565b9695505050505050565b60006001600160e01b031982166380ac58cd60e01b148061288357506001600160e01b03198216635b5e139f60e01b145b8061075f57506301ffc9a760e01b6001600160e01b031983161461075f565b600060016128af84611086565b6128b991906130eb565b60008381526007602052604090205490915080821461290c576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b600854600090612951906001906130eb565b6000838152600960205260408120546008805493945090928490811061297957612979613102565b90600052602060002001549050806008838154811061299a5761299a613102565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806129d2576129d26133b3565b6001900381819060005260206000200160009055905550505050565b60006129f983611086565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160a01b038216612a885760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604482015260640161085f565b612a91816119fe565b15612ade5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604482015260640161085f565b612aea600083836123ed565b6001600160a01b0382166000908152600360205260408120805460019290612b1390849061321e565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b60608315612b80575081611408565b825115612b905782518084602001fd5b8160405162461bcd60e51b815260040161085f9190612c38565b6001600160e01b031981168114612bc057600080fd5b50565b600060208284031215612bd557600080fd5b813561140881612baa565b60005b83811015612bfb578181015183820152602001612be3565b83811115610a475750506000910152565b60008151808452612c24816020860160208601612be0565b601f01601f19169290920160200192915050565b6020815260006114086020830184612c0c565b600060208284031215612c5d57600080fd5b5035919050565b80356001600160a01b038116811461112857600080fd5b60008060408385031215612c8e57600080fd5b612c9783612c64565b946020939093013593505050565b600080600060608486031215612cba57600080fd5b612cc384612c64565b9250612cd160208501612c64565b9150604084013590509250925092565b60008060408385031215612cf457600080fd5b50508035926020909101359150565b60008060408385031215612d1657600080fd5b82359150612d2660208401612c64565b90509250929050565b600060208284031215612d4157600080fd5b61140882612c64565b8015158114612bc057600080fd5b60008060408385031215612d6b57600080fd5b612d7483612c64565b91506020830135612d8481612d4a565b809150509250929050565b60008060208385031215612da257600080fd5b823567ffffffffffffffff80821115612dba57600080fd5b818501915085601f830112612dce57600080fd5b813581811115612ddd57600080fd5b8660208260051b8501011115612df257600080fd5b60209290920196919550909350505050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015612e5957603f19888603018452612e47858351612c0c565b94509285019290850190600101612e2b565b5092979650505050505050565b634e487b7160e01b600052604160045260246000fd5b60008060008060808587031215612e9257600080fd5b612e9b85612c64565b9350612ea960208601612c64565b925060408501359150606085013567ffffffffffffffff80821115612ecd57600080fd5b818701915087601f830112612ee157600080fd5b813581811115612ef357612ef3612e66565b604051601f8201601f19908116603f01168101908382118183101715612f1b57612f1b612e66565b816040528281528a6020848701011115612f3457600080fd5b82602086016020830137600060208483010152809550505050505092959194509250565b600080600060608486031215612f6d57600080fd5b612f7684612c64565b95602085013595506040909401359392505050565b6020808252825182820181905260009190848201906040850190845b81811015612fc357835183529284019291840191600101612fa7565b50909695505050505050565b80356003811061112857600080fd5b600060208284031215612ff057600080fd5b61140882612fcf565b6000806040838503121561300c57600080fd5b61301583612c64565b9150612d2660208401612c64565b6000806040838503121561303657600080fd5b612c9783612fcf565b6000806000806080858703121561305557600080fd5b5050823594602084013594506040840135936060013592509050565b600181811c9082168061308557607f821691505b6020821081036130a557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000826130e6576130e66130ab565b500490565b6000828210156130fd576130fd6130c1565b500390565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052602160045260246000fd5b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006020828403121561316457600080fd5b815161140881612d4a565b6000808335601e1984360301811261318657600080fd5b83018035915067ffffffffffffffff8211156131a157600080fd5b6020019150368190038213156131b657600080fd5b9250929050565b6000600182016131cf576131cf6130c1565b5060010190565b600083516131e8818460208801612be0565b8351908301906131fc818360208801612be0565b01949350505050565b60006020828403121561321757600080fd5b5051919050565b60008219821115613231576132316130c1565b500190565b6000816000190483118215151615613250576132506130c1565b500290565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161328d816017850160208801612be0565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516132be816028840160208801612be0565b01602801949350505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008261332b5761332b6130ab565b500690565b60008161333f5761333f6130c1565b506000190190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061284890830184612c0c565b60006020828403121561338c57600080fd5b815161140881612baa565b600082516133a9818460208701612be0565b9190910192915050565b634e487b7160e01b600052603160045260246000fdfe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220ef7cc0f790572353dd7652c99fad7ea809cee9f7871f806db3a910799d1594b564736f6c634300080d0033000000000000000000000000eb6814043dc2184b0b321f6de995bf11bdbcc5b800000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc300000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc300000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc3
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000eb6814043dc2184b0b321f6de995bf11bdbcc5b800000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc300000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc300000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc3
-----Decoded View---------------
Arg [0] : currencyAddress_ (address): 0xeb6814043dc2184b0b321f6de995bf11bdbcc5b8
Arg [1] : aclManager_ (address): 0x31e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc3
Arg [2] : marketAdmin_ (address): 0x31e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc3
Arg [3] : treasuryAdmin_ (address): 0x31e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc3
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000eb6814043dc2184b0b321f6de995bf11bdbcc5b8
Arg [1] : 00000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc3
Arg [2] : 00000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc3
Arg [3] : 00000000000000000000000031e0afda9e1ece2468bbcb2fb24b24ef1cb9cdc3