zellic-audit
Initial commit
f998fcd
raw
history blame
206 kB
{
"language": "Solidity",
"sources": {
"src/Radbro.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0;\n\n/*\n\n╢╬╬╬╬╠╠╟╠╬╢╠╬╬╠╠╠╢╬╬╠╠╠╠╬╬╬╣▌▌▓▌▌▌▌▌▌╬╬▓▓▓▓▓▓▌▓▓▓▓▒░»=┐;»:»░»¡;\":¡░¡!:░┐░░░░░!░░\n╠╠╠╠╠╠╠╬╣╬╬╬╬╬╬╠╠╠╠╠╠╬╬▓████████████████████████████▌▄φφφφφφφφ╦▒φφ╦φ╦▒φ╦╦╦╦φφφφφ\n▒╠▓╬▒▒▒▒▒▒▒▒╠╠╠╠╠╣╣╬▓██████████████████████████████████▓▓▌╬╟╬╢╠╟╠╠╠╠╠╟╟╠╠╠╠╠╠╠╠╠\n▒╚▓╣▓▓▓▓╣╬▄▓▓▒▒╠▓▒▒▓███████████████████████████▓▓▓█▓█▓█▓▓█▓▓╬╠╠╟╠╠╠╠╢╠╠╠╠╠╬╢╠╠╠╠\n▒Å▓▓▓▓▓▓█▓▓▓╬╫▌╠▓▓████████████████████▓▓████████▓█▓▓█▓▓▓▓█▓█▓▓╬╠╠╠╠╠╠╠╠╠╠╬╠╬╠╠╠╟\n▒╚╚░▒╚╚╩╠╬╣▓╬╣▓╣▓███████████████▓█▓██████████████████▓█▓██▓█▓██▓╬╢╟╠╠╠╢╠╟╠╠╠╠╠╟╟\n╟▒▒░░Γ▒╣▒▒░#▒▒╚▓████████████████▓██████▓████████████████████████▓╬╠╠╠╟╠╬╠╟╠╬╠╠╠╠\n▒╠╠╩▒▒╟▓▓▓▓╣▓▓▓███████████████▓████████████▀╫███████████████████▓▓╬╠╠╠╠╠╠╠╠╠╬╠╠╠\n▒▒▒Γ░Γ▒╬╬▀╬╣▓▓███████████████████████████▓╨░░╫████████████████████▓╬╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▌╬╬╠╬▒▒▒▒████████████████████████████░¡░░!╫██████████▓╟██▓██████▌╠╠╠╠╠╠╠╠╠╠╠\n███████████▓██████▓████████▀╫███████████▒∩¡░░░░╙▀▓╟████▌┤░░╫███▀▀███▌╠╠╠╠╠╠╠╠╠╠╠\n███████████████████████████░╙███▌│╩╨╙██▌░░░░░░░░░░░██▓╝░░░Q▓███████▓╠╠╠╟╠╠╠╠╠╠╠╠\n▓▓▓███████████████████████▌ü███▓▄▄Q░░██▒\\░░░░¡░░░░░╫▓▌▓███████▀▀▀╫╬╠╠╬╠╠╟╟╠╠╠╠╠╟\n╬▓╬╣╬╣╣╣╣╬▓╬████████████╩▀▒░▀▀▀▀▀▀▀███████▓▌▄µ░░░░░▀▀▀╫███████Γ░░╠╟╠╠╠╠╠╠╠╠╠╠╠╠╠\n█▓▓▓▓▓▓▓▓▓▓▓▓███████████░░░░░░∩░░░Q▄▄▄▄░░░┘┤╨├░¡░░░░░▄███▄█████▒░╟╠╠╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▓▓▓▓▓▓▓▓▓███████████▒░░░░░▓███▀█████▄░░░░░░░¡░░ΓΓ██████████┤Γ╬╠╠╠╠╠╬╠╠╠╠╠╠╠╠\n╬╬╬╣╬╣╬╬╣╬╬╬╣▓███████████░░░▄█████████████▄░░░░░¡░░░░█████████δ░░▓╬╣╣▓▓▓▓▓▓╣╣▓▓▓\n╬╬╬╬╣╬╣╬╬╬╬╬╬▓████▒░░∩░▀█▒░▀██╙█▓███████▓█▌░░¡░░░░░░░╚█████▓█▒░░╫▓████▓█▓▓▓▓▓▓▓▓\n╬╣╬╢╬╬╣╬╣╬╬╬╣▓███▌░░░░░░░░░░░┤~╙█▓█████▀██▒░¡░░░░░░φ░░███▓██▒░░░▓▓▓╬╚╙╫╬╫███████\n╬╬╣╬╬╬╣▓▓██▓╬▓███▓░░░░░░░░░░░░(=├▀██▓█████░░░¡░>░\"\"░Γ░░░░░░Γ░░░╫▓▓▓▓▓▓▓█▓█▓▓▓▓▓▓\n╬╫╬╬╬╬╣▓╬╟╬▓╬█████▓▄▒░░░░░░░░░∩░░│▀▀▀╫╨╨╨╨░░░¡░¡░░¡¡░░░░░░░░░░╢▓██▓▓█████████▓██\n▓▓▓▓▓▓▓▓╬╬╫█████████████▓▌▒░░░░░░░░░░!░░░░¡░░░░Q▄▄▄▄▄░░░░Γ░Γ▄▓▓█████████████████\n▓█████╬╣▓▓▓████████████████▓▌▒░░░░░░░░░░░░░░░░████▀▀░░░░░░▄▓▓▓██████████████████\n▓▓▓╬▓▓╬╣╬╬╬╬╬╬╬╬███████████████▌▄▒░░░░░░░░░░░░░░░░░░░░½▄▓▓███▓██████████████████\n▓╬╠▓▓▓▓╣╣╬╣╣╬╣▓╬████▓██████████████▓▓▌▄▄░░░░░░░░φ╦▄▄▓▓███████▓█████████████▓╠▓██\n▓▌╠▓▓▓╬╬╣╬╬╬╬╬╬╬▓█▓████▓█▓╬╢▓██▓▓▓▓▓▓▓▓▓▒Σ▒▒#░#▓▓▓▓▓▓██████████████▓▓████▓▓▓╬╬╬╬\n▓▓╠▓███▓▓╣╣╬╣╬╣╢▓▓▓▓▓▓██▓▓▓╣▓▓█▓▓█▓██▓╬#Γ#▒▒▒░Σ╣█████████████▓╣╬▓███▓████▓╣╣╬╣╣▓\n▓▓╬▓▓▓▓▓▓▓▓▓▓█▓╬▓▓▓▓▓▓▓▓█████████████▄ΓΓ╚Γ░ΓΓΓ▐▄█████████████▓╬╬╬╫█████▓╬╬╣╬╬╬╬╬\n▓▓▓▓▓▓▓▓▓▓▓█████████████████▓▓██████████▓▓▓▓▓████████████▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬\n▓███████████████████████████████████████████████████████╬╣╬╬╬╬╬╬╬╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬\n▓████████████████████████████████████████████████████████╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╬╬╬\n██████████████████████████████████▓██▓█▓▓▓███▓██▓█████████╬╬╣╬╬╣╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╣\n▓█████████████████▓▓▓▓╬╬╬██████████████████▓██▓██╣████████▓╬╬╫╬╢╬╫╬╬╬╬╬╣╬╣╬╬╬╣╬╣\n██████▓█▓▓╬╬╬╬╬╬╬╬╬╬╣╬╬╬▓██████████▌▓╬▒╫▓▓▌╣██▓▓╬▒█████████▌╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬\n╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬╬╬╬╬╬╣████████████╣╟▓╬╣▓▓▓▓▓▓▓▓▓╫█████████╬╬╬╬╬╣╬╬╬╬╬╬╬╬╬╣╬╬╬░\n ; \n ED. : \n E#Wi t#, \n j. E###G. . j. ;##W. \n EW, .. E#fD#W; Ef. EW, :#L:WE \n E##j ;W, E#t t##L E#Wi E##j .KG ,#D \n E###D. j##, E#t .E#K, E#K#D: E###D. EE ;#f \n E#jG#W; G###, E#t j##f E#t,E#f. E#jG#W; f#. t#i\n E#t t##f :E####, E#t :E#K:E#WEE##Wt E#t t##f :#G GK \n E#t :K#E: ;W#DG##, E#t t##L E##Ei;;;;. E#t :K#E:;#L LW. \n E#KDDDD###i j###DW##, E#t .D#W; E#DWWt E#KDDDD###it#f f#: \n E#f,t#Wi,,, G##i,,G##, E#tiW#G. E#t f#K; E#f,t#Wi,,, f#D#; \n E#t ;#W: :K#K: L##, E#K##i E#Dfff##E, E#t ;#W: G#t \n DWi ,KK: ;##D. L##, E##D. jLLLLLLLLL;DWi ,KK: t \n ,,, .,, E#t \n L: \n\n*/\n\nimport {ERC721A} from \"erc721a/contracts/ERC721A.sol\";\nimport {ERC721ACommon} from \"@divergencetech/ethier/contracts/erc721/ERC721ACommon.sol\";\nimport {BaseTokenURI} from \"@divergencetech/ethier/contracts/erc721/BaseTokenURI.sol\";\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport {Radlist, AddCollectionParams, ClaimRadlistParams} from \"./Radlist.sol\";\nimport {RadArt} from \"./RadArt.sol\";\nimport {Radcoin} from \"./Radcoin.sol\";\nimport {Radmath} from \"./Radmath.sol\";\n\n/// @notice The Original Radbro.\n/// @author 10xdegen\n/// @dev This contract is the main entry point for the Radbro ecosystem.\n/// It is responsible for minting new Radbro NFTs and earning Radcoin.\n/// Credit goes to the Radbro team StuxnetTypeBeat AEQEA RiverGod and 10xdegen\ncontract Radbro is\n ERC721ACommon,\n BaseTokenURI,\n ReentrancyGuard,\n Radlist,\n RadArt,\n Radmath\n{\n /*//////////////////////////////////////////////////////////////\n ADDRESSES\n //////////////////////////////////////////////////////////////*/\n\n /// @notice The address of the Radcoin ERC20 token contract.\n Radcoin public radcoin;\n\n /*//////////////////////////////////////////////////////////////\n MINT CONSTANTS\n //////////////////////////////////////////////////////////////*/\n\n /// @notice Maximum number of mintable radbros.\n uint256 public constant MAX_SUPPLY = 4000;\n\n /// @notice Maximum amount of radbros mintable via radlist.\n uint256 public constant RADLIST_MINTABLE = 1000;\n\n /// @notice Maximum amount of radbros reserved for team / community.\n uint256 public constant RESERVED_SUPPLY = 400;\n\n /// @notice Maximum amount of radbros that can be minted via Radcoin.\n // prettier-ignore\n uint256 public constant RADCOIN_MINTABLE = MAX_SUPPLY \n - RESERVED_SUPPLY\n - RADLIST_MINTABLE;\n\n /*//////////////////////////////////////////////////////////////\n MINTING STATE\n //////////////////////////////////////////////////////////////*/\n\n /// @notice Total number of radbros minted from the Radlist.\n uint256 public mintedFromRadlist;\n\n /// @notice Total number of radbros minted from the Radlist.\n uint256 public mintedFromReserve;\n\n /// @notice Total number of radbros minted with Radcoin.\n uint256 public mintedFromRadcoin;\n\n /// @notice The current spot price for minting radbros (in $RAD).\n uint128 public spotPrice;\n\n /// @notice Price increase for radbro (1e18+1e17 == 10% increase) on every mint.\n uint128 public priceDelta;\n\n /// @notice The current price for rerolling radbro art (in $RAD).\n uint128 public radrollPrice;\n\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n event RadbroMinted(address indexed user, uint8 quantity);\n event RadlistClaimed(address indexed user, uint8 quantity);\n event ArrtRadrolled(\n address indexed user,\n uint256 indexed radbroId,\n uint256 newArt\n );\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n bytes32 _merkleRoot\n )\n ERC721ACommon(\"Radbro Webring\", \"RADBRO\", payable(msg.sender), 0)\n Radlist(_merkleRoot)\n RadArt(4_000, 8_000) // 4k initial art, 8k secondary art\n BaseTokenURI(\"\")\n {\n spotPrice = 5 ether; // 5 RAD\n priceDelta = 1.01 ether; // 1% increase\n radrollPrice = 2 ether; // 2 RAD to radroll\n }\n\n /*//////////////////////////////////////////////////////////////\n INITIALIZATION\n //////////////////////////////////////////////////////////////*/\n\n /// @notice Initialize the Radcoin address.\n function initialize(address _radcoin) external onlyOwner {\n require(address(radcoin) == address(0), \"Radbro: Radcoin already set\");\n radcoin = Radcoin(_radcoin);\n }\n\n /*//////////////////////////////////////////////////////////////\n MINTING\n //////////////////////////////////////////////////////////////*/\n\n /**\n @notice Mint as a member of the public (using $RAD).\n */\n function mintFromRadcoin(\n address to,\n uint256[] calldata radbroIds,\n uint256 n,\n uint256 maxInput\n ) external nonReentrant {\n require(n > 0, \"Radbro: Must mint at least one\");\n require(\n mintedFromRadcoin + n <= RADCOIN_MINTABLE,\n \"Radbro: Cannot mint more than RADCOIN_MINTABLE\"\n );\n (uint128 newSpotPrice, uint256 inputValue) = getBuyInfo(\n spotPrice,\n priceDelta,\n n\n );\n\n require(inputValue <= maxInput, \"Radbro: Input value exceeds maxInput\");\n _spendRad(_msgSender(), radbroIds, inputValue);\n\n mintedFromRadcoin += n;\n spotPrice = newSpotPrice;\n\n _mintInternal(to, n);\n }\n\n /**\n * @dev Mint tokens via the Radlist.\n * @param to The address that will own the minted tokens.\n * @param params Parameters for claiming from the Radlist.\n */\n function mintFromRadlist(\n address to,\n ClaimRadlistParams calldata params\n ) external nonReentrant {\n uint256 totalClaimed = _claimRadlist(_msgSender(), params);\n require(\n mintedFromRadlist + totalClaimed <= RADLIST_MINTABLE,\n \"Radbro: Max mintable reached\"\n );\n\n mintedFromRadlist += totalClaimed;\n\n _mintInternal(to, totalClaimed);\n }\n\n /**\n * @dev Mint tokens reserved for the team.\n * @param to The address that will own the minted tokens.\n * @param n The number to mint.\n */\n function mintFromReserve(address to, uint256 n) external onlyOwner {\n require(\n mintedFromReserve + n <= RESERVED_SUPPLY,\n \"Radbro: Max mintable from reserve reached\"\n );\n\n mintedFromReserve += n;\n\n _mintInternal(to, n);\n }\n\n function _mintInternal(address to, uint256 n) internal whenNotPaused {\n require(totalSupply() + n <= MAX_SUPPLY, \"Radbro: Max supply reached\");\n\n // start radcoin claim counter\n for (uint256 i = totalSupply() + 1; i <= totalSupply() + n; i++) {\n radcoin.initializeRadbro(i, block.timestamp);\n }\n\n _safeMint(to, n);\n }\n\n // override start token id to 1\n function _startTokenId() internal pure override returns (uint256) {\n return 1;\n }\n\n /*//////////////////////////////////////////////////////////////\n ART\n //////////////////////////////////////////////////////////////*/\n\n /**\n * @dev Update the price for rerolling radbro art.\n */\n function setRadrollPrice(uint128 _radrollPrice) external onlyOwner {\n radrollPrice = _radrollPrice;\n }\n\n /**\n * @dev Radroll the art for a radbro.\n */\n function radrollArt(\n uint256 tokenId,\n uint256[] calldata radbroIds\n ) public returns (uint256 newArt) {\n require(\n _exists(tokenId),\n \"ERC721Metadata: URI query for nonexistent token\"\n );\n require(\n ownerOf(tokenId) == _msgSender(),\n \"ERC721: caller is not the owner\"\n );\n _spendRad(_msgSender(), radbroIds, radrollPrice);\n\n // if we are not yet minted out, you can only radroll into art that is past max supply\n bool allowFromInit = totalSupply() == MAX_SUPPLY;\n\n newArt = _rerollArt(tokenId, allowFromInit);\n }\n\n function tokenURI(\n uint256 tokenId\n ) public view override(ERC721A) returns (string memory) {\n require(\n _exists(tokenId),\n \"ERC721Metadata: URI query for nonexistent token\"\n );\n (uint256 art, bool initial) = getArt(tokenId);\n if (art == 0) {\n art = tokenId;\n } else if (!initial) {\n art += 4_000;\n }\n return string(abi.encodePacked(_baseURI(), _toString(art)));\n }\n\n /**\n @dev Required override to select the correct baseTokenURI.\n */\n function _baseURI()\n internal\n view\n override(BaseTokenURI, ERC721A)\n returns (string memory)\n {\n return BaseTokenURI._baseURI();\n }\n\n /*//////////////////////////////////////////////////////////////\n PAYMENTS (RADCOIN)\n //////////////////////////////////////////////////////////////*/\n\n /// @notice Burn Radcoin from the user's account.\n /// If there is sufficient unclaimed Radcoin to claim, claim that instead of burning.\n function _spendRad(\n address owner,\n uint256[] calldata radbroIds,\n uint256 amount\n ) internal {\n require(address(radcoin) != address(0), \"Radbro: Radcoin not set\");\n\n for (uint256 i = 0; i < radbroIds.length; i++) {\n uint256 radbroId = radbroIds[i];\n require(_exists(radbroId), \"Radbro: Radbro does not exist\");\n require(ownerOf(radbroId) == owner, \"Radbro: Not owner of Radbro\");\n uint256 reward = radcoin.getClaimReward(radbroId);\n\n if (reward == 0) {\n continue;\n }\n if (reward >= amount) {\n radcoin.claimForRadbro(radbroId, amount);\n return;\n } else {\n radcoin.claimForRadbro(radbroId, reward);\n amount -= reward;\n }\n }\n\n radcoin.burnForRadbros(owner, amount);\n }\n}\n"
},
"lib/erc721a/contracts/ERC721A.sol": {
"content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v4.2.3\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\nimport './IERC721A.sol';\n\n/**\n * @dev Interface of ERC721 token receiver.\n */\ninterface ERC721A__IERC721Receiver {\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n\n/**\n * @title ERC721A\n *\n * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)\n * Non-Fungible Token Standard, including the Metadata extension.\n * Optimized for lower gas during batch mints.\n *\n * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)\n * starting from `_startTokenId()`.\n *\n * Assumptions:\n *\n * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.\n * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).\n */\ncontract ERC721A is IERC721A {\n // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).\n struct TokenApprovalRef {\n address value;\n }\n\n // =============================================================\n // CONSTANTS\n // =============================================================\n\n // Mask of an entry in packed address data.\n uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;\n\n // The bit position of `numberMinted` in packed address data.\n uint256 private constant _BITPOS_NUMBER_MINTED = 64;\n\n // The bit position of `numberBurned` in packed address data.\n uint256 private constant _BITPOS_NUMBER_BURNED = 128;\n\n // The bit position of `aux` in packed address data.\n uint256 private constant _BITPOS_AUX = 192;\n\n // Mask of all 256 bits in packed address data except the 64 bits for `aux`.\n uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;\n\n // The bit position of `startTimestamp` in packed ownership.\n uint256 private constant _BITPOS_START_TIMESTAMP = 160;\n\n // The bit mask of the `burned` bit in packed ownership.\n uint256 private constant _BITMASK_BURNED = 1 << 224;\n\n // The bit position of the `nextInitialized` bit in packed ownership.\n uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;\n\n // The bit mask of the `nextInitialized` bit in packed ownership.\n uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;\n\n // The bit position of `extraData` in packed ownership.\n uint256 private constant _BITPOS_EXTRA_DATA = 232;\n\n // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.\n uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;\n\n // The mask of the lower 160 bits for addresses.\n uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;\n\n // The maximum `quantity` that can be minted with {_mintERC2309}.\n // This limit is to prevent overflows on the address data entries.\n // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}\n // is required to cause an overflow, which is unrealistic.\n uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;\n\n // The `Transfer` event signature is given by:\n // `keccak256(bytes(\"Transfer(address,address,uint256)\"))`.\n bytes32 private constant _TRANSFER_EVENT_SIGNATURE =\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\n\n // =============================================================\n // STORAGE\n // =============================================================\n\n // The next token ID to be minted.\n uint256 private _currentIndex;\n\n // The number of tokens burned.\n uint256 private _burnCounter;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to ownership details\n // An empty struct value does not necessarily mean the token is unowned.\n // See {_packedOwnershipOf} implementation for details.\n //\n // Bits Layout:\n // - [0..159] `addr`\n // - [160..223] `startTimestamp`\n // - [224] `burned`\n // - [225] `nextInitialized`\n // - [232..255] `extraData`\n mapping(uint256 => uint256) private _packedOwnerships;\n\n // Mapping owner address to address data.\n //\n // Bits Layout:\n // - [0..63] `balance`\n // - [64..127] `numberMinted`\n // - [128..191] `numberBurned`\n // - [192..255] `aux`\n mapping(address => uint256) private _packedAddressData;\n\n // Mapping from token ID to approved address.\n mapping(uint256 => TokenApprovalRef) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n // =============================================================\n // CONSTRUCTOR\n // =============================================================\n\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n _currentIndex = _startTokenId();\n }\n\n // =============================================================\n // TOKEN COUNTING OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the starting token ID.\n * To change the starting token ID, please override this function.\n */\n function _startTokenId() internal view virtual returns (uint256) {\n return 0;\n }\n\n /**\n * @dev Returns the next token ID to be minted.\n */\n function _nextTokenId() internal view virtual returns (uint256) {\n return _currentIndex;\n }\n\n /**\n * @dev Returns the total number of tokens in existence.\n * Burned tokens will reduce the count.\n * To get the total number of tokens minted, please see {_totalMinted}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n // Counter underflow is impossible as _burnCounter cannot be incremented\n // more than `_currentIndex - _startTokenId()` times.\n unchecked {\n return _currentIndex - _burnCounter - _startTokenId();\n }\n }\n\n /**\n * @dev Returns the total amount of tokens minted in the contract.\n */\n function _totalMinted() internal view virtual returns (uint256) {\n // Counter underflow is impossible as `_currentIndex` does not decrement,\n // and it is initialized to `_startTokenId()`.\n unchecked {\n return _currentIndex - _startTokenId();\n }\n }\n\n /**\n * @dev Returns the total number of tokens burned.\n */\n function _totalBurned() internal view virtual returns (uint256) {\n return _burnCounter;\n }\n\n // =============================================================\n // ADDRESS DATA OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the number of tokens in `owner`'s account.\n */\n function balanceOf(address owner) public view virtual override returns (uint256) {\n if (owner == address(0)) revert BalanceQueryForZeroAddress();\n return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the number of tokens minted by `owner`.\n */\n function _numberMinted(address owner) internal view returns (uint256) {\n return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the number of tokens burned by or on behalf of `owner`.\n */\n function _numberBurned(address owner) internal view returns (uint256) {\n return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\n */\n function _getAux(address owner) internal view returns (uint64) {\n return uint64(_packedAddressData[owner] >> _BITPOS_AUX);\n }\n\n /**\n * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\n * If there are multiple variables, please pack them into a uint64.\n */\n function _setAux(address owner, uint64 aux) internal virtual {\n uint256 packed = _packedAddressData[owner];\n uint256 auxCasted;\n // Cast `aux` with assembly to avoid redundant masking.\n assembly {\n auxCasted := aux\n }\n packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);\n _packedAddressData[owner] = packed;\n }\n\n // =============================================================\n // IERC165\n // =============================================================\n\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30000 gas.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n // The interface IDs are constants representing the first 4 bytes\n // of the XOR of all function selectors in the interface.\n // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)\n // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)\n return\n interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.\n interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.\n interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.\n }\n\n // =============================================================\n // IERC721Metadata\n // =============================================================\n\n /**\n * @dev Returns the token collection name.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n string memory baseURI = _baseURI();\n return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, it can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return '';\n }\n\n // =============================================================\n // OWNERSHIPS OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n return address(uint160(_packedOwnershipOf(tokenId)));\n }\n\n /**\n * @dev Gas spent here starts off proportional to the maximum mint batch size.\n * It gradually moves to O(1) as tokens get transferred around over time.\n */\n function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {\n return _unpackedOwnership(_packedOwnershipOf(tokenId));\n }\n\n /**\n * @dev Returns the unpacked `TokenOwnership` struct at `index`.\n */\n function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {\n return _unpackedOwnership(_packedOwnerships[index]);\n }\n\n /**\n * @dev Initializes the ownership slot minted at `index` for efficiency purposes.\n */\n function _initializeOwnershipAt(uint256 index) internal virtual {\n if (_packedOwnerships[index] == 0) {\n _packedOwnerships[index] = _packedOwnershipOf(index);\n }\n }\n\n /**\n * Returns the packed ownership data of `tokenId`.\n */\n function _packedOwnershipOf(uint256 tokenId) private view returns (uint256 packed) {\n if (_startTokenId() <= tokenId) {\n packed = _packedOwnerships[tokenId];\n // If not burned.\n if (packed & _BITMASK_BURNED == 0) {\n // If the data at the starting slot does not exist, start the scan.\n if (packed == 0) {\n if (tokenId >= _currentIndex) revert OwnerQueryForNonexistentToken();\n // Invariant:\n // There will always be an initialized ownership slot\n // (i.e. `ownership.addr != address(0) && ownership.burned == false`)\n // before an unintialized ownership slot\n // (i.e. `ownership.addr == address(0) && ownership.burned == false`)\n // Hence, `tokenId` will not underflow.\n //\n // We can directly compare the packed value.\n // If the address is zero, packed will be zero.\n for (;;) {\n unchecked {\n packed = _packedOwnerships[--tokenId];\n }\n if (packed == 0) continue;\n return packed;\n }\n }\n // Otherwise, the data exists and is not burned. We can skip the scan.\n // This is possible because we have already achieved the target condition.\n // This saves 2143 gas on transfers of initialized tokens.\n return packed;\n }\n }\n revert OwnerQueryForNonexistentToken();\n }\n\n /**\n * @dev Returns the unpacked `TokenOwnership` struct from `packed`.\n */\n function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {\n ownership.addr = address(uint160(packed));\n ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);\n ownership.burned = packed & _BITMASK_BURNED != 0;\n ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);\n }\n\n /**\n * @dev Packs ownership data into a single uint256.\n */\n function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {\n assembly {\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.\n owner := and(owner, _BITMASK_ADDRESS)\n // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.\n result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))\n }\n }\n\n /**\n * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.\n */\n function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {\n // For branchless setting of the `nextInitialized` flag.\n assembly {\n // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.\n result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))\n }\n }\n\n // =============================================================\n // APPROVAL OPERATIONS\n // =============================================================\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account. See {ERC721A-_approve}.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n */\n function approve(address to, uint256 tokenId) public payable virtual override {\n _approve(to, tokenId, true);\n }\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) public view virtual override returns (address) {\n if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();\n\n return _tokenApprovals[tokenId].value;\n }\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) public virtual override {\n _operatorApprovals[_msgSenderERC721A()][operator] = approved;\n emit ApprovalForAll(_msgSenderERC721A(), operator, approved);\n }\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted. See {_mint}.\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return\n _startTokenId() <= tokenId &&\n tokenId < _currentIndex && // If within bounds,\n _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.\n }\n\n /**\n * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.\n */\n function _isSenderApprovedOrOwner(\n address approvedAddress,\n address owner,\n address msgSender\n ) private pure returns (bool result) {\n assembly {\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.\n owner := and(owner, _BITMASK_ADDRESS)\n // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.\n msgSender := and(msgSender, _BITMASK_ADDRESS)\n // `msgSender == owner || msgSender == approvedAddress`.\n result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))\n }\n }\n\n /**\n * @dev Returns the storage slot and value for the approved address of `tokenId`.\n */\n function _getApprovedSlotAndAddress(uint256 tokenId)\n private\n view\n returns (uint256 approvedAddressSlot, address approvedAddress)\n {\n TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];\n // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.\n assembly {\n approvedAddressSlot := tokenApproval.slot\n approvedAddress := sload(approvedAddressSlot)\n }\n }\n\n // =============================================================\n // TRANSFER OPERATIONS\n // =============================================================\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public payable virtual override {\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\n\n if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();\n\n (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);\n\n // The nested ifs save around 20+ gas over a compound boolean condition.\n if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))\n if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();\n\n if (to == address(0)) revert TransferToZeroAddress();\n\n _beforeTokenTransfers(from, to, tokenId, 1);\n\n // Clear approvals from the previous owner.\n assembly {\n if approvedAddress {\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\n sstore(approvedAddressSlot, 0)\n }\n }\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\n unchecked {\n // We can directly increment and decrement the balances.\n --_packedAddressData[from]; // Updates: `balance -= 1`.\n ++_packedAddressData[to]; // Updates: `balance += 1`.\n\n // Updates:\n // - `address` to the next owner.\n // - `startTimestamp` to the timestamp of transfering.\n // - `burned` to `false`.\n // - `nextInitialized` to `true`.\n _packedOwnerships[tokenId] = _packOwnershipData(\n to,\n _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)\n );\n\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\n if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {\n uint256 nextTokenId = tokenId + 1;\n // If the next slot's address is zero and not burned (i.e. packed value is zero).\n if (_packedOwnerships[nextTokenId] == 0) {\n // If the next slot is within bounds.\n if (nextTokenId != _currentIndex) {\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\n }\n }\n }\n }\n\n emit Transfer(from, to, tokenId);\n _afterTokenTransfers(from, to, tokenId, 1);\n }\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public payable virtual override {\n safeTransferFrom(from, to, tokenId, '');\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public payable virtual override {\n transferFrom(from, to, tokenId);\n if (to.code.length != 0)\n if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n }\n\n /**\n * @dev Hook that is called before a set of serially-ordered token IDs\n * are about to be transferred. This includes minting.\n * And also called before burning one token.\n *\n * `startTokenId` - the first token ID to be transferred.\n * `quantity` - the amount to be transferred.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _beforeTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after a set of serially-ordered token IDs\n * have been transferred. This includes minting.\n * And also called after one token has been burned.\n *\n * `startTokenId` - the first token ID to be transferred.\n * `quantity` - the amount to be transferred.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been\n * transferred to `to`.\n * - When `from` is zero, `tokenId` has been minted for `to`.\n * - When `to` is zero, `tokenId` has been burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _afterTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.\n *\n * `from` - Previous owner of the given token ID.\n * `to` - Target address that will receive the token.\n * `tokenId` - Token ID to be transferred.\n * `_data` - Optional data to send along with the call.\n *\n * Returns whether the call correctly returned the expected magic value.\n */\n function _checkContractOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) private returns (bool) {\n try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (\n bytes4 retval\n ) {\n return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert TransferToNonERC721ReceiverImplementer();\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n\n // =============================================================\n // MINT OPERATIONS\n // =============================================================\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {Transfer} event for each mint.\n */\n function _mint(address to, uint256 quantity) internal virtual {\n uint256 startTokenId = _currentIndex;\n if (quantity == 0) revert MintZeroQuantity();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are incredibly unrealistic.\n // `balance` and `numberMinted` have a maximum limit of 2**64.\n // `tokenId` has a maximum limit of 2**256.\n unchecked {\n // Updates:\n // - `balance += quantity`.\n // - `numberMinted += quantity`.\n //\n // We can directly add to the `balance` and `numberMinted`.\n _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);\n\n // Updates:\n // - `address` to the owner.\n // - `startTimestamp` to the timestamp of minting.\n // - `burned` to `false`.\n // - `nextInitialized` to `quantity == 1`.\n _packedOwnerships[startTokenId] = _packOwnershipData(\n to,\n _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)\n );\n\n uint256 toMasked;\n uint256 end = startTokenId + quantity;\n\n // Use assembly to loop and emit the `Transfer` event for gas savings.\n // The duplicated `log4` removes an extra check and reduces stack juggling.\n // The assembly, together with the surrounding Solidity code, have been\n // delicately arranged to nudge the compiler into producing optimized opcodes.\n assembly {\n // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.\n toMasked := and(to, _BITMASK_ADDRESS)\n // Emit the `Transfer` event.\n log4(\n 0, // Start of data (0, since no data).\n 0, // End of data (0, since no data).\n _TRANSFER_EVENT_SIGNATURE, // Signature.\n 0, // `address(0)`.\n toMasked, // `to`.\n startTokenId // `tokenId`.\n )\n\n // The `iszero(eq(,))` check ensures that large values of `quantity`\n // that overflows uint256 will make the loop run out of gas.\n // The compiler will optimize the `iszero` away for performance.\n for {\n let tokenId := add(startTokenId, 1)\n } iszero(eq(tokenId, end)) {\n tokenId := add(tokenId, 1)\n } {\n // Emit the `Transfer` event. Similar to above.\n log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)\n }\n }\n if (toMasked == 0) revert MintToZeroAddress();\n\n _currentIndex = end;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * This function is intended for efficient minting only during contract creation.\n *\n * It emits only one {ConsecutiveTransfer} as defined in\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),\n * instead of a sequence of {Transfer} event(s).\n *\n * Calling this function outside of contract creation WILL make your contract\n * non-compliant with the ERC721 standard.\n * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309\n * {ConsecutiveTransfer} event is only permissible during contract creation.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {ConsecutiveTransfer} event.\n */\n function _mintERC2309(address to, uint256 quantity) internal virtual {\n uint256 startTokenId = _currentIndex;\n if (to == address(0)) revert MintToZeroAddress();\n if (quantity == 0) revert MintZeroQuantity();\n if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are unrealistic due to the above check for `quantity` to be below the limit.\n unchecked {\n // Updates:\n // - `balance += quantity`.\n // - `numberMinted += quantity`.\n //\n // We can directly add to the `balance` and `numberMinted`.\n _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);\n\n // Updates:\n // - `address` to the owner.\n // - `startTimestamp` to the timestamp of minting.\n // - `burned` to `false`.\n // - `nextInitialized` to `quantity == 1`.\n _packedOwnerships[startTokenId] = _packOwnershipData(\n to,\n _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)\n );\n\n emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);\n\n _currentIndex = startTokenId + quantity;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Safely mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.\n * - `quantity` must be greater than 0.\n *\n * See {_mint}.\n *\n * Emits a {Transfer} event for each mint.\n */\n function _safeMint(\n address to,\n uint256 quantity,\n bytes memory _data\n ) internal virtual {\n _mint(to, quantity);\n\n unchecked {\n if (to.code.length != 0) {\n uint256 end = _currentIndex;\n uint256 index = end - quantity;\n do {\n if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n } while (index < end);\n // Reentrancy protection.\n if (_currentIndex != end) revert();\n }\n }\n }\n\n /**\n * @dev Equivalent to `_safeMint(to, quantity, '')`.\n */\n function _safeMint(address to, uint256 quantity) internal virtual {\n _safeMint(to, quantity, '');\n }\n\n // =============================================================\n // APPROVAL OPERATIONS\n // =============================================================\n\n /**\n * @dev Equivalent to `_approve(to, tokenId, false)`.\n */\n function _approve(address to, uint256 tokenId) internal virtual {\n _approve(to, tokenId, false);\n }\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function _approve(\n address to,\n uint256 tokenId,\n bool approvalCheck\n ) internal virtual {\n address owner = ownerOf(tokenId);\n\n if (approvalCheck)\n if (_msgSenderERC721A() != owner)\n if (!isApprovedForAll(owner, _msgSenderERC721A())) {\n revert ApprovalCallerNotOwnerNorApproved();\n }\n\n _tokenApprovals[tokenId].value = to;\n emit Approval(owner, to, tokenId);\n }\n\n // =============================================================\n // BURN OPERATIONS\n // =============================================================\n\n /**\n * @dev Equivalent to `_burn(tokenId, false)`.\n */\n function _burn(uint256 tokenId) internal virtual {\n _burn(tokenId, false);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId, bool approvalCheck) internal virtual {\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\n\n address from = address(uint160(prevOwnershipPacked));\n\n (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);\n\n if (approvalCheck) {\n // The nested ifs save around 20+ gas over a compound boolean condition.\n if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))\n if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();\n }\n\n _beforeTokenTransfers(from, address(0), tokenId, 1);\n\n // Clear approvals from the previous owner.\n assembly {\n if approvedAddress {\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\n sstore(approvedAddressSlot, 0)\n }\n }\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\n unchecked {\n // Updates:\n // - `balance -= 1`.\n // - `numberBurned += 1`.\n //\n // We can directly decrement the balance, and increment the number burned.\n // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.\n _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;\n\n // Updates:\n // - `address` to the last owner.\n // - `startTimestamp` to the timestamp of burning.\n // - `burned` to `true`.\n // - `nextInitialized` to `true`.\n _packedOwnerships[tokenId] = _packOwnershipData(\n from,\n (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)\n );\n\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\n if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {\n uint256 nextTokenId = tokenId + 1;\n // If the next slot's address is zero and not burned (i.e. packed value is zero).\n if (_packedOwnerships[nextTokenId] == 0) {\n // If the next slot is within bounds.\n if (nextTokenId != _currentIndex) {\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\n }\n }\n }\n }\n\n emit Transfer(from, address(0), tokenId);\n _afterTokenTransfers(from, address(0), tokenId, 1);\n\n // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.\n unchecked {\n _burnCounter++;\n }\n }\n\n // =============================================================\n // EXTRA DATA OPERATIONS\n // =============================================================\n\n /**\n * @dev Directly sets the extra data for the ownership data `index`.\n */\n function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {\n uint256 packed = _packedOwnerships[index];\n if (packed == 0) revert OwnershipNotInitializedForExtraData();\n uint256 extraDataCasted;\n // Cast `extraData` with assembly to avoid redundant masking.\n assembly {\n extraDataCasted := extraData\n }\n packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);\n _packedOwnerships[index] = packed;\n }\n\n /**\n * @dev Called during each token transfer to set the 24bit `extraData` field.\n * Intended to be overridden by the cosumer contract.\n *\n * `previousExtraData` - the value of `extraData` before transfer.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _extraData(\n address from,\n address to,\n uint24 previousExtraData\n ) internal view virtual returns (uint24) {}\n\n /**\n * @dev Returns the next extra data for the packed ownership data.\n * The returned result is shifted into position.\n */\n function _nextExtraData(\n address from,\n address to,\n uint256 prevOwnershipPacked\n ) private view returns (uint256) {\n uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);\n return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;\n }\n\n // =============================================================\n // OTHER OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the message sender (defaults to `msg.sender`).\n *\n * If you are writing GSN compatible contracts, you need to override this function.\n */\n function _msgSenderERC721A() internal view virtual returns (address) {\n return msg.sender;\n }\n\n /**\n * @dev Converts a uint256 to its ASCII string decimal representation.\n */\n function _toString(uint256 value) internal pure virtual returns (string memory str) {\n assembly {\n // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\n // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\n // We will need 1 word for the trailing zeros padding, 1 word for the length,\n // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.\n let m := add(mload(0x40), 0xa0)\n // Update the free memory pointer to allocate.\n mstore(0x40, m)\n // Assign the `str` to the end.\n str := sub(m, 0x20)\n // Zeroize the slot after the string.\n mstore(str, 0)\n\n // Cache the end of the memory to calculate the length later.\n let end := str\n\n // We write the string from rightmost digit to leftmost digit.\n // The following is essentially a do-while loop that also handles the zero case.\n // prettier-ignore\n for { let temp := value } 1 {} {\n str := sub(str, 1)\n // Write the character to the pointer.\n // The ASCII index of the '0' character is 48.\n mstore8(str, add(48, mod(temp, 10)))\n // Keep dividing `temp` until zero.\n temp := div(temp, 10)\n // prettier-ignore\n if iszero(temp) { break }\n }\n\n let length := sub(end, str)\n // Move the pointer 32 bytes leftwards to make room for the length.\n str := sub(str, 0x20)\n // Store the length.\n mstore(str, length)\n }\n }\n}\n"
},
"lib/ethier/contracts/erc721/ERC721ACommon.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier)\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"erc721a/contracts/ERC721A.sol\";\nimport \"../utils/OwnerPausable.sol\";\nimport \"@openzeppelin/contracts/token/common/ERC2981.sol\";\n\n/**\n@notice An ERC721A contract with common functionality:\n - Pausable with toggling functions exposed to Owner only\n - ERC2981 royalties\n */\ncontract ERC721ACommon is ERC721A, OwnerPausable, ERC2981 {\n constructor(\n string memory name,\n string memory symbol,\n address payable royaltyReciever,\n uint96 royaltyBasisPoints\n ) ERC721A(name, symbol) {\n _setDefaultRoyalty(royaltyReciever, royaltyBasisPoints);\n }\n\n /// @notice Requires that the token exists.\n modifier tokenExists(uint256 tokenId) {\n require(ERC721A._exists(tokenId), \"ERC721ACommon: Token doesn't exist\");\n _;\n }\n\n /// @notice Requires that msg.sender owns or is approved for the token.\n modifier onlyApprovedOrOwner(uint256 tokenId) {\n require(\n _ownershipOf(tokenId).addr == _msgSender() ||\n getApproved(tokenId) == _msgSender(),\n \"ERC721ACommon: Not approved nor owner\"\n );\n _;\n }\n\n function _beforeTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual override {\n require(!paused(), \"ERC721ACommon: paused\");\n super._beforeTokenTransfers(from, to, startTokenId, quantity);\n }\n\n /// @notice Overrides supportsInterface as required by inheritance.\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(ERC721A, ERC2981)\n returns (bool)\n {\n return\n ERC721A.supportsInterface(interfaceId) ||\n ERC2981.supportsInterface(interfaceId);\n }\n\n /// @notice Sets the royalty receiver and percentage (in units of basis\n /// points = 0.01%).\n function setDefaultRoyalty(address receiver, uint96 basisPoints)\n public\n virtual\n onlyOwner\n {\n _setDefaultRoyalty(receiver, basisPoints);\n }\n}\n"
},
"lib/ethier/contracts/erc721/BaseTokenURI.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n@notice ERC721 extension that overrides the OpenZeppelin _baseURI() function to\nreturn a prefix that can be set by the contract owner.\n */\ncontract BaseTokenURI is Ownable {\n /// @notice Base token URI used as a prefix by tokenURI().\n string public baseTokenURI;\n\n constructor(string memory _baseTokenURI) {\n setBaseTokenURI(_baseTokenURI);\n }\n\n /// @notice Sets the base token URI prefix.\n function setBaseTokenURI(string memory _baseTokenURI) public onlyOwner {\n baseTokenURI = _baseTokenURI;\n }\n\n /**\n @notice Concatenates and returns the base token URI and the token ID without\n any additional characters (e.g. a slash).\n @dev This requires that an inheriting contract that also inherits from OZ's\n ERC721 will have to override both contracts; although we could simply\n require that users implement their own _baseURI() as here, this can easily\n be forgotten and the current approach guides them with compiler errors. This\n favours the latter half of \"APIs should be easy to use and hard to misuse\"\n from https://www.infoq.com/articles/API-Design-Joshua-Bloch/.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return baseTokenURI;\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/security/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n"
},
"src/Radlist.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0;\n\n/*\n\n╢╬╬╬╬╠╠╟╠╬╢╠╬╬╠╠╠╢╬╬╠╠╠╠╬╬╬╣▌▌▓▌▌▌▌▌▌╬╬▓▓▓▓▓▓▌▓▓▓▓▒░»=┐;»:»░»¡;\":¡░¡!:░┐░░░░░!░░\n╠╠╠╠╠╠╠╬╣╬╬╬╬╬╬╠╠╠╠╠╠╬╬▓████████████████████████████▌▄φφφφφφφφ╦▒φφ╦φ╦▒φ╦╦╦╦φφφφφ\n▒╠▓╬▒▒▒▒▒▒▒▒╠╠╠╠╠╣╣╬▓██████████████████████████████████▓▓▌╬╟╬╢╠╟╠╠╠╠╠╟╟╠╠╠╠╠╠╠╠╠\n▒╚▓╣▓▓▓▓╣╬▄▓▓▒▒╠▓▒▒▓███████████████████████████▓▓▓█▓█▓█▓▓█▓▓╬╠╠╟╠╠╠╠╢╠╠╠╠╠╬╢╠╠╠╠\n▒Å▓▓▓▓▓▓█▓▓▓╬╫▌╠▓▓████████████████████▓▓████████▓█▓▓█▓▓▓▓█▓█▓▓╬╠╠╠╠╠╠╠╠╠╠╬╠╬╠╠╠╟\n▒╚╚░▒╚╚╩╠╬╣▓╬╣▓╣▓███████████████▓█▓██████████████████▓█▓██▓█▓██▓╬╢╟╠╠╠╢╠╟╠╠╠╠╠╟╟\n╟▒▒░░Γ▒╣▒▒░#▒▒╚▓████████████████▓██████▓████████████████████████▓╬╠╠╠╟╠╬╠╟╠╬╠╠╠╠\n▒╠╠╩▒▒╟▓▓▓▓╣▓▓▓███████████████▓████████████▀╫███████████████████▓▓╬╠╠╠╠╠╠╠╠╠╬╠╠╠\n▒▒▒Γ░Γ▒╬╬▀╬╣▓▓███████████████████████████▓╨░░╫████████████████████▓╬╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▌╬╬╠╬▒▒▒▒████████████████████████████░¡░░!╫██████████▓╟██▓██████▌╠╠╠╠╠╠╠╠╠╠╠\n███████████▓██████▓████████▀╫███████████▒∩¡░░░░╙▀▓╟████▌┤░░╫███▀▀███▌╠╠╠╠╠╠╠╠╠╠╠\n███████████████████████████░╙███▌│╩╨╙██▌░░░░░░░░░░░██▓╝░░░Q▓███████▓╠╠╠╟╠╠╠╠╠╠╠╠\n▓▓▓███████████████████████▌ü███▓▄▄Q░░██▒\\░░░░¡░░░░░╫▓▌▓███████▀▀▀╫╬╠╠╬╠╠╟╟╠╠╠╠╠╟\n╬▓╬╣╬╣╣╣╣╬▓╬████████████╩▀▒░▀▀▀▀▀▀▀███████▓▌▄µ░░░░░▀▀▀╫███████Γ░░╠╟╠╠╠╠╠╠╠╠╠╠╠╠╠\n█▓▓▓▓▓▓▓▓▓▓▓▓███████████░░░░░░∩░░░Q▄▄▄▄░░░┘┤╨├░¡░░░░░▄███▄█████▒░╟╠╠╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▓▓▓▓▓▓▓▓▓███████████▒░░░░░▓███▀█████▄░░░░░░░¡░░ΓΓ██████████┤Γ╬╠╠╠╠╠╬╠╠╠╠╠╠╠╠\n╬╬╬╣╬╣╬╬╣╬╬╬╣▓███████████░░░▄█████████████▄░░░░░¡░░░░█████████δ░░▓╬╣╣▓▓▓▓▓▓╣╣▓▓▓\n╬╬╬╬╣╬╣╬╬╬╬╬╬▓████▒░░∩░▀█▒░▀██╙█▓███████▓█▌░░¡░░░░░░░╚█████▓█▒░░╫▓████▓█▓▓▓▓▓▓▓▓\n╬╣╬╢╬╬╣╬╣╬╬╬╣▓███▌░░░░░░░░░░░┤~╙█▓█████▀██▒░¡░░░░░░φ░░███▓██▒░░░▓▓▓╬╚╙╫╬╫███████\n╬╬╣╬╬╬╣▓▓██▓╬▓███▓░░░░░░░░░░░░(=├▀██▓█████░░░¡░>░\"\"░Γ░░░░░░Γ░░░╫▓▓▓▓▓▓▓█▓█▓▓▓▓▓▓\n╬╫╬╬╬╬╣▓╬╟╬▓╬█████▓▄▒░░░░░░░░░∩░░│▀▀▀╫╨╨╨╨░░░¡░¡░░¡¡░░░░░░░░░░╢▓██▓▓█████████▓██\n▓▓▓▓▓▓▓▓╬╬╫█████████████▓▌▒░░░░░░░░░░!░░░░¡░░░░Q▄▄▄▄▄░░░░Γ░Γ▄▓▓█████████████████\n▓█████╬╣▓▓▓████████████████▓▌▒░░░░░░░░░░░░░░░░████▀▀░░░░░░▄▓▓▓██████████████████\n▓▓▓╬▓▓╬╣╬╬╬╬╬╬╬╬███████████████▌▄▒░░░░░░░░░░░░░░░░░░░░½▄▓▓███▓██████████████████\n▓╬╠▓▓▓▓╣╣╬╣╣╬╣▓╬████▓██████████████▓▓▌▄▄░░░░░░░░φ╦▄▄▓▓███████▓█████████████▓╠▓██\n▓▌╠▓▓▓╬╬╣╬╬╬╬╬╬╬▓█▓████▓█▓╬╢▓██▓▓▓▓▓▓▓▓▓▒Σ▒▒#░#▓▓▓▓▓▓██████████████▓▓████▓▓▓╬╬╬╬\n▓▓╠▓███▓▓╣╣╬╣╬╣╢▓▓▓▓▓▓██▓▓▓╣▓▓█▓▓█▓██▓╬#Γ#▒▒▒░Σ╣█████████████▓╣╬▓███▓████▓╣╣╬╣╣▓\n▓▓╬▓▓▓▓▓▓▓▓▓▓█▓╬▓▓▓▓▓▓▓▓█████████████▄ΓΓ╚Γ░ΓΓΓ▐▄█████████████▓╬╬╬╫█████▓╬╬╣╬╬╬╬╬\n▓▓▓▓▓▓▓▓▓▓▓█████████████████▓▓██████████▓▓▓▓▓████████████▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬\n▓███████████████████████████████████████████████████████╬╣╬╬╬╬╬╬╬╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬\n▓████████████████████████████████████████████████████████╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╬╬╬\n██████████████████████████████████▓██▓█▓▓▓███▓██▓█████████╬╬╣╬╬╣╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╣\n▓█████████████████▓▓▓▓╬╬╬██████████████████▓██▓██╣████████▓╬╬╫╬╢╬╫╬╬╬╬╬╣╬╣╬╬╬╣╬╣\n██████▓█▓▓╬╬╬╬╬╬╬╬╬╬╣╬╬╬▓██████████▌▓╬▒╫▓▓▌╣██▓▓╬▒█████████▌╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬\n╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬╬╬╬╬╬╣████████████╣╟▓╬╣▓▓▓▓▓▓▓▓▓╫█████████╬╬╬╬╬╣╬╬╬╬╬╬╬╬╬╣╬╬╬░\n ; \n ED. : \n E#Wi t#, \n j. E###G. . j. ;##W. \n EW, .. E#fD#W; Ef. EW, :#L:WE \n E##j ;W, E#t t##L E#Wi E##j .KG ,#D \n E###D. j##, E#t .E#K, E#K#D: E###D. EE ;#f \n E#jG#W; G###, E#t j##f E#t,E#f. E#jG#W; f#. t#i\n E#t t##f :E####, E#t :E#K:E#WEE##Wt E#t t##f :#G GK \n E#t :K#E: ;W#DG##, E#t t##L E##Ei;;;;. E#t :K#E:;#L LW. \n E#KDDDD###i j###DW##, E#t .D#W; E#DWWt E#KDDDD###it#f f#: \n E#f,t#Wi,,, G##i,,G##, E#tiW#G. E#t f#K; E#f,t#Wi,,, f#D#; \n E#t ;#W: :K#K: L##, E#K##i E#Dfff##E, E#t ;#W: G#t \n DWi ,KK: ;##D. L##, E##D. jLLLLLLLLL;DWi ,KK: t \n ,,, .,, E#t \n L: \n\n*/\n\nimport {OwnerPausable} from \"@divergencetech/ethier/contracts/utils/OwnerPausable.sol\";\nimport {ERC721Redeemer} from \"@divergencetech/ethier/contracts/erc721/ERC721Redeemer.sol\";\nimport {MerkleProofLib} from \"solmate/utils/MerkleProofLib.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\n\n/// @notice A contract for redeeming ERC721 tokens from a merkle root, as well as whitelisted NFT collections.\n/// @author 10xdegen\n/*//////////////////////////////////////////////////////////////\n PARAMETER TYPES\n//////////////////////////////////////////////////////////////*/\n\nstruct AddCollectionParams {\n address collection;\n uint16 multiplier;\n uint16 maxPerWallet;\n}\n\nstruct ClaimRadlistParams {\n ClaimRadlistForMerkleProof merkleProof;\n ClaimRadlistForCollection[] collections;\n}\n\nstruct ClaimRadlistForMerkleProof {\n uint256 merkleAmount;\n bytes32[] merkleProof;\n}\n\nstruct ClaimRadlistForCollection {\n address collection;\n uint256[] ids;\n}\n\n/// @notice Radlist, on-chain Radness verification.\n/// @author 10xdegen\nabstract contract Radlist is OwnerPausable {\n using ERC721Redeemer for ERC721Redeemer.SingleClaims;\n using Strings for uint16;\n\n /*//////////////////////////////////////////////////////////////\n STORAGE TYPES\n //////////////////////////////////////////////////////////////*/\n\n struct RadlistedCollection {\n Options options;\n Claimed claimed;\n }\n\n struct Options {\n uint16 multiplier;\n uint16 maxPerWallet;\n }\n\n struct Claimed {\n ERC721Redeemer.SingleClaims claims;\n // number claimed per wallet\n mapping(address => uint16) perWallet;\n }\n\n /*//////////////////////////////////////////////////////////////\n STATE\n //////////////////////////////////////////////////////////////*/\n\n // radlist merkle root\n bytes32 public merkleRoot;\n\n // claimed radlist\n mapping(address => uint16) public merkleClaimed;\n\n // list of radlisted nft collections\n address[] public collectionList;\n\n // config and state of radlisted nft collections\n mapping(address => RadlistedCollection) collections;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n /**\n * @dev Constructor.\n * @param _merkleRoot The merkle root.\n */\n constructor(bytes32 _merkleRoot) {\n merkleRoot = _merkleRoot;\n }\n\n /**\n * @dev Add a collection to the radlist.\n * @param _collections The collections to add.\n */\n function addCollections(\n AddCollectionParams[] memory _collections\n ) external onlyOwner {\n for (uint256 i = 0; i < _collections.length; i++) {\n address collection = _collections[i].collection;\n uint16 multiplier = _collections[i].multiplier;\n if (multiplier == 0) multiplier = 1;\n collectionList.push(collection);\n collections[collection].options = Options(\n multiplier,\n _collections[i].maxPerWallet\n );\n }\n }\n\n /**\n @dev Update the merkle root, for adding new radlisters.\n */\n function updateMerkleRoot(bytes32 _merkleRoot) external onlyOwner {\n merkleRoot = _merkleRoot;\n }\n\n /**\n @dev Check if an NFT has already been claimed.\n */\n function claimedNFT(\n address collection,\n uint256 id\n ) public view returns (bool) {\n RadlistedCollection storage radlistedCollection = collections[\n collection\n ];\n Claimed storage claimed = radlistedCollection.claimed;\n return claimed.claims.claimed(id);\n }\n\n function _claimRadlist(\n address wallet,\n ClaimRadlistParams calldata params\n ) internal returns (uint16 totalClaimed) {\n // verify merkle proof\n if (params.merkleProof.merkleAmount > 0) {\n require(\n verifyMerkleProof(\n wallet,\n params.merkleProof.merkleAmount + merkleClaimed[wallet],\n params.merkleProof.merkleProof\n ),\n \"Radlist: invalid merkle proof\"\n );\n merkleClaimed[wallet] += uint16(params.merkleProof.merkleAmount);\n totalClaimed += uint16(params.merkleProof.merkleAmount);\n }\n\n // claim radlisted nfts\n for (uint256 i = 0; i < params.collections.length; i++) {\n address collection = params.collections[i].collection;\n uint256[] calldata ids = params.collections[i].ids;\n\n RadlistedCollection storage radlistedCollection = collections[\n collection\n ];\n Claimed storage claimed = radlistedCollection.claimed;\n Options storage options = radlistedCollection.options;\n\n // check redemption\n uint256 amount = claimed.claims.redeem(\n wallet,\n IERC721(collection),\n ids\n ) * options.multiplier;\n\n // check max per wallet\n uint256 alreadyClaimed = claimed.perWallet[wallet];\n require(\n alreadyClaimed + amount <= options.maxPerWallet,\n string(\n abi.encodePacked(\n \"Radlist: max per wallet exceeded\",\n \" \",\n wallet,\n \" \",\n uint16(amount).toString(),\n \" \",\n options.maxPerWallet.toString()\n )\n )\n );\n\n // increment claimed amounts\n claimed.perWallet[wallet] = uint16(alreadyClaimed + amount);\n totalClaimed += uint16(amount);\n }\n }\n\n /**\n * @dev Helper fuction to get already claimed amount for a wallet.\n */\n function claimedAmount(\n address wallet,\n address collection\n ) public view returns (uint16) {\n RadlistedCollection storage radlistedCollection = collections[\n collection\n ];\n Claimed storage claimed = radlistedCollection.claimed;\n return claimed.perWallet[wallet];\n }\n\n /**\n * @dev Verify a merkle proof.\n * @param wallet The address to claim spots for.\n * @param amount The number of spots to claim.\n * @param merkleProof The merkle proof.\n * @return valid if the proof is valid.\n */\n function verifyMerkleProof(\n address wallet,\n uint256 amount,\n bytes32[] calldata merkleProof\n ) public view returns (bool valid) {\n if (amount == 0) return true; // no spots to claim\n bytes32 node = keccak256(abi.encodePacked(wallet, amount));\n valid = MerkleProofLib.verify(merkleProof, merkleRoot, node);\n }\n\n /**\n * @dev Verify radlisted NFTs.\n * @param wallet The address to claim spots for.\n * @param collection The NFT collection address.\n * @param ids The NFT ids to claim spots with.\n * @return eligibleIds The NFT ids that are valid to claim with.\n * @return claims The number of total redeemable claims for the list.\n */\n function getRadlistedNFTs(\n address wallet,\n address collection,\n uint256[] calldata ids\n ) external view returns (uint256[] memory, uint256 claims) {\n RadlistedCollection storage radlistedCollection = collections[\n collection\n ];\n uint16 alreadyClaimed = radlistedCollection.claimed.perWallet[wallet];\n\n IERC721 nft = IERC721(collection);\n\n uint256[] memory eligibleIds = new uint256[](ids.length);\n uint256 eligibleCount = 0;\n\n for (uint256 i = 0; i < ids.length; i++) {\n uint256 id = ids[i];\n if (\n nft.ownerOf(id) == wallet &&\n !radlistedCollection.claimed.claims.claimed(id)\n ) {\n eligibleIds[eligibleCount] = id;\n eligibleCount++;\n claims += radlistedCollection.options.multiplier;\n }\n }\n\n if (\n claims + alreadyClaimed > radlistedCollection.options.maxPerWallet\n ) {\n claims = radlistedCollection.options.maxPerWallet - alreadyClaimed;\n }\n\n return (eligibleIds, claims);\n }\n}\n"
},
"src/RadArt.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0;\n\n/*\n\n╢╬╬╬╬╠╠╟╠╬╢╠╬╬╠╠╠╢╬╬╠╠╠╠╬╬╬╣▌▌▓▌▌▌▌▌▌╬╬▓▓▓▓▓▓▌▓▓▓▓▒░»=┐;»:»░»¡;\":¡░¡!:░┐░░░░░!░░\n╠╠╠╠╠╠╠╬╣╬╬╬╬╬╬╠╠╠╠╠╠╬╬▓████████████████████████████▌▄φφφφφφφφ╦▒φφ╦φ╦▒φ╦╦╦╦φφφφφ\n▒╠▓╬▒▒▒▒▒▒▒▒╠╠╠╠╠╣╣╬▓██████████████████████████████████▓▓▌╬╟╬╢╠╟╠╠╠╠╠╟╟╠╠╠╠╠╠╠╠╠\n▒╚▓╣▓▓▓▓╣╬▄▓▓▒▒╠▓▒▒▓███████████████████████████▓▓▓█▓█▓█▓▓█▓▓╬╠╠╟╠╠╠╠╢╠╠╠╠╠╬╢╠╠╠╠\n▒Å▓▓▓▓▓▓█▓▓▓╬╫▌╠▓▓████████████████████▓▓████████▓█▓▓█▓▓▓▓█▓█▓▓╬╠╠╠╠╠╠╠╠╠╠╬╠╬╠╠╠╟\n▒╚╚░▒╚╚╩╠╬╣▓╬╣▓╣▓███████████████▓█▓██████████████████▓█▓██▓█▓██▓╬╢╟╠╠╠╢╠╟╠╠╠╠╠╟╟\n╟▒▒░░Γ▒╣▒▒░#▒▒╚▓████████████████▓██████▓████████████████████████▓╬╠╠╠╟╠╬╠╟╠╬╠╠╠╠\n▒╠╠╩▒▒╟▓▓▓▓╣▓▓▓███████████████▓████████████▀╫███████████████████▓▓╬╠╠╠╠╠╠╠╠╠╬╠╠╠\n▒▒▒Γ░Γ▒╬╬▀╬╣▓▓███████████████████████████▓╨░░╫████████████████████▓╬╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▌╬╬╠╬▒▒▒▒████████████████████████████░¡░░!╫██████████▓╟██▓██████▌╠╠╠╠╠╠╠╠╠╠╠\n███████████▓██████▓████████▀╫███████████▒∩¡░░░░╙▀▓╟████▌┤░░╫███▀▀███▌╠╠╠╠╠╠╠╠╠╠╠\n███████████████████████████░╙███▌│╩╨╙██▌░░░░░░░░░░░██▓╝░░░Q▓███████▓╠╠╠╟╠╠╠╠╠╠╠╠\n▓▓▓███████████████████████▌ü███▓▄▄Q░░██▒\\░░░░¡░░░░░╫▓▌▓███████▀▀▀╫╬╠╠╬╠╠╟╟╠╠╠╠╠╟\n╬▓╬╣╬╣╣╣╣╬▓╬████████████╩▀▒░▀▀▀▀▀▀▀███████▓▌▄µ░░░░░▀▀▀╫███████Γ░░╠╟╠╠╠╠╠╠╠╠╠╠╠╠╠\n█▓▓▓▓▓▓▓▓▓▓▓▓███████████░░░░░░∩░░░Q▄▄▄▄░░░┘┤╨├░¡░░░░░▄███▄█████▒░╟╠╠╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▓▓▓▓▓▓▓▓▓███████████▒░░░░░▓███▀█████▄░░░░░░░¡░░ΓΓ██████████┤Γ╬╠╠╠╠╠╬╠╠╠╠╠╠╠╠\n╬╬╬╣╬╣╬╬╣╬╬╬╣▓███████████░░░▄█████████████▄░░░░░¡░░░░█████████δ░░▓╬╣╣▓▓▓▓▓▓╣╣▓▓▓\n╬╬╬╬╣╬╣╬╬╬╬╬╬▓████▒░░∩░▀█▒░▀██╙█▓███████▓█▌░░¡░░░░░░░╚█████▓█▒░░╫▓████▓█▓▓▓▓▓▓▓▓\n╬╣╬╢╬╬╣╬╣╬╬╬╣▓███▌░░░░░░░░░░░┤~╙█▓█████▀██▒░¡░░░░░░φ░░███▓██▒░░░▓▓▓╬╚╙╫╬╫███████\n╬╬╣╬╬╬╣▓▓██▓╬▓███▓░░░░░░░░░░░░(=├▀██▓█████░░░¡░>░\"\"░Γ░░░░░░Γ░░░╫▓▓▓▓▓▓▓█▓█▓▓▓▓▓▓\n╬╫╬╬╬╬╣▓╬╟╬▓╬█████▓▄▒░░░░░░░░░∩░░│▀▀▀╫╨╨╨╨░░░¡░¡░░¡¡░░░░░░░░░░╢▓██▓▓█████████▓██\n▓▓▓▓▓▓▓▓╬╬╫█████████████▓▌▒░░░░░░░░░░!░░░░¡░░░░Q▄▄▄▄▄░░░░Γ░Γ▄▓▓█████████████████\n▓█████╬╣▓▓▓████████████████▓▌▒░░░░░░░░░░░░░░░░████▀▀░░░░░░▄▓▓▓██████████████████\n▓▓▓╬▓▓╬╣╬╬╬╬╬╬╬╬███████████████▌▄▒░░░░░░░░░░░░░░░░░░░░½▄▓▓███▓██████████████████\n▓╬╠▓▓▓▓╣╣╬╣╣╬╣▓╬████▓██████████████▓▓▌▄▄░░░░░░░░φ╦▄▄▓▓███████▓█████████████▓╠▓██\n▓▌╠▓▓▓╬╬╣╬╬╬╬╬╬╬▓█▓████▓█▓╬╢▓██▓▓▓▓▓▓▓▓▓▒Σ▒▒#░#▓▓▓▓▓▓██████████████▓▓████▓▓▓╬╬╬╬\n▓▓╠▓███▓▓╣╣╬╣╬╣╢▓▓▓▓▓▓██▓▓▓╣▓▓█▓▓█▓██▓╬#Γ#▒▒▒░Σ╣█████████████▓╣╬▓███▓████▓╣╣╬╣╣▓\n▓▓╬▓▓▓▓▓▓▓▓▓▓█▓╬▓▓▓▓▓▓▓▓█████████████▄ΓΓ╚Γ░ΓΓΓ▐▄█████████████▓╬╬╬╫█████▓╬╬╣╬╬╬╬╬\n▓▓▓▓▓▓▓▓▓▓▓█████████████████▓▓██████████▓▓▓▓▓████████████▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬\n▓███████████████████████████████████████████████████████╬╣╬╬╬╬╬╬╬╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬\n▓████████████████████████████████████████████████████████╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╬╬╬\n██████████████████████████████████▓██▓█▓▓▓███▓██▓█████████╬╬╣╬╬╣╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╣\n▓█████████████████▓▓▓▓╬╬╬██████████████████▓██▓██╣████████▓╬╬╫╬╢╬╫╬╬╬╬╬╣╬╣╬╬╬╣╬╣\n██████▓█▓▓╬╬╬╬╬╬╬╬╬╬╣╬╬╬▓██████████▌▓╬▒╫▓▓▌╣██▓▓╬▒█████████▌╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬\n╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬╬╬╬╬╬╣████████████╣╟▓╬╣▓▓▓▓▓▓▓▓▓╫█████████╬╬╬╬╬╣╬╬╬╬╬╬╬╬╬╣╬╬╬░\n ; \n ED. : \n E#Wi t#, \n j. E###G. . j. ;##W. \n EW, .. E#fD#W; Ef. EW, :#L:WE \n E##j ;W, E#t t##L E#Wi E##j .KG ,#D \n E###D. j##, E#t .E#K, E#K#D: E###D. EE ;#f \n E#jG#W; G###, E#t j##f E#t,E#f. E#jG#W; f#. t#i\n E#t t##f :E####, E#t :E#K:E#WEE##Wt E#t t##f :#G GK \n E#t :K#E: ;W#DG##, E#t t##L E##Ei;;;;. E#t :K#E:;#L LW. \n E#KDDDD###i j###DW##, E#t .D#W; E#DWWt E#KDDDD###it#f f#: \n E#f,t#Wi,,, G##i,,G##, E#tiW#G. E#t f#K; E#f,t#Wi,,, f#D#; \n E#t ;#W: :K#K: L##, E#K##i E#Dfff##E, E#t ;#W: G#t \n DWi ,KK: ;##D. L##, E##D. jLLLLLLLLL;DWi ,KK: t \n ,,, .,, E#t \n L: \n\n*/\n\nimport {Bitmaps} from \"./utils/Bitmap.sol\";\nimport {OwnerPausable} from \"@divergencetech/ethier/contracts/utils/OwnerPausable.sol\";\n\n/// @notice Library for mapping Radbros to rerollable art.\n/// @author 10xdegen\nlibrary ArtMaps {\n using Bitmaps for Bitmaps.Bitmap;\n struct ArtMap {\n uint256 supply;\n uint256 totalUsed;\n Bitmaps.Bitmap usedArt;\n bool initial;\n }\n\n function makeArtMap(\n uint256 _size,\n bool _initial\n ) internal pure returns (ArtMap memory) {\n ArtMap memory artMap;\n artMap.supply = _size;\n artMap.usedArt = Bitmaps.makeBitmap(_size);\n artMap.initial = _initial;\n if (_initial) {\n artMap.totalUsed = _size;\n }\n return artMap;\n }\n\n function setArtInUse(\n ArtMap storage _artMap,\n uint256 _index,\n bool _inUse\n ) internal {\n bool storageBit = _artMap.initial ? !_inUse : _inUse;\n if (_artMap.usedArt.get(_index) != storageBit) {\n _artMap.usedArt.set(_index, storageBit);\n if (_inUse) {\n _artMap.totalUsed++;\n } else {\n _artMap.totalUsed--;\n }\n }\n }\n\n // get a random unused art\n // WARNING: this function may incur a high gas cost that scales with maxSupply.\n function getRandomUnusedArt(\n ArtMap storage _artMap\n ) internal view returns (uint256) {\n // choose a random index and start counting in our bitmap\n uint256 _startIndex = randInt(0, _artMap.supply);\n for (uint256 i = _startIndex; i < _artMap.supply; i++) {\n if (_artInUse(_artMap, i)) {\n continue;\n }\n // stop on the first random art after our start index\n return i;\n }\n // start from the beginning of the loop and continue until the start index\n for (uint256 i = 0; i < _startIndex; i++) {\n if (_artInUse(_artMap, i)) {\n continue;\n }\n // return the first available art\n return i;\n }\n return 0; // no art available\n }\n\n function _artInUse(\n ArtMap storage _artMap,\n uint256 _art\n ) internal view returns (bool) {\n return _artMap.usedArt.get(_art);\n }\n}\n\nabstract contract RadArt is OwnerPausable {\n using ArtMaps for ArtMaps.ArtMap;\n\n /*//////////////////////////////////////////////////////////////\n TYPES\n //////////////////////////////////////////////////////////////*/\n\n struct ArtRef {\n uint256 artId;\n bool initial;\n }\n\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event ArtRolled(\n address indexed user,\n uint256 indexed tokenId,\n bool initialArt,\n uint256 newArt\n );\n\n /*//////////////////////////////////////////////////////////////\n STORAGE\n //////////////////////////////////////////////////////////////*/\n\n // whether or not rerolling has been started\n bool public rerollStarted;\n // initial art is used when the bit is set to 0\n ArtMaps.ArtMap public initialArt;\n // secondary art is used when the bit is set to 1\n ArtMaps.ArtMap public secondaryArt;\n // the map of token id to art\n mapping(uint256 => ArtRef) public tokenArt;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n constructor(uint256 _initialAmount, uint256 _secondaryAmount) {\n initialArt = ArtMaps.makeArtMap(_initialAmount, true);\n secondaryArt = ArtMaps.makeArtMap(_secondaryAmount, false);\n }\n\n /*//////////////////////////////////////////////////////////////\n RE-ROLL\n //////////////////////////////////////////////////////////////*/\n /// @notice Start the rerolling process.\n function startReroll() external onlyOwner {\n rerollStarted = true;\n }\n\n /// @notice Reroll the art for a token.\n function _rerollArt(\n uint256 tokenId,\n bool allowFromInit\n ) internal returns (uint256 newArt) {\n require(rerollStarted, \"Reroll not started\");\n bool useInit = allowFromInit &&\n initialArt.totalUsed < secondaryArt.totalUsed;\n\n // get a random art from the secondary art map.\n if (useInit) {\n newArt = initialArt.getRandomUnusedArt();\n initialArt.setArtInUse(newArt, true);\n } else {\n newArt = secondaryArt.getRandomUnusedArt();\n secondaryArt.setArtInUse(newArt, true);\n }\n\n uint256 currentArt = tokenArt[tokenId].artId;\n if (currentArt == 0) {\n // token is currently using initial art.\n // free up the initial art\n initialArt.setArtInUse(tokenId, false);\n } else {\n // token has already been rolled.\n // free up the current art\n ArtMaps.ArtMap storage currentArtMap = tokenArt[tokenId].initial\n ? initialArt\n : secondaryArt;\n currentArtMap.setArtInUse(currentArt, false);\n }\n\n // set the new art for the token\n tokenArt[tokenId] = ArtRef(newArt, useInit);\n\n // emit the event\n emit ArtRolled(msg.sender, tokenId, useInit, newArt);\n }\n\n /*//////////////////////////////////////////////////////////////\n GETTER\n //////////////////////////////////////////////////////////////*/\n function getArt(\n uint256 tokenId\n ) public view returns (uint256 artId, bool initial) {\n ArtRef memory artRef = tokenArt[tokenId];\n return (artRef.artId, artRef.initial);\n }\n}\n\nfunction randInt(uint256 _min, uint256 _max) view returns (uint256) {\n require(_min < _max, \"min must be less than max\");\n return\n _min +\n (uint256(\n keccak256(\n abi.encodePacked(\n _min,\n _max,\n block.timestamp,\n block.number,\n block.difficulty,\n msg.sender\n )\n )\n ) % (_max - _min));\n}\n"
},
"src/Radcoin.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/*\n\n╢╬╬╬╬╠╠╟╠╬╢╠╬╬╠╠╠╢╬╬╠╠╠╠╬╬╬╣▌▌▓▌▌▌▌▌▌╬╬▓▓▓▓▓▓▌▓▓▓▓▒░»=┐;»:»░»¡;\":¡░¡!:░┐░░░░░!░░\n╠╠╠╠╠╠╠╬╣╬╬╬╬╬╬╠╠╠╠╠╠╬╬▓████████████████████████████▌▄φφφφφφφφ╦▒φφ╦φ╦▒φ╦╦╦╦φφφφφ\n▒╠▓╬▒▒▒▒▒▒▒▒╠╠╠╠╠╣╣╬▓██████████████████████████████████▓▓▌╬╟╬╢╠╟╠╠╠╠╠╟╟╠╠╠╠╠╠╠╠╠\n▒╚▓╣▓▓▓▓╣╬▄▓▓▒▒╠▓▒▒▓███████████████████████████▓▓▓█▓█▓█▓▓█▓▓╬╠╠╟╠╠╠╠╢╠╠╠╠╠╬╢╠╠╠╠\n▒Å▓▓▓▓▓▓█▓▓▓╬╫▌╠▓▓████████████████████▓▓████████▓█▓▓█▓▓▓▓█▓█▓▓╬╠╠╠╠╠╠╠╠╠╠╬╠╬╠╠╠╟\n▒╚╚░▒╚╚╩╠╬╣▓╬╣▓╣▓███████████████▓█▓██████████████████▓█▓██▓█▓██▓╬╢╟╠╠╠╢╠╟╠╠╠╠╠╟╟\n╟▒▒░░Γ▒╣▒▒░#▒▒╚▓████████████████▓██████▓████████████████████████▓╬╠╠╠╟╠╬╠╟╠╬╠╠╠╠\n▒╠╠╩▒▒╟▓▓▓▓╣▓▓▓███████████████▓████████████▀╫███████████████████▓▓╬╠╠╠╠╠╠╠╠╠╬╠╠╠\n▒▒▒Γ░Γ▒╬╬▀╬╣▓▓███████████████████████████▓╨░░╫████████████████████▓╬╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▌╬╬╠╬▒▒▒▒████████████████████████████░¡░░!╫██████████▓╟██▓██████▌╠╠╠╠╠╠╠╠╠╠╠\n███████████▓██████▓████████▀╫███████████▒∩¡░░░░╙▀▓╟████▌┤░░╫███▀▀███▌╠╠╠╠╠╠╠╠╠╠╠\n███████████████████████████░╙███▌│╩╨╙██▌░░░░░░░░░░░██▓╝░░░Q▓███████▓╠╠╠╟╠╠╠╠╠╠╠╠\n▓▓▓███████████████████████▌ü███▓▄▄Q░░██▒\\░░░░¡░░░░░╫▓▌▓███████▀▀▀╫╬╠╠╬╠╠╟╟╠╠╠╠╠╟\n╬▓╬╣╬╣╣╣╣╬▓╬████████████╩▀▒░▀▀▀▀▀▀▀███████▓▌▄µ░░░░░▀▀▀╫███████Γ░░╠╟╠╠╠╠╠╠╠╠╠╠╠╠╠\n█▓▓▓▓▓▓▓▓▓▓▓▓███████████░░░░░░∩░░░Q▄▄▄▄░░░┘┤╨├░¡░░░░░▄███▄█████▒░╟╠╠╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▓▓▓▓▓▓▓▓▓███████████▒░░░░░▓███▀█████▄░░░░░░░¡░░ΓΓ██████████┤Γ╬╠╠╠╠╠╬╠╠╠╠╠╠╠╠\n╬╬╬╣╬╣╬╬╣╬╬╬╣▓███████████░░░▄█████████████▄░░░░░¡░░░░█████████δ░░▓╬╣╣▓▓▓▓▓▓╣╣▓▓▓\n╬╬╬╬╣╬╣╬╬╬╬╬╬▓████▒░░∩░▀█▒░▀██╙█▓███████▓█▌░░¡░░░░░░░╚█████▓█▒░░╫▓████▓█▓▓▓▓▓▓▓▓\n╬╣╬╢╬╬╣╬╣╬╬╬╣▓███▌░░░░░░░░░░░┤~╙█▓█████▀██▒░¡░░░░░░φ░░███▓██▒░░░▓▓▓╬╚╙╫╬╫███████\n╬╬╣╬╬╬╣▓▓██▓╬▓███▓░░░░░░░░░░░░(=├▀██▓█████░░░¡░>░\"\"░Γ░░░░░░Γ░░░╫▓▓▓▓▓▓▓█▓█▓▓▓▓▓▓\n╬╫╬╬╬╬╣▓╬╟╬▓╬█████▓▄▒░░░░░░░░░∩░░│▀▀▀╫╨╨╨╨░░░¡░¡░░¡¡░░░░░░░░░░╢▓██▓▓█████████▓██\n▓▓▓▓▓▓▓▓╬╬╫█████████████▓▌▒░░░░░░░░░░!░░░░¡░░░░Q▄▄▄▄▄░░░░Γ░Γ▄▓▓█████████████████\n▓█████╬╣▓▓▓████████████████▓▌▒░░░░░░░░░░░░░░░░████▀▀░░░░░░▄▓▓▓██████████████████\n▓▓▓╬▓▓╬╣╬╬╬╬╬╬╬╬███████████████▌▄▒░░░░░░░░░░░░░░░░░░░░½▄▓▓███▓██████████████████\n▓╬╠▓▓▓▓╣╣╬╣╣╬╣▓╬████▓██████████████▓▓▌▄▄░░░░░░░░φ╦▄▄▓▓███████▓█████████████▓╠▓██\n▓▌╠▓▓▓╬╬╣╬╬╬╬╬╬╬▓█▓████▓█▓╬╢▓██▓▓▓▓▓▓▓▓▓▒Σ▒▒#░#▓▓▓▓▓▓██████████████▓▓████▓▓▓╬╬╬╬\n▓▓╠▓███▓▓╣╣╬╣╬╣╢▓▓▓▓▓▓██▓▓▓╣▓▓█▓▓█▓██▓╬#Γ#▒▒▒░Σ╣█████████████▓╣╬▓███▓████▓╣╣╬╣╣▓\n▓▓╬▓▓▓▓▓▓▓▓▓▓█▓╬▓▓▓▓▓▓▓▓█████████████▄ΓΓ╚Γ░ΓΓΓ▐▄█████████████▓╬╬╬╫█████▓╬╬╣╬╬╬╬╬\n▓▓▓▓▓▓▓▓▓▓▓█████████████████▓▓██████████▓▓▓▓▓████████████▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬\n▓███████████████████████████████████████████████████████╬╣╬╬╬╬╬╬╬╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬\n▓████████████████████████████████████████████████████████╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╬╬╬\n██████████████████████████████████▓██▓█▓▓▓███▓██▓█████████╬╬╣╬╬╣╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╣\n▓█████████████████▓▓▓▓╬╬╬██████████████████▓██▓██╣████████▓╬╬╫╬╢╬╫╬╬╬╬╬╣╬╣╬╬╬╣╬╣\n██████▓█▓▓╬╬╬╬╬╬╬╬╬╬╣╬╬╬▓██████████▌▓╬▒╫▓▓▌╣██▓▓╬▒█████████▌╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬\n╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬╬╬╬╬╬╣████████████╣╟▓╬╣▓▓▓▓▓▓▓▓▓╫█████████╬╬╬╬╬╣╬╬╬╬╬╬╬╬╬╣╬╬╬░\n ; \n ED. : \n E#Wi t#, \n j. E###G. . j. ;##W. \n EW, .. E#fD#W; Ef. EW, :#L:WE \n E##j ;W, E#t t##L E#Wi E##j .KG ,#D \n E###D. j##, E#t .E#K, E#K#D: E###D. EE ;#f \n E#jG#W; G###, E#t j##f E#t,E#f. E#jG#W; f#. t#i\n E#t t##f :E####, E#t :E#K:E#WEE##Wt E#t t##f :#G GK \n E#t :K#E: ;W#DG##, E#t t##L E##Ei;;;;. E#t :K#E:;#L LW. \n E#KDDDD###i j###DW##, E#t .D#W; E#DWWt E#KDDDD###it#f f#: \n E#f,t#Wi,,, G##i,,G##, E#tiW#G. E#t f#K; E#f,t#Wi,,, f#D#; \n E#t ;#W: :K#K: L##, E#K##i E#Dfff##E, E#t ;#W: G#t \n DWi ,KK: ;##D. L##, E##D. jLLLLLLLLL;DWi ,KK: t \n ,,, .,, E#t \n L: \n\n*/\n\nimport {ERC20} from \"solmate/tokens/ERC20.sol\";\nimport {SafeTransferLib} from \"solmate/utils/SafeTransferLib.sol\";\nimport {FixedPointMathLib} from \"solmate/utils/FixedPointMathLib.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {ReentrancyGuard} from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\n\n/// @notice Radcoins for Radbros.\n/// @author 10xdegen\ncontract Radcoin is ERC20, ReentrancyGuard {\n using SafeTransferLib for ERC20;\n using FixedPointMathLib for uint256;\n\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Claim(\n address indexed caller,\n address indexed receiver,\n address indexed owner,\n uint256[] radbros,\n uint256 amount\n );\n\n /*//////////////////////////////////////////////////////////////\n RADBRO\n //////////////////////////////////////////////////////////////*/\n\n address public immutable radbro;\n uint256 public immutable MAX_PER_RADBRO = 250 ether;\n uint256 public immutable REWARD_PER_DAY = 1 ether;\n\n /*//////////////////////////////////////////////////////////////\n STATE\n //////////////////////////////////////////////////////////////*/\n\n struct ClaimState {\n uint256 startTime; // time\n uint256 totalClaimed; // total amount claimed\n }\n\n // token id to the state of the claim\n mapping(uint256 => ClaimState) public claims;\n\n /*//////////////////////////////////////////////////////////////\n ERRORS\n //////////////////////////////////////////////////////////////*/\n\n error Unauthorized();\n\n /*//////////////////////////////////////////////////////////////\n MODIFIERS\n //////////////////////////////////////////////////////////////*/\n\n /// @notice Requires caller address to match user address.\n modifier only(address user) {\n if (msg.sender != user) revert Unauthorized();\n\n _;\n }\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(address _radbro) ERC20(\"Radcoin\", \"RAD\", 18) {\n radbro = _radbro;\n }\n\n /*//////////////////////////////////////////////////////////////\n CLAIMING\n //////////////////////////////////////////////////////////////*/\n\n /// @notice Each radbro starts with 0 reward.\n /// Called on new radbro mint.\n function initializeRadbro(\n uint256 id,\n uint256 startTime\n ) external only(radbro) {\n claims[id] = ClaimState(startTime, 0);\n }\n\n // @notice Gets the claim state for the radbro id.\n // @param radbroId The radbro id.\n // @return The claim state.\n function getClaim(\n uint256 radbroId\n ) public view returns (ClaimState memory) {\n return claims[radbroId];\n }\n\n // @notice Get the radcoin reward for a given radbro. Each Radbro pays 1e18 Radcoin per day.\n // @param radbroId The radbro id.\n // @return The radcoin reward.\n function getClaimRewards(\n uint256[] calldata radbroIds\n ) public view returns (uint256 reward) {\n for (uint256 i = 0; i < radbroIds.length; i++) {\n uint256 radbroId = radbroIds[i];\n reward += getClaimReward(radbroId);\n }\n }\n\n // @notice Get the radcoin reward for a given radbro. Each Radbro pays 1e18 Radcoin per day.\n // @param radbroId The radbro id.\n // @return The radcoin reward.\n function getClaimReward(\n uint256 radbroId\n ) public view returns (uint256 reward) {\n ClaimState memory claim = getClaim(radbroId);\n require(claim.startTime != 0, \"NOT_INITIALIZED\");\n if (claim.startTime >= block.timestamp) return 0; // should never happen\n\n uint256 radbroAge = block.timestamp - claim.startTime;\n\n uint256 totalEarned = ((radbroAge * REWARD_PER_DAY) / 1 days);\n\n reward = totalEarned - claim.totalClaimed;\n\n if (reward > MAX_PER_RADBRO - claim.totalClaimed) {\n reward = MAX_PER_RADBRO - claim.totalClaimed; // cap at MAX_PER_RADBRO per radbro\n }\n }\n\n /// @notice Claim RAD for a set of Radbros. Caller must be the owner of the Radbros.\n /// @param _receiver The address to receive the RAD.\n /// @param _radbros The Radbros to claim for.\n /// @return amount The amount of RAD claimed.\n function claimRadcoin(\n address _receiver,\n uint256[] calldata _radbros\n ) external nonReentrant returns (uint256 amount) {\n for (uint256 i = 0; i < _radbros.length; i++) {\n uint256 radbroId = _radbros[i];\n\n require(\n IERC721(radbro).ownerOf(radbroId) == msg.sender,\n \"NOT_RAD_BRO\"\n );\n\n uint256 rewardForRadbro = getClaimReward(radbroId);\n if (rewardForRadbro > 0) {\n claims[radbroId].totalClaimed += rewardForRadbro;\n amount += rewardForRadbro;\n }\n }\n\n require(amount > 0, \"NO_RAD_CLAIMABLE\");\n\n _mint(_receiver, amount);\n }\n\n /// @notice Spend (burn) virtual radcoin without needing to mint. Can only be called by Radbro.\n /// @param radbroId The id of the radbro to burn claim from.\n /// @param amount The amount of radcoin to burn.\n function claimForRadbro(\n uint256 radbroId,\n uint256 amount\n ) external only(radbro) {\n uint256 rewardForRadbro = getClaimReward(radbroId);\n require(rewardForRadbro >= amount, \"NOT_ENOUGH_REWARD\");\n\n if (amount > 0) {\n claims[radbroId].totalClaimed += amount;\n }\n }\n\n /*//////////////////////////////////////////////////////////////\n BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n /// @notice Burn any amount of radcoin from a user. Can only be called by Radbros.\n /// @param from The address of the user to burn radcoin from.\n /// @param amount The amount of radcoin to burn.\n function burnForRadbros(\n address from,\n uint256 amount\n ) external only(radbro) {\n require(balanceOf[from] >= amount, \"NOT_ENOUGH_BALANCE\");\n _burn(from, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, deducting from the caller's\n * allowance.\n *\n * See {ERC20-_burn} and {ERC20-allowance}.\n *\n * Requirements:\n *\n * - the caller must have allowance for ``accounts``'s tokens of at least\n * `amount`.\n */\n function burnFrom(address account, uint256 amount) external nonReentrant {\n require(balanceOf[account] >= amount, \"NOT_ENOUGH_BALANCE\");\n _spendAllowance(account, msg.sender, amount);\n _burn(account, amount);\n }\n\n function _spendAllowance(\n address owner,\n address spender,\n uint256 amount\n ) internal {\n uint256 currentAllowance = allowance[owner][spender];\n require(\n currentAllowance >= amount,\n \"ERC20: transfer amount exceeds allowance\"\n );\n unchecked {\n _approve(owner, spender, currentAllowance - amount);\n }\n }\n\n function _approve(address owner, address spender, uint256 amount) internal {\n allowance[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n}\n"
},
"src/Radmath.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0;\n\n/*\n╢╬╬╬╬╠╠╟╠╬╢╠╬╬╠╠╠╢╬╬╠╠╠╠╬╬╬╣▌▌▓▌▌▌▌▌▌╬╬▓▓▓▓▓▓▌▓▓▓▓▒░»=┐;»:»░»¡;\":¡░¡!:░┐░░░░░!░░\n╠╠╠╠╠╠╠╬╣╬╬╬╬╬╬╠╠╠╠╠╠╬╬▓████████████████████████████▌▄φφφφφφφφ╦▒φφ╦φ╦▒φ╦╦╦╦φφφφφ\n▒╠▓╬▒▒▒▒▒▒▒▒╠╠╠╠╠╣╣╬▓██████████████████████████████████▓▓▌╬╟╬╢╠╟╠╠╠╠╠╟╟╠╠╠╠╠╠╠╠╠\n▒╚▓╣▓▓▓▓╣╬▄▓▓▒▒╠▓▒▒▓███████████████████████████▓▓▓█▓█▓█▓▓█▓▓╬╠╠╟╠╠╠╠╢╠╠╠╠╠╬╢╠╠╠╠\n▒Å▓▓▓▓▓▓█▓▓▓╬╫▌╠▓▓████████████████████▓▓████████▓█▓▓█▓▓▓▓█▓█▓▓╬╠╠╠╠╠╠╠╠╠╠╬╠╬╠╠╠╟\n▒╚╚░▒╚╚╩╠╬╣▓╬╣▓╣▓███████████████▓█▓██████████████████▓█▓██▓█▓██▓╬╢╟╠╠╠╢╠╟╠╠╠╠╠╟╟\n╟▒▒░░Γ▒╣▒▒░#▒▒╚▓████████████████▓██████▓████████████████████████▓╬╠╠╠╟╠╬╠╟╠╬╠╠╠╠\n▒╠╠╩▒▒╟▓▓▓▓╣▓▓▓███████████████▓████████████▀╫███████████████████▓▓╬╠╠╠╠╠╠╠╠╠╬╠╠╠\n▒▒▒Γ░Γ▒╬╬▀╬╣▓▓███████████████████████████▓╨░░╫████████████████████▓╬╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▌╬╬╠╬▒▒▒▒████████████████████████████░¡░░!╫██████████▓╟██▓██████▌╠╠╠╠╠╠╠╠╠╠╠\n███████████▓██████▓████████▀╫███████████▒∩¡░░░░╙▀▓╟████▌┤░░╫███▀▀███▌╠╠╠╠╠╠╠╠╠╠╠\n███████████████████████████░╙███▌│╩╨╙██▌░░░░░░░░░░░██▓╝░░░Q▓███████▓╠╠╠╟╠╠╠╠╠╠╠╠\n▓▓▓███████████████████████▌ü███▓▄▄Q░░██▒\\░░░░¡░░░░░╫▓▌▓███████▀▀▀╫╬╠╠╬╠╠╟╟╠╠╠╠╠╟\n╬▓╬╣╬╣╣╣╣╬▓╬████████████╩▀▒░▀▀▀▀▀▀▀███████▓▌▄µ░░░░░▀▀▀╫███████Γ░░╠╟╠╠╠╠╠╠╠╠╠╠╠╠╠\n█▓▓▓▓▓▓▓▓▓▓▓▓███████████░░░░░░∩░░░Q▄▄▄▄░░░┘┤╨├░¡░░░░░▄███▄█████▒░╟╠╠╠╠╠╠╠╠╠╠╠╠╠╠\n▓▓▓▓▓▓▓▓▓▓▓▓▓███████████▒░░░░░▓███▀█████▄░░░░░░░¡░░ΓΓ██████████┤Γ╬╠╠╠╠╠╬╠╠╠╠╠╠╠╠\n╬╬╬╣╬╣╬╬╣╬╬╬╣▓███████████░░░▄█████████████▄░░░░░¡░░░░█████████δ░░▓╬╣╣▓▓▓▓▓▓╣╣▓▓▓\n╬╬╬╬╣╬╣╬╬╬╬╬╬▓████▒░░∩░▀█▒░▀██╙█▓███████▓█▌░░¡░░░░░░░╚█████▓█▒░░╫▓████▓█▓▓▓▓▓▓▓▓\n╬╣╬╢╬╬╣╬╣╬╬╬╣▓███▌░░░░░░░░░░░┤~╙█▓█████▀██▒░¡░░░░░░φ░░███▓██▒░░░▓▓▓╬╚╙╫╬╫███████\n╬╬╣╬╬╬╣▓▓██▓╬▓███▓░░░░░░░░░░░░(=├▀██▓█████░░░¡░>░\"\"░Γ░░░░░░Γ░░░╫▓▓▓▓▓▓▓█▓█▓▓▓▓▓▓\n╬╫╬╬╬╬╣▓╬╟╬▓╬█████▓▄▒░░░░░░░░░∩░░│▀▀▀╫╨╨╨╨░░░¡░¡░░¡¡░░░░░░░░░░╢▓██▓▓█████████▓██\n▓▓▓▓▓▓▓▓╬╬╫█████████████▓▌▒░░░░░░░░░░!░░░░¡░░░░Q▄▄▄▄▄░░░░Γ░Γ▄▓▓█████████████████\n▓█████╬╣▓▓▓████████████████▓▌▒░░░░░░░░░░░░░░░░████▀▀░░░░░░▄▓▓▓██████████████████\n▓▓▓╬▓▓╬╣╬╬╬╬╬╬╬╬███████████████▌▄▒░░░░░░░░░░░░░░░░░░░░½▄▓▓███▓██████████████████\n▓╬╠▓▓▓▓╣╣╬╣╣╬╣▓╬████▓██████████████▓▓▌▄▄░░░░░░░░φ╦▄▄▓▓███████▓█████████████▓╠▓██\n▓▌╠▓▓▓╬╬╣╬╬╬╬╬╬╬▓█▓████▓█▓╬╢▓██▓▓▓▓▓▓▓▓▓▒Σ▒▒#░#▓▓▓▓▓▓██████████████▓▓████▓▓▓╬╬╬╬\n▓▓╠▓███▓▓╣╣╬╣╬╣╢▓▓▓▓▓▓██▓▓▓╣▓▓█▓▓█▓██▓╬#Γ#▒▒▒░Σ╣█████████████▓╣╬▓███▓████▓╣╣╬╣╣▓\n▓▓╬▓▓▓▓▓▓▓▓▓▓█▓╬▓▓▓▓▓▓▓▓█████████████▄ΓΓ╚Γ░ΓΓΓ▐▄█████████████▓╬╬╬╫█████▓╬╬╣╬╬╬╬╬\n▓▓▓▓▓▓▓▓▓▓▓█████████████████▓▓██████████▓▓▓▓▓████████████▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬\n▓███████████████████████████████████████████████████████╬╣╬╬╬╬╬╬╬╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬\n▓████████████████████████████████████████████████████████╬╬╬╬╫╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╬╬╬\n██████████████████████████████████▓██▓█▓▓▓███▓██▓█████████╬╬╣╬╬╣╬╬╬╬╬╣╬╬╬╬╬╬╬╬╣╣\n▓█████████████████▓▓▓▓╬╬╬██████████████████▓██▓██╣████████▓╬╬╫╬╢╬╫╬╬╬╬╬╣╬╣╬╬╬╣╬╣\n██████▓█▓▓╬╬╬╬╬╬╬╬╬╬╣╬╬╬▓██████████▌▓╬▒╫▓▓▌╣██▓▓╬▒█████████▌╣╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬\n╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╣╬╬╬╬╬╬╣████████████╣╟▓╬╣▓▓▓▓▓▓▓▓▓╫█████████╬╬╬╬╬╣╬╬╬╬╬╬╬╬╬╣╬╬╬░\n ; \n ED. : \n E#Wi t#, \n j. E###G. . j. ;##W. \n EW, .. E#fD#W; Ef. EW, :#L:WE \n E##j ;W, E#t t##L E#Wi E##j .KG ,#D \n E###D. j##, E#t .E#K, E#K#D: E###D. EE ;#f \n E#jG#W; G###, E#t j##f E#t,E#f. E#jG#W; f#. t#i\n E#t t##f :E####, E#t :E#K:E#WEE##Wt E#t t##f :#G GK \n E#t :K#E: ;W#DG##, E#t t##L E##Ei;;;;. E#t :K#E:;#L LW. \n E#KDDDD###i j###DW##, E#t .D#W; E#DWWt E#KDDDD###it#f f#: \n E#f,t#Wi,,, G##i,,G##, E#tiW#G. E#t f#K; E#f,t#Wi,,, f#D#; \n E#t ;#W: :K#K: L##, E#K##i E#Dfff##E, E#t ;#W: G#t \n DWi ,KK: ;##D. L##, E##D. jLLLLLLLLL;DWi ,KK: t \n ,,, .,, E#t \n L: \n\n*/\n\nimport { FixedPointMathLib } from \"solmate/utils/FixedPointMathLib.sol\";\n\nabstract contract Radmath {\n using FixedPointMathLib for uint256;\n\n /**\n @dev get the purchase price for a given Delta (% in wei)\n */\n function getBuyInfo(\n uint128 spotPrice,\n uint128 delta,\n uint256 numItems\n ) public pure returns (uint128 newSpotPrice, uint256 inputValue) {\n // NOTE: we assume delta is > 1, as checked by validateDelta()\n require(delta > 1, \"DELTA_TOO_SMALL\");\n // We only calculate changes for buying 1 or more NFTs\n require(numItems > 0, \"INVALID_NUM_ITEMS\");\n\n uint256 deltaPowN = uint256(delta).rpow(numItems, FixedPointMathLib.WAD);\n\n // For an exponential curve, the spot price is multiplied by delta for each item bought\n uint256 newSpotPrice_ = uint256(spotPrice).mulWadUp(deltaPowN);\n require(newSpotPrice_ <= type(uint128).max, \"SPOT_PRICE_OVERFLOW\");\n newSpotPrice = uint128(newSpotPrice_);\n\n // Spot price is assumed to be the instant sell price. To avoid arbitraging LPs, we adjust the buy price upwards.\n // If spot price for buy and sell were the same, then someone could buy 1 NFT and then sell for immediate profit.\n // EX: Let S be spot price. Then buying 1 NFT costs S ETH, now new spot price is (S * delta).\n // The same person could then sell for (S * delta) ETH, netting them delta ETH profit.\n // If spot price for buy and sell differ by delta, then buying costs (S * delta) ETH.\n // The new spot price would become (S * delta), so selling would also yield (S * delta) ETH.\n uint256 buySpotPrice = uint256(spotPrice).mulDivUp(delta, FixedPointMathLib.WAD);\n\n // If the user buys n items, then the total cost is equal to:\n // buySpotPrice + (delta * buySpotPrice) + (delta^2 * buySpotPrice) + ... (delta^(numItems - 1) * buySpotPrice)\n // This is equal to buySpotPrice * (delta^n - 1) / (delta - 1)\n inputValue = buySpotPrice.mulWadUp((deltaPowN - FixedPointMathLib.WAD).divWadUp(delta - FixedPointMathLib.WAD));\n }\n}\n"
},
"lib/erc721a/contracts/IERC721A.sol": {
"content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v4.2.3\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\n/**\n * @dev Interface of ERC721A.\n */\ninterface IERC721A {\n /**\n * The caller must own the token or be an approved operator.\n */\n error ApprovalCallerNotOwnerNorApproved();\n\n /**\n * The token does not exist.\n */\n error ApprovalQueryForNonexistentToken();\n\n /**\n * Cannot query the balance for the zero address.\n */\n error BalanceQueryForZeroAddress();\n\n /**\n * Cannot mint to the zero address.\n */\n error MintToZeroAddress();\n\n /**\n * The quantity of tokens minted must be more than zero.\n */\n error MintZeroQuantity();\n\n /**\n * The token does not exist.\n */\n error OwnerQueryForNonexistentToken();\n\n /**\n * The caller must own the token or be an approved operator.\n */\n error TransferCallerNotOwnerNorApproved();\n\n /**\n * The token must be owned by `from`.\n */\n error TransferFromIncorrectOwner();\n\n /**\n * Cannot safely transfer to a contract that does not implement the\n * ERC721Receiver interface.\n */\n error TransferToNonERC721ReceiverImplementer();\n\n /**\n * Cannot transfer to the zero address.\n */\n error TransferToZeroAddress();\n\n /**\n * The token does not exist.\n */\n error URIQueryForNonexistentToken();\n\n /**\n * The `quantity` minted with ERC2309 exceeds the safety limit.\n */\n error MintERC2309QuantityExceedsLimit();\n\n /**\n * The `extraData` cannot be set on an unintialized ownership slot.\n */\n error OwnershipNotInitializedForExtraData();\n\n // =============================================================\n // STRUCTS\n // =============================================================\n\n struct TokenOwnership {\n // The address of the owner.\n address addr;\n // Stores the start time of ownership with minimal overhead for tokenomics.\n uint64 startTimestamp;\n // Whether the token has been burned.\n bool burned;\n // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.\n uint24 extraData;\n }\n\n // =============================================================\n // TOKEN COUNTERS\n // =============================================================\n\n /**\n * @dev Returns the total number of tokens in existence.\n * Burned tokens will reduce the count.\n * To get the total number of tokens minted, please see {_totalMinted}.\n */\n function totalSupply() external view returns (uint256);\n\n // =============================================================\n // IERC165\n // =============================================================\n\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n\n // =============================================================\n // IERC721\n // =============================================================\n\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables\n * (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in `owner`'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`,\n * checking first that contract recipients are aware of the ERC721 protocol\n * to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move\n * this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external payable;\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external payable;\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom}\n * whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external payable;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external payable;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n // =============================================================\n // IERC721Metadata\n // =============================================================\n\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n // =============================================================\n // IERC2309\n // =============================================================\n\n /**\n * @dev Emitted when tokens in `fromTokenId` to `toTokenId`\n * (inclusive) is transferred from `from` to `to`, as defined in the\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.\n *\n * See {_mintERC2309} for more details.\n */\n event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);\n}\n"
},
"lib/ethier/contracts/utils/OwnerPausable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/security/Pausable.sol\";\n\n/// @notice A Pausable contract that can only be toggled by the Owner.\ncontract OwnerPausable is Ownable, Pausable {\n /// @notice Pauses the contract.\n function pause() public onlyOwner {\n Pausable._pause();\n }\n\n /// @notice Unpauses the contract.\n function unpause() public onlyOwner {\n Pausable._unpause();\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/token/common/ERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/common/ERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/IERC2981.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.\n *\n * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for\n * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.\n *\n * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the\n * fee is specified in basis points by default.\n *\n * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See\n * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to\n * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.\n *\n * _Available since v4.5._\n */\nabstract contract ERC2981 is IERC2981, ERC165 {\n struct RoyaltyInfo {\n address receiver;\n uint96 royaltyFraction;\n }\n\n RoyaltyInfo private _defaultRoyaltyInfo;\n mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;\n\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) {\n return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /**\n * @inheritdoc IERC2981\n */\n function royaltyInfo(uint256 _tokenId, uint256 _salePrice)\n external\n view\n virtual\n override\n returns (address, uint256)\n {\n RoyaltyInfo memory royalty = _tokenRoyaltyInfo[_tokenId];\n\n if (royalty.receiver == address(0)) {\n royalty = _defaultRoyaltyInfo;\n }\n\n uint256 royaltyAmount = (_salePrice * royalty.royaltyFraction) / _feeDenominator();\n\n return (royalty.receiver, royaltyAmount);\n }\n\n /**\n * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a\n * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an\n * override.\n */\n function _feeDenominator() internal pure virtual returns (uint96) {\n return 10000;\n }\n\n /**\n * @dev Sets the royalty information that all ids in this contract will default to.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator.\n */\n function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {\n require(feeNumerator <= _feeDenominator(), \"ERC2981: royalty fee will exceed salePrice\");\n require(receiver != address(0), \"ERC2981: invalid receiver\");\n\n _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);\n }\n\n /**\n * @dev Removes default royalty information.\n */\n function _deleteDefaultRoyalty() internal virtual {\n delete _defaultRoyaltyInfo;\n }\n\n /**\n * @dev Sets the royalty information for a specific token id, overriding the global default.\n *\n * Requirements:\n *\n * - `tokenId` must be already minted.\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator.\n */\n function _setTokenRoyalty(\n uint256 tokenId,\n address receiver,\n uint96 feeNumerator\n ) internal virtual {\n require(feeNumerator <= _feeDenominator(), \"ERC2981: royalty fee will exceed salePrice\");\n require(receiver != address(0), \"ERC2981: Invalid parameters\");\n\n _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);\n }\n\n /**\n * @dev Resets royalty information for the token id back to the global default.\n */\n function _resetTokenRoyalty(uint256 tokenId) internal virtual {\n delete _tokenRoyaltyInfo[tokenId];\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n _;\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"lib/ethier/contracts/erc721/ERC721Redeemer.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier)\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/interfaces/IERC721.sol\";\nimport \"@openzeppelin/contracts/utils/Strings.sol\";\nimport \"@openzeppelin/contracts/utils/structs/BitMaps.sol\";\n\n/**\n@notice Allows holders of ERC721 tokens to redeem rights to some claim; for\nexample, the right to mint a token of some other collection.\n*/\nlibrary ERC721Redeemer {\n using BitMaps for BitMaps.BitMap;\n using Strings for uint256;\n\n /**\n @notice Storage value to track already-claimed redemptions for a specific\n token collection.\n */\n struct Claims {\n /**\n @dev This field MUST NOT be considered part of the public API. Instead,\n prefer `using ERC721Redeemer for ERC721Redeemer.Claims` and utilise the\n provided functions.\n */\n mapping(uint256 => uint256) _total;\n }\n\n /**\n @notice Storage value to track already-claimed redemptions for a specific\n token collection, given that there is only a single claim allowed per\n tokenId.\n */\n struct SingleClaims {\n /**\n @dev This field MUST NOT be considered part of the public API. Instead,\n prefer `using ERC721Redeemer for ERC721Redeemer.SingleClaims` and\n utilise the provided functions.\n */\n BitMaps.BitMap _claimed;\n }\n\n /**\n @notice Emitted when a token's claim is redeemed.\n */\n event Redemption(\n IERC721 indexed token,\n address indexed redeemer,\n uint256 tokenId,\n uint256 n\n );\n\n /**\n @notice Checks that the redeemer is allowed to redeem the claims for the\n tokenIds by being either the owner or approved address for all tokenIds, and\n updates the Claims to reflect this.\n @dev For more efficient gas usage, recurring values in tokenIds SHOULD be\n adjacent to one another as this will batch expensive operations. The\n simplest way to achieve this is by sorting tokenIds.\n @param tokenIds The token IDs for which the claims are being redeemed. If\n maxAllowance > 1 then identical tokenIds can be passed more than once; see\n dev comments.\n @return The number of redeemed claims; either 0 or tokenIds.length;\n */\n function redeem(\n Claims storage claims,\n uint256 maxAllowance,\n address redeemer,\n IERC721 token,\n uint256[] calldata tokenIds\n ) internal returns (uint256) {\n if (maxAllowance == 0 || tokenIds.length == 0) {\n return 0;\n }\n\n // See comment for `endSameId`.\n bool multi = maxAllowance > 1;\n\n for (\n uint256 i = 0;\n i < tokenIds.length; /* note increment at end */\n\n ) {\n uint256 tokenId = tokenIds[i];\n requireOwnerOrApproved(token, tokenId, redeemer);\n\n uint256 n = 1;\n if (multi) {\n // If allowed > 1 we can save on expensive operations like\n // checking ownership / remaining allowance by batching equal\n // tokenIds. The algorithm assumes that equal IDs are adjacent\n // in the array.\n uint256 endSameId;\n for (\n endSameId = i + 1;\n endSameId < tokenIds.length &&\n tokenIds[endSameId] == tokenId;\n endSameId++\n ) {} // solhint-disable-line no-empty-blocks\n n = endSameId - i;\n }\n\n claims._total[tokenId] += n;\n if (claims._total[tokenId] > maxAllowance) {\n revertWithTokenId(\n \"ERC721Redeemer: over allowance for\",\n tokenId\n );\n }\n i += n;\n\n emit Redemption(token, redeemer, tokenId, n);\n }\n\n return tokenIds.length;\n }\n\n /**\n @notice Checks that the redeemer is allowed to redeem the single claim for\n each of the tokenIds by being either the owner or approved address for all\n tokenIds, and updates the SingleClaims to reflect this.\n @param tokenIds The token IDs for which the claims are being redeemed. Only\n a single claim can be made against a tokenId.\n @return The number of redeemed claims; either 0 or tokenIds.length;\n */\n function redeem(\n SingleClaims storage claims,\n address redeemer,\n IERC721 token,\n uint256[] calldata tokenIds\n ) internal returns (uint256) {\n if (tokenIds.length == 0) {\n return 0;\n }\n\n for (uint256 i = 0; i < tokenIds.length; i++) {\n uint256 tokenId = tokenIds[i];\n requireOwnerOrApproved(token, tokenId, redeemer);\n\n if (claims._claimed.get(tokenId)) {\n revertWithTokenId(\n \"ERC721Redeemer: over allowance for\",\n tokenId\n );\n }\n\n claims._claimed.set(tokenId);\n emit Redemption(token, redeemer, tokenId, 1);\n }\n return tokenIds.length;\n }\n\n /**\n @dev Reverts if neither the owner nor approved for the tokenId.\n */\n function requireOwnerOrApproved(\n IERC721 token,\n uint256 tokenId,\n address redeemer\n ) private view {\n if (\n token.ownerOf(tokenId) != redeemer &&\n token.getApproved(tokenId) != redeemer\n ) {\n revertWithTokenId(\n \"ERC721Redeemer: not approved nor owner of\",\n tokenId\n );\n }\n }\n\n /**\n @notice Reverts with the concatenation of revertMsg and tokenId.toString().\n @dev Used to save gas by constructing the revert message only as required,\n instead of passing it to require().\n */\n function revertWithTokenId(string memory revertMsg, uint256 tokenId)\n private\n pure\n {\n revert(string(abi.encodePacked(revertMsg, \" \", tokenId.toString())));\n }\n\n /**\n @notice Returns the number of claimed redemptions for the token.\n */\n function claimed(Claims storage claims, uint256 tokenId)\n internal\n view\n returns (uint256)\n {\n return claims._total[tokenId];\n }\n\n /**\n @notice Returns whether the token has had a claim made against it.\n */\n function claimed(SingleClaims storage claims, uint256 tokenId)\n internal\n view\n returns (bool)\n {\n return claims._claimed.get(tokenId);\n }\n}\n"
},
"lib/solmate/src/utils/MerkleProofLib.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/// @notice Gas optimized merkle proof verification library.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/MerkleProofLib.sol)\n/// @author Modified from Solady (https://github.com/Vectorized/solady/blob/main/src/utils/MerkleProofLib.sol)\nlibrary MerkleProofLib {\n function verify(\n bytes32[] calldata proof,\n bytes32 root,\n bytes32 leaf\n ) internal pure returns (bool isValid) {\n /// @solidity memory-safe-assembly\n assembly {\n if proof.length {\n // Left shifting by 5 is like multiplying by 32.\n let end := add(proof.offset, shl(5, proof.length))\n\n // Initialize offset to the offset of the proof in calldata.\n let offset := proof.offset\n\n // Iterate over proof elements to compute root hash.\n // prettier-ignore\n for {} 1 {} {\n // Slot where the leaf should be put in scratch space. If\n // leaf > calldataload(offset): slot 32, otherwise: slot 0.\n let leafSlot := shl(5, gt(leaf, calldataload(offset)))\n\n // Store elements to hash contiguously in scratch space.\n // The xor puts calldataload(offset) in whichever slot leaf\n // is not occupying, so 0 if leafSlot is 32, and 32 otherwise.\n mstore(leafSlot, leaf)\n mstore(xor(leafSlot, 32), calldataload(offset))\n\n // Reuse leaf to store the hash to reduce stack operations.\n leaf := keccak256(0, 64) // Hash both slots of scratch space.\n\n offset := add(offset, 32) // Shift 1 word per cycle.\n\n // prettier-ignore\n if iszero(lt(offset, end)) { break }\n }\n }\n\n isValid := eq(leaf, root) // The proof is valid if the roots match.\n }\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/Strings.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n // Inspired by OraclizeAPI's implementation - MIT licence\n // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n if (value == 0) {\n return \"0\";\n }\n uint256 temp = value;\n uint256 digits;\n while (temp != 0) {\n digits++;\n temp /= 10;\n }\n bytes memory buffer = new bytes(digits);\n while (value != 0) {\n digits -= 1;\n buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n value /= 10;\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n if (value == 0) {\n return \"0x00\";\n }\n uint256 temp = value;\n uint256 length = 0;\n while (temp != 0) {\n length++;\n temp >>= 8;\n }\n return toHexString(value, length);\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _HEX_SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n}\n"
},
"src/utils/Bitmap.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0;\n\nlibrary Bitmaps {\n struct Bitmap {\n // This variable should never be directly accessed by users of the library: interactions must be restricted to\n // the library's function.\n // bitmaps length should be maxSupply / 256.\n uint256[] _bitmaps;\n }\n\n function makeBitmap(uint256 _size) internal pure returns (Bitmap memory) {\n Bitmap memory bitmap;\n bitmap._bitmaps = new uint256[](_size / 256 + 1);\n return bitmap;\n }\n\n using Bits for uint256;\n\n function set(Bitmap storage _bitmap, uint256 _index, bool _value) internal {\n uint256 _bitmapIndex = _index / 256;\n uint256 _bitIndex = _index % 256;\n if (_value) {\n _bitmap._bitmaps[_bitmapIndex] = _bitmap._bitmaps[_bitmapIndex].setBit(_bitIndex);\n } else {\n _bitmap._bitmaps[_bitmapIndex] = _bitmap._bitmaps[_bitmapIndex].clearBit(_bitIndex);\n }\n }\n\n function get(Bitmap storage _bitmap, uint256 _index) internal view returns (bool) {\n uint256 _bitmapIndex = _index / 256;\n uint256 _bitIndex = _index % 256;\n return _bitmap._bitmaps[_bitmapIndex].bitSet(_bitIndex);\n }\n}\n\nlibrary Bits {\n uint256 internal constant ONE = uint256(1);\n\n // Sets the bit at the given 'index' in 'self' to '1'.\n // Returns the modified value.\n function setBit(uint256 self, uint256 index) internal pure returns (uint256) {\n return self | (ONE << index);\n }\n\n // Sets the bit at the given 'index' in 'self' to '0'.\n // Returns the modified value.\n function clearBit(uint256 self, uint256 index) internal pure returns (uint256) {\n return self & ~(ONE << index);\n }\n\n // Sets the bit at the given 'index' in 'self' to:\n // '1' - if the bit is '0'\n // '0' - if the bit is '1'\n // Returns the modified value.\n function toggleBit(uint256 self, uint256 index) internal pure returns (uint256) {\n return self ^ (ONE << index);\n }\n\n // Get the value of the bit at the given 'index' in 'self'.\n function bit(uint256 self, uint256 index) internal pure returns (uint256) {\n return uint256((self >> index) & 1);\n }\n\n // Check if the bit at the given 'index' in 'self' is set.\n // Returns:\n // 'true' - if the value of the bit is '1'\n // 'false' - if the value of the bit is '0'\n function bitSet(uint256 self, uint256 index) internal pure returns (bool) {\n return (self >> index) & 1 == 1;\n }\n\n // Checks if the bit at the given 'index' in 'self' is equal to the corresponding\n // bit in 'other'.\n // Returns:\n // 'true' - if both bits are '0' or both bits are '1'\n // 'false' - otherwise\n function bitEqual(uint256 self, uint256 other, uint256 index) internal pure returns (bool) {\n return ((self ^ other) >> index) & 1 == 0;\n }\n\n // Get the bitwise NOT of the bit at the given 'index' in 'self'.\n function bitNot(uint256 self, uint256 index) internal pure returns (uint256) {\n return uint256(1 - ((self >> index) & 1));\n }\n\n // Computes the bitwise AND of the bit at the given 'index' in 'self', and the\n // corresponding bit in 'other', and returns the value.\n function bitAnd(uint256 self, uint256 other, uint256 index) internal pure returns (uint256) {\n return uint256(((self & other) >> index) & 1);\n }\n\n // Computes the bitwise OR of the bit at the given 'index' in 'self', and the\n // corresponding bit in 'other', and returns the value.\n function bitOr(uint256 self, uint256 other, uint256 index) internal pure returns (uint256) {\n return uint256(((self | other) >> index) & 1);\n }\n\n // Computes the bitwise XOR of the bit at the given 'index' in 'self', and the\n // corresponding bit in 'other', and returns the value.\n function bitXor(uint256 self, uint256 other, uint256 index) internal pure returns (uint256) {\n return uint256(((self ^ other) >> index) & 1);\n }\n\n // Computes the index of the highest bit set in 'self'.\n // Returns the highest bit set as an 'uint256'.\n // Requires that 'self != 0'.\n function highestBitSet(uint256 self) internal pure returns (uint256 highest) {\n require(self != 0);\n uint256 val = self;\n for (uint256 i = 128; i >= 1; i >>= 1) {\n if (val & (((ONE << i) - 1) << i) != 0) {\n highest += i;\n val >>= i;\n }\n }\n }\n\n // Computes the index of the lowest bit set in 'self'.\n // Returns the lowest bit set as an 'uint256'.\n // Requires that 'self != 0'.\n function lowestBitSet(uint256 self) internal pure returns (uint256 lowest) {\n require(self != 0);\n uint256 val = self;\n for (uint256 i = 128; i >= 1; i >>= 1) {\n if (val & ((ONE << i) - 1) == 0) {\n lowest += i;\n val >>= i;\n }\n }\n }\n}\n"
},
"lib/solmate/src/tokens/ERC20.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC20.sol)\n/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)\n/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.\nabstract contract ERC20 {\n /*//////////////////////////////////////////////////////////////\n EVENTS\n //////////////////////////////////////////////////////////////*/\n\n event Transfer(address indexed from, address indexed to, uint256 amount);\n\n event Approval(address indexed owner, address indexed spender, uint256 amount);\n\n /*//////////////////////////////////////////////////////////////\n METADATA STORAGE\n //////////////////////////////////////////////////////////////*/\n\n string public name;\n\n string public symbol;\n\n uint8 public immutable decimals;\n\n /*//////////////////////////////////////////////////////////////\n ERC20 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 public totalSupply;\n\n mapping(address => uint256) public balanceOf;\n\n mapping(address => mapping(address => uint256)) public allowance;\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 STORAGE\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal immutable INITIAL_CHAIN_ID;\n\n bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;\n\n mapping(address => uint256) public nonces;\n\n /*//////////////////////////////////////////////////////////////\n CONSTRUCTOR\n //////////////////////////////////////////////////////////////*/\n\n constructor(\n string memory _name,\n string memory _symbol,\n uint8 _decimals\n ) {\n name = _name;\n symbol = _symbol;\n decimals = _decimals;\n\n INITIAL_CHAIN_ID = block.chainid;\n INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function approve(address spender, uint256 amount) public virtual returns (bool) {\n allowance[msg.sender][spender] = amount;\n\n emit Approval(msg.sender, spender, amount);\n\n return true;\n }\n\n function transfer(address to, uint256 amount) public virtual returns (bool) {\n balanceOf[msg.sender] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(msg.sender, to, amount);\n\n return true;\n }\n\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) public virtual returns (bool) {\n uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.\n\n if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;\n\n balanceOf[from] -= amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(from, to, amount);\n\n return true;\n }\n\n /*//////////////////////////////////////////////////////////////\n EIP-2612 LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) public virtual {\n require(deadline >= block.timestamp, \"PERMIT_DEADLINE_EXPIRED\");\n\n // Unchecked because the only math done is incrementing\n // the owner's nonce which cannot realistically overflow.\n unchecked {\n address recoveredAddress = ecrecover(\n keccak256(\n abi.encodePacked(\n \"\\x19\\x01\",\n DOMAIN_SEPARATOR(),\n keccak256(\n abi.encode(\n keccak256(\n \"Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)\"\n ),\n owner,\n spender,\n value,\n nonces[owner]++,\n deadline\n )\n )\n )\n ),\n v,\n r,\n s\n );\n\n require(recoveredAddress != address(0) && recoveredAddress == owner, \"INVALID_SIGNER\");\n\n allowance[recoveredAddress][spender] = value;\n }\n\n emit Approval(owner, spender, value);\n }\n\n function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {\n return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();\n }\n\n function computeDomainSeparator() internal view virtual returns (bytes32) {\n return\n keccak256(\n abi.encode(\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\"),\n keccak256(bytes(name)),\n keccak256(\"1\"),\n block.chainid,\n address(this)\n )\n );\n }\n\n /*//////////////////////////////////////////////////////////////\n INTERNAL MINT/BURN LOGIC\n //////////////////////////////////////////////////////////////*/\n\n function _mint(address to, uint256 amount) internal virtual {\n totalSupply += amount;\n\n // Cannot overflow because the sum of all user\n // balances can't exceed the max uint256 value.\n unchecked {\n balanceOf[to] += amount;\n }\n\n emit Transfer(address(0), to, amount);\n }\n\n function _burn(address from, uint256 amount) internal virtual {\n balanceOf[from] -= amount;\n\n // Cannot underflow because a user's balance\n // will never be larger than the total supply.\n unchecked {\n totalSupply -= amount;\n }\n\n emit Transfer(from, address(0), amount);\n }\n}\n"
},
"lib/solmate/src/utils/SafeTransferLib.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\nimport {ERC20} from \"../tokens/ERC20.sol\";\n\n/// @notice Safe ETH and ERC20 transfer library that gracefully handles missing return values.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SafeTransferLib.sol)\n/// @dev Use with caution! Some functions in this library knowingly create dirty bits at the destination of the free memory pointer.\n/// @dev Note that none of the functions in this library check that a token has code at all! That responsibility is delegated to the caller.\nlibrary SafeTransferLib {\n /*//////////////////////////////////////////////////////////////\n ETH OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferETH(address to, uint256 amount) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Transfer the ETH and store if it succeeded or not.\n success := call(gas(), to, amount, 0, 0, 0, 0)\n }\n\n require(success, \"ETH_TRANSFER_FAILED\");\n }\n\n /*//////////////////////////////////////////////////////////////\n ERC20 OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function safeTransferFrom(\n ERC20 token,\n address from,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x23b872dd00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), from) // Append the \"from\" argument.\n mstore(add(freeMemoryPointer, 36), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 68), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 100, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FROM_FAILED\");\n }\n\n function safeTransfer(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"TRANSFER_FAILED\");\n }\n\n function safeApprove(\n ERC20 token,\n address to,\n uint256 amount\n ) internal {\n bool success;\n\n /// @solidity memory-safe-assembly\n assembly {\n // Get a pointer to some free memory.\n let freeMemoryPointer := mload(0x40)\n\n // Write the abi-encoded calldata into memory, beginning with the function selector.\n mstore(freeMemoryPointer, 0x095ea7b300000000000000000000000000000000000000000000000000000000)\n mstore(add(freeMemoryPointer, 4), to) // Append the \"to\" argument.\n mstore(add(freeMemoryPointer, 36), amount) // Append the \"amount\" argument.\n\n success := and(\n // Set success to whether the call reverted, if not we check it either\n // returned exactly 1 (can't just be non-zero data), or had no return data.\n or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),\n // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.\n // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.\n // Counterintuitively, this call must be positioned second to the or() call in the\n // surrounding and() call or else returndatasize() will be zero during the computation.\n call(gas(), token, 0, freeMemoryPointer, 68, 0, 32)\n )\n }\n\n require(success, \"APPROVE_FAILED\");\n }\n}\n"
},
"lib/solmate/src/utils/FixedPointMathLib.sol": {
"content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity >=0.8.0;\n\n/// @notice Arithmetic library with operations for fixed-point numbers.\n/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/FixedPointMathLib.sol)\n/// @author Inspired by USM (https://github.com/usmfum/USM/blob/master/contracts/WadMath.sol)\nlibrary FixedPointMathLib {\n /*//////////////////////////////////////////////////////////////\n SIMPLIFIED FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n uint256 internal constant MAX_UINT256 = 2**256 - 1;\n\n uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\n\n function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\n }\n\n function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\n }\n\n function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\n }\n\n function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\n }\n\n /*//////////////////////////////////////////////////////////////\n LOW LEVEL FIXED POINT OPERATIONS\n //////////////////////////////////////////////////////////////*/\n\n function mulDivDown(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n /// @solidity memory-safe-assembly\n assembly {\n // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))\n if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {\n revert(0, 0)\n }\n\n // Divide x * y by the denominator.\n z := div(mul(x, y), denominator)\n }\n }\n\n function mulDivUp(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) internal pure returns (uint256 z) {\n /// @solidity memory-safe-assembly\n assembly {\n // Equivalent to require(denominator != 0 && (y == 0 || x <= type(uint256).max / y))\n if iszero(mul(denominator, iszero(mul(y, gt(x, div(MAX_UINT256, y)))))) {\n revert(0, 0)\n }\n\n // If x * y modulo the denominator is strictly greater than 0,\n // 1 is added to round up the division of x * y by the denominator.\n z := add(gt(mod(mul(x, y), denominator), 0), div(mul(x, y), denominator))\n }\n }\n\n function rpow(\n uint256 x,\n uint256 n,\n uint256 scalar\n ) internal pure returns (uint256 z) {\n /// @solidity memory-safe-assembly\n assembly {\n switch x\n case 0 {\n switch n\n case 0 {\n // 0 ** 0 = 1\n z := scalar\n }\n default {\n // 0 ** n = 0\n z := 0\n }\n }\n default {\n switch mod(n, 2)\n case 0 {\n // If n is even, store scalar in z for now.\n z := scalar\n }\n default {\n // If n is odd, store x in z for now.\n z := x\n }\n\n // Shifting right by 1 is like dividing by 2.\n let half := shr(1, scalar)\n\n for {\n // Shift n right by 1 before looping to halve it.\n n := shr(1, n)\n } n {\n // Shift n right by 1 each iteration to halve it.\n n := shr(1, n)\n } {\n // Revert immediately if x ** 2 would overflow.\n // Equivalent to iszero(eq(div(xx, x), x)) here.\n if shr(128, x) {\n revert(0, 0)\n }\n\n // Store x squared.\n let xx := mul(x, x)\n\n // Round to the nearest number.\n let xxRound := add(xx, half)\n\n // Revert if xx + half overflowed.\n if lt(xxRound, xx) {\n revert(0, 0)\n }\n\n // Set x to scaled xxRound.\n x := div(xxRound, scalar)\n\n // If n is even:\n if mod(n, 2) {\n // Compute z * x.\n let zx := mul(z, x)\n\n // If z * x overflowed:\n if iszero(eq(div(zx, x), z)) {\n // Revert if x is non-zero.\n if iszero(iszero(x)) {\n revert(0, 0)\n }\n }\n\n // Round to the nearest number.\n let zxRound := add(zx, half)\n\n // Revert if zx + half overflowed.\n if lt(zxRound, zx) {\n revert(0, 0)\n }\n\n // Return properly scaled zxRound.\n z := div(zxRound, scalar)\n }\n }\n }\n }\n }\n\n /*//////////////////////////////////////////////////////////////\n GENERAL NUMBER UTILITIES\n //////////////////////////////////////////////////////////////*/\n\n function sqrt(uint256 x) internal pure returns (uint256 z) {\n /// @solidity memory-safe-assembly\n assembly {\n let y := x // We start y at x, which will help us make our initial estimate.\n\n z := 181 // The \"correct\" value is 1, but this saves a multiplication later.\n\n // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\n // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\n\n // We check y >= 2^(k + 8) but shift right by k bits\n // each branch to ensure that if x >= 256, then y >= 256.\n if iszero(lt(y, 0x10000000000000000000000000000000000)) {\n y := shr(128, y)\n z := shl(64, z)\n }\n if iszero(lt(y, 0x1000000000000000000)) {\n y := shr(64, y)\n z := shl(32, z)\n }\n if iszero(lt(y, 0x10000000000)) {\n y := shr(32, y)\n z := shl(16, z)\n }\n if iszero(lt(y, 0x1000000)) {\n y := shr(16, y)\n z := shl(8, z)\n }\n\n // Goal was to get z*z*y within a small factor of x. More iterations could\n // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\n // We ensured y >= 256 so that the relative difference between y and y+1 is small.\n // That's not possible if x < 256 but we can just verify those cases exhaustively.\n\n // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\n // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\n // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\n\n // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\n // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\n\n // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\n // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\n\n // There is no overflow risk here since y < 2^136 after the first branch above.\n z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\n\n // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n z := shr(1, add(z, div(x, z)))\n\n // If x+1 is a perfect square, the Babylonian method cycles between\n // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\n // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\n // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\n // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\n z := sub(z, lt(div(x, z), z))\n }\n }\n\n function unsafeMod(uint256 x, uint256 y) internal pure returns (uint256 z) {\n /// @solidity memory-safe-assembly\n assembly {\n // Mod x by y. Note this will return\n // 0 instead of reverting if y is zero.\n z := mod(x, y)\n }\n }\n\n function unsafeDiv(uint256 x, uint256 y) internal pure returns (uint256 r) {\n /// @solidity memory-safe-assembly\n assembly {\n // Divide x by y. Note this will return\n // 0 instead of reverting if y is zero.\n r := div(x, y)\n }\n }\n\n function unsafeDivUp(uint256 x, uint256 y) internal pure returns (uint256 z) {\n /// @solidity memory-safe-assembly\n assembly {\n // Add 1 to x * y if x % y > 0. Note this will\n // return 0 instead of reverting if y is zero.\n z := add(gt(mod(x, y), 0), div(x, y))\n }\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/security/Pausable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n /**\n * @dev Emitted when the pause is triggered by `account`.\n */\n event Paused(address account);\n\n /**\n * @dev Emitted when the pause is lifted by `account`.\n */\n event Unpaused(address account);\n\n bool private _paused;\n\n /**\n * @dev Initializes the contract in unpaused state.\n */\n constructor() {\n _paused = false;\n }\n\n /**\n * @dev Returns true if the contract is paused, and false otherwise.\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is not paused.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n modifier whenNotPaused() {\n require(!paused(), \"Pausable: paused\");\n _;\n }\n\n /**\n * @dev Modifier to make a function callable only when the contract is paused.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n modifier whenPaused() {\n require(paused(), \"Pausable: not paused\");\n _;\n }\n\n /**\n * @dev Triggers stopped state.\n *\n * Requirements:\n *\n * - The contract must not be paused.\n */\n function _pause() internal virtual whenNotPaused {\n _paused = true;\n emit Paused(_msgSender());\n }\n\n /**\n * @dev Returns to normal state.\n *\n * Requirements:\n *\n * - The contract must be paused.\n */\n function _unpause() internal virtual whenPaused {\n _paused = false;\n emit Unpaused(_msgSender());\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/interfaces/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC721/IERC721.sol\";\n"
},
"lib/openzeppelin-contracts/contracts/utils/structs/BitMaps.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/BitMaps.sol)\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing uint256 to bool mapping in a compact and efficient way, providing the keys are sequential.\n * Largelly inspired by Uniswap's https://github.com/Uniswap/merkle-distributor/blob/master/contracts/MerkleDistributor.sol[merkle-distributor].\n */\nlibrary BitMaps {\n struct BitMap {\n mapping(uint256 => uint256) _data;\n }\n\n /**\n * @dev Returns whether the bit at `index` is set.\n */\n function get(BitMap storage bitmap, uint256 index) internal view returns (bool) {\n uint256 bucket = index >> 8;\n uint256 mask = 1 << (index & 0xff);\n return bitmap._data[bucket] & mask != 0;\n }\n\n /**\n * @dev Sets the bit at `index` to the boolean `value`.\n */\n function setTo(\n BitMap storage bitmap,\n uint256 index,\n bool value\n ) internal {\n if (value) {\n set(bitmap, index);\n } else {\n unset(bitmap, index);\n }\n }\n\n /**\n * @dev Sets the bit at `index`.\n */\n function set(BitMap storage bitmap, uint256 index) internal {\n uint256 bucket = index >> 8;\n uint256 mask = 1 << (index & 0xff);\n bitmap._data[bucket] |= mask;\n }\n\n /**\n * @dev Unsets the bit at `index`.\n */\n function unset(BitMap storage bitmap, uint256 index) internal {\n uint256 bucket = index >> 8;\n uint256 mask = 1 << (index & 0xff);\n bitmap._data[bucket] &= ~mask;\n }\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
}
},
"settings": {
"remappings": [
"#@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@divergencetech/ethier/=lib/ethier/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"ds-test/=lib/ds-test/src/",
"erc721a/=lib/erc721a/",
"ethier/=lib/ethier/contracts/",
"forge-std/=lib/ethier/lib/forge-std/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"prb-math/=lib/prb-math/contracts/",
"solmate/=lib/solmate/src/",
"synthetix/=lib/synthetix/contracts/",
"src/=src/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
}