Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
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 Source Code Verified (Exact Match)
Contract Name:
Collection
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.20; /** * █████ ╨████████▀ ▌██████▌┌──└▌█████ █████ * ▐▀█████ ╫█████ █████ ╙████▌ ▄▀█████ * ▀ █████▌ ╟████ █████ █████ ⌐ █████▄ * ▌ █████ ╟████ █████ █████ ▌ █████ * ╫ █████ ╟████ █████ ▄████ ▌ █████ * ╓─ ▀█████ ╟████ █████╥╥╥╥╥▄███ ▐ ▓█████ * ▌ █████▄ ╟████ █████ ─█████ ▀ █████▄ * ▓ █████ ╟████ █████ █████ ▓ █████ * ▄ █████ ╟████ ▓▌ █████ █████▌ ╫ └█████ * ╓▌ ██████ ╟████ █▌ █████ █████▀ ╓▀ ██████ * ╓█ █████▄ ╟████ ███▌ █████ █████ ▄█ █████▄ * ,█████▌ ,███████ ▄██████▄ ,█████▌ ███████ █████╨ ,█████▌ ,███████ * └└└└└└└└ └└└└└└└└└└ └└└└└└└└└└┌─┌└└└└└└└ └└└└└└└└└└──└└─ └└└└└└└─ └└└└└└└└└└ */ import {AccessControlEnumerable} from "openzeppelin-contracts/access/AccessControlEnumerable.sol"; import {Ownable} from "openzeppelin-contracts/access/Ownable.sol"; import {ERC721AUpgradeable} from "erc721a/ERC721AUpgradeable.sol"; import {ECDSA} from "openzeppelin-contracts/utils/cryptography/ECDSA.sol"; import {Initializable} from "openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol"; import {IERC2981} from "openzeppelin-contracts/interfaces/IERC2981.sol"; import {IAlbaDelegate} from "./IAlbaDelegate.sol"; import {IPaymentSplitter} from "./IPaymentSplitter.sol"; import {CollectionConfig, SaleConfig, PaymentConfig, SaleType} from "./Types.sol"; import {AlbaCollectionPricing} from "./libraries/Pricing.sol"; import {Splitters} from "./libraries/Splitters.sol"; interface CollectionEvents { event SaleFinished(); event RebateClaimed(address claimer, address recipient, uint256 amount); event PaymentFlushed(uint256 amount); event MaxSalePiecesReduced(uint256 newMax); event SaleConfigChanged(SaleConfig newConfig); event ReservesReleased(); event AlbaEjected(); } /** * @title Collection * @notice The Alba Collection contract. * @dev This contract uses `ERC721AUpgradeable`, but that is because it is deployed as a minimal proxy * to a base collection for implementation. This contract itself is *not* upgradeable. */ contract Collection is Initializable, CollectionEvents, ERC721AUpgradeable, Ownable, AccessControlEnumerable { bytes32 public constant ROLE_MANAGER = keccak256("ROLE_MANAGER"); bytes32 public constant ROLE_ARTIST = keccak256("ROLE_ARTIST"); // Differentiate signature type uint8 private constant SIG_TYPE_RESERVED = 0xFF; uint256 public constant MIN_REDUCE_BUFFER = 7 days; error InvalidConfiguration(); error InvalidPayment(); error TooManyMintsRequested(); error InsufficientTokensRemanining(); error SaleNotActive(); error NoRebateAvailable(); error UnknownToken(); error Unauthorized(); error InvalidRoyaltyPercentage(); error PaymentFailed(); error AuctionStillActive(); IAlbaDelegate public albaDelegate; SaleConfig public saleConfig; CollectionConfig public collectionConfig; // Location of primary sale payment splitter. IPaymentSplitter public paymentSplitter; // Location of secondary sale payment splitter. IPaymentSplitter public paymentSplitterRoyalties; // Basis points for royalty payments. uint16 public royaltyBasisPoints; // Override for token URI. Allows artists to set a custom URI if needed. string public tokenURIOverride; /* Mint mechanics */ // Flag to indicate that the sale has been closed. // This is different to selling out or the auction ending. // It is only used when the sale is explcitly closed by the artist. bool public isSaleClosed; // Keeps track of the number of reserved tokens minted (keyed by message hash) mapping(bytes32 => uint256) private numReserveMintedFrom; // Tracks the total number of reserve mints to ensure we don't mint more than the max. // This allows us to overallocate reserves if we want to. uint32 public numReservedMinted; // Tracks the number of retained tokens minted by the artist. uint16 public numRetainedMinted; // Tracks the number of Alba pieces minted. uint16 public numAlbaMinted; /* Auction specific properties */ // Final price used for rebates. uint256 public finalSalePrice; // Number of _potential_ 'rebate mints' i.e. mints which might be eligible for a rebate. uint256 private numRebateMints; // Purchase prices used to compute rebates. mapping(address => uint256[]) public mintPrices; // Expose a general mapping for metadata. This can be used to store arbitrary information // about the collection which should be preserved on-chain, such as the browser info, // licences, gallery details, etc. For flexibility we intentionally leave this unrestricted and // rely on conventions defined by Alba for the shape of this data. mapping(string => string) public metadata; // Modifiers modifier tokenExists(uint256 tokenId) { if (!_exists(tokenId)) revert UnknownToken(); _; } // Access control modifiers modifier managerOrArtist() { if (!hasRole(ROLE_MANAGER, msg.sender) && !hasRole(ROLE_ARTIST, msg.sender)) revert Unauthorized(); _; } modifier onlyAlbaReceiver() { if (msg.sender != albaDelegate.getAlbaFeeReceiver()) revert Unauthorized(); _; } // Auction time modifiers modifier mintingActive() { if (isSaleClosed || block.timestamp < saleConfig.startTime) revert SaleNotActive(); _; } modifier afterAuction() { if (block.timestamp < saleConfig.auctionEndTime) revert AuctionStillActive(); _; } function initialize( IAlbaDelegate _albaDelegate, CollectionConfig calldata _config, SaleConfig calldata _saleConfig, PaymentConfig calldata _paymentConfig, address albaManager, address[] calldata artists ) public initializerERC721A initializer { uint256 numArtists = artists.length; if (numArtists == 0) { revert InvalidConfiguration(); } __ERC721A_init(_config.name, _config.token); _setupRole(DEFAULT_ADMIN_ROLE, albaManager); _setupRole(ROLE_MANAGER, albaManager); for (uint256 i = 0; i < numArtists; i++) { _setupRole(ROLE_ARTIST, artists[i]); } albaDelegate = _albaDelegate; collectionConfig = _config; royaltyBasisPoints = _paymentConfig.royaltyBasisPoints; // Ensure the config is valid before writing it (check relies on comparing old/new) _validateSaleConfig(_saleConfig); saleConfig = _saleConfig; (paymentSplitter, paymentSplitterRoyalties) = Splitters.setupPaymentSplitters(_paymentConfig, _albaDelegate); if (collectionConfig.metadataKeys.length != 0) { writeMetadata(collectionConfig.metadataKeys, collectionConfig.metadataValues); } // Make the artist the owner of the contract. // Note that this leaves in place the manager role for the Alba // platform to continue to manage the contract. This will let // Alba make changes to the contract in the future, such as replacing // the delegate to fix issues or change things like the way on-chain // HTML is built. // To remove Alba's managaer role, see `assumeTotalOwnership`. // Note: The first artist becomes the owner - we could use a multisig contract // but that would make UX for collabs much more difficult. _transferOwnership(artists[0]); } // Minting /** * @notice Mint a number of tokens to a user. * @param collectionId The collection ID. * @param user The user to mint to. * @param num The number of tokens to mint. * @param nonce The nonce to use for the signature. * @param signature The signature to verify. * @dev We use a signature to verify the mints. This gives us an opportunity to * prevent bots. */ function mint(bytes16 collectionId, address user, uint16 num, uint32 nonce, bytes calldata signature) external payable mintingActive { // Max mints do not include reserved mints. uint256 publicMinted = _salePiecesMinted() - numReservedMinted; uint256 publicLimit = saleConfig.maxSalePieces - saleConfig.numReserved; if (publicMinted + num > publicLimit) revert InsufficientTokensRemanining(); albaDelegate.verifyMint(collectionId, user, num, nonce, signature); _mintInternal({user: user, num: num, isReserve: false}); } /** * @notice Mint a number of tokens to a user. * See mint function for params * @dev This is separate from the normal mint function as we don't want to check supply * limits, and no mints can happen after the end time, unlike other sales which stay open. * It uses the same internal function for payments, but we ensure that there can be * no rebate for OE mints in config, so it takes the simple path through the mint function. */ function mintTimeLimited(bytes16 collectionId, address user, uint16 num, uint32 nonce, bytes calldata signature) external payable mintingActive { if (saleConfig.saleType != SaleType.FixedPriceTimeLimited) { revert InvalidConfiguration(); } if (_hasAuctionFinished()) { revert SaleNotActive(); } albaDelegate.verifyMint(collectionId, user, num, nonce, signature); _mintInternal({user: user, num: num, isReserve: false}); } /** * @notice Mint reserved tokens to a user. * @param collectionId The collection ID. * @param user The user to mint to. * @param num The number of tokens to mint. * @param maxMints The maximum number of mints allowed for this user. * @param nonce The nonce to use for the signature. * @param signature The signature to verify. * @dev Reserves are not allowed for TimeLimited sales, but we don't explicitly need to handle them * here as the config shouldn't allow reserves. */ function mintReserved( bytes16 collectionId, address user, uint16 num, uint16 maxMints, uint32 nonce, bytes calldata signature ) external payable mintingActive { // Ensure signature is valid bytes32 message = _reserveMessage(collectionId, user, maxMints, nonce); albaDelegate.verifyMintReserve(message, signature); if (num + numReserveMintedFrom[message] > maxMints) revert TooManyMintsRequested(); if (numReservedMinted + num > saleConfig.numReserved) revert InsufficientTokensRemanining(); if (_salePiecesMinted() + num > saleConfig.maxSalePieces) revert InsufficientTokensRemanining(); // Record how many reserved mints have been made from this address numReserveMintedFrom[message] += num; numReservedMinted += num; _mintInternal({user: user, num: num, isReserve: true}); } /** * @notice Mints tokens for the artist only. * @dev This does not call mintInternal because these mints are completely separate from the sale. * They can happen at any time, cost nothing, and are only limited by the number of tokens * in the configuration. */ function mintRetained(uint16 num) external onlyRole(ROLE_ARTIST) { if (numRetainedMinted + num > saleConfig.numRetained) revert InsufficientTokensRemanining(); numRetainedMinted += num; _mint(msg.sender, num); } /** * @notice Mints the Alba retained piece. * These are special pieces for the Alba gallery, used to share and exhibit the work. * This can be called by Alba, even if the contract is fully owned by the artist. */ function mintAlba(address to, uint16 num) external onlyAlbaReceiver { if (numAlbaMinted + num > saleConfig.numAlba) { revert TooManyMintsRequested(); } numAlbaMinted += num; _mint(to, num); } /** * @dev Internal mint function. * This does the standard checks and records generic information about the sale. * It also controls the auction mechanics. * Callers must verify that the mint signature is valid before using this function. * Any extra money sent for the mints is kept by the contract, though will be returned * as part of the rebate if the rebate is enabled. We do this to avoid issues with * continuous auctions where the price may change between when the transaction is sent and * included in a block. * NOTE: It is important to understand that reserve mints can happen after the _auction_ * has finished. This means that mints _may_ happen after the final price is set. However, * reserve mints cannot _set_ the final price. */ function _mintInternal(address user, uint256 num, bool isReserve) private { uint256 price = getPrice(); uint256 saleTotal = num * price; if (msg.value < saleTotal) { revert InvalidPayment(); } // Rebate logic is complex, so we split it out into a separate function. if (saleConfig.hasRebate) { _mintInternalWithRebate(user, num, isReserve, price, saleTotal); return; } (bool success,) = payable(address(paymentSplitter)).call{value: msg.value}(""); if (!success) revert PaymentFailed(); // Do the mint _mint(user, num); } function _mintInternalWithRebate(address user, uint256 num, bool isReserve, uint256 price, uint256 saleTotal) private { // We don't want to wait for all reserves to mint to 'sell out', as they may be // held for a long time. However, we still treat the mints the same as public ones // (i.e. eligible for rebate if applicable). // TODO: Handle case where Last piece is reserve and sells before resting price reached? if (!isReserve) { uint256 publicMinted = _salePiecesMinted() - numReservedMinted; uint256 publicPieceLimit = saleConfig.maxSalePieces - saleConfig.numReserved; // If the final price is not already set, then set it if we've sold out if (finalSalePrice == 0 && publicMinted + num == publicPieceLimit) { finalSalePrice = price; emit SaleFinished(); } } bool hasOverpaid = msg.value > saleTotal; uint256 overpayDelta = 0; if (hasOverpaid) { overpayDelta = msg.value - saleTotal; } // If the auction has a rebate and the resting price has not been discovered, // record the price paid for each mint. // Record that these mints are 'rebate mints' so we know how much money // to flush later on. if (finalSalePrice == 0 && price > saleConfig.finalPrice) { // If there's an overpayment, which can happen during auctions due to the price changing between tx submit // and it being included in a block, then attach that extra value to the first price for the rebate (which // is guaranteed to be there) // Note: We use msg.sender as the key, as we always allow the minter to claim rebate, rather than the recipient. mintPrices[msg.sender].push(price + overpayDelta); overpayDelta = 0; // Starting from index 1, push any extra prices. for (uint256 i = 1; i < num; i++) { mintPrices[msg.sender].push(price); } numRebateMints += num; } // If there's still an overpay delta, we've hit the case where there's no rebate but there was // an overpayment. This could happen when the auction is over and the final price is set, but // the user has sent more than the final price. In this case, we send the overpayment back to the user. if (overpayDelta > 0) { (bool success,) = payable(msg.sender).call{value: overpayDelta}(""); if (!success) revert PaymentFailed(); } // Send the payment on to the splitter. // If there is a rebate, the value will stay in the contract waiting to be claimed. // However, once the auction is finished, we know that the mint price is always // the final price, so we can send the payment on to the splitter immediately. This // removes the need for having the artist flush the payment more than once, and subsequently // we don't need to keep track of which mints are already accounted for in the flushing // process. // We send the payment directly if: // 1. The final price is not 0 (i.e. the sale has finished) // 2. The price paid is not the final price (i.e. the auction is still ongoing) // 3. The auction has finished - this case ensures we send value after the auction is there's no sellout. if (finalSalePrice != 0 || price == saleConfig.finalPrice || _hasAuctionFinished()) { (bool success,) = payable(address(paymentSplitter)).call{value: saleTotal}(""); if (!success) revert PaymentFailed(); } // Do the mint _mint(user, num); } /** * @notice Returns the number of reserves used by the given user. */ function reservesUsed(bytes16 collectionId, address user, uint16 maxMints, uint32 nonce) external view returns (uint256) { bytes32 message = _reserveMessage(collectionId, user, maxMints, nonce); return numReserveMintedFrom[message]; } /** * @notice Returns the message that is used for reserve mints. * @dev This can be used to verify signatures as well as check the number of mints used. * We prepend a type byte before the collectionID to ensure that we don't have any overlapping * signatures (without this the params may be identical to the public mint signature). This is * in place of the typed signature EIP which we should upgrade to ideally. */ function _reserveMessage(bytes16 collectionId, address user, uint16 maxMints, uint32 nonce) internal view returns (bytes32) { return ECDSA.toEthSignedMessageHash( keccak256(abi.encodePacked(SIG_TYPE_RESERVED, collectionId, user, maxMints, nonce, block.chainid)) ); } // Auction functions /** * @notice Returns the number of pieces that have been minted in the sale. * This exludes the artist 'retained' mints, but does include the reserved mints. */ function _salePiecesMinted() internal view returns (uint256) { return totalSupply() - numRetainedMinted - numAlbaMinted; } /** * @notice Returns true if the auction has finished. * Note that the auction finishing is not the same as the sale finishing. * The auction finishes when the price stops changing, but the sale can * continue after that indefinitely until stopped by the artist. */ function _hasAuctionFinished() internal view returns (bool) { return block.timestamp >= saleConfig.auctionEndTime; } function getPrice() public view returns (uint256) { if (finalSalePrice != 0) { return finalSalePrice; } return AlbaCollectionPricing.getPrice(saleConfig); } /** * @notice Allows users to claim a rebate if applicable. * @dev Rebates are only available if the sale has a rebate, and if: * - The auction period has finished, or * - The sale has finished (sold out). * If the sale has finished, the rebate is calculated based on the final price paid. * otherwise, it's based on the final price of the auction. */ function claimRebate(address payable recipient) external { uint256 totalRebate = getRebateAmount(msg.sender); if (totalRebate == 0) { revert NoRebateAvailable(); } delete (mintPrices[msg.sender]); // External call, ensure rebate is marked as claimed before calling for reentrancy. (bool success,) = recipient.call{value: totalRebate}(""); require(success, "Transfer failed"); emit RebateClaimed(msg.sender, recipient, totalRebate); } /** * @notice Returns the amount of rebate that a user is eligible for. */ function getRebateAmount(address user) public view returns (uint256) { // Auction not over yet and no sellout, means you can't claim yet // as we don't know the final price. if (!_hasAuctionFinished() && finalSalePrice == 0) { return 0; } // We reuse this storage slot to indicate that the rebate has been claimed. if (mintPrices[user].length == 0) { return 0; } uint256 restingPrice = finalSalePrice > 0 ? finalSalePrice : saleConfig.finalPrice; uint256 totalRebate = 0; for (uint256 i = 0; i < mintPrices[user].length; i++) { if (mintPrices[user][i] > restingPrice) { totalRebate += mintPrices[user][i] - restingPrice; } } return totalRebate; } // ERC721 /// @notice Returns the URI for token metadata. function tokenURI(uint256 tokenId) public view override tokenExists(tokenId) returns (string memory) { return albaDelegate.tokenURI(tokenId, collectionConfig.slug, tokenURIOverride); } // ERC165 function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721AUpgradeable, AccessControlEnumerable) returns (bool) { return ERC721AUpgradeable.supportsInterface(interfaceId) || AccessControlEnumerable.supportsInterface(interfaceId) || interfaceId == type(IERC2981).interfaceId; } // ERC2981 + Payments function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) { royaltyAmount = (salePrice / 10000) * royaltyBasisPoints; receiver = payable(address(paymentSplitterRoyalties)); } /** * @notice Returns the amount of payments that can be flushed to the splitter. * Note that this is only applicable for rebate auctions which have finished. */ function flushablePayments() public view returns (uint256) { if (!saleConfig.hasRebate || !_hasAuctionFinished() || numRebateMints == 0) { return 0; } uint256 finalValue = finalSalePrice != 0 ? finalSalePrice : saleConfig.finalPrice; return numRebateMints * finalValue; } // 721 On-chain Extensions /** * @notice Returns the seed of a token. * @dev The seed is computed from the seed of the batch in which the given * token was minted. */ function tokenSeed(uint256 tokenId) public view tokenExists(tokenId) returns (bytes32) { uint24 batchSeed = _ownershipOf(tokenId).extraData; return keccak256(abi.encodePacked(address(this), batchSeed, tokenId)); } /** * @notice Computes a pseudorandom seed for a mint batch. * @dev Even though this process can be gamed in principle, it is extremly * difficult to do so in practise. Therefore we can still rely on this to * derive fair seeds. */ function _computeBatchSeed(address to) private view returns (uint24) { return uint24( bytes3(keccak256(abi.encodePacked(block.timestamp, block.prevrandao, blockhash(block.number - 1), to))) ); } /** * @dev sets the batch seed on mint. */ function _extraData(address from, address to, uint24 previousExtraData) internal view virtual override returns (uint24) { // if minting, compute a batch seed if (from == address(0)) { return _computeBatchSeed(to); } // else return the current value return previousExtraData; } /** * @notice Returns the HTML to render a token. * @dev This includes all dependencies and the collection script to allow for rendering of the piece * directly in the browser, with no external dependencies. */ function tokenHTML(uint256 tokenId) public view tokenExists(tokenId) returns (string memory) { return string( albaDelegate.tokenHTML(collectionConfig.uuid, tokenId, tokenSeed(tokenId), collectionConfig.dependencies) ); } // Admin functions /** * @notice Sets the delegate for this collection. */ function setDelegate(IAlbaDelegate newDelegate) external onlyRole(ROLE_MANAGER) { albaDelegate = newDelegate; } /** * @notice Sets the royalty percentage, in basis points */ function setRoyalyPercentage(uint16 newRoyaltyBasisPoints) external managerOrArtist { if (newRoyaltyBasisPoints > 10000) { revert InvalidRoyaltyPercentage(); } royaltyBasisPoints = newRoyaltyBasisPoints; } /** * @notice Validate a given sale config. * @dev Note that the validation here is minimal, and only checks for invariants which * would break the contract rather than things which are likely not desired. E.g. (1 second auctions). * We do this to allow for maximum flexibility with use cases in the future. * The Alba backend will do validation before deployment for those other cases. */ function _validateSaleConfig(SaleConfig memory sc) internal view { // Ensure the start time is at least 'minSaleStartBuffer' in the future if it's changing. // Note that this also covers the initial deploy as the initial value will be 0. if ( saleConfig.startTime != sc.startTime && sc.startTime < block.timestamp + albaDelegate.getMinSaleStartBuffer() ) { revert InvalidConfiguration(); } // Validation for time limited sales. // They must have an end time and cannot have reserves or sale pieces. if (sc.saleType == SaleType.FixedPriceTimeLimited) { if (sc.auctionEndTime == 0 || sc.numReserved != 0 || sc.maxSalePieces != 0 || sc.hasRebate) { revert InvalidConfiguration(); } } // Validation for fixed price if (sc.saleType == SaleType.FixedPrice) { if (sc.hasRebate || sc.auctionEndTime != 0) { revert InvalidConfiguration(); } if (sc.numReserved > sc.maxSalePieces) { revert InvalidConfiguration(); } } // Validation for auction config if (sc.saleType == SaleType.ExponentialDutchAuction) { if (sc.auctionEndTime <= sc.startTime) { revert InvalidConfiguration(); } if (sc.initialPrice <= sc.finalPrice) { revert InvalidConfiguration(); } if ((sc.auctionEndTime - sc.startTime) > 2 hours) { revert InvalidConfiguration(); } // Can't have only reserved pieces in an auction because reserves are not used // to set the final price. Must use fixed price sale for this. if (sc.numReserved >= sc.maxSalePieces) { revert InvalidConfiguration(); } } } /** * @notice Change the sale config. This can only be called at least MIN_CHANGE_BUFFER time before the * sale has started. This can be used to postpone the sale, change pricing etc. * @param newConf The new sale config. * @dev We only allow for changing this with ample notice so that artists cannot cause havoc by changing * params at the last minute. This ensures there is time for the backend to reflect the update. */ function changeSaleConfig(SaleConfig calldata newConf) external managerOrArtist { // Ensure we are at least minDeployBuffer time before the current sale start time. if (block.timestamp >= saleConfig.startTime - albaDelegate.getMinSaleStartBuffer()) { revert InvalidConfiguration(); } _validateSaleConfig(newConf); saleConfig = newConf; emit SaleConfigChanged(saleConfig); } /** * @notice Close the sale. * The auctionEndTime parameter of the config only describes when the price in * the auction will stop changing, but does not stop the sale from continuing. * This function can be called by the manager or the artist to stop the sale entirely. * Warning: this is permanent, and cannot be undone. * @dev We don't need to set the finalSalePrice here, because price will have always * settled at the auction end price. */ function closeSale() external managerOrArtist mintingActive afterAuction { // Set the sale as closed. isSaleClosed = true; emit SaleFinished(); } /** * @notice Set the token URI override. * @dev This can be used to set a custom URI for the collection. * This is useful in the event of Alba being unavailable, or if the artist * wants to fully take control of the collection. */ function setTokenURIOverride(string calldata uri) external managerOrArtist { tokenURIOverride = uri; } /** * @notice Release reserves for the sale. * @dev To 'release' means to effectively remove all reserves and allow all remaining * mints to be done via the public mint process. We don't update the maxSalePieces * because that value is the total, which was previously subdivided by public/reserves. */ function releaseReserves() public managerOrArtist mintingActive afterAuction { // Already minted all the reserves, so nothing to do. if (numReservedMinted >= saleConfig.numReserved) { return; } saleConfig.numReserved = numReservedMinted; emit ReservesReleased(); } /** * @notice Reduce the number of sale pieces. * @dev This can be used to reduce the number of sale pieces after the sale has started. * The number of pieces can only be reduced after the auction has been finished for at least * 7 days. This is to prevent manipulating the launch mechanics. */ function reduceMaxSalePiecesTo(uint32 newTotal) external managerOrArtist mintingActive { if (block.timestamp < saleConfig.startTime + MIN_REDUCE_BUFFER) { revert InvalidConfiguration(); } // Ensure the new total is valid. If the newTotal is exactly the same, as the current number // that means no more mints, so you should use closeSale instead.) if (newTotal <= _salePiecesMinted() || newTotal >= saleConfig.maxSalePieces) { revert InvalidConfiguration(); } // If there are reserves remaining, we assume they are no longer wanted and we release them. if (saleConfig.numReserved > 0 && numReservedMinted < saleConfig.numReserved) { releaseReserves(); } saleConfig.maxSalePieces = newTotal; emit MaxSalePiecesReduced(newTotal); } /** * @notice Allow the artist to flush the funds to the payment splitter. * @dev For FixedPrice sales, the payment is sent directly to the splitter on each mint. * For auctions, the payment is initially buffered in the contract so that rebates can be * claimed. We don't know the final price until a sell-out or the auction ends. * For simplicity we wait until the end of the auction to allow the artist to flush the funds. * At the end of the auction, any subsequent mints will be sent directly to the splitter as * we know the final price already. * Note that by the time the flush is called, the users may not have claimed their rebates. * So to ensure we don't flush too much, we need to store the number of 'rebateMints' i.e. * mints which have a *potential* to collect a rebate. We can't use the total number of mints * because some of these may have been sold at the final price, and therefore don't have a rebate, * and some may be free retained mints. */ function flushPaymentToSplitter() public managerOrArtist { // Fixed price sales push to splitter on each mint. if (saleConfig.saleType == SaleType.FixedPrice || saleConfig.saleType == SaleType.FixedPriceTimeLimited) { revert InvalidConfiguration(); } // For simplicity, we require that the auction has finished. // This ensures that either 'finalSalePrice' is set due to a sellout, OR // any remaining sales will be at the resting price. We therefore know that // futher mints are sent to the splitter directly, and we can flush based // on the number of (poential) 'rebate mints'. if (!_hasAuctionFinished()) { revert AuctionStillActive(); } if (numRebateMints == 0) { revert InvalidConfiguration(); } uint256 finalValue = finalSalePrice != 0 ? finalSalePrice : saleConfig.finalPrice; uint256 totalValue = numRebateMints * finalValue; // Set the pending rebates to 0, so that we can't flush twice. numRebateMints = 0; (bool success,) = payable(address(paymentSplitter)).call{value: totalValue}(""); if (!success) revert PaymentFailed(); emit PaymentFlushed(totalValue); } /** * @notice Allows artists to write arbitrary metadata for preservation. */ function writeMetadata(string[] memory keys, string[] memory values) public managerOrArtist { if (keys.length != values.length) { revert InvalidConfiguration(); } for (uint256 i = 0; i < keys.length; i++) { metadata[keys[i]] = values[i]; } } /** * @notice Allow the artist to assume complete control of the contract. * The artist owns the contract at deployment time by default, but Alba * is retained as a manager to allow for simple builk management. * @dev We only allow this after the auction has finished to ensure that someone * can't lock us out of the ability to postpone/remove a sale. */ function assumeTotalOwnership() external onlyOwner afterAuction { address currentManager = getRoleMember(ROLE_MANAGER, 0); // Make the artist the admin of all roles. _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); // Make the artist a manager. _grantRole(ROLE_MANAGER, msg.sender); // Revoke the existing manager from roles. _revokeRole(ROLE_MANAGER, currentManager); _revokeRole(DEFAULT_ADMIN_ROLE, currentManager); emit AlbaEjected(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerable.sol"; import "./AccessControl.sol"; import "../utils/structs/EnumerableSet.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl { using EnumerableSet for EnumerableSet.AddressSet; mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) { return _roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) { return _roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); _roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); _roleMembers[role].remove(account); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; import './IERC721AUpgradeable.sol'; import {ERC721AStorage} from './ERC721AStorage.sol'; import './ERC721A__Initializable.sol'; /** * @dev Interface of ERC721 token receiver. */ interface ERC721A__IERC721ReceiverUpgradeable { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC721A * * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721) * Non-Fungible Token Standard, including the Metadata extension. * Optimized for lower gas during batch mints. * * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...) * starting from `_startTokenId()`. * * Assumptions: * * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256). */ contract ERC721AUpgradeable is ERC721A__Initializable, IERC721AUpgradeable { using ERC721AStorage for ERC721AStorage.Layout; // ============================================================= // CONSTANTS // ============================================================= // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant _BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant _BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant _BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant _BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant _BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant _BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; // The maximum `quantity` that can be minted with {_mintERC2309}. // This limit is to prevent overflows on the address data entries. // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309} // is required to cause an overflow, which is unrealistic. uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000; // The `Transfer` event signature is given by: // `keccak256(bytes("Transfer(address,address,uint256)"))`. bytes32 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; // ============================================================= // CONSTRUCTOR // ============================================================= function __ERC721A_init(string memory name_, string memory symbol_) internal onlyInitializingERC721A { __ERC721A_init_unchained(name_, symbol_); } function __ERC721A_init_unchained(string memory name_, string memory symbol_) internal onlyInitializingERC721A { ERC721AStorage.layout()._name = name_; ERC721AStorage.layout()._symbol = symbol_; ERC721AStorage.layout()._currentIndex = _startTokenId(); } // ============================================================= // TOKEN COUNTING OPERATIONS // ============================================================= /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view virtual returns (uint256) { return ERC721AStorage.layout()._currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() public view virtual override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return ERC721AStorage.layout()._currentIndex - ERC721AStorage.layout()._burnCounter - _startTokenId(); } } /** * @dev Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view virtual returns (uint256) { // Counter underflow is impossible as `_currentIndex` does not decrement, // and it is initialized to `_startTokenId()`. unchecked { return ERC721AStorage.layout()._currentIndex - _startTokenId(); } } /** * @dev Returns the total number of tokens burned. */ function _totalBurned() internal view virtual returns (uint256) { return ERC721AStorage.layout()._burnCounter; } // ============================================================= // ADDRESS DATA OPERATIONS // ============================================================= /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) public view virtual override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return ERC721AStorage.layout()._packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return (ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return (ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY; } /** * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return uint64(ERC721AStorage.layout()._packedAddressData[owner] >> _BITPOS_AUX); } /** * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal virtual { uint256 packed = ERC721AStorage.layout()._packedAddressData[owner]; uint256 auxCasted; // Cast `aux` with assembly to avoid redundant masking. assembly { auxCasted := aux } packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX); ERC721AStorage.layout()._packedAddressData[owner] = packed; } // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { // The interface IDs are constants representing the first 4 bytes // of the XOR of all function selectors in the interface. // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165) // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`) return interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165. interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721. interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata. } // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() public view virtual override returns (string memory) { return ERC721AStorage.layout()._name; } /** * @dev Returns the token collection symbol. */ function symbol() public view virtual override returns (string memory) { return ERC721AStorage.layout()._symbol; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); string memory baseURI = _baseURI(); return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ''; } /** * @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, it can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ''; } // ============================================================= // OWNERSHIPS OPERATIONS // ============================================================= /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around over time. */ function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(_packedOwnershipOf(tokenId)); } /** * @dev Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(ERC721AStorage.layout()._packedOwnerships[index]); } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal virtual { if (ERC721AStorage.layout()._packedOwnerships[index] == 0) { ERC721AStorage.layout()._packedOwnerships[index] = _packedOwnershipOf(index); } } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf(uint256 tokenId) private view returns (uint256 packed) { if (_startTokenId() <= tokenId) { packed = ERC721AStorage.layout()._packedOwnerships[tokenId]; // If not burned. if (packed & _BITMASK_BURNED == 0) { // If the data at the starting slot does not exist, start the scan. if (packed == 0) { if (tokenId >= ERC721AStorage.layout()._currentIndex) revert OwnerQueryForNonexistentToken(); // Invariant: // There will always be an initialized ownership slot // (i.e. `ownership.addr != address(0) && ownership.burned == false`) // before an unintialized ownership slot // (i.e. `ownership.addr == address(0) && ownership.burned == false`) // Hence, `tokenId` will not underflow. // // We can directly compare the packed value. // If the address is zero, packed will be zero. for (;;) { unchecked { packed = ERC721AStorage.layout()._packedOwnerships[--tokenId]; } if (packed == 0) continue; return packed; } } // Otherwise, the data exists and is not burned. We can skip the scan. // This is possible because we have already achieved the target condition. // This saves 2143 gas on transfers of initialized tokens. return packed; } } revert OwnerQueryForNonexistentToken(); } /** * @dev Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP); ownership.burned = packed & _BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`. result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)) } } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`. result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. See {ERC721A-_approve}. * * Requirements: * * - The caller must own the token or be an approved operator. */ function approve(address to, uint256 tokenId) public payable virtual override { _approve(to, tokenId, true); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return ERC721AStorage.layout()._tokenApprovals[tokenId].value; } /** * @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) public virtual override { ERC721AStorage.layout()._operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return ERC721AStorage.layout()._operatorApprovals[owner][operator]; } /** * @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. See {_mint}. */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _startTokenId() <= tokenId && tokenId < ERC721AStorage.layout()._currentIndex && // If within bounds, ERC721AStorage.layout()._packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned. } /** * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`. */ function _isSenderApprovedOrOwner( address approvedAddress, address owner, address msgSender ) private pure returns (bool result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, _BITMASK_ADDRESS) // `msgSender == owner || msgSender == approvedAddress`. result := or(eq(msgSender, owner), eq(msgSender, approvedAddress)) } } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedSlotAndAddress(uint256 tokenId) private view returns (uint256 approvedAddressSlot, address approvedAddress) { ERC721AStorage.TokenApprovalRef storage tokenApproval = ERC721AStorage.layout()._tokenApprovals[tokenId]; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`. assembly { approvedAddressSlot := tokenApproval.slot approvedAddress := sload(approvedAddressSlot) } } // ============================================================= // TRANSFER OPERATIONS // ============================================================= /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) public payable virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --ERC721AStorage.layout()._packedAddressData[from]; // Updates: `balance -= 1`. ++ERC721AStorage.layout()._packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != ERC721AStorage.layout()._currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public payable virtual override { safeTransferFrom(from, to, tokenId, ''); } /** * @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 memory _data ) public payable virtual override { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Hook that is called before a set of serially-ordered token IDs * are about to be transferred. This includes minting. * And also called before burning one token. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * 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, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token IDs * have been transferred. This includes minting. * And also called after one token has been burned. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * `from` - Previous owner of the given token ID. * `to` - Target address that will receive the token. * `tokenId` - Token ID to be transferred. * `_data` - Optional data to send along with the call. * * Returns whether the call correctly returned the expected magic value. */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (bytes4 retval) { return retval == ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } // ============================================================= // MINT OPERATIONS // ============================================================= /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal virtual { uint256 startTokenId = ERC721AStorage.layout()._currentIndex; if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); uint256 toMasked; uint256 end = startTokenId + quantity; // Use assembly to loop and emit the `Transfer` event for gas savings. // The duplicated `log4` removes an extra check and reduces stack juggling. // The assembly, together with the surrounding Solidity code, have been // delicately arranged to nudge the compiler into producing optimized opcodes. assembly { // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. toMasked := and(to, _BITMASK_ADDRESS) // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. 0, // `address(0)`. toMasked, // `to`. startTokenId // `tokenId`. ) // The `iszero(eq(,))` check ensures that large values of `quantity` // that overflows uint256 will make the loop run out of gas. // The compiler will optimize the `iszero` away for performance. for { let tokenId := add(startTokenId, 1) } iszero(eq(tokenId, end)) { tokenId := add(tokenId, 1) } { // Emit the `Transfer` event. Similar to above. log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId) } } if (toMasked == 0) revert MintToZeroAddress(); ERC721AStorage.layout()._currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * This function is intended for efficient minting only during contract creation. * * It emits only one {ConsecutiveTransfer} as defined in * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309), * instead of a sequence of {Transfer} event(s). * * Calling this function outside of contract creation WILL make your contract * non-compliant with the ERC721 standard. * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309 * {ConsecutiveTransfer} event is only permissible during contract creation. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {ConsecutiveTransfer} event. */ function _mintERC2309(address to, uint256 quantity) internal virtual { uint256 startTokenId = ERC721AStorage.layout()._currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are unrealistic due to the above check for `quantity` to be below the limit. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to); ERC721AStorage.layout()._currentIndex = startTokenId + quantity; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal virtual { _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = ERC721AStorage.layout()._currentIndex; uint256 index = end - quantity; do { if (!_checkContractOnERC721Received(address(0), to, index++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (index < end); // Reentrancy protection. if (ERC721AStorage.layout()._currentIndex != end) revert(); } } } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ''); } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Equivalent to `_approve(to, tokenId, false)`. */ function _approve(address to, uint256 tokenId) internal virtual { _approve(to, tokenId, false); } /** * @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: * * - `tokenId` must exist. * * Emits an {Approval} event. */ function _approve( address to, uint256 tokenId, bool approvalCheck ) internal virtual { address owner = ownerOf(tokenId); if (approvalCheck) if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } ERC721AStorage.layout()._tokenApprovals[tokenId].value = to; emit Approval(owner, to, tokenId); } // ============================================================= // BURN OPERATIONS // ============================================================= /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); address from = address(uint160(prevOwnershipPacked)); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); if (approvalCheck) { // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // Updates: // - `balance -= 1`. // - `numberBurned += 1`. // // We can directly decrement the balance, and increment the number burned. // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`. ERC721AStorage.layout()._packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1; // Updates: // - `address` to the last owner. // - `startTimestamp` to the timestamp of burning. // - `burned` to `true`. // - `nextInitialized` to `true`. ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData( from, (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != ERC721AStorage.layout()._currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { ERC721AStorage.layout()._burnCounter++; } } // ============================================================= // EXTRA DATA OPERATIONS // ============================================================= /** * @dev Directly sets the extra data for the ownership data `index`. */ function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual { uint256 packed = ERC721AStorage.layout()._packedOwnerships[index]; if (packed == 0) revert OwnershipNotInitializedForExtraData(); uint256 extraDataCasted; // Cast `extraData` with assembly to avoid redundant masking. assembly { extraDataCasted := extraData } packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA); ERC721AStorage.layout()._packedOwnerships[index] = packed; } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * 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, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData( address from, address to, uint24 previousExtraData ) internal view virtual returns (uint24) {} /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData( address from, address to, uint256 prevOwnershipPacked ) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA; } // ============================================================= // OTHER OPERATIONS // ============================================================= /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a uint256 to its ASCII string decimal representation. */ function _toString(uint256 value) internal pure virtual returns (string memory str) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. // We will need 1 word for the trailing zeros padding, 1 word for the length, // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0. let m := add(mload(0x40), 0xa0) // Update the free memory pointer to allocate. mstore(0x40, m) // Assign the `str` to the end. str := sub(m, 0x20) // Zeroize the slot after the string. mstore(str, 0) // Cache the end of the memory to calculate the length later. let end := str // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // prettier-ignore for { let temp := value } 1 {} { str := sub(str, 1) // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(str, add(48, mod(temp, 10))) // Keep dividing `temp` until zero. temp := div(temp, 10) // prettier-ignore if iszero(temp) { break } } let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 0x20) // Store the length. mstore(str, length) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV // Deprecated in v4.8 } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be paid in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.13; import {IPaymentSplitterFactory} from "ethier/factories/IPaymentSplitterFactory.sol"; interface IAlbaDelegate { function tokenURI(uint256 tokenId, string memory slug) external view returns (string memory); function tokenURI(uint256 tokenId, string memory slug, string memory uriOverride) external view returns (string memory); function verifyMintReserve(bytes32 message, bytes calldata signature) external view; function verifyMint(bytes16 collectionId, address user, uint16 num, uint32 nonce, bytes calldata signature) external view; function tokenHTML(bytes16 uuid, uint256 tokenId, bytes32 seed, bytes16[] memory deps) external view returns (bytes memory); function paymentSplitterFactory() external view returns (IPaymentSplitterFactory); function operatorFilterSubscription() external view returns (address); function getAlbaFeeReceiver() external view returns (address); function getMinSaleStartBuffer() external view returns (uint256); }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.13; import {IERC20} from "openzeppelin-contracts/token/ERC20/IERC20.sol"; interface IPaymentSplitter { function releasable(address account) external view returns (uint256); function releasable(IERC20 token, address account) external view returns (uint256); function release(address payable account) external; function release(IERC20 token, address account) external; }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.13; struct CollectionConfig { bytes16 uuid; string name; string token; string slug; bytes16[] dependencies; string[] metadataKeys; string[] metadataValues; } enum SaleType { FixedPrice, DeprecatedReserved, ExponentialDutchAuction, FixedPriceTimeLimited } struct SaleConfig { SaleType saleType; // uint8 for packing uint32 maxSalePieces; // Maximum number of pieces to sell (including reserves) uint32 numReserved; // Number of pieces to reserve for specific wallets uint16 numRetained; // Number of pieces to retain for the artist uint16 numAlba; // Number of pieces to retain for Alba uint40 startTime; // Sale start time uint40 auctionEndTime; // Sale doesn't stop here, but price decay stops. Needed for rebate if non-sellout. bool hasRebate; // Whether or not to give a rebate to resting price uint256 initialPrice; // Starting price for Dutch Auction uint256 finalPrice; // Ending price for Dutch Auction } struct PaymentConfig { address[] primaryPayees; // Addresses for primary payment. uint256[] primaryShareBasisPoints; // Share of primary sales for each address (basis points). address[] secondaryPayees; // Addresses for secondary payment. uint256[] secondaryShareBasisPoints; // Share of secondary sales for each address (basis points). uint16 royaltyBasisPoints; // Total royalty basis points. } struct StoredScript { string fileName; uint256 wrappedLength; }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.20; import {SaleType, SaleConfig} from "../Types.sol"; import {Math} from "./Math.sol"; library AlbaCollectionPricing { /** * @notice Returns the current price of the sale. * @dev Wrapper for different pricing strategies based on sale type. */ function getPrice(SaleConfig storage saleConfig) public view returns (uint256) { if (saleConfig.saleType == SaleType.FixedPrice || saleConfig.saleType == SaleType.FixedPriceTimeLimited) { return saleConfig.initialPrice; } if (block.timestamp <= saleConfig.startTime) { return saleConfig.initialPrice; } if (saleConfig.saleType == SaleType.ExponentialDutchAuction) { return _getPriceExponentialDA(saleConfig); } return 0; } /** * @notice Returns the current price of the sale using a continuous dutch auction pricing strategy. * @dev This works by computing the time elapsed since the start of the auction, and then interpolating * the price based on the initial price and the final price. The interpolation is linear. */ function _getPriceExponentialDA(SaleConfig storage saleConfig) internal view returns (uint256) { if (block.timestamp >= saleConfig.auctionEndTime) { return saleConfig.finalPrice; } uint256 timeElapsed = block.timestamp - saleConfig.startTime; uint40 totalDuration = saleConfig.auctionEndTime - saleConfig.startTime; // This choice guarantees that `elapsed/tau < 5` meaning that the approximant is applicable (with rel error < 1%) // and that the price difference has sufficiently decayed (to <0.007) at the end of the auction. uint40 tau = totalDuration / 5; (uint256 expNumerator, uint256 expDenominator) = Math.expPadeApprox5(int48(int256(timeElapsed)), -int48(uint48(tau))); uint256 priceDifference = saleConfig.initialPrice - saleConfig.finalPrice; return saleConfig.finalPrice + (priceDifference * expNumerator) / expDenominator; } }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.20; import {PaymentConfig} from "../Types.sol"; import {IAlbaDelegate} from "../IAlbaDelegate.sol"; import {IPaymentSplitter} from "../IPaymentSplitter.sol"; library Splitters { error InvalidConfiguration(); /** * Setup the sales splitters. * @dev We expect an array of length 1 for a single user (if there's no Alba fee). This is less efficient * than just using the artist's address rather than a splitter, but it provides consistent UX for claiming. */ function setupPaymentSplitters(PaymentConfig calldata conf, IAlbaDelegate albaDelegate) public returns (IPaymentSplitter, IPaymentSplitter) { if (conf.primaryPayees.length == 0 || conf.primaryPayees.length != conf.primaryShareBasisPoints.length) { revert InvalidConfiguration(); } IPaymentSplitter paymentSplitter; IPaymentSplitter paymentSplitterRoyalties; address primary = albaDelegate.paymentSplitterFactory().deploy(conf.primaryPayees, conf.primaryShareBasisPoints); paymentSplitter = IPaymentSplitter(primary); // Only deploy a contract for secondary payments if there are secondary payees. if (conf.secondaryPayees.length > 0) { if (conf.secondaryPayees.length != conf.secondaryShareBasisPoints.length) { revert InvalidConfiguration(); } address secondary = albaDelegate.paymentSplitterFactory().deploy(conf.secondaryPayees, conf.secondaryShareBasisPoints); paymentSplitterRoyalties = IPaymentSplitter(secondary); } return (paymentSplitter, paymentSplitterRoyalties); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerable is IAccessControl { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (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); _; } /** * @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 `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @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(account), " 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. * * May emit a {RoleGranted} event. */ 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. * * May emit a {RoleRevoked} event. */ 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`. * * May emit a {RoleRevoked} event. */ 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. * * May emit a {RoleGranted} event. * * [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. * * May emit a {RoleGranted} event. */ 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. * * May emit a {RoleRevoked} event. */ 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 (last updated v4.8.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// 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 // ERC721A Contracts v4.2.3 // Creator: Chiru Labs pragma solidity ^0.8.4; /** * @dev Interface of ERC721A. */ interface IERC721AUpgradeable { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the * ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); // ============================================================= // STRUCTS // ============================================================= struct TokenOwnership { // The address of the owner. address addr; // Stores the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}. uint24 extraData; } // ============================================================= // TOKEN COUNTERS // ============================================================= /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() external view returns (uint256); // ============================================================= // IERC165 // ============================================================= /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * to learn more about how these ids are created. * * This function call must use less than 30000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); // ============================================================= // IERC721 // ============================================================= /** * @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, bytes calldata data ) external payable; /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external payable; /** * @dev Transfers `tokenId` 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 payable; /** * @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 payable; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) external view returns (bool); // ============================================================= // IERC721Metadata // ============================================================= /** * @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); // ============================================================= // IERC2309 // ============================================================= /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` * (inclusive) is transferred from `from` to `to`, as defined in the * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard. * * See {_mintERC2309} for more details. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library ERC721AStorage { // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364). struct TokenApprovalRef { address value; } struct Layout { // ============================================================= // STORAGE // ============================================================= // The next token ID to be minted. uint256 _currentIndex; // The number of tokens burned. uint256 _burnCounter; // Token name string _name; // Token symbol string _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See {_packedOwnershipOf} implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => ERC721AStorage.TokenApprovalRef) _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) _operatorApprovals; } bytes32 internal constant STORAGE_SLOT = keccak256('ERC721A.contracts.storage.ERC721A'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable diamond facet contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ import {ERC721A__InitializableStorage} from './ERC721A__InitializableStorage.sol'; abstract contract ERC721A__Initializable { using ERC721A__InitializableStorage for ERC721A__InitializableStorage.Layout; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializerERC721A() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require( ERC721A__InitializableStorage.layout()._initializing ? _isConstructor() : !ERC721A__InitializableStorage.layout()._initialized, 'ERC721A__Initializable: contract is already initialized' ); bool isTopLevelCall = !ERC721A__InitializableStorage.layout()._initializing; if (isTopLevelCall) { ERC721A__InitializableStorage.layout()._initializing = true; ERC721A__InitializableStorage.layout()._initialized = true; } _; if (isTopLevelCall) { ERC721A__InitializableStorage.layout()._initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializingERC721A() { require( ERC721A__InitializableStorage.layout()._initializing, 'ERC721A__Initializable: contract is not initializing' ); _; } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/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 // Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier) pragma solidity >=0.8.0 <0.9.0; interface IPaymentSplitterFactory { /// @notice Deploys a minimal contract proxy to a PaymentSplitter. function deploy(address[] memory payees, uint256[] memory shares) external returns (address); /** @notice Deploys a minimal contract proxy to a PaymentSplitter, at a deterministic address. @dev Use predictDeploymentAddress() with the same salt to predit the address before calling deployDeterministic(). See OpenZeppelin's proxy/Clones.sol for details and caveats, primarily that this will revert if a salt is reused. */ function deployDeterministic( bytes32 salt, address[] memory payees, uint256[] memory shares ) external returns (address); /** @notice Returns the address at which a new PaymentSplitter will be deployed if using the same salt as passed to this function. */ function predictDeploymentAddress(bytes32 salt) external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.20; library Math { // Coefficients for the expanded Pade approximant of the exponential function exp(x/y). uint16 private constant EXP_PADE_5_COEFF_X0_Y5 = 30240; uint16 private constant EXP_PADE_5_COEFF_X1_Y4 = 15120; uint16 private constant EXP_PADE_5_COEFF_X2_Y3 = 3360; uint16 private constant EXP_PADE_5_COEFF_X3_Y2 = 420; uint16 private constant EXP_PADE_5_COEFF_X4_Y1 = 30; uint16 private constant EXP_PADE_5_COEFF_X5_Y0 = 1; /// @notice Expanded Pade approximant of order 5 of the exponential function `exp(x/y)`. /// @dev The pade approximant is given by (latex notation): `\frac{\frac{x^5}{30240 y^5}+\frac{x^4}{1008 y^4}+\frac{x^3}{72 y^3}+\frac{x^2}{9 y^2}+\frac{x}{2 y}+1}{-\frac{x^5}{30240 y^5}+\frac{x^4}{1008 y^4}-\frac{x^3}{72 y^3}+\frac{x^2}{9 y^2}-\frac{x}{2 y}+1}` /// @dev Both the numerator and the denominator were expanded (i.e. multiplied by `30240 y^5`) to obtain integer coefficients and avoid truncation errors in the divisions. /// @dev See also https://www.wolframalpha.com/input?i=PadeApproximant%5BExp%5Bx%2Fy%5D%2C+%7Bx%2C+0%2C+5%7D%5D /// @dev The relative accuracy is <1% for `x/y <= 5`. /// @dev The input types are limited to 48 bits to avoid overflow in the powers (max power `x^5` hence takes 240 bits) /// @param x The numerator of the exponent. /// @param y The denominator of the exponent. /// @return a The numerator of the result. /// @return b The denominator of the result. function expPadeApprox5(int48 x, int48 y) internal pure returns (uint256, uint256) { int256 a = 0; int256 b = 0; assembly { let xyPowers := exp(y, 5) let c := 0 c := mul(EXP_PADE_5_COEFF_X0_Y5, xyPowers) a := add(a, c) b := add(b, c) xyPowers := sdiv(mul(xyPowers, x), y) c := mul(EXP_PADE_5_COEFF_X1_Y4, xyPowers) a := add(a, c) b := sub(b, c) xyPowers := sdiv(mul(xyPowers, x), y) c := mul(EXP_PADE_5_COEFF_X2_Y3, xyPowers) a := add(a, c) b := add(b, c) xyPowers := sdiv(mul(xyPowers, x), y) c := mul(EXP_PADE_5_COEFF_X3_Y2, xyPowers) a := add(a, c) b := sub(b, c) xyPowers := sdiv(mul(xyPowers, x), y) c := mul(EXP_PADE_5_COEFF_X4_Y1, xyPowers) a := add(a, c) b := add(b, c) xyPowers := sdiv(mul(xyPowers, x), y) c := mul(EXP_PADE_5_COEFF_X5_Y0, xyPowers) a := add(a, c) b := sub(b, c) } if (b < 0) { a = -a; b = -b; } return (uint256(a), uint256(b)); } }
// 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; }
// 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 pragma solidity ^0.8.0; /** * @dev This is a base storage for the initialization function for upgradeable diamond facet contracts **/ library ERC721A__InitializableStorage { struct Layout { /* * Indicates that the contract has been initialized. */ bool _initialized; /* * Indicates that the contract is in the process of being initialized. */ bool _initializing; } bytes32 internal constant STORAGE_SLOT = keccak256('ERC721A.contracts.storage.initializable.facet'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
{ "remappings": [ "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "ethier/=lib/ethier/contracts/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@openzeppelin/=lib/openzeppelin-contracts/", "erc721a/=lib/ERC721A-Upgradeable/contracts/", "ethfs/=lib/ethfs/packages/contracts/src/", "scripty/=lib/scripty.sol/contracts/scripty/", "ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/", "ERC721A/=lib/ERC721A/contracts/", "openzeppelin/=lib/ethfs/packages/contracts/lib/openzeppelin-contracts/contracts/", "scripty.sol/=lib/scripty.sol/contracts/", "solady/=lib/ethfs/packages/contracts/lib/solady/src/", "solmate/=lib/ethfs/packages/contracts/lib/solady/lib/solmate/src/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": { "src/libraries/Pricing.sol": { "AlbaCollectionPricing": "0x19bC0b68A262A0f56A812bd0cABE1466fC1Ca875" }, "src/libraries/Splitters.sol": { "Splitters": "0xD47d5F3cb05d4fC80B8B8a828e0626bc3a02C44e" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"AuctionStillActive","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"InsufficientTokensRemanining","type":"error"},{"inputs":[],"name":"InvalidConfiguration","type":"error"},{"inputs":[],"name":"InvalidPayment","type":"error"},{"inputs":[],"name":"InvalidRoyaltyPercentage","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"NoRebateAvailable","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"PaymentFailed","type":"error"},{"inputs":[],"name":"SaleNotActive","type":"error"},{"inputs":[],"name":"TooManyMintsRequested","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnknownToken","type":"error"},{"anonymous":false,"inputs":[],"name":"AlbaEjected","type":"event"},{"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":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMax","type":"uint256"}],"name":"MaxSalePiecesReduced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"PaymentFlushed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RebateClaimed","type":"event"},{"anonymous":false,"inputs":[],"name":"ReservesReleased","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":[{"components":[{"internalType":"enum SaleType","name":"saleType","type":"uint8"},{"internalType":"uint32","name":"maxSalePieces","type":"uint32"},{"internalType":"uint32","name":"numReserved","type":"uint32"},{"internalType":"uint16","name":"numRetained","type":"uint16"},{"internalType":"uint16","name":"numAlba","type":"uint16"},{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"uint40","name":"auctionEndTime","type":"uint40"},{"internalType":"bool","name":"hasRebate","type":"bool"},{"internalType":"uint256","name":"initialPrice","type":"uint256"},{"internalType":"uint256","name":"finalPrice","type":"uint256"}],"indexed":false,"internalType":"struct SaleConfig","name":"newConfig","type":"tuple"}],"name":"SaleConfigChanged","type":"event"},{"anonymous":false,"inputs":[],"name":"SaleFinished","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"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_REDUCE_BUFFER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_ARTIST","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_MANAGER","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"albaDelegate","outputs":[{"internalType":"contract IAlbaDelegate","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"assumeTotalOwnership","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":[{"components":[{"internalType":"enum SaleType","name":"saleType","type":"uint8"},{"internalType":"uint32","name":"maxSalePieces","type":"uint32"},{"internalType":"uint32","name":"numReserved","type":"uint32"},{"internalType":"uint16","name":"numRetained","type":"uint16"},{"internalType":"uint16","name":"numAlba","type":"uint16"},{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"uint40","name":"auctionEndTime","type":"uint40"},{"internalType":"bool","name":"hasRebate","type":"bool"},{"internalType":"uint256","name":"initialPrice","type":"uint256"},{"internalType":"uint256","name":"finalPrice","type":"uint256"}],"internalType":"struct SaleConfig","name":"newConf","type":"tuple"}],"name":"changeSaleConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"recipient","type":"address"}],"name":"claimRebate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"closeSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectionConfig","outputs":[{"internalType":"bytes16","name":"uuid","type":"bytes16"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"token","type":"string"},{"internalType":"string","name":"slug","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalSalePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"flushPaymentToSplitter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"flushablePayments","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getRebateAmount","outputs":[{"internalType":"uint256","name":"","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":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","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":"contract IAlbaDelegate","name":"_albaDelegate","type":"address"},{"components":[{"internalType":"bytes16","name":"uuid","type":"bytes16"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"token","type":"string"},{"internalType":"string","name":"slug","type":"string"},{"internalType":"bytes16[]","name":"dependencies","type":"bytes16[]"},{"internalType":"string[]","name":"metadataKeys","type":"string[]"},{"internalType":"string[]","name":"metadataValues","type":"string[]"}],"internalType":"struct CollectionConfig","name":"_config","type":"tuple"},{"components":[{"internalType":"enum SaleType","name":"saleType","type":"uint8"},{"internalType":"uint32","name":"maxSalePieces","type":"uint32"},{"internalType":"uint32","name":"numReserved","type":"uint32"},{"internalType":"uint16","name":"numRetained","type":"uint16"},{"internalType":"uint16","name":"numAlba","type":"uint16"},{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"uint40","name":"auctionEndTime","type":"uint40"},{"internalType":"bool","name":"hasRebate","type":"bool"},{"internalType":"uint256","name":"initialPrice","type":"uint256"},{"internalType":"uint256","name":"finalPrice","type":"uint256"}],"internalType":"struct SaleConfig","name":"_saleConfig","type":"tuple"},{"components":[{"internalType":"address[]","name":"primaryPayees","type":"address[]"},{"internalType":"uint256[]","name":"primaryShareBasisPoints","type":"uint256[]"},{"internalType":"address[]","name":"secondaryPayees","type":"address[]"},{"internalType":"uint256[]","name":"secondaryShareBasisPoints","type":"uint256[]"},{"internalType":"uint16","name":"royaltyBasisPoints","type":"uint16"}],"internalType":"struct PaymentConfig","name":"_paymentConfig","type":"tuple"},{"internalType":"address","name":"albaManager","type":"address"},{"internalType":"address[]","name":"artists","type":"address[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","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":[],"name":"isSaleClosed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"metadata","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16","name":"collectionId","type":"bytes16"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint16","name":"num","type":"uint16"},{"internalType":"uint32","name":"nonce","type":"uint32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint16","name":"num","type":"uint16"}],"name":"mintAlba","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"mintPrices","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16","name":"collectionId","type":"bytes16"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint16","name":"num","type":"uint16"},{"internalType":"uint16","name":"maxMints","type":"uint16"},{"internalType":"uint32","name":"nonce","type":"uint32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"mintReserved","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint16","name":"num","type":"uint16"}],"name":"mintRetained","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"collectionId","type":"bytes16"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint16","name":"num","type":"uint16"},{"internalType":"uint32","name":"nonce","type":"uint32"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"mintTimeLimited","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numAlbaMinted","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numReservedMinted","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numRetainedMinted","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentSplitter","outputs":[{"internalType":"contract IPaymentSplitter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentSplitterRoyalties","outputs":[{"internalType":"contract IPaymentSplitter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"newTotal","type":"uint32"}],"name":"reduceMaxSalePiecesTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"releaseReserves","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"collectionId","type":"bytes16"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint16","name":"maxMints","type":"uint16"},{"internalType":"uint32","name":"nonce","type":"uint32"}],"name":"reservesUsed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"royaltyBasisPoints","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"royaltyAmount","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":"safeTransferFrom","outputs":[],"stateMutability":"payable","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":"payable","type":"function"},{"inputs":[],"name":"saleConfig","outputs":[{"internalType":"enum SaleType","name":"saleType","type":"uint8"},{"internalType":"uint32","name":"maxSalePieces","type":"uint32"},{"internalType":"uint32","name":"numReserved","type":"uint32"},{"internalType":"uint16","name":"numRetained","type":"uint16"},{"internalType":"uint16","name":"numAlba","type":"uint16"},{"internalType":"uint40","name":"startTime","type":"uint40"},{"internalType":"uint40","name":"auctionEndTime","type":"uint40"},{"internalType":"bool","name":"hasRebate","type":"bool"},{"internalType":"uint256","name":"initialPrice","type":"uint256"},{"internalType":"uint256","name":"finalPrice","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IAlbaDelegate","name":"newDelegate","type":"address"}],"name":"setDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"newRoyaltyBasisPoints","type":"uint16"}],"name":"setRoyalyPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"uri","type":"string"}],"name":"setTokenURIOverride","outputs":[],"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":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenHTML","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenSeed","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"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":"tokenURIOverride","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":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"keys","type":"string[]"},{"internalType":"string[]","name":"values","type":"string[]"}],"name":"writeMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506200001d3362000023565b6200007e565b600080546001600160a01b038381166201000081810262010000600160b01b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b615f83806200008e6000396000f3fe6080604052600436106103d95760003560e01c806384778eba116101fd578063bb011cbb11610118578063d547741f116100ab578063ec06789d1161007a578063ec06789d14610bbe578063ed4a6b0c14610bd1578063ee55efee14610bf1578063f2fde38b14610c06578063f5b944eb14610c2657600080fd5b8063d547741f14610b49578063d76b47cb14610b69578063e756d96914610b7e578063e985e9c514610b9e57600080fd5b8063c9910973116100e7578063c991097314610ad6578063ca15c87314610af6578063ca5eb5e114610b16578063d2e8281f14610b3657600080fd5b8063bb011cbb14610a6a578063bf964b4e14610a7f578063c56ca30614610a9f578063c87b56dd14610ab657600080fd5b80639acd26d511610190578063acfc03521161015f578063acfc035214610a02578063b45e01e914610a22578063b79bebaf14610a37578063b88d4fde14610a5757600080fd5b80639acd26d514610995578063a217fddf146109b8578063a22cb465146109cd578063a404d794146109ed57600080fd5b806390aa0b0f116101cc57806390aa0b0f146108bc57806391d148541461094b57806395d89b411461096b57806398d5fdca1461098057600080fd5b806384778eba1461084d5780638c1478a2146108625780638da5cb5b146108785780639010d07c1461089c57600080fd5b806336568abe116102f85780636352211e1161028b578063715018a61161025a578063715018a6146107c5578063774c96ce146107da5780637ea249ad146107ed5780637ec9704f1461080d57806380a6dfa01461082d57600080fd5b80636352211e1461073e57806369005cd61461075e5780636b34d7251461078057806370a08231146107a557600080fd5b806342842e0e116102c757806342842e0e146106cb5780635c21f6d8146106de5780635f516836146106fe5780636343e0a21461071e57600080fd5b806336568abe1461062457806337fe26b91461064457806339fd52c31461066457806342260b5d1461069657600080fd5b80631e1a268b116103705780632a55205a1161033f5780632a55205a146105855780632c316c1d146105c45780632f2ff15d146105e4578063357b62171461060457600080fd5b80631e1a268b1461050757806323b872dd14610521578063248a9ca314610534578063249672151461056557600080fd5b8063095ea7b3116103ac578063095ea7b31461049d5780630a62ae41146104b2578063146bc04e146104d257806318160ddd146104f257600080fd5b806301ffc9a7146103de57806303366c411461041357806306fdde0314610443578063081812fc14610465575b600080fd5b3480156103ea57600080fd5b506103fe6103f9366004614554565b610c48565b60405190151581526020015b60405180910390f35b34801561041f57600080fd5b50610435600080516020615f0e83398151915281565b60405190815260200161040a565b34801561044f57600080fd5b50610458610c83565b60405161040a91906145c1565b34801561047157600080fd5b506104856104803660046145d4565b610d1e565b6040516001600160a01b03909116815260200161040a565b6104b06104ab36600461460d565b610d6b565b005b3480156104be57600080fd5b506104b06104cd3660046146a9565b610d7b565b3480156104de57600080fd5b506104b06104ed366004614779565b6113d0565b3480156104fe57600080fd5b506104356114fa565b34801561051357600080fd5b506011546103fe9060ff1681565b6104b061052f366004614796565b611519565b34801561054057600080fd5b5061043561054f3660046145d4565b6000908152600160208190526040909120015490565b34801561057157600080fd5b506104b06105803660046147d7565b61172e565b34801561059157600080fd5b506105a56105a03660046147f4565b611893565b604080516001600160a01b03909316835260208301919091520161040a565b3480156105d057600080fd5b506104b06105df366004614831565b6118d2565b3480156105f057600080fd5b506104b06105ff36600461484e565b61197d565b34801561061057600080fd5b506104b061061f366004614831565b6119a8565b34801561063057600080fd5b506104b061063f36600461484e565b611a48565b34801561065057600080fd5b5061043561065f3660046148b1565b611ac2565b34801561067057600080fd5b506013546106819063ffffffff1681565b60405163ffffffff909116815260200161040a565b3480156106a257600080fd5b50600f546106b890600160a01b900461ffff1681565b60405161ffff909116815260200161040a565b6104b06106d9366004614796565b611aec565b3480156106ea57600080fd5b506104b06106f936600461490d565b611b07565b34801561070a57600080fd5b506104356107193660046145d4565b611cb5565b34801561072a57600080fd5b506104b061073936600461496b565b611d45565b34801561074a57600080fd5b506104856107593660046145d4565b611da9565b34801561076a57600080fd5b506013546106b890600160301b900461ffff1681565b34801561078c57600080fd5b50610795611db4565b60405161040a94939291906149ac565b3480156107b157600080fd5b506104356107c0366004614779565b611f6c565b3480156107d157600080fd5b506104b0611fd4565b6104b06107e8366004614a00565b611fe8565b3480156107f957600080fd5b5061043561080836600461460d565b6121dd565b34801561081957600080fd5b50610435610828366004614779565b61220e565b34801561083957600080fd5b50610458610848366004614b81565b61233e565b34801561085957600080fd5b506104b06123e3565b34801561086e57600080fd5b5061043560145481565b34801561088457600080fd5b506000546201000090046001600160a01b0316610485565b3480156108a857600080fd5b506104856108b73660046147f4565b612518565b3480156108c857600080fd5b506004546005546006546109359260ff8082169363ffffffff6101008404811694600160281b85049091169361ffff600160481b8204811694600160581b83049091169364ffffffffff600160681b8404811694600160901b850490911693600160b81b9004909216918a565b60405161040a9a99989796959493929190614bed565b34801561095757600080fd5b506103fe61096636600461484e565b612537565b34801561097757600080fd5b50610458612562565b34801561098c57600080fd5b5061043561257a565b3480156109a157600080fd5b506013546106b890640100000000900461ffff1681565b3480156109c457600080fd5b50610435600081565b3480156109d957600080fd5b506104b06109e8366004614c73565b612605565b3480156109f957600080fd5b506104b0612682565b348015610a0e57600080fd5b506104b0610a1d366004614ca1565b61274a565b348015610a2e57600080fd5b50610435612883565b348015610a4357600080fd5b50610458610a523660046145d4565b6128f2565b6104b0610a65366004614ccf565b6129ab565b348015610a7657600080fd5b506104b06129f5565b348015610a8b57600080fd5b50600f54610485906001600160a01b031681565b348015610aab57600080fd5b5061043562093a8081565b348015610ac257600080fd5b50610458610ad13660046145d4565b612bd2565b348015610ae257600080fd5b506104b0610af1366004614dec565b612c31565b348015610b0257600080fd5b50610435610b113660046145d4565b612d1c565b348015610b2257600080fd5b506104b0610b31366004614779565b612d33565b6104b0610b44366004614e4f565b612d6e565b348015610b5557600080fd5b506104b0610b6436600461484e565b612ea1565b348015610b7557600080fd5b50610458612ec7565b348015610b8a57600080fd5b50600354610485906001600160a01b031681565b348015610baa57600080fd5b506103fe610bb9366004614edc565b612ed4565b6104b0610bcc366004614e4f565b612f11565b348015610bdd57600080fd5b50600e54610485906001600160a01b031681565b348015610bfd57600080fd5b506104b0613030565b348015610c1257600080fd5b506104b0610c21366004614779565b61312e565b348015610c3257600080fd5b50610435600080516020615eee83398151915281565b6000610c53826131a7565b80610c625750610c62826131f5565b80610c7d57506001600160e01b0319821663152a902d60e11b145b92915050565b6060610c8d61321a565b6002018054610c9b90614f0a565b80601f0160208091040260200160405190810160405280929190818152602001828054610cc790614f0a565b8015610d145780601f10610ce957610100808354040283529160200191610d14565b820191906000526020600020905b815481529060010190602001808311610cf757829003601f168201915b5050505050905090565b6000610d298261323e565b610d46576040516333d1c03960e21b815260040160405180910390fd5b610d4e61321a565b60009283526006016020525060409020546001600160a01b031690565b610d778282600161327a565b5050565b600080516020615f2e83398151915254610100900460ff16610db057600080516020615f2e8339815191525460ff1615610db4565b303b155b610e2b5760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a656400000000000000000060648201526084015b60405180910390fd5b600080516020615f2e83398151915254610100900460ff16158015610e6757600080516020615f2e833981519152805461ffff19166101011790555b600054610100900460ff1615808015610e875750600054600160ff909116105b80610ea15750303b158015610ea1575060005460ff166001145b610f045760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610e22565b6000805460ff191660011790558015610f27576000805461ff0019166101001790555b826000819003610f4a5760405163c52a9bd360e01b815260040160405180910390fd5b610fd6610f5a60208b018b614f3e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f9c9250505060408c018c614f3e565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061332f92505050565b610fe160008761336d565b610ff9600080516020615eee8339815191528761336d565b60005b8181101561104a57611042600080516020615f0e83398151915287878481811061102857611028614f84565b905060200201602081019061103d9190614779565b61336d565b600101610ffc565b50600380546001600160a01b0319166001600160a01b038c161790558860076110738282615270565b50611086905060a0880160808901614831565b600f805461ffff92909216600160a01b0261ffff60a01b199092169190911790556110be6110b9368a90038a018a615448565b613377565b8760046110cb8282615538565b505060405163bacf749160e01b815273d47d5f3cb05d4fc80b8b8a828e0626bc3a02c44e9063bacf749190611106908a908e906004016157a9565b6040805180830381865af4158015611122573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611146919061587d565b600f80546001600160a01b039283166001600160a01b031991821617909155600e8054939092169216919091179055600c541561132f5761132f6007600501805480602002602001604051908101604052809291908181526020016000905b828210156112515783829060005260206000200180546111c490614f0a565b80601f01602080910402602001604051908101604052809291908181526020018280546111f090614f0a565b801561123d5780601f106112125761010080835404028352916020019161123d565b820191906000526020600020905b81548152906001019060200180831161122057829003601f168201915b5050505050815260200190600101906111a5565b505050506007600601805480602002602001604051908101604052809291908181526020016000905b8282101561132657838290600052602060002001805461129990614f0a565b80601f01602080910402602001604051908101604052809291908181526020018280546112c590614f0a565b80156113125780601f106112e757610100808354040283529160200191611312565b820191906000526020600020905b8154815290600101906020018083116112f557829003601f168201915b50505050508152602001906001019061127a565b50505050612c31565b61135f8585600081811061134557611345614f84565b905060200201602081019061135a9190614779565b613632565b5080156113a6576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5080156113c657600080516020615f2e833981519152805461ff00191690555b5050505050505050565b60006113db3361220e565b9050806000036113fe57604051631b33a9b960e11b815260040160405180910390fd5b3360009081526016602052604081206114169161450c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611463576040519150601f19603f3d011682016040523d82523d6000602084013e611468565b606091505b50509050806114ab5760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610e22565b604080513381526001600160a01b03851660208201529081018390527f6d8c333bddf62a96b71c9e7d33a50120f1a1a46c94289b529f813a6ec3fbc488906060015b60405180910390a1505050565b60008061150561321a565b6001015461151161321a565b540303919050565b60006115248261368d565b9050836001600160a01b0316816001600160a01b0316146115575760405162a1148160e81b815260040160405180910390fd5b60008061156384613732565b9150915061158881876115733390565b6001600160a01b039081169116811491141790565b6115b3576115968633612ed4565b6115b357604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166115da57604051633a954ecd60e21b815260040160405180910390fd5b80156115e557600082555b6115ed61321a565b6001600160a01b038716600090815260059190910160205260409020805460001901905561161961321a565b6001600160a01b038616600090815260059190910160205260409020805460010190556116668561164b88828761375a565b600160e11b174260a01b176001600160a01b03919091161790565b61166e61321a565b60008681526004919091016020526040812091909155600160e11b841690036116e4576001840161169d61321a565b6000828152600491909101602052604081205490036116e2576116be61321a565b5481146116e257836116ce61321a565b600083815260049190910160205260409020555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b611746600080516020615eee83398151915233612537565b1580156117685750611766600080516020615f0e83398151915233612537565b155b15611785576040516282b42960e81b815260040160405180910390fd5b600360009054906101000a90046001600160a01b03166001600160a01b031663becee8146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fc91906158ac565b6004546118179190600160681b900464ffffffffff166158c5565b42106118365760405163c52a9bd360e01b815260040160405180910390fd5b6118486110b936839003830183615448565b8060046118558282615538565b9050507f2b4af2afe566e73a74e66c021d2430e915158858051a2986507682f58300df0f600460405161188891906158d8565b60405180910390a150565b600f546000908190600160a01b900461ffff166118b26127108561596b565b6118bc9190615113565b600f546001600160a01b03169590945092505050565b600080516020615f0e8339815191526118ea8161377d565b60045460135461ffff600160481b9092048216916119139185916401000000009091041661598d565b61ffff16111561193657604051630f196e0f60e21b815260040160405180910390fd5b81601360048282829054906101000a900461ffff16611955919061598d565b92506101000a81548161ffff021916908361ffff160217905550610d77338361ffff16613787565b600082815260016020819052604090912001546119998161377d565b6119a383836138e1565b505050565b6119c0600080516020615eee83398151915233612537565b1580156119e257506119e0600080516020615f0e83398151915233612537565b155b156119ff576040516282b42960e81b815260040160405180910390fd5b6127108161ffff161115611a265760405163134aed6960e21b815260040160405180910390fd5b600f805461ffff909216600160a01b0261ffff60a01b19909216919091179055565b6001600160a01b0381163314611ab85760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610e22565b610d778282613903565b600080611ad186868686613925565b6000908152601260205260409020549150505b949350505050565b6119a3838383604051806020016040528060008152506129ab565b611b1f600080516020615eee83398151915233612537565b158015611b415750611b3f600080516020615f0e83398151915233612537565b155b15611b5e576040516282b42960e81b815260040160405180910390fd5b60115460ff1680611b7e5750600454600160681b900464ffffffffff1642105b15611b9c5760405163b7b2409760e01b815260040160405180910390fd5b600454611bbb9062093a8090600160681b900464ffffffffff166159a8565b421015611bdb5760405163c52a9bd360e01b815260040160405180910390fd5b611be3613a04565b8163ffffffff16111580611c08575060045463ffffffff610100909104811690821610155b15611c265760405163c52a9bd360e01b815260040160405180910390fd5b600454600160281b900463ffffffff1615801590611c58575060045460135463ffffffff600160281b90920482169116105b15611c6557611c656123e3565b6004805464ffffffff00191661010063ffffffff8416908102919091179091556040519081527fdf59cbfdd7be2f761f91be74e6a7ae19c163c601feb064f51cc62e387a33412a90602001611888565b600081611cc18161323e565b611cde57604051638698bf3760e01b815260040160405180910390fd5b6000611ce984613a3c565b6060908101516040513090921b6001600160601b031916602083015260e881901b6001600160e81b0319166034830152603782018690529150605701604051602081830303815290604052805190602001209250505b50919050565b611d5d600080516020615eee83398151915233612537565b158015611d7f5750611d7d600080516020615f0e83398151915233612537565b155b15611d9c576040516282b42960e81b815260040160405180910390fd5b60106119a3828483614ff5565b6000610c7d8261368d565b600780546008805460809290921b9291611dcd90614f0a565b80601f0160208091040260200160405190810160405280929190818152602001828054611df990614f0a565b8015611e465780601f10611e1b57610100808354040283529160200191611e46565b820191906000526020600020905b815481529060010190602001808311611e2957829003601f168201915b505050505090806002018054611e5b90614f0a565b80601f0160208091040260200160405190810160405280929190818152602001828054611e8790614f0a565b8015611ed45780601f10611ea957610100808354040283529160200191611ed4565b820191906000526020600020905b815481529060010190602001808311611eb757829003601f168201915b505050505090806003018054611ee990614f0a565b80601f0160208091040260200160405190810160405280929190818152602001828054611f1590614f0a565b8015611f625780601f10611f3757610100808354040283529160200191611f62565b820191906000526020600020905b815481529060010190602001808311611f4557829003601f168201915b5050505050905084565b60006001600160a01b038216611f95576040516323d3ad8160e21b815260040160405180910390fd5b6001600160401b03611fa561321a565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b611fdc613ab3565b611fe66000613632565b565b60115460ff16806120085750600454600160681b900464ffffffffff1642105b156120265760405163b7b2409760e01b815260040160405180910390fd5b600061203488888787613925565b60035460405163cb3f5efd60e01b81529192506001600160a01b03169063cb3f5efd90612069908490879087906004016159e4565b60006040518083038186803b15801561208157600080fd5b505afa158015612095573d6000803e3d6000fd5b50505060008281526012602052604090205461ffff80881692506120bb919089166159a8565b11156120da5760405163342e754760e21b815260040160405180910390fd5b60045460135463ffffffff600160281b9092048216916121009161ffff8a1691166159fe565b63ffffffff16111561212557604051630f196e0f60e21b815260040160405180910390fd5b600454610100900463ffffffff1661ffff8716612140613a04565b61214a91906159a8565b111561216957604051630f196e0f60e21b815260040160405180910390fd5b6000818152601260205260408120805461ffff8916929061218b9084906159a8565b90915550506013805461ffff881691906000906121af90849063ffffffff166159fe565b92506101000a81548163ffffffff021916908363ffffffff1602179055506113c6878761ffff166001613b14565b601660205281600052604060002081815481106121f957600080fd5b90600052602060002001600091509150505481565b600454600090600160901b900464ffffffffff16421080156122305750601454155b1561223d57506000919050565b6001600160a01b038216600090815260166020526040812054900361226457506000919050565b600080601454116122775760065461227b565b6014545b90506000805b6001600160a01b038516600090815260166020526040902054811015612336576001600160a01b03851660009081526016602052604090208054849190839081106122ce576122ce614f84565b9060005260206000200154111561232e576001600160a01b038516600090815260166020526040902080548491908390811061230c5761230c614f84565b906000526020600020015461232191906158c5565b61232b90836159a8565b91505b600101612281565b509392505050565b80516020818301810180516017825292820191909301209152805461236290614f0a565b80601f016020809104026020016040519081016040528092919081815260200182805461238e90614f0a565b80156123db5780601f106123b0576101008083540402835291602001916123db565b820191906000526020600020905b8154815290600101906020018083116123be57829003601f168201915b505050505081565b6123fb600080516020615eee83398151915233612537565b15801561241d575061241b600080516020615f0e83398151915233612537565b155b1561243a576040516282b42960e81b815260040160405180910390fd5b60115460ff168061245a5750600454600160681b900464ffffffffff1642105b156124785760405163b7b2409760e01b815260040160405180910390fd5b600454600160901b900464ffffffffff164210156124a957604051630ca00c6160e01b815260040160405180910390fd5b60045460135463ffffffff600160281b909204821691161015611fe6576013546004805468ffffffff0000000000191663ffffffff909216600160281b029190911790556040517f31d3f5c743c51d955be3eb25850b4674ff70cecbf66917bf5798402e79f0d87590600090a1565b60008281526002602052604081206125309083613bf3565b9392505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606061256c61321a565b6003018054610c9b90614f0a565b600060145460001461258d575060145490565b6040516373a5726b60e01b81526004808201527319bc0b68a262a0f56a812bd0cabe1466fc1ca875906373a5726b90602401602060405180830381865af41580156125dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061260091906158ac565b905090565b8061260e61321a565b336000818152600792909201602090815260408084206001600160a01b03881680865290835293819020805460ff19169515159590951790945592518415158152919290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61268a613ab3565b600454600160901b900464ffffffffff164210156126bb57604051630ca00c6160e01b815260040160405180910390fd5b60006126d6600080516020615eee8339815191526000612518565b90506126e36000336138e1565b6126fb600080516020615eee833981519152336138e1565b612713600080516020615eee83398151915282613903565b61271e600082613903565b6040517f6040e61f478cab6309d426e690027716f353f33e0c0a2e00637aad97a55aa40a90600090a150565b600360009054906101000a90046001600160a01b03166001600160a01b0316637a69a41b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561279d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c19190615a1b565b6001600160a01b0316336001600160a01b0316146127f1576040516282b42960e81b815260040160405180910390fd5b60045460135461ffff600160581b909204821691612819918491600160301b9091041661598d565b61ffff16111561283c5760405163342e754760e21b815260040160405180910390fd5b80601360068282829054906101000a900461ffff1661285b919061598d565b92506101000a81548161ffff021916908361ffff160217905550610d77828261ffff16613787565b600454600090600160b81b900460ff1615806128ae5750600454600160901b900464ffffffffff1642105b806128b95750601554155b156128c45750600090565b60006014546000036128d8576006546128dc565b6014545b9050806015546128ec9190615113565b91505090565b6060816128fe8161323e565b61291b57604051638698bf3760e01b815260040160405180910390fd5b6003546007546001600160a01b039091169063e6ecd1bb9060801b8561294081611cb5565b6040516001600160e01b031960e086901b16815261296693929190600b90600401615a38565b600060405180830381865afa158015612983573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526125309190810190615b4c565b6129b6848484611519565b6001600160a01b0383163b156129ef576129d284848484613bff565b6129ef576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b612a0d600080516020615eee83398151915233612537565b158015612a2f5750612a2d600080516020615f0e83398151915233612537565b155b15612a4c576040516282b42960e81b815260040160405180910390fd5b600060045460ff166003811115612a6557612a65614bb5565b1480612a875750600360045460ff166003811115612a8557612a85614bb5565b145b15612aa55760405163c52a9bd360e01b815260040160405180910390fd5b600454600160901b900464ffffffffff16421015612ad657604051630ca00c6160e01b815260040160405180910390fd5b601554600003612af95760405163c52a9bd360e01b815260040160405180910390fd5b6000601454600003612b0d57600654612b11565b6014545b9050600081601554612b239190615113565b60006015819055600e5460405192935090916001600160a01b039091169083908381818185875af1925050503d8060008114612b7b576040519150601f19603f3d011682016040523d82523d6000602084013e612b80565b606091505b5050905080612ba2576040516307a4ced160e51b815260040160405180910390fd5b6040518281527f89b30d91afe451fad93250252429a175014da30702be5cdcba095813737baabc906020016114ed565b606081612bde8161323e565b612bfb57604051638698bf3760e01b815260040160405180910390fd5b60035460405163641af18160e11b81526001600160a01b039091169063c835e30290612966908690600a90601090600401615c11565b612c49600080516020615eee83398151915233612537565b158015612c6b5750612c69600080516020615f0e83398151915233612537565b155b15612c88576040516282b42960e81b815260040160405180910390fd5b8051825114612caa5760405163c52a9bd360e01b815260040160405180910390fd5b60005b82518110156119a357818181518110612cc857612cc8614f84565b60200260200101516017848381518110612ce457612ce4614f84565b6020026020010151604051612cf99190615c46565b90815260200160405180910390209081612d139190615c62565b50600101612cad565b6000818152600260205260408120610c7d90613ce7565b600080516020615eee833981519152612d4b8161377d565b50600380546001600160a01b0319166001600160a01b0392909216919091179055565b60115460ff1680612d8e5750600454600160681b900464ffffffffff1642105b15612dac5760405163b7b2409760e01b815260040160405180910390fd5b60135460009063ffffffff16612dc0613a04565b612dca91906158c5565b600454909150600090612df19063ffffffff600160281b8204811691610100900416615d21565b63ffffffff16905080612e0861ffff8816846159a8565b1115612e2757604051630f196e0f60e21b815260040160405180910390fd5b60035460405163031ffc5160e51b81526001600160a01b03909116906363ff8a2090612e61908b908b908b908b908b908b90600401615d3e565b60006040518083038186803b158015612e7957600080fd5b505afa158015612e8d573d6000803e3d6000fd5b505050506113c6878761ffff166000613b14565b60008281526001602081905260409091200154612ebd8161377d565b6119a38383613903565b6010805461236290614f0a565b6000612ede61321a565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b60115460ff1680612f315750600454600160681b900464ffffffffff1642105b15612f4f5760405163b7b2409760e01b815260040160405180910390fd5b600360045460ff166003811115612f6857612f68614bb5565b14612f865760405163c52a9bd360e01b815260040160405180910390fd5b600454600160901b900464ffffffffff164210612fb65760405163b7b2409760e01b815260040160405180910390fd5b60035460405163031ffc5160e51b81526001600160a01b03909116906363ff8a2090612ff090899089908990899089908990600401615d3e565b60006040518083038186803b15801561300857600080fd5b505afa15801561301c573d6000803e3d6000fd5b50505050611726858561ffff166000613b14565b613048600080516020615eee83398151915233612537565b15801561306a5750613068600080516020615f0e83398151915233612537565b155b15613087576040516282b42960e81b815260040160405180910390fd5b60115460ff16806130a75750600454600160681b900464ffffffffff1642105b156130c55760405163b7b2409760e01b815260040160405180910390fd5b600454600160901b900464ffffffffff164210156130f657604051630ca00c6160e01b815260040160405180910390fd5b6011805460ff191660011790556040517f0734f1adc097bd79a3404c9d255d53ced9e8fef12f9718038823aa8265e51c3490600090a1565b613136613ab3565b6001600160a01b03811661319b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610e22565b6131a481613632565b50565b60006301ffc9a760e01b6001600160e01b0319831614806131d857506380ac58cd60e01b6001600160e01b03198316145b80610c7d5750506001600160e01b031916635b5e139f60e01b1490565b60006001600160e01b03198216635a05180f60e01b1480610c7d5750610c7d82613cf1565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b600061324861321a565b5482108015610c7d5750600160e01b61325f61321a565b60008481526004919091016020526040902054161592915050565b600061328583611da9565b905081156132c457336001600160a01b038216146132c4576132a78133612ed4565b6132c4576040516367d9dca160e11b815260040160405180910390fd5b836132cd61321a565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b600080516020615f2e83398151915254610100900460ff166133635760405162461bcd60e51b8152600401610e2290615d89565b610d778282613d26565b610d7782826138e1565b60a0810151600454600160681b900464ffffffffff9081169116148015906134295750600360009054906101000a90046001600160a01b03166001600160a01b031663becee8146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341191906158ac565b61341b90426159a8565b8160a0015164ffffffffff16105b156134475760405163c52a9bd360e01b815260040160405180910390fd5b60038151600381111561345c5761345c614bb5565b036134c05760c081015164ffffffffff1615806134825750604081015163ffffffff1615155b806134965750602081015163ffffffff1615155b806134a257508060e001515b156134c05760405163c52a9bd360e01b815260040160405180910390fd5b6000815160038111156134d5576134d5614bb5565b03613547578060e00151806134f4575060c081015164ffffffffff1615155b156135125760405163c52a9bd360e01b815260040160405180910390fd5b806020015163ffffffff16816040015163ffffffff1611156135475760405163c52a9bd360e01b815260040160405180910390fd5b60028151600381111561355c5761355c614bb5565b036131a4578060a0015164ffffffffff168160c0015164ffffffffff16116135975760405163c52a9bd360e01b815260040160405180910390fd5b806101200151816101000151116135c15760405163c52a9bd360e01b815260040160405180910390fd5b611c208160a001518260c001516135d89190615ddd565b64ffffffffff1611156135fe5760405163c52a9bd360e01b815260040160405180910390fd5b806020015163ffffffff16816040015163ffffffff16106131a45760405163c52a9bd360e01b815260040160405180910390fd5b600080546001600160a01b038381166201000081810262010000600160b01b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b600061369761321a565b600083815260049190910160205260408120549150600160e01b821690036137195780600003613714576136c961321a565b5482106136e957604051636f96cda160e11b815260040160405180910390fd5b6136f161321a565b6000199092016000818152600493909301602052604090922054905080156136e9575b919050565b604051636f96cda160e11b815260040160405180910390fd5b600080600061373f61321a565b60009485526006016020525050604090912080549092909150565b600060e882811c9061376d868684613d99565b62ffffff16901b95945050505050565b6131a48133613dc0565b600061379161321a565b54905060008290036137b65760405163b562e8dd60e01b815260040160405180910390fd5b6801000000000000000182026137ca61321a565b6001600160a01b038516600090815260059190910160205260408120805490920190915561381c9084906137ff90828161375a565b6001851460e11b174260a01b176001600160a01b03919091161790565b61382461321a565b600083815260049190910160205260408120919091556001600160a01b0384169083830190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b8181146138ae57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101613876565b50816000036138cf57604051622e076360e81b815260040160405180910390fd5b806138d861321a565b55506119a39050565b6138eb8282613e19565b60008281526002602052604090206119a39082613e84565b61390d8282613e99565b60008281526002602052604090206119a39082613f00565b6040516001600160f81b031960208201526001600160801b0319851660218201526001600160601b0319606085901b1660318201526001600160f01b031960f084901b1660458201526001600160e01b031960e083901b16604782015246604b8201526000906139fb90606b01604051602081830303815290604052805190602001206040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b95945050505050565b60135460009061ffff600160301b8204811691640100000000900416613a286114fa565b613a3291906158c5565b61260091906158c5565b604080516080810182526000808252602082018190529181018290526060810191909152610c7d613a6c8361368d565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b6000546001600160a01b0362010000909104163314611fe65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610e22565b6000613b1e61257a565b90506000613b2c8285615113565b905080341015613b4f5760405163078d696560e31b815260040160405180910390fd5b600454600160b81b900460ff1615613b7557613b6e8585858585613f15565b5050505050565b600e546040516000916001600160a01b03169034908381818185875af1925050503d8060008114613bc2576040519150601f19603f3d011682016040523d82523d6000602084013e613bc7565b606091505b5050905080613be9576040516307a4ced160e51b815260040160405180910390fd5b6117268686613787565b60006125308383614193565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290613c34903390899088908890600401615dfb565b6020604051808303816000875af1925050508015613c6f575060408051601f3d908101601f19168201909252613c6c91810190615e2e565b60015b613ccd573d808015613c9d576040519150601f19603f3d011682016040523d82523d6000602084013e613ca2565b606091505b508051600003613cc5576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611ae4565b6000610c7d825490565b60006001600160e01b03198216637965db0b60e01b1480610c7d57506301ffc9a760e01b6001600160e01b0319831614610c7d565b600080516020615f2e83398151915254610100900460ff16613d5a5760405162461bcd60e51b8152600401610e2290615d89565b81613d6361321a565b60020190613d719082615c62565b5080613d7b61321a565b60030190613d899082615c62565b506000613d9461321a565b555050565b60006001600160a01b038416613db957613db2836141bd565b9050612530565b5092915050565b613dca8282612537565b610d7757613dd78161421d565b613de283602061422f565b604051602001613df3929190615e4b565b60408051601f198184030181529082905262461bcd60e51b8252610e22916004016145c1565b613e238282612537565b610d775760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000612530836001600160a01b0384166143ca565b613ea38282612537565b15610d775760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000612530836001600160a01b038416614419565b82613fb85760135460009063ffffffff16613f2e613a04565b613f3891906158c5565b600454909150600090613f5f9063ffffffff600160281b8204811691610100900416615d21565b63ffffffff1690506014546000148015613f81575080613f7f87846159a8565b145b15613fb55760148490556040517f0734f1adc097bd79a3404c9d255d53ced9e8fef12f9718038823aa8265e51c3490600090a15b50505b34811060008115613fd057613fcd83346158c5565b90505b601454158015613fe1575060065484115b1561406857336000908152601660205260409020613fff82866159a8565b815460018181018455600093845260208420909101919091559091505b8681101561404f57336000908152601660209081526040822080546001818101835591845291909220018690550161401c565b50856015600082825461406291906159a8565b90915550505b80156140d957604051600090339083908381818185875af1925050503d80600081146140b0576040519150601f19603f3d011682016040523d82523d6000602084013e6140b5565b606091505b50509050806140d7576040516307a4ced160e51b815260040160405180910390fd5b505b6014541515806140ea575060065484145b806141055750600454600160901b900464ffffffffff164210155b1561418057600e546040516000916001600160a01b03169085908381818185875af1925050503d8060008114614157576040519150601f19603f3d011682016040523d82523d6000602084013e61415c565b606091505b505090508061417e576040516307a4ced160e51b815260040160405180910390fd5b505b61418a8787613787565b50505050505050565b60008260000182815481106141aa576141aa614f84565b9060005260206000200154905092915050565b600042446141cc6001436158c5565b6040805160208101949094528301919091524060608083019190915283901b6001600160601b03191660808201526094016040516020818303038152906040528051906020012060e81c9050919050565b6060610c7d6001600160a01b03831660145b6060600061423e836002615113565b6142499060026159a8565b6001600160401b0381111561426057614260614a8d565b6040519080825280601f01601f19166020018201604052801561428a576020820181803683370190505b509050600360fc1b816000815181106142a5576142a5614f84565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106142d4576142d4614f84565b60200101906001600160f81b031916908160001a90535060006142f8846002615113565b6143039060016159a8565b90505b600181111561437b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061433757614337614f84565b1a60f81b82828151811061434d5761434d614f84565b60200101906001600160f81b031916908160001a90535060049490941c9361437481615ec0565b9050614306565b5083156125305760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610e22565b600081815260018301602052604081205461441157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c7d565b506000610c7d565b6000818152600183016020526040812054801561450257600061443d6001836158c5565b8554909150600090614451906001906158c5565b90508181146144b657600086600001828154811061447157614471614f84565b906000526020600020015490508087600001848154811061449457614494614f84565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806144c7576144c7615ed7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c7d565b6000915050610c7d565b50805460008255906000526020600020908101906131a491905b8082111561453a5760008155600101614526565b5090565b6001600160e01b0319811681146131a457600080fd5b60006020828403121561456657600080fd5b81356125308161453e565b60005b8381101561458c578181015183820152602001614574565b50506000910152565b600081518084526145ad816020860160208601614571565b601f01601f19169290920160200192915050565b6020815260006125306020830184614595565b6000602082840312156145e657600080fd5b5035919050565b6001600160a01b03811681146131a457600080fd5b8035613714816145ed565b6000806040838503121561462057600080fd5b823561462b816145ed565b946020939093013593505050565b60006101408284031215611d3f57600080fd5b600060a08284031215611d3f57600080fd5b60008083601f84011261467057600080fd5b5081356001600160401b0381111561468757600080fd5b6020830191508360208260051b85010111156146a257600080fd5b9250929050565b60008060008060008060006101e0888a0312156146c557600080fd5b87356146d0816145ed565b965060208801356001600160401b03808211156146ec57600080fd5b9089019060e0828c03121561470057600080fd5b8197506147108b60408c01614639565b96506101808a013591508082111561472757600080fd5b6147338b838c0161464c565b95506147426101a08b01614602565b94506101c08a013591508082111561475957600080fd5b506147668a828b0161465e565b989b979a50959850939692959293505050565b60006020828403121561478b57600080fd5b8135612530816145ed565b6000806000606084860312156147ab57600080fd5b83356147b6816145ed565b925060208401356147c6816145ed565b929592945050506040919091013590565b600061014082840312156147ea57600080fd5b6125308383614639565b6000806040838503121561480757600080fd5b50508035926020909101359150565b61ffff811681146131a457600080fd5b803561371481614816565b60006020828403121561484357600080fd5b813561253081614816565b6000806040838503121561486157600080fd5b823591506020830135614873816145ed565b809150509250929050565b6001600160801b0319811681146131a457600080fd5b63ffffffff811681146131a457600080fd5b803561371481614894565b600080600080608085870312156148c757600080fd5b84356148d28161487e565b935060208501356148e2816145ed565b925060408501356148f281614816565b9150606085013561490281614894565b939692955090935050565b60006020828403121561491f57600080fd5b813561253081614894565b60008083601f84011261493c57600080fd5b5081356001600160401b0381111561495357600080fd5b6020830191508360208285010111156146a257600080fd5b6000806020838503121561497e57600080fd5b82356001600160401b0381111561499457600080fd5b6149a08582860161492a565b90969095509350505050565b6001600160801b0319851681526080602082015260006149cf6080830186614595565b82810360408401526149e18186614595565b905082810360608401526149f58185614595565b979650505050505050565b600080600080600080600060c0888a031215614a1b57600080fd5b8735614a268161487e565b96506020880135614a36816145ed565b95506040880135614a4681614816565b94506060880135614a5681614816565b93506080880135614a6681614894565b925060a08801356001600160401b03811115614a8157600080fd5b6147668a828b0161492a565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b0381118282101715614ac657614ac6614a8d565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614af457614af4614a8d565b604052919050565b60006001600160401b03821115614b1557614b15614a8d565b50601f01601f191660200190565b6000614b36614b3184614afc565b614acc565b9050828152838383011115614b4a57600080fd5b828260208301376000602084830101529392505050565b600082601f830112614b7257600080fd5b61253083833560208501614b23565b600060208284031215614b9357600080fd5b81356001600160401b03811115614ba957600080fd5b611ae484828501614b61565b634e487b7160e01b600052602160045260246000fd5b60048110614be957634e487b7160e01b600052602160045260246000fd5b9052565b6101408101614bfc828d614bcb565b63ffffffff9a8b1660208301529890991660408a015261ffff96871660608a015294909516608088015264ffffffffff92831660a0880152911660c0860152151560e085015261010084019190915261012090920191909152919050565b80151581146131a457600080fd5b803561371481614c5a565b60008060408385031215614c8657600080fd5b8235614c91816145ed565b9150602083013561487381614c5a565b60008060408385031215614cb457600080fd5b8235614cbf816145ed565b9150602083013561487381614816565b60008060008060808587031215614ce557600080fd5b8435614cf0816145ed565b93506020850135614d00816145ed565b92506040850135915060608501356001600160401b03811115614d2257600080fd5b8501601f81018713614d3357600080fd5b614d4287823560208401614b23565b91505092959194509250565b600082601f830112614d5f57600080fd5b813560206001600160401b0380831115614d7b57614d7b614a8d565b8260051b614d8a838201614acc565b9384528581018301938381019088861115614da457600080fd5b84880192505b85831015614de057823584811115614dc25760008081fd5b614dd08a87838c0101614b61565b8352509184019190840190614daa565b98975050505050505050565b60008060408385031215614dff57600080fd5b82356001600160401b0380821115614e1657600080fd5b614e2286838701614d4e565b93506020850135915080821115614e3857600080fd5b50614e4585828601614d4e565b9150509250929050565b60008060008060008060a08789031215614e6857600080fd5b8635614e738161487e565b95506020870135614e83816145ed565b94506040870135614e9381614816565b93506060870135614ea381614894565b925060808701356001600160401b03811115614ebe57600080fd5b614eca89828a0161492a565b979a9699509497509295939492505050565b60008060408385031215614eef57600080fd5b8235614efa816145ed565b91506020830135614873816145ed565b600181811c90821680614f1e57607f821691505b602082108103611d3f57634e487b7160e01b600052602260045260246000fd5b6000808335601e19843603018112614f5557600080fd5b8301803591506001600160401b03821115614f6f57600080fd5b6020019150368190038213156146a257600080fd5b634e487b7160e01b600052603260045260246000fd5b60008135610c7d8161487e565b5b81811015610d775760008155600101614fa8565b601f8211156119a357806000526020600020601f840160051c81016020851015614fe35750805b613b6e601f850160051c830182614fa7565b6001600160401b0383111561500c5761500c614a8d565b6150208361501a8354614f0a565b83614fbc565b6000601f841160018114615054576000851561503c5750838201355b600019600387901b1c1916600186901b178355613b6e565b600083815260209020601f19861690835b828110156150855786850135825560209485019460019092019101615065565b50868210156150a25760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b6000808335601e198436030181126150cb57600080fd5b8301803591506001600160401b038211156150e557600080fd5b6020019150600581901b36038213156146a257600080fd5b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610c7d57610c7d6150fd565b600160401b82111561513e5761513e614a8d565b8054828255808310156119a3578160005260206000206001840160011c810160108560041b168015615181576000198083018054828460200360031b1c16815550505b50613b6e6001840160011c830182614fa7565b600160401b8311156151a8576151a8614a8d565b805483825580841015615231576000828152602081208581019083015b8082101561522d576151d78254614f0a565b801561522157601f808211600181146151f25785855561521e565b60008581526020902061520f83850160051c820160018301614fa7565b50600085815260208120818755555b50505b506001820191506151c5565b5050505b5060008181526020812083915b85811015611726576152508386614f3e565b61525b818386614ff5565b5050602092909201916001918201910161523e565b813561527b8161487e565b8060801c6001600160801b031983541617825550600160206152a06020850185614f3e565b6152ae818360018801614ff5565b505060026152bf6040860186614f3e565b6152cd818360028901614ff5565b50506152dc6060860186614f3e565b6152ea818360038901614ff5565b505060048085016152fe60808801886150b4565b6001600160401b0381111561531557615315614a8d565b61531f818461512a565b60008381526020902092508060011c60005b81811015615391576000805b888110156153855761537861535a61535488614f9a565b60801c90565b6001600160801b03908116838b1b60031b90811b91901b1984161790565b958a019591508a0161533d565b50858201558801615331565b50600119821695508582038683146153d1576000805b828110156153cb576153be61535a61535488614f9a565b958a019591508a016153a7565b50858301555b5050505050505050506153e760a08301836150b4565b6153f5818360058601615194565b505061540460c08301836150b4565b6129ef818360068601615194565b600481106131a457600080fd5b803561371481615412565b64ffffffffff811681146131a457600080fd5b80356137148161542a565b6000610140828403121561545b57600080fd5b615463614aa3565b61546c8361541f565b815261547a602084016148a6565b602082015261548b604084016148a6565b604082015261549c60608401614826565b60608201526154ad60808401614826565b60808201526154be60a0840161543d565b60a08201526154cf60c0840161543d565b60c08201526154e060e08401614c68565b60e08201526101008381013590820152610120928301359281019290925250919050565b60008135610c7d81614894565b60008135610c7d81614816565b60008135610c7d8161542a565b60008135610c7d81614c5a565b813561554381615412565b6004811061556157634e487b7160e01b600052602160045260246000fd5b60ff1982541660ff821681178355505061559c61558060208401615504565b825464ffffffff00191660089190911b64ffffffff0016178255565b6155cf6155ab60408401615504565b825468ffffffff0000000000191660289190911b68ffffffff000000000016178255565b6156066155de60608401615511565b82546affff000000000000000000191660489190911b6affff00000000000000000016178255565b61563561561560808401615511565b82805461ffff60581b191660589290921b61ffff60581b16919091179055565b61566a61564460a0840161551e565b82805464ffffffffff60681b191660689290921b64ffffffffff60681b16919091179055565b61569f61567960c0840161551e565b82805464ffffffffff60901b191660909290921b64ffffffffff60901b16919091179055565b6156cc6156ae60e0840161552b565b82805460ff60b81b191691151560b81b60ff60b81b16919091179055565b610100820135600182015561012082013560028201555050565b6000808335601e198436030181126156fd57600080fd5b83016020810192503590506001600160401b0381111561571c57600080fd5b8060051b36038213156146a257600080fd5b8183526000602080850194508260005b8581101561576c578135615751816145ed565b6001600160a01b03168752958201959082019060010161573e565b509495945050505050565b81835260006001600160fb1b0383111561579057600080fd5b8260051b80836020870137939093016020019392505050565b6040815260006157b984856156e6565b60a060408501526157ce60e08501828461572e565b9150506157de60208601866156e6565b603f19808685030160608701526157f6848385615777565b935061580560408901896156e6565b935091508086850301608087015261581e84848461572e565b935061582d60608901896156e6565b93509150808685030160a087015250615847838383615777565b92505050608085013561585981614816565b61ffff1660c08401526001600160a01b039390931660209092019190915250919050565b6000806040838503121561589057600080fd5b825161589b816145ed565b6020840151909250614873816145ed565b6000602082840312156158be57600080fd5b5051919050565b81810381811115610c7d57610c7d6150fd565b81546101408201906158ed8360ff8316614bcb565b63ffffffff600882901c81166020850152602882901c16604084015261ffff604882901c81166060850152605882901c16608084015264ffffffffff606882901c811660a0850152609082901c1660c084015260ff60b882901c16151560e08401525060018301546101008301526002909201546101209091015290565b60008261598857634e487b7160e01b600052601260045260246000fd5b500490565b61ffff818116838216019080821115613db957613db96150fd565b80820180821115610c7d57610c7d6150fd565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8381526040602082015260006139fb6040830184866159bb565b63ffffffff818116838216019080821115613db957613db96150fd565b600060208284031215615a2d57600080fd5b8151612530816145ed565b600060808083016001600160801b031980891685526020886020870152604088604088015260806060880152838854615a75818790815260200190565b60008b81526020812097509092505b60018281830110615a955750615abf565b87546001600160801b0319818b1b8116865290881616868501529096019591830191600201615a84565b8654975081811015615aec57615ae1838960801b6001600160801b0319169052565b602092909201916001015b81811015615b0a576001600160801b03198887161683526020830192505b50909c9b505050505050505050505050565b6000615b2a614b3184614afc565b9050828152838383011115615b3e57600080fd5b612530836020830184614571565b600060208284031215615b5e57600080fd5b81516001600160401b03811115615b7457600080fd5b8201601f81018413615b8557600080fd5b611ae484825160208401615b1c565b60008154615ba181614f0a565b808552602060018381168015615bbe5760018114615bd857615c06565b60ff1985168884015283151560051b880183019550615c06565b866000528260002060005b85811015615bfe5781548a8201860152908301908401615be3565b890184019650505b505050505092915050565b838152606060208201526000615c2a6060830185615b94565b8281036040840152615c3c8185615b94565b9695505050505050565b60008251615c58818460208701614571565b9190910192915050565b81516001600160401b03811115615c7b57615c7b614a8d565b615c8f81615c898454614f0a565b84614fbc565b602080601f831160018114615cc45760008415615cac5750858301515b600019600386901b1c1916600185901b178555611726565b600085815260208120601f198616915b82811015615cf357888601518255948401946001909101908401615cd4565b5085821015615d115787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b63ffffffff828116828216039080821115613db957613db96150fd565b6001600160801b0319871681526001600160a01b038616602082015261ffff8516604082015263ffffffff8416606082015260a060808201819052600090614de090830184866159bb565b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b64ffffffffff828116828216039080821115613db957613db96150fd565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615c3c90830184614595565b600060208284031215615e4057600080fd5b81516125308161453e565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615e83816017850160208801614571565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615eb4816028840160208801614571565b01602801949350505050565b600081615ecf57615ecf6150fd565b506000190190565b634e487b7160e01b600052603160045260246000fdfef206625bad3d9112d5609b8d356e6fbd514cd1f69980d4ce2b3e6e68e1789ace63680df430131e002a919e96864c2a88aef0a4ae2b002894ffc3d31894db09c4ee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85fa2646970667358221220c692c6a58fa64fece5f9ab53656939343d7d030cef9ca4e4c30568d273f4e40164736f6c63430008170033
Deployed Bytecode
0x6080604052600436106103d95760003560e01c806384778eba116101fd578063bb011cbb11610118578063d547741f116100ab578063ec06789d1161007a578063ec06789d14610bbe578063ed4a6b0c14610bd1578063ee55efee14610bf1578063f2fde38b14610c06578063f5b944eb14610c2657600080fd5b8063d547741f14610b49578063d76b47cb14610b69578063e756d96914610b7e578063e985e9c514610b9e57600080fd5b8063c9910973116100e7578063c991097314610ad6578063ca15c87314610af6578063ca5eb5e114610b16578063d2e8281f14610b3657600080fd5b8063bb011cbb14610a6a578063bf964b4e14610a7f578063c56ca30614610a9f578063c87b56dd14610ab657600080fd5b80639acd26d511610190578063acfc03521161015f578063acfc035214610a02578063b45e01e914610a22578063b79bebaf14610a37578063b88d4fde14610a5757600080fd5b80639acd26d514610995578063a217fddf146109b8578063a22cb465146109cd578063a404d794146109ed57600080fd5b806390aa0b0f116101cc57806390aa0b0f146108bc57806391d148541461094b57806395d89b411461096b57806398d5fdca1461098057600080fd5b806384778eba1461084d5780638c1478a2146108625780638da5cb5b146108785780639010d07c1461089c57600080fd5b806336568abe116102f85780636352211e1161028b578063715018a61161025a578063715018a6146107c5578063774c96ce146107da5780637ea249ad146107ed5780637ec9704f1461080d57806380a6dfa01461082d57600080fd5b80636352211e1461073e57806369005cd61461075e5780636b34d7251461078057806370a08231146107a557600080fd5b806342842e0e116102c757806342842e0e146106cb5780635c21f6d8146106de5780635f516836146106fe5780636343e0a21461071e57600080fd5b806336568abe1461062457806337fe26b91461064457806339fd52c31461066457806342260b5d1461069657600080fd5b80631e1a268b116103705780632a55205a1161033f5780632a55205a146105855780632c316c1d146105c45780632f2ff15d146105e4578063357b62171461060457600080fd5b80631e1a268b1461050757806323b872dd14610521578063248a9ca314610534578063249672151461056557600080fd5b8063095ea7b3116103ac578063095ea7b31461049d5780630a62ae41146104b2578063146bc04e146104d257806318160ddd146104f257600080fd5b806301ffc9a7146103de57806303366c411461041357806306fdde0314610443578063081812fc14610465575b600080fd5b3480156103ea57600080fd5b506103fe6103f9366004614554565b610c48565b60405190151581526020015b60405180910390f35b34801561041f57600080fd5b50610435600080516020615f0e83398151915281565b60405190815260200161040a565b34801561044f57600080fd5b50610458610c83565b60405161040a91906145c1565b34801561047157600080fd5b506104856104803660046145d4565b610d1e565b6040516001600160a01b03909116815260200161040a565b6104b06104ab36600461460d565b610d6b565b005b3480156104be57600080fd5b506104b06104cd3660046146a9565b610d7b565b3480156104de57600080fd5b506104b06104ed366004614779565b6113d0565b3480156104fe57600080fd5b506104356114fa565b34801561051357600080fd5b506011546103fe9060ff1681565b6104b061052f366004614796565b611519565b34801561054057600080fd5b5061043561054f3660046145d4565b6000908152600160208190526040909120015490565b34801561057157600080fd5b506104b06105803660046147d7565b61172e565b34801561059157600080fd5b506105a56105a03660046147f4565b611893565b604080516001600160a01b03909316835260208301919091520161040a565b3480156105d057600080fd5b506104b06105df366004614831565b6118d2565b3480156105f057600080fd5b506104b06105ff36600461484e565b61197d565b34801561061057600080fd5b506104b061061f366004614831565b6119a8565b34801561063057600080fd5b506104b061063f36600461484e565b611a48565b34801561065057600080fd5b5061043561065f3660046148b1565b611ac2565b34801561067057600080fd5b506013546106819063ffffffff1681565b60405163ffffffff909116815260200161040a565b3480156106a257600080fd5b50600f546106b890600160a01b900461ffff1681565b60405161ffff909116815260200161040a565b6104b06106d9366004614796565b611aec565b3480156106ea57600080fd5b506104b06106f936600461490d565b611b07565b34801561070a57600080fd5b506104356107193660046145d4565b611cb5565b34801561072a57600080fd5b506104b061073936600461496b565b611d45565b34801561074a57600080fd5b506104856107593660046145d4565b611da9565b34801561076a57600080fd5b506013546106b890600160301b900461ffff1681565b34801561078c57600080fd5b50610795611db4565b60405161040a94939291906149ac565b3480156107b157600080fd5b506104356107c0366004614779565b611f6c565b3480156107d157600080fd5b506104b0611fd4565b6104b06107e8366004614a00565b611fe8565b3480156107f957600080fd5b5061043561080836600461460d565b6121dd565b34801561081957600080fd5b50610435610828366004614779565b61220e565b34801561083957600080fd5b50610458610848366004614b81565b61233e565b34801561085957600080fd5b506104b06123e3565b34801561086e57600080fd5b5061043560145481565b34801561088457600080fd5b506000546201000090046001600160a01b0316610485565b3480156108a857600080fd5b506104856108b73660046147f4565b612518565b3480156108c857600080fd5b506004546005546006546109359260ff8082169363ffffffff6101008404811694600160281b85049091169361ffff600160481b8204811694600160581b83049091169364ffffffffff600160681b8404811694600160901b850490911693600160b81b9004909216918a565b60405161040a9a99989796959493929190614bed565b34801561095757600080fd5b506103fe61096636600461484e565b612537565b34801561097757600080fd5b50610458612562565b34801561098c57600080fd5b5061043561257a565b3480156109a157600080fd5b506013546106b890640100000000900461ffff1681565b3480156109c457600080fd5b50610435600081565b3480156109d957600080fd5b506104b06109e8366004614c73565b612605565b3480156109f957600080fd5b506104b0612682565b348015610a0e57600080fd5b506104b0610a1d366004614ca1565b61274a565b348015610a2e57600080fd5b50610435612883565b348015610a4357600080fd5b50610458610a523660046145d4565b6128f2565b6104b0610a65366004614ccf565b6129ab565b348015610a7657600080fd5b506104b06129f5565b348015610a8b57600080fd5b50600f54610485906001600160a01b031681565b348015610aab57600080fd5b5061043562093a8081565b348015610ac257600080fd5b50610458610ad13660046145d4565b612bd2565b348015610ae257600080fd5b506104b0610af1366004614dec565b612c31565b348015610b0257600080fd5b50610435610b113660046145d4565b612d1c565b348015610b2257600080fd5b506104b0610b31366004614779565b612d33565b6104b0610b44366004614e4f565b612d6e565b348015610b5557600080fd5b506104b0610b6436600461484e565b612ea1565b348015610b7557600080fd5b50610458612ec7565b348015610b8a57600080fd5b50600354610485906001600160a01b031681565b348015610baa57600080fd5b506103fe610bb9366004614edc565b612ed4565b6104b0610bcc366004614e4f565b612f11565b348015610bdd57600080fd5b50600e54610485906001600160a01b031681565b348015610bfd57600080fd5b506104b0613030565b348015610c1257600080fd5b506104b0610c21366004614779565b61312e565b348015610c3257600080fd5b50610435600080516020615eee83398151915281565b6000610c53826131a7565b80610c625750610c62826131f5565b80610c7d57506001600160e01b0319821663152a902d60e11b145b92915050565b6060610c8d61321a565b6002018054610c9b90614f0a565b80601f0160208091040260200160405190810160405280929190818152602001828054610cc790614f0a565b8015610d145780601f10610ce957610100808354040283529160200191610d14565b820191906000526020600020905b815481529060010190602001808311610cf757829003601f168201915b5050505050905090565b6000610d298261323e565b610d46576040516333d1c03960e21b815260040160405180910390fd5b610d4e61321a565b60009283526006016020525060409020546001600160a01b031690565b610d778282600161327a565b5050565b600080516020615f2e83398151915254610100900460ff16610db057600080516020615f2e8339815191525460ff1615610db4565b303b155b610e2b5760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a656400000000000000000060648201526084015b60405180910390fd5b600080516020615f2e83398151915254610100900460ff16158015610e6757600080516020615f2e833981519152805461ffff19166101011790555b600054610100900460ff1615808015610e875750600054600160ff909116105b80610ea15750303b158015610ea1575060005460ff166001145b610f045760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610e22565b6000805460ff191660011790558015610f27576000805461ff0019166101001790555b826000819003610f4a5760405163c52a9bd360e01b815260040160405180910390fd5b610fd6610f5a60208b018b614f3e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610f9c9250505060408c018c614f3e565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061332f92505050565b610fe160008761336d565b610ff9600080516020615eee8339815191528761336d565b60005b8181101561104a57611042600080516020615f0e83398151915287878481811061102857611028614f84565b905060200201602081019061103d9190614779565b61336d565b600101610ffc565b50600380546001600160a01b0319166001600160a01b038c161790558860076110738282615270565b50611086905060a0880160808901614831565b600f805461ffff92909216600160a01b0261ffff60a01b199092169190911790556110be6110b9368a90038a018a615448565b613377565b8760046110cb8282615538565b505060405163bacf749160e01b815273d47d5f3cb05d4fc80b8b8a828e0626bc3a02c44e9063bacf749190611106908a908e906004016157a9565b6040805180830381865af4158015611122573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611146919061587d565b600f80546001600160a01b039283166001600160a01b031991821617909155600e8054939092169216919091179055600c541561132f5761132f6007600501805480602002602001604051908101604052809291908181526020016000905b828210156112515783829060005260206000200180546111c490614f0a565b80601f01602080910402602001604051908101604052809291908181526020018280546111f090614f0a565b801561123d5780601f106112125761010080835404028352916020019161123d565b820191906000526020600020905b81548152906001019060200180831161122057829003601f168201915b5050505050815260200190600101906111a5565b505050506007600601805480602002602001604051908101604052809291908181526020016000905b8282101561132657838290600052602060002001805461129990614f0a565b80601f01602080910402602001604051908101604052809291908181526020018280546112c590614f0a565b80156113125780601f106112e757610100808354040283529160200191611312565b820191906000526020600020905b8154815290600101906020018083116112f557829003601f168201915b50505050508152602001906001019061127a565b50505050612c31565b61135f8585600081811061134557611345614f84565b905060200201602081019061135a9190614779565b613632565b5080156113a6576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5080156113c657600080516020615f2e833981519152805461ff00191690555b5050505050505050565b60006113db3361220e565b9050806000036113fe57604051631b33a9b960e11b815260040160405180910390fd5b3360009081526016602052604081206114169161450c565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114611463576040519150601f19603f3d011682016040523d82523d6000602084013e611468565b606091505b50509050806114ab5760405162461bcd60e51b815260206004820152600f60248201526e151c985b9cd9995c8819985a5b1959608a1b6044820152606401610e22565b604080513381526001600160a01b03851660208201529081018390527f6d8c333bddf62a96b71c9e7d33a50120f1a1a46c94289b529f813a6ec3fbc488906060015b60405180910390a1505050565b60008061150561321a565b6001015461151161321a565b540303919050565b60006115248261368d565b9050836001600160a01b0316816001600160a01b0316146115575760405162a1148160e81b815260040160405180910390fd5b60008061156384613732565b9150915061158881876115733390565b6001600160a01b039081169116811491141790565b6115b3576115968633612ed4565b6115b357604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b0385166115da57604051633a954ecd60e21b815260040160405180910390fd5b80156115e557600082555b6115ed61321a565b6001600160a01b038716600090815260059190910160205260409020805460001901905561161961321a565b6001600160a01b038616600090815260059190910160205260409020805460010190556116668561164b88828761375a565b600160e11b174260a01b176001600160a01b03919091161790565b61166e61321a565b60008681526004919091016020526040812091909155600160e11b841690036116e4576001840161169d61321a565b6000828152600491909101602052604081205490036116e2576116be61321a565b5481146116e257836116ce61321a565b600083815260049190910160205260409020555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b611746600080516020615eee83398151915233612537565b1580156117685750611766600080516020615f0e83398151915233612537565b155b15611785576040516282b42960e81b815260040160405180910390fd5b600360009054906101000a90046001600160a01b03166001600160a01b031663becee8146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117fc91906158ac565b6004546118179190600160681b900464ffffffffff166158c5565b42106118365760405163c52a9bd360e01b815260040160405180910390fd5b6118486110b936839003830183615448565b8060046118558282615538565b9050507f2b4af2afe566e73a74e66c021d2430e915158858051a2986507682f58300df0f600460405161188891906158d8565b60405180910390a150565b600f546000908190600160a01b900461ffff166118b26127108561596b565b6118bc9190615113565b600f546001600160a01b03169590945092505050565b600080516020615f0e8339815191526118ea8161377d565b60045460135461ffff600160481b9092048216916119139185916401000000009091041661598d565b61ffff16111561193657604051630f196e0f60e21b815260040160405180910390fd5b81601360048282829054906101000a900461ffff16611955919061598d565b92506101000a81548161ffff021916908361ffff160217905550610d77338361ffff16613787565b600082815260016020819052604090912001546119998161377d565b6119a383836138e1565b505050565b6119c0600080516020615eee83398151915233612537565b1580156119e257506119e0600080516020615f0e83398151915233612537565b155b156119ff576040516282b42960e81b815260040160405180910390fd5b6127108161ffff161115611a265760405163134aed6960e21b815260040160405180910390fd5b600f805461ffff909216600160a01b0261ffff60a01b19909216919091179055565b6001600160a01b0381163314611ab85760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610e22565b610d778282613903565b600080611ad186868686613925565b6000908152601260205260409020549150505b949350505050565b6119a3838383604051806020016040528060008152506129ab565b611b1f600080516020615eee83398151915233612537565b158015611b415750611b3f600080516020615f0e83398151915233612537565b155b15611b5e576040516282b42960e81b815260040160405180910390fd5b60115460ff1680611b7e5750600454600160681b900464ffffffffff1642105b15611b9c5760405163b7b2409760e01b815260040160405180910390fd5b600454611bbb9062093a8090600160681b900464ffffffffff166159a8565b421015611bdb5760405163c52a9bd360e01b815260040160405180910390fd5b611be3613a04565b8163ffffffff16111580611c08575060045463ffffffff610100909104811690821610155b15611c265760405163c52a9bd360e01b815260040160405180910390fd5b600454600160281b900463ffffffff1615801590611c58575060045460135463ffffffff600160281b90920482169116105b15611c6557611c656123e3565b6004805464ffffffff00191661010063ffffffff8416908102919091179091556040519081527fdf59cbfdd7be2f761f91be74e6a7ae19c163c601feb064f51cc62e387a33412a90602001611888565b600081611cc18161323e565b611cde57604051638698bf3760e01b815260040160405180910390fd5b6000611ce984613a3c565b6060908101516040513090921b6001600160601b031916602083015260e881901b6001600160e81b0319166034830152603782018690529150605701604051602081830303815290604052805190602001209250505b50919050565b611d5d600080516020615eee83398151915233612537565b158015611d7f5750611d7d600080516020615f0e83398151915233612537565b155b15611d9c576040516282b42960e81b815260040160405180910390fd5b60106119a3828483614ff5565b6000610c7d8261368d565b600780546008805460809290921b9291611dcd90614f0a565b80601f0160208091040260200160405190810160405280929190818152602001828054611df990614f0a565b8015611e465780601f10611e1b57610100808354040283529160200191611e46565b820191906000526020600020905b815481529060010190602001808311611e2957829003601f168201915b505050505090806002018054611e5b90614f0a565b80601f0160208091040260200160405190810160405280929190818152602001828054611e8790614f0a565b8015611ed45780601f10611ea957610100808354040283529160200191611ed4565b820191906000526020600020905b815481529060010190602001808311611eb757829003601f168201915b505050505090806003018054611ee990614f0a565b80601f0160208091040260200160405190810160405280929190818152602001828054611f1590614f0a565b8015611f625780601f10611f3757610100808354040283529160200191611f62565b820191906000526020600020905b815481529060010190602001808311611f4557829003601f168201915b5050505050905084565b60006001600160a01b038216611f95576040516323d3ad8160e21b815260040160405180910390fd5b6001600160401b03611fa561321a565b6005016000846001600160a01b03166001600160a01b0316815260200190815260200160002054169050919050565b611fdc613ab3565b611fe66000613632565b565b60115460ff16806120085750600454600160681b900464ffffffffff1642105b156120265760405163b7b2409760e01b815260040160405180910390fd5b600061203488888787613925565b60035460405163cb3f5efd60e01b81529192506001600160a01b03169063cb3f5efd90612069908490879087906004016159e4565b60006040518083038186803b15801561208157600080fd5b505afa158015612095573d6000803e3d6000fd5b50505060008281526012602052604090205461ffff80881692506120bb919089166159a8565b11156120da5760405163342e754760e21b815260040160405180910390fd5b60045460135463ffffffff600160281b9092048216916121009161ffff8a1691166159fe565b63ffffffff16111561212557604051630f196e0f60e21b815260040160405180910390fd5b600454610100900463ffffffff1661ffff8716612140613a04565b61214a91906159a8565b111561216957604051630f196e0f60e21b815260040160405180910390fd5b6000818152601260205260408120805461ffff8916929061218b9084906159a8565b90915550506013805461ffff881691906000906121af90849063ffffffff166159fe565b92506101000a81548163ffffffff021916908363ffffffff1602179055506113c6878761ffff166001613b14565b601660205281600052604060002081815481106121f957600080fd5b90600052602060002001600091509150505481565b600454600090600160901b900464ffffffffff16421080156122305750601454155b1561223d57506000919050565b6001600160a01b038216600090815260166020526040812054900361226457506000919050565b600080601454116122775760065461227b565b6014545b90506000805b6001600160a01b038516600090815260166020526040902054811015612336576001600160a01b03851660009081526016602052604090208054849190839081106122ce576122ce614f84565b9060005260206000200154111561232e576001600160a01b038516600090815260166020526040902080548491908390811061230c5761230c614f84565b906000526020600020015461232191906158c5565b61232b90836159a8565b91505b600101612281565b509392505050565b80516020818301810180516017825292820191909301209152805461236290614f0a565b80601f016020809104026020016040519081016040528092919081815260200182805461238e90614f0a565b80156123db5780601f106123b0576101008083540402835291602001916123db565b820191906000526020600020905b8154815290600101906020018083116123be57829003601f168201915b505050505081565b6123fb600080516020615eee83398151915233612537565b15801561241d575061241b600080516020615f0e83398151915233612537565b155b1561243a576040516282b42960e81b815260040160405180910390fd5b60115460ff168061245a5750600454600160681b900464ffffffffff1642105b156124785760405163b7b2409760e01b815260040160405180910390fd5b600454600160901b900464ffffffffff164210156124a957604051630ca00c6160e01b815260040160405180910390fd5b60045460135463ffffffff600160281b909204821691161015611fe6576013546004805468ffffffff0000000000191663ffffffff909216600160281b029190911790556040517f31d3f5c743c51d955be3eb25850b4674ff70cecbf66917bf5798402e79f0d87590600090a1565b60008281526002602052604081206125309083613bf3565b9392505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606061256c61321a565b6003018054610c9b90614f0a565b600060145460001461258d575060145490565b6040516373a5726b60e01b81526004808201527319bc0b68a262a0f56a812bd0cabe1466fc1ca875906373a5726b90602401602060405180830381865af41580156125dc573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061260091906158ac565b905090565b8061260e61321a565b336000818152600792909201602090815260408084206001600160a01b03881680865290835293819020805460ff19169515159590951790945592518415158152919290917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61268a613ab3565b600454600160901b900464ffffffffff164210156126bb57604051630ca00c6160e01b815260040160405180910390fd5b60006126d6600080516020615eee8339815191526000612518565b90506126e36000336138e1565b6126fb600080516020615eee833981519152336138e1565b612713600080516020615eee83398151915282613903565b61271e600082613903565b6040517f6040e61f478cab6309d426e690027716f353f33e0c0a2e00637aad97a55aa40a90600090a150565b600360009054906101000a90046001600160a01b03166001600160a01b0316637a69a41b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561279d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c19190615a1b565b6001600160a01b0316336001600160a01b0316146127f1576040516282b42960e81b815260040160405180910390fd5b60045460135461ffff600160581b909204821691612819918491600160301b9091041661598d565b61ffff16111561283c5760405163342e754760e21b815260040160405180910390fd5b80601360068282829054906101000a900461ffff1661285b919061598d565b92506101000a81548161ffff021916908361ffff160217905550610d77828261ffff16613787565b600454600090600160b81b900460ff1615806128ae5750600454600160901b900464ffffffffff1642105b806128b95750601554155b156128c45750600090565b60006014546000036128d8576006546128dc565b6014545b9050806015546128ec9190615113565b91505090565b6060816128fe8161323e565b61291b57604051638698bf3760e01b815260040160405180910390fd5b6003546007546001600160a01b039091169063e6ecd1bb9060801b8561294081611cb5565b6040516001600160e01b031960e086901b16815261296693929190600b90600401615a38565b600060405180830381865afa158015612983573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526125309190810190615b4c565b6129b6848484611519565b6001600160a01b0383163b156129ef576129d284848484613bff565b6129ef576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b612a0d600080516020615eee83398151915233612537565b158015612a2f5750612a2d600080516020615f0e83398151915233612537565b155b15612a4c576040516282b42960e81b815260040160405180910390fd5b600060045460ff166003811115612a6557612a65614bb5565b1480612a875750600360045460ff166003811115612a8557612a85614bb5565b145b15612aa55760405163c52a9bd360e01b815260040160405180910390fd5b600454600160901b900464ffffffffff16421015612ad657604051630ca00c6160e01b815260040160405180910390fd5b601554600003612af95760405163c52a9bd360e01b815260040160405180910390fd5b6000601454600003612b0d57600654612b11565b6014545b9050600081601554612b239190615113565b60006015819055600e5460405192935090916001600160a01b039091169083908381818185875af1925050503d8060008114612b7b576040519150601f19603f3d011682016040523d82523d6000602084013e612b80565b606091505b5050905080612ba2576040516307a4ced160e51b815260040160405180910390fd5b6040518281527f89b30d91afe451fad93250252429a175014da30702be5cdcba095813737baabc906020016114ed565b606081612bde8161323e565b612bfb57604051638698bf3760e01b815260040160405180910390fd5b60035460405163641af18160e11b81526001600160a01b039091169063c835e30290612966908690600a90601090600401615c11565b612c49600080516020615eee83398151915233612537565b158015612c6b5750612c69600080516020615f0e83398151915233612537565b155b15612c88576040516282b42960e81b815260040160405180910390fd5b8051825114612caa5760405163c52a9bd360e01b815260040160405180910390fd5b60005b82518110156119a357818181518110612cc857612cc8614f84565b60200260200101516017848381518110612ce457612ce4614f84565b6020026020010151604051612cf99190615c46565b90815260200160405180910390209081612d139190615c62565b50600101612cad565b6000818152600260205260408120610c7d90613ce7565b600080516020615eee833981519152612d4b8161377d565b50600380546001600160a01b0319166001600160a01b0392909216919091179055565b60115460ff1680612d8e5750600454600160681b900464ffffffffff1642105b15612dac5760405163b7b2409760e01b815260040160405180910390fd5b60135460009063ffffffff16612dc0613a04565b612dca91906158c5565b600454909150600090612df19063ffffffff600160281b8204811691610100900416615d21565b63ffffffff16905080612e0861ffff8816846159a8565b1115612e2757604051630f196e0f60e21b815260040160405180910390fd5b60035460405163031ffc5160e51b81526001600160a01b03909116906363ff8a2090612e61908b908b908b908b908b908b90600401615d3e565b60006040518083038186803b158015612e7957600080fd5b505afa158015612e8d573d6000803e3d6000fd5b505050506113c6878761ffff166000613b14565b60008281526001602081905260409091200154612ebd8161377d565b6119a38383613903565b6010805461236290614f0a565b6000612ede61321a565b6001600160a01b039384166000908152600791909101602090815260408083209490951682529290925250205460ff1690565b60115460ff1680612f315750600454600160681b900464ffffffffff1642105b15612f4f5760405163b7b2409760e01b815260040160405180910390fd5b600360045460ff166003811115612f6857612f68614bb5565b14612f865760405163c52a9bd360e01b815260040160405180910390fd5b600454600160901b900464ffffffffff164210612fb65760405163b7b2409760e01b815260040160405180910390fd5b60035460405163031ffc5160e51b81526001600160a01b03909116906363ff8a2090612ff090899089908990899089908990600401615d3e565b60006040518083038186803b15801561300857600080fd5b505afa15801561301c573d6000803e3d6000fd5b50505050611726858561ffff166000613b14565b613048600080516020615eee83398151915233612537565b15801561306a5750613068600080516020615f0e83398151915233612537565b155b15613087576040516282b42960e81b815260040160405180910390fd5b60115460ff16806130a75750600454600160681b900464ffffffffff1642105b156130c55760405163b7b2409760e01b815260040160405180910390fd5b600454600160901b900464ffffffffff164210156130f657604051630ca00c6160e01b815260040160405180910390fd5b6011805460ff191660011790556040517f0734f1adc097bd79a3404c9d255d53ced9e8fef12f9718038823aa8265e51c3490600090a1565b613136613ab3565b6001600160a01b03811661319b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610e22565b6131a481613632565b50565b60006301ffc9a760e01b6001600160e01b0319831614806131d857506380ac58cd60e01b6001600160e01b03198316145b80610c7d5750506001600160e01b031916635b5e139f60e01b1490565b60006001600160e01b03198216635a05180f60e01b1480610c7d5750610c7d82613cf1565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4090565b600061324861321a565b5482108015610c7d5750600160e01b61325f61321a565b60008481526004919091016020526040902054161592915050565b600061328583611da9565b905081156132c457336001600160a01b038216146132c4576132a78133612ed4565b6132c4576040516367d9dca160e11b815260040160405180910390fd5b836132cd61321a565b6000858152600691909101602052604080822080546001600160a01b0319166001600160a01b0394851617905551859287811692908516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259190a450505050565b600080516020615f2e83398151915254610100900460ff166133635760405162461bcd60e51b8152600401610e2290615d89565b610d778282613d26565b610d7782826138e1565b60a0810151600454600160681b900464ffffffffff9081169116148015906134295750600360009054906101000a90046001600160a01b03166001600160a01b031663becee8146040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133ed573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061341191906158ac565b61341b90426159a8565b8160a0015164ffffffffff16105b156134475760405163c52a9bd360e01b815260040160405180910390fd5b60038151600381111561345c5761345c614bb5565b036134c05760c081015164ffffffffff1615806134825750604081015163ffffffff1615155b806134965750602081015163ffffffff1615155b806134a257508060e001515b156134c05760405163c52a9bd360e01b815260040160405180910390fd5b6000815160038111156134d5576134d5614bb5565b03613547578060e00151806134f4575060c081015164ffffffffff1615155b156135125760405163c52a9bd360e01b815260040160405180910390fd5b806020015163ffffffff16816040015163ffffffff1611156135475760405163c52a9bd360e01b815260040160405180910390fd5b60028151600381111561355c5761355c614bb5565b036131a4578060a0015164ffffffffff168160c0015164ffffffffff16116135975760405163c52a9bd360e01b815260040160405180910390fd5b806101200151816101000151116135c15760405163c52a9bd360e01b815260040160405180910390fd5b611c208160a001518260c001516135d89190615ddd565b64ffffffffff1611156135fe5760405163c52a9bd360e01b815260040160405180910390fd5b806020015163ffffffff16816040015163ffffffff16106131a45760405163c52a9bd360e01b815260040160405180910390fd5b600080546001600160a01b038381166201000081810262010000600160b01b0319851617855560405193049190911692909183917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a35050565b600061369761321a565b600083815260049190910160205260408120549150600160e01b821690036137195780600003613714576136c961321a565b5482106136e957604051636f96cda160e11b815260040160405180910390fd5b6136f161321a565b6000199092016000818152600493909301602052604090922054905080156136e9575b919050565b604051636f96cda160e11b815260040160405180910390fd5b600080600061373f61321a565b60009485526006016020525050604090912080549092909150565b600060e882811c9061376d868684613d99565b62ffffff16901b95945050505050565b6131a48133613dc0565b600061379161321a565b54905060008290036137b65760405163b562e8dd60e01b815260040160405180910390fd5b6801000000000000000182026137ca61321a565b6001600160a01b038516600090815260059190910160205260408120805490920190915561381c9084906137ff90828161375a565b6001851460e11b174260a01b176001600160a01b03919091161790565b61382461321a565b600083815260049190910160205260408120919091556001600160a01b0384169083830190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b8181146138ae57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101613876565b50816000036138cf57604051622e076360e81b815260040160405180910390fd5b806138d861321a565b55506119a39050565b6138eb8282613e19565b60008281526002602052604090206119a39082613e84565b61390d8282613e99565b60008281526002602052604090206119a39082613f00565b6040516001600160f81b031960208201526001600160801b0319851660218201526001600160601b0319606085901b1660318201526001600160f01b031960f084901b1660458201526001600160e01b031960e083901b16604782015246604b8201526000906139fb90606b01604051602081830303815290604052805190602001206040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b95945050505050565b60135460009061ffff600160301b8204811691640100000000900416613a286114fa565b613a3291906158c5565b61260091906158c5565b604080516080810182526000808252602082018190529181018290526060810191909152610c7d613a6c8361368d565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b6000546001600160a01b0362010000909104163314611fe65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610e22565b6000613b1e61257a565b90506000613b2c8285615113565b905080341015613b4f5760405163078d696560e31b815260040160405180910390fd5b600454600160b81b900460ff1615613b7557613b6e8585858585613f15565b5050505050565b600e546040516000916001600160a01b03169034908381818185875af1925050503d8060008114613bc2576040519150601f19603f3d011682016040523d82523d6000602084013e613bc7565b606091505b5050905080613be9576040516307a4ced160e51b815260040160405180910390fd5b6117268686613787565b60006125308383614193565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290613c34903390899088908890600401615dfb565b6020604051808303816000875af1925050508015613c6f575060408051601f3d908101601f19168201909252613c6c91810190615e2e565b60015b613ccd573d808015613c9d576040519150601f19603f3d011682016040523d82523d6000602084013e613ca2565b606091505b508051600003613cc5576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611ae4565b6000610c7d825490565b60006001600160e01b03198216637965db0b60e01b1480610c7d57506301ffc9a760e01b6001600160e01b0319831614610c7d565b600080516020615f2e83398151915254610100900460ff16613d5a5760405162461bcd60e51b8152600401610e2290615d89565b81613d6361321a565b60020190613d719082615c62565b5080613d7b61321a565b60030190613d899082615c62565b506000613d9461321a565b555050565b60006001600160a01b038416613db957613db2836141bd565b9050612530565b5092915050565b613dca8282612537565b610d7757613dd78161421d565b613de283602061422f565b604051602001613df3929190615e4b565b60408051601f198184030181529082905262461bcd60e51b8252610e22916004016145c1565b613e238282612537565b610d775760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000612530836001600160a01b0384166143ca565b613ea38282612537565b15610d775760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000612530836001600160a01b038416614419565b82613fb85760135460009063ffffffff16613f2e613a04565b613f3891906158c5565b600454909150600090613f5f9063ffffffff600160281b8204811691610100900416615d21565b63ffffffff1690506014546000148015613f81575080613f7f87846159a8565b145b15613fb55760148490556040517f0734f1adc097bd79a3404c9d255d53ced9e8fef12f9718038823aa8265e51c3490600090a15b50505b34811060008115613fd057613fcd83346158c5565b90505b601454158015613fe1575060065484115b1561406857336000908152601660205260409020613fff82866159a8565b815460018181018455600093845260208420909101919091559091505b8681101561404f57336000908152601660209081526040822080546001818101835591845291909220018690550161401c565b50856015600082825461406291906159a8565b90915550505b80156140d957604051600090339083908381818185875af1925050503d80600081146140b0576040519150601f19603f3d011682016040523d82523d6000602084013e6140b5565b606091505b50509050806140d7576040516307a4ced160e51b815260040160405180910390fd5b505b6014541515806140ea575060065484145b806141055750600454600160901b900464ffffffffff164210155b1561418057600e546040516000916001600160a01b03169085908381818185875af1925050503d8060008114614157576040519150601f19603f3d011682016040523d82523d6000602084013e61415c565b606091505b505090508061417e576040516307a4ced160e51b815260040160405180910390fd5b505b61418a8787613787565b50505050505050565b60008260000182815481106141aa576141aa614f84565b9060005260206000200154905092915050565b600042446141cc6001436158c5565b6040805160208101949094528301919091524060608083019190915283901b6001600160601b03191660808201526094016040516020818303038152906040528051906020012060e81c9050919050565b6060610c7d6001600160a01b03831660145b6060600061423e836002615113565b6142499060026159a8565b6001600160401b0381111561426057614260614a8d565b6040519080825280601f01601f19166020018201604052801561428a576020820181803683370190505b509050600360fc1b816000815181106142a5576142a5614f84565b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106142d4576142d4614f84565b60200101906001600160f81b031916908160001a90535060006142f8846002615113565b6143039060016159a8565b90505b600181111561437b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061433757614337614f84565b1a60f81b82828151811061434d5761434d614f84565b60200101906001600160f81b031916908160001a90535060049490941c9361437481615ec0565b9050614306565b5083156125305760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610e22565b600081815260018301602052604081205461441157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610c7d565b506000610c7d565b6000818152600183016020526040812054801561450257600061443d6001836158c5565b8554909150600090614451906001906158c5565b90508181146144b657600086600001828154811061447157614471614f84565b906000526020600020015490508087600001848154811061449457614494614f84565b6000918252602080832090910192909255918252600188019052604090208390555b85548690806144c7576144c7615ed7565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610c7d565b6000915050610c7d565b50805460008255906000526020600020908101906131a491905b8082111561453a5760008155600101614526565b5090565b6001600160e01b0319811681146131a457600080fd5b60006020828403121561456657600080fd5b81356125308161453e565b60005b8381101561458c578181015183820152602001614574565b50506000910152565b600081518084526145ad816020860160208601614571565b601f01601f19169290920160200192915050565b6020815260006125306020830184614595565b6000602082840312156145e657600080fd5b5035919050565b6001600160a01b03811681146131a457600080fd5b8035613714816145ed565b6000806040838503121561462057600080fd5b823561462b816145ed565b946020939093013593505050565b60006101408284031215611d3f57600080fd5b600060a08284031215611d3f57600080fd5b60008083601f84011261467057600080fd5b5081356001600160401b0381111561468757600080fd5b6020830191508360208260051b85010111156146a257600080fd5b9250929050565b60008060008060008060006101e0888a0312156146c557600080fd5b87356146d0816145ed565b965060208801356001600160401b03808211156146ec57600080fd5b9089019060e0828c03121561470057600080fd5b8197506147108b60408c01614639565b96506101808a013591508082111561472757600080fd5b6147338b838c0161464c565b95506147426101a08b01614602565b94506101c08a013591508082111561475957600080fd5b506147668a828b0161465e565b989b979a50959850939692959293505050565b60006020828403121561478b57600080fd5b8135612530816145ed565b6000806000606084860312156147ab57600080fd5b83356147b6816145ed565b925060208401356147c6816145ed565b929592945050506040919091013590565b600061014082840312156147ea57600080fd5b6125308383614639565b6000806040838503121561480757600080fd5b50508035926020909101359150565b61ffff811681146131a457600080fd5b803561371481614816565b60006020828403121561484357600080fd5b813561253081614816565b6000806040838503121561486157600080fd5b823591506020830135614873816145ed565b809150509250929050565b6001600160801b0319811681146131a457600080fd5b63ffffffff811681146131a457600080fd5b803561371481614894565b600080600080608085870312156148c757600080fd5b84356148d28161487e565b935060208501356148e2816145ed565b925060408501356148f281614816565b9150606085013561490281614894565b939692955090935050565b60006020828403121561491f57600080fd5b813561253081614894565b60008083601f84011261493c57600080fd5b5081356001600160401b0381111561495357600080fd5b6020830191508360208285010111156146a257600080fd5b6000806020838503121561497e57600080fd5b82356001600160401b0381111561499457600080fd5b6149a08582860161492a565b90969095509350505050565b6001600160801b0319851681526080602082015260006149cf6080830186614595565b82810360408401526149e18186614595565b905082810360608401526149f58185614595565b979650505050505050565b600080600080600080600060c0888a031215614a1b57600080fd5b8735614a268161487e565b96506020880135614a36816145ed565b95506040880135614a4681614816565b94506060880135614a5681614816565b93506080880135614a6681614894565b925060a08801356001600160401b03811115614a8157600080fd5b6147668a828b0161492a565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b0381118282101715614ac657614ac6614a8d565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614af457614af4614a8d565b604052919050565b60006001600160401b03821115614b1557614b15614a8d565b50601f01601f191660200190565b6000614b36614b3184614afc565b614acc565b9050828152838383011115614b4a57600080fd5b828260208301376000602084830101529392505050565b600082601f830112614b7257600080fd5b61253083833560208501614b23565b600060208284031215614b9357600080fd5b81356001600160401b03811115614ba957600080fd5b611ae484828501614b61565b634e487b7160e01b600052602160045260246000fd5b60048110614be957634e487b7160e01b600052602160045260246000fd5b9052565b6101408101614bfc828d614bcb565b63ffffffff9a8b1660208301529890991660408a015261ffff96871660608a015294909516608088015264ffffffffff92831660a0880152911660c0860152151560e085015261010084019190915261012090920191909152919050565b80151581146131a457600080fd5b803561371481614c5a565b60008060408385031215614c8657600080fd5b8235614c91816145ed565b9150602083013561487381614c5a565b60008060408385031215614cb457600080fd5b8235614cbf816145ed565b9150602083013561487381614816565b60008060008060808587031215614ce557600080fd5b8435614cf0816145ed565b93506020850135614d00816145ed565b92506040850135915060608501356001600160401b03811115614d2257600080fd5b8501601f81018713614d3357600080fd5b614d4287823560208401614b23565b91505092959194509250565b600082601f830112614d5f57600080fd5b813560206001600160401b0380831115614d7b57614d7b614a8d565b8260051b614d8a838201614acc565b9384528581018301938381019088861115614da457600080fd5b84880192505b85831015614de057823584811115614dc25760008081fd5b614dd08a87838c0101614b61565b8352509184019190840190614daa565b98975050505050505050565b60008060408385031215614dff57600080fd5b82356001600160401b0380821115614e1657600080fd5b614e2286838701614d4e565b93506020850135915080821115614e3857600080fd5b50614e4585828601614d4e565b9150509250929050565b60008060008060008060a08789031215614e6857600080fd5b8635614e738161487e565b95506020870135614e83816145ed565b94506040870135614e9381614816565b93506060870135614ea381614894565b925060808701356001600160401b03811115614ebe57600080fd5b614eca89828a0161492a565b979a9699509497509295939492505050565b60008060408385031215614eef57600080fd5b8235614efa816145ed565b91506020830135614873816145ed565b600181811c90821680614f1e57607f821691505b602082108103611d3f57634e487b7160e01b600052602260045260246000fd5b6000808335601e19843603018112614f5557600080fd5b8301803591506001600160401b03821115614f6f57600080fd5b6020019150368190038213156146a257600080fd5b634e487b7160e01b600052603260045260246000fd5b60008135610c7d8161487e565b5b81811015610d775760008155600101614fa8565b601f8211156119a357806000526020600020601f840160051c81016020851015614fe35750805b613b6e601f850160051c830182614fa7565b6001600160401b0383111561500c5761500c614a8d565b6150208361501a8354614f0a565b83614fbc565b6000601f841160018114615054576000851561503c5750838201355b600019600387901b1c1916600186901b178355613b6e565b600083815260209020601f19861690835b828110156150855786850135825560209485019460019092019101615065565b50868210156150a25760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b6000808335601e198436030181126150cb57600080fd5b8301803591506001600160401b038211156150e557600080fd5b6020019150600581901b36038213156146a257600080fd5b634e487b7160e01b600052601160045260246000fd5b8082028115828204841417610c7d57610c7d6150fd565b600160401b82111561513e5761513e614a8d565b8054828255808310156119a3578160005260206000206001840160011c810160108560041b168015615181576000198083018054828460200360031b1c16815550505b50613b6e6001840160011c830182614fa7565b600160401b8311156151a8576151a8614a8d565b805483825580841015615231576000828152602081208581019083015b8082101561522d576151d78254614f0a565b801561522157601f808211600181146151f25785855561521e565b60008581526020902061520f83850160051c820160018301614fa7565b50600085815260208120818755555b50505b506001820191506151c5565b5050505b5060008181526020812083915b85811015611726576152508386614f3e565b61525b818386614ff5565b5050602092909201916001918201910161523e565b813561527b8161487e565b8060801c6001600160801b031983541617825550600160206152a06020850185614f3e565b6152ae818360018801614ff5565b505060026152bf6040860186614f3e565b6152cd818360028901614ff5565b50506152dc6060860186614f3e565b6152ea818360038901614ff5565b505060048085016152fe60808801886150b4565b6001600160401b0381111561531557615315614a8d565b61531f818461512a565b60008381526020902092508060011c60005b81811015615391576000805b888110156153855761537861535a61535488614f9a565b60801c90565b6001600160801b03908116838b1b60031b90811b91901b1984161790565b958a019591508a0161533d565b50858201558801615331565b50600119821695508582038683146153d1576000805b828110156153cb576153be61535a61535488614f9a565b958a019591508a016153a7565b50858301555b5050505050505050506153e760a08301836150b4565b6153f5818360058601615194565b505061540460c08301836150b4565b6129ef818360068601615194565b600481106131a457600080fd5b803561371481615412565b64ffffffffff811681146131a457600080fd5b80356137148161542a565b6000610140828403121561545b57600080fd5b615463614aa3565b61546c8361541f565b815261547a602084016148a6565b602082015261548b604084016148a6565b604082015261549c60608401614826565b60608201526154ad60808401614826565b60808201526154be60a0840161543d565b60a08201526154cf60c0840161543d565b60c08201526154e060e08401614c68565b60e08201526101008381013590820152610120928301359281019290925250919050565b60008135610c7d81614894565b60008135610c7d81614816565b60008135610c7d8161542a565b60008135610c7d81614c5a565b813561554381615412565b6004811061556157634e487b7160e01b600052602160045260246000fd5b60ff1982541660ff821681178355505061559c61558060208401615504565b825464ffffffff00191660089190911b64ffffffff0016178255565b6155cf6155ab60408401615504565b825468ffffffff0000000000191660289190911b68ffffffff000000000016178255565b6156066155de60608401615511565b82546affff000000000000000000191660489190911b6affff00000000000000000016178255565b61563561561560808401615511565b82805461ffff60581b191660589290921b61ffff60581b16919091179055565b61566a61564460a0840161551e565b82805464ffffffffff60681b191660689290921b64ffffffffff60681b16919091179055565b61569f61567960c0840161551e565b82805464ffffffffff60901b191660909290921b64ffffffffff60901b16919091179055565b6156cc6156ae60e0840161552b565b82805460ff60b81b191691151560b81b60ff60b81b16919091179055565b610100820135600182015561012082013560028201555050565b6000808335601e198436030181126156fd57600080fd5b83016020810192503590506001600160401b0381111561571c57600080fd5b8060051b36038213156146a257600080fd5b8183526000602080850194508260005b8581101561576c578135615751816145ed565b6001600160a01b03168752958201959082019060010161573e565b509495945050505050565b81835260006001600160fb1b0383111561579057600080fd5b8260051b80836020870137939093016020019392505050565b6040815260006157b984856156e6565b60a060408501526157ce60e08501828461572e565b9150506157de60208601866156e6565b603f19808685030160608701526157f6848385615777565b935061580560408901896156e6565b935091508086850301608087015261581e84848461572e565b935061582d60608901896156e6565b93509150808685030160a087015250615847838383615777565b92505050608085013561585981614816565b61ffff1660c08401526001600160a01b039390931660209092019190915250919050565b6000806040838503121561589057600080fd5b825161589b816145ed565b6020840151909250614873816145ed565b6000602082840312156158be57600080fd5b5051919050565b81810381811115610c7d57610c7d6150fd565b81546101408201906158ed8360ff8316614bcb565b63ffffffff600882901c81166020850152602882901c16604084015261ffff604882901c81166060850152605882901c16608084015264ffffffffff606882901c811660a0850152609082901c1660c084015260ff60b882901c16151560e08401525060018301546101008301526002909201546101209091015290565b60008261598857634e487b7160e01b600052601260045260246000fd5b500490565b61ffff818116838216019080821115613db957613db96150fd565b80820180821115610c7d57610c7d6150fd565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8381526040602082015260006139fb6040830184866159bb565b63ffffffff818116838216019080821115613db957613db96150fd565b600060208284031215615a2d57600080fd5b8151612530816145ed565b600060808083016001600160801b031980891685526020886020870152604088604088015260806060880152838854615a75818790815260200190565b60008b81526020812097509092505b60018281830110615a955750615abf565b87546001600160801b0319818b1b8116865290881616868501529096019591830191600201615a84565b8654975081811015615aec57615ae1838960801b6001600160801b0319169052565b602092909201916001015b81811015615b0a576001600160801b03198887161683526020830192505b50909c9b505050505050505050505050565b6000615b2a614b3184614afc565b9050828152838383011115615b3e57600080fd5b612530836020830184614571565b600060208284031215615b5e57600080fd5b81516001600160401b03811115615b7457600080fd5b8201601f81018413615b8557600080fd5b611ae484825160208401615b1c565b60008154615ba181614f0a565b808552602060018381168015615bbe5760018114615bd857615c06565b60ff1985168884015283151560051b880183019550615c06565b866000528260002060005b85811015615bfe5781548a8201860152908301908401615be3565b890184019650505b505050505092915050565b838152606060208201526000615c2a6060830185615b94565b8281036040840152615c3c8185615b94565b9695505050505050565b60008251615c58818460208701614571565b9190910192915050565b81516001600160401b03811115615c7b57615c7b614a8d565b615c8f81615c898454614f0a565b84614fbc565b602080601f831160018114615cc45760008415615cac5750858301515b600019600386901b1c1916600185901b178555611726565b600085815260208120601f198616915b82811015615cf357888601518255948401946001909101908401615cd4565b5085821015615d115787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b63ffffffff828116828216039080821115613db957613db96150fd565b6001600160801b0319871681526001600160a01b038616602082015261ffff8516604082015263ffffffff8416606082015260a060808201819052600090614de090830184866159bb565b60208082526034908201527f455243373231415f5f496e697469616c697a61626c653a20636f6e7472616374604082015273206973206e6f7420696e697469616c697a696e6760601b606082015260800190565b64ffffffffff828116828216039080821115613db957613db96150fd565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090615c3c90830184614595565b600060208284031215615e4057600080fd5b81516125308161453e565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615e83816017850160208801614571565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351615eb4816028840160208801614571565b01602801949350505050565b600081615ecf57615ecf6150fd565b506000190190565b634e487b7160e01b600052603160045260246000fdfef206625bad3d9112d5609b8d356e6fbd514cd1f69980d4ce2b3e6e68e1789ace63680df430131e002a919e96864c2a88aef0a4ae2b002894ffc3d31894db09c4ee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85fa2646970667358221220c692c6a58fa64fece5f9ab53656939343d7d030cef9ca4e4c30568d273f4e40164736f6c63430008170033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.