Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 15498648 | 669 days ago | IN | Create: SpellsToken | 0 ETH | 0.14399554 |
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Name:
SpellsToken
Compiler Version
v0.8.15+commit.e14f2714
Optimization Enabled:
Yes with 300 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; import { ERC165Storage } from "@solidstate/contracts/introspection/ERC165Storage.sol"; import { LibDiamond } from "../libraries/LibDiamond.sol"; import { ISpellsCoin } from "../../coin/ISpellsCoin.sol"; import { ECDSA } from "../../helpers/ECDSA.sol"; import { SpellsCastStorage } from "./SpellsCastStorage.sol"; import { SpellsStorage } from "./SpellsStorage.sol"; import { ERC721Checkpointable } from "./ERC721Checkpointable/ERC721Checkpointable.sol"; import {ERC721AQueryableUpgradeable} from "./ERC721A/extensions/ERC721AQueryableUpgradeable.sol"; import { CallProtection } from "./shared/Access/CallProtection.sol"; import { LinearVRGDA } from "./VRGDA/LinearVRGDA.sol"; import { toDaysWadUnsafe } from "./VRGDA/math/SignedWadMath.sol"; import { ReentryProtection } from "./shared/reentry/ReentryProtection.sol"; import { ERC721Checkpointable } from "./ERC721Checkpointable/ERC721Checkpointable.sol"; contract SpellsToken is ERC721AQueryableUpgradeable, ReentryProtection, CallProtection, LinearVRGDA { using ERC165Storage for ERC165Storage.Layout; using SpellsCastStorage for SpellsCastStorage.Storage; using SpellsStorage for SpellsStorage.Storage; /// MINTING error MintClosed(); error EternalMintNotOpen(); error MintMaxReached(); error MintInsufficientPayment(uint256 price); error MintQuantityExceedsLimit(); error MintQuantityExceedsAllowance(); error ZeroAmount(); error ConjureMaxReached(); error MintNotAuthorized(); // PAYMENTS error PaymentTransferFailed(); // ADMIN error SenderNotSpellGate(); uint256 privateStartTime; uint256 publicStartTime; function initializeSpellsTokenFacet( string memory name_, string memory symbol_, int256 _targetPrice, int256 _priceDecayPercent, int256 _perTimeUnit, uint256 _seedPrice, uint256 _seedSupply, address _spellGate, address _godspell ) external initializerERC721A protectedCall { __ERC721A_init(name_, symbol_); __linearVRGDA_init(_targetPrice, _priceDecayPercent, _perTimeUnit); ERC165Storage.layout().setSupportedInterface(0x80ac58cd, true); // ERC165 interface ID for ERC721. ERC165Storage.layout().setSupportedInterface(0x5b5e139f, true); // ERC165 interface ID for ERC721Metadata. SpellsStorage.getStorage().seedMintPrice = _seedPrice; SpellsStorage.getStorage().seedSupply = _seedSupply; SpellsStorage.getStorage().spellGate = _spellGate; SpellsStorage.getStorage().godspell = _godspell; } modifier onlySpellGate() { if(msg.sender != SpellsStorage.getStorage().spellGate) revert SenderNotSpellGate(); _; } function getPrice() external view returns (uint256) { return _price(totalSupply()+1); } function _price(uint256 tokenId) private view returns (uint256) { if(tokenId > SpellsStorage.getStorage().seedSupply){ return getVRGDAPrice( toDaysWadUnsafe(block.timestamp - SpellsStorage.getStorage().eternalStartTime), tokenId - 1 - SpellsStorage.getStorage().seedSupply); } return SpellsStorage.getStorage().seedMintPrice; } function getFaction(uint256 tokenId) external view returns (uint256) { return SpellsCastStorage.getStorage().factions[tokenId]; } function eternalMintActive() public view returns (bool) { return SpellsStorage.getStorage().eternalStartTime > 0; } function gateMint( address to, uint256 gate ) external payable onlySpellGate noReentry { SpellsStorage.Storage storage store = SpellsStorage.getStorage(); if(store.saleState == SpellsStorage.SaleState.CLOSED) revert MintClosed(); if(msg.sender != address(store.spellGate)) revert SenderNotSpellGate(); // Set faction to gate SpellsCastStorage.getStorage().factions[totalSupply() + 1] = gate; /// @dev assign faction to tokenId before minting is safe because godspell /// tokens are issued after the tokens are minted to recipient. _conjure(to, 1); } /// @dev Sets random seed for the given tokenId. function _setSeed(address to, uint256 tokenId) internal { SpellsStorage.Storage storage store = SpellsStorage.getStorage(); store.seed = uint256(keccak256(abi.encodePacked(store.seed, to, tokenId, block.coinbase, block.timestamp))); store.tokenSeed[tokenId] = store.seed; } function tokenSeed(uint256 _tokenId) external view returns (uint256) { return SpellsStorage.tokenSeed(_tokenId); } function _mintTo( address to, uint256 amount ) private returns (uint256) { if(amount == 0) revert ZeroAmount(); SpellsStorage.Storage storage store = SpellsStorage.getStorage(); SpellsCastStorage.Storage storage spellsStorage = SpellsCastStorage .getStorage(); uint256 tokenId = totalSupply() + 1; if(store.eternalStartTime == 0 && tokenId + amount - 1 >= store.seedSupply) { store.eternalStartTime = block.timestamp; store.saleState = SpellsStorage.SaleState.ETERNAL; } uint256 nGodspell = 0; uint256 price = 0; for (uint256 i; i < amount; i++) { _setSeed(to, tokenId); spellsStorage.spellsCoin.mint( address(this), tokenId, SpellsStorage.initialSpellsCoinOf(tokenId) * spellsStorage.spellsCoinMultiplier ); price += _price(tokenId); if(tokenId % 10 == 0) { nGodspell++; } ++tokenId; } _safeMint(to, amount); /// Mint tokens to godspell in single batch after target mint batch. /// Theoretically allows recursion to catch all founder tokens, but actual /// per call amount is limited and prevents this. if(nGodspell > 0){ _mintTo(store.godspell, nGodspell); } return price; } /// @dev Mints tokens to recipient loading batch price dynamically based on VRGDA. function _conjure( address to, uint256 amount ) private { uint256 price = _mintTo(to, amount); if(msg.value < price) revert MintInsufficientPayment(price); if (price > 0) { bool sent = payable(LibDiamond.treasury()).send( price ); if(!sent) revert PaymentTransferFailed(); /// Refund the difference if (msg.value - price > 0) { payable(msg.sender).transfer(msg.value - price); } } } function conjure() external payable noReentry { if(SpellsStorage.getStorage().saleState < SpellsStorage.SaleState.OPEN) revert MintClosed(); _conjure(msg.sender, 1); } function conjure(uint256 amount) external payable noReentry { if(amount > 5) revert MintQuantityExceedsLimit(); if(SpellsStorage.getStorage().saleState < SpellsStorage.SaleState.OPEN) revert MintClosed(); _conjure(msg.sender, amount); } /// @dev contract owner is changed to SpellsDAO after seed completed. function conjure( uint256 _allowed, uint256 _amount, uint8 _v, bytes32 _r, bytes32 _s ) external payable noReentry { SpellsStorage.Storage storage store = SpellsStorage.getStorage(); if(store.saleState == SpellsStorage.SaleState.CLOSED) revert MintClosed(); if(!ECDSA.isValidAccessMessage( LibDiamond.diamondStorage().contractOwner, keccak256(abi.encodePacked(msg.sender, _allowed)), _v, _r, _s ) ) revert MintNotAuthorized(); uint256 used = store.mintCounts[msg.sender]; if(used >= _allowed || _allowed - used < _amount) revert MintQuantityExceedsAllowance(); store.mintCounts[msg.sender] += _amount; _conjure(msg.sender, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ import {IDiamondCut} from "../interfaces/IDiamondCut.sol"; library LibDiamond { bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct FacetAddressAndPosition { address facetAddress; uint96 functionSelectorPosition; // position in facetFunctionSelectors.functionSelectors array } struct FacetFunctionSelectors { bytes4[] functionSelectors; uint256 facetAddressPosition; // position of facetAddress in facetAddresses array } struct DiamondStorage { // maps function selector to the facet address and // the position of the selector in the facetFunctionSelectors.selectors array mapping(bytes4 => FacetAddressAndPosition) selectorToFacetAndPosition; // maps facet addresses to function selectors mapping(address => FacetFunctionSelectors) facetFunctionSelectors; // facet addresses address[] facetAddresses; // owner of the contract address contractOwner; // treasury address address treasury; } function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } } event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); event TreasuryTransferred( address indexed previousTreasury, address indexed newTreasury ); function setContractOwner(address _newOwner) internal { DiamondStorage storage ds = diamondStorage(); address previousOwner = ds.contractOwner; ds.contractOwner = _newOwner; emit OwnershipTransferred(previousOwner, _newOwner); } function contractOwner() internal view returns (address contractOwner_) { contractOwner_ = diamondStorage().contractOwner; } function setTreasury(address _treasury) internal { DiamondStorage storage ds = diamondStorage(); address previousTreasury = ds.treasury; ds.treasury = _treasury; emit TreasuryTransferred(previousTreasury, _treasury); } function treasury() internal view returns (address treasury_) { treasury_ = diamondStorage().treasury; if(treasury_ == address(0)) { treasury_ = contractOwner(); } } function enforceIsContractOwner() internal view { require( msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner" ); } event DiamondCut( IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata ); // Internal function version of diamondCut function diamondCut( IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata ) internal { for ( uint256 facetIndex; facetIndex < _diamondCut.length; facetIndex++ ) { IDiamondCut.FacetCutAction action = _diamondCut[facetIndex].action; if (action == IDiamondCut.FacetCutAction.Add) { addFunctions( _diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors ); } else if (action == IDiamondCut.FacetCutAction.Replace) { replaceFunctions( _diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors ); } else if (action == IDiamondCut.FacetCutAction.Remove) { removeFunctions( _diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].functionSelectors ); } else { revert("LibDiamondCut: Incorrect FacetCutAction"); } } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } function addFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { require( _functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut" ); DiamondStorage storage ds = diamondStorage(); require( _facetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)" ); uint96 selectorPosition = uint96( ds.facetFunctionSelectors[_facetAddress].functionSelectors.length ); // add new facet address if it does not exist if (selectorPosition == 0) { addFacet(ds, _facetAddress); } for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds .selectorToFacetAndPosition[selector] .facetAddress; require( oldFacetAddress == address(0), "LibDiamondCut: Can't add function that already exists" ); addFunction(ds, selector, selectorPosition, _facetAddress); selectorPosition++; } } function replaceFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { require( _functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut" ); DiamondStorage storage ds = diamondStorage(); require( _facetAddress != address(0), "LibDiamondCut: Add facet can't be address(0)" ); uint96 selectorPosition = uint96( ds.facetFunctionSelectors[_facetAddress].functionSelectors.length ); // add new facet address if it does not exist if (selectorPosition == 0) { addFacet(ds, _facetAddress); } for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds .selectorToFacetAndPosition[selector] .facetAddress; require( oldFacetAddress != _facetAddress, "LibDiamondCut: Can't replace function with same function" ); removeFunction(ds, oldFacetAddress, selector); addFunction(ds, selector, selectorPosition, _facetAddress); selectorPosition++; } } function removeFunctions( address _facetAddress, bytes4[] memory _functionSelectors ) internal { require( _functionSelectors.length > 0, "LibDiamondCut: No selectors in facet to cut" ); DiamondStorage storage ds = diamondStorage(); // if function does not exist then do nothing and return require( _facetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)" ); for ( uint256 selectorIndex; selectorIndex < _functionSelectors.length; selectorIndex++ ) { bytes4 selector = _functionSelectors[selectorIndex]; address oldFacetAddress = ds .selectorToFacetAndPosition[selector] .facetAddress; removeFunction(ds, oldFacetAddress, selector); } } function addFacet(DiamondStorage storage ds, address _facetAddress) internal { enforceHasContractCode( _facetAddress, "LibDiamondCut: New facet has no code" ); ds.facetFunctionSelectors[_facetAddress].facetAddressPosition = ds .facetAddresses .length; ds.facetAddresses.push(_facetAddress); } function addFunction( DiamondStorage storage ds, bytes4 _selector, uint96 _selectorPosition, address _facetAddress ) internal { ds .selectorToFacetAndPosition[_selector] .functionSelectorPosition = _selectorPosition; ds.facetFunctionSelectors[_facetAddress].functionSelectors.push( _selector ); ds.selectorToFacetAndPosition[_selector].facetAddress = _facetAddress; } function removeFunction( DiamondStorage storage ds, address _facetAddress, bytes4 _selector ) internal { require( _facetAddress != address(0), "LibDiamondCut: Can't remove function that doesn't exist" ); // an immutable function is a function defined directly in a diamond require( _facetAddress != address(this), "LibDiamondCut: Can't remove immutable function" ); // replace selector with last selector, then delete last selector uint256 selectorPosition = ds .selectorToFacetAndPosition[_selector] .functionSelectorPosition; uint256 lastSelectorPosition = ds .facetFunctionSelectors[_facetAddress] .functionSelectors .length - 1; // if not the same then replace _selector with lastSelector if (selectorPosition != lastSelectorPosition) { bytes4 lastSelector = ds .facetFunctionSelectors[_facetAddress] .functionSelectors[lastSelectorPosition]; ds.facetFunctionSelectors[_facetAddress].functionSelectors[ selectorPosition ] = lastSelector; ds .selectorToFacetAndPosition[lastSelector] .functionSelectorPosition = uint96(selectorPosition); } // delete the last selector ds.facetFunctionSelectors[_facetAddress].functionSelectors.pop(); delete ds.selectorToFacetAndPosition[_selector]; // if no more selectors for facet address then delete the facet address if (lastSelectorPosition == 0) { // replace facet address with last facet address and delete last facet address uint256 lastFacetAddressPosition = ds.facetAddresses.length - 1; uint256 facetAddressPosition = ds .facetFunctionSelectors[_facetAddress] .facetAddressPosition; if (facetAddressPosition != lastFacetAddressPosition) { address lastFacetAddress = ds.facetAddresses[ lastFacetAddressPosition ]; ds.facetAddresses[facetAddressPosition] = lastFacetAddress; ds .facetFunctionSelectors[lastFacetAddress] .facetAddressPosition = facetAddressPosition; } ds.facetAddresses.pop(); delete ds .facetFunctionSelectors[_facetAddress] .facetAddressPosition; } } function initializeDiamondCut(address _init, bytes memory _calldata) internal { if (_init == address(0)) { require( _calldata.length == 0, "LibDiamondCut: _init is address(0) but_calldata is not empty" ); } else { require( _calldata.length > 0, "LibDiamondCut: _calldata is empty but _init is not address(0)" ); if (_init != address(this)) { enforceHasContractCode( _init, "LibDiamondCut: _init address has no code" ); } (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up the error revert(string(error)); } else { revert("LibDiamondCut: _init function reverted"); } } } } function enforceHasContractCode( address _contract, string memory _errorMessage ) internal view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } require(contractSize > 0, _errorMessage); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ interface IDiamondCut { enum FacetCutAction {Add, Replace, Remove} // Add=0, Replace=1, Remove=2 struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; import "./LibReentryProtectionStorage.sol"; contract ReentryProtection { modifier noReentry() { // Use counter to only write to storage once LibReentryProtectionStorage.RPStorage storage s = LibReentryProtectionStorage.rpStorage(); s.lockCounter++; uint256 lockValue = s.lockCounter; _; require( lockValue == s.lockCounter, "ReentryProtectionFacet.noReentry: reentry detected" ); } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; library LibReentryProtectionStorage { bytes32 constant REENTRY_STORAGE_POSITION = keccak256("diamond.standard.reentry.storage"); struct RPStorage { uint256 lockCounter; } function rpStorage() internal pure returns (RPStorage storage bs) { bytes32 position = REENTRY_STORAGE_POSITION; assembly { bs.slot := position } } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; import "../../../libraries/LibDiamond.sol"; contract CallProtection { modifier protectedCall() { require( msg.sender == LibDiamond.diamondStorage().contractOwner || msg.sender == address(this), "NOT_ALLOWED" ); _; } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; /// @title Signed Wad Math /// @author transmissions11 <[email protected]> /// @author FrankieIsLost <[email protected]> /// @author Remco Bloemen <[email protected]> /// @notice Efficient signed wad arithmetic. /// @dev Will not revert on overflow, only use where overflow is not possible. function toWadUnsafe(uint256 x) pure returns (int256 r) { assembly { // Multiply x by 1e18. r := mul(x, 1000000000000000000) } } /// @dev Takes an integer amount of seconds and converts it to a wad amount of days. /// @dev Will not revert on overflow, only use where overflow is not possible. function toDaysWadUnsafe(uint256 x) pure returns (int256 r) { assembly { // Multiply x by 1e18 and then divide it by 86400. r := div(mul(x, 1000000000000000000), 86400) } } /// @dev Takes a wad amount of days and converts it to an integer amount of seconds. /// @dev Will not revert on overflow, only use where overflow is not possible. /// @dev Not compatible with negative day amounts, it assumes x is positive. function fromDaysWadUnsafe(int256 x) pure returns (uint256 r) { assembly { // Multiply x by 86400 and then divide it by 1e18. r := div(mul(x, 86400), 1000000000000000000) } } /// @dev Will not revert on overflow, only use where overflow is not possible. function unsafeWadMul(int256 x, int256 y) pure returns (int256 r) { assembly { // Multiply x by y and divide by 1e18. r := sdiv(mul(x, y), 1000000000000000000) } } /// @dev Will return 0 instead of reverting if y is zero and will /// not revert on overflow, only use where overflow is not possible. function unsafeWadDiv(int256 x, int256 y) pure returns (int256 r) { assembly { // Multiply x by 1e18 and divide it by y. r := sdiv(mul(x, 1000000000000000000), y) } } function wadMul(int256 x, int256 y) pure returns (int256 r) { assembly { // Store x * y in r for now. r := mul(x, y) // Equivalent to require(x == 0 || (x * y) / x == y) if iszero(or(iszero(x), eq(sdiv(r, x), y))) { revert(0, 0) } // Scale the result down by 1e18. r := sdiv(r, 1000000000000000000) } } function wadDiv(int256 x, int256 y) pure returns (int256 r) { assembly { // Store x * 1e18 in r for now. r := mul(x, 1000000000000000000) // Equivalent to require(y != 0 && ((x * 1e18) / 1e18 == x)) if iszero(and(iszero(iszero(y)), eq(sdiv(r, 1000000000000000000), x))) { revert(0, 0) } // Divide r by y. r := sdiv(r, y) } } function wadExp(int256 x) pure returns (int256 r) { unchecked { // When the result is < 0.5 we return zero. This happens when // x <= floor(log(0.5e18) * 1e18) ~ -42e18 if (x <= -42139678854452767551) return 0; // When the result is > (2**255 - 1) / 1e18 we can not represent it as an // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135. if (x >= 135305999368893231589) revert("EXP_OVERFLOW"); // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96 // for more intermediate precision and a binary basis. This base conversion // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78. x = (x << 78) / 5**18; // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers // of two such that exp(x) = exp(x') * 2**k, where k is an integer. // Solving this gives k = round(x / log(2)) and x' = x - k * log(2). int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96; x = x - k * 54916777467707473351141471128; // k is in the range [-61, 195]. // Evaluate using a (6, 7)-term rational approximation. // p is made monic, we'll multiply by a scale factor later. int256 y = x + 1346386616545796478920950773328; y = ((y * x) >> 96) + 57155421227552351082224309758442; int256 p = y + x - 94201549194550492254356042504812; p = ((p * y) >> 96) + 28719021644029726153956944680412240; p = p * x + (4385272521454847904659076985693276 << 96); // We leave p in 2**192 basis so we don't need to scale it back up for the division. int256 q = x - 2855989394907223263936484059900; q = ((q * x) >> 96) + 50020603652535783019961831881945; q = ((q * x) >> 96) - 533845033583426703283633433725380; q = ((q * x) >> 96) + 3604857256930695427073651918091429; q = ((q * x) >> 96) - 14423608567350463180887372962807573; q = ((q * x) >> 96) + 26449188498355588339934803723976023; assembly { // Div in assembly because solidity adds a zero check despite the unchecked. // The q polynomial won't have zeros in the domain as all its roots are complex. // No scaling is necessary because p is already 2**96 too large. r := sdiv(p, q) } // r should be in the range (0.09, 0.25) * 2**96. // We now need to multiply r by: // * the scale factor s = ~6.031367120. // * the 2**k factor from the range reduction. // * the 1e18 / 2**96 factor for base conversion. // We do this all at once, with an intermediate result in 2**213 // basis, so the final right shift is always by a positive amount. r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k)); } } function wadLn(int256 x) pure returns (int256 r) { unchecked { require(x > 0, "UNDEFINED"); // We want to convert x from 10**18 fixed point to 2**96 fixed point. // We do this by multiplying by 2**96 / 10**18. But since // ln(x * C) = ln(x) + ln(C), we can simply do nothing here // and add ln(2**96 / 10**18) at the end. assembly { r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x)) r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x)))) r := or(r, shl(5, lt(0xffffffff, shr(r, x)))) r := or(r, shl(4, lt(0xffff, shr(r, x)))) r := or(r, shl(3, lt(0xff, shr(r, x)))) r := or(r, shl(2, lt(0xf, shr(r, x)))) r := or(r, shl(1, lt(0x3, shr(r, x)))) r := or(r, lt(0x1, shr(r, x))) } // Reduce range of x to (1, 2) * 2**96 // ln(2^k * x) = k * ln(2) + ln(x) int256 k = r - 96; x <<= uint256(159 - k); x = int256(uint256(x) >> 159); // Evaluate using a (8, 8)-term rational approximation. // p is made monic, we will multiply by a scale factor later. int256 p = x + 3273285459638523848632254066296; p = ((p * x) >> 96) + 24828157081833163892658089445524; p = ((p * x) >> 96) + 43456485725739037958740375743393; p = ((p * x) >> 96) - 11111509109440967052023855526967; p = ((p * x) >> 96) - 45023709667254063763336534515857; p = ((p * x) >> 96) - 14706773417378608786704636184526; p = p * x - (795164235651350426258249787498 << 96); // We leave p in 2**192 basis so we don't need to scale it back up for the division. // q is monic by convention. int256 q = x + 5573035233440673466300451813936; q = ((q * x) >> 96) + 71694874799317883764090561454958; q = ((q * x) >> 96) + 283447036172924575727196451306956; q = ((q * x) >> 96) + 401686690394027663651624208769553; q = ((q * x) >> 96) + 204048457590392012362485061816622; q = ((q * x) >> 96) + 31853899698501571402653359427138; q = ((q * x) >> 96) + 909429971244387300277376558375; assembly { // Div in assembly because solidity adds a zero check despite the unchecked. // The q polynomial is known not to have zeros in the domain. // No scaling required because p is already 2**96 too large. r := sdiv(p, q) } // r is in the range (0, 0.125) * 2**96 // Finalization, we need to: // * multiply by the scale factor s = 5.549… // * add ln(2**96 / 10**18) // * add k * ln(2) // * multiply by 10**18 / 2**96 = 5**18 >> 78 // mul s * 5e18 * 2**96, base is now 5**18 * 2**192 r *= 1677202110996718588342820967067443963516166; // add ln(2) * k * 5e18 * 2**192 r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k; // add ln(2**96 / 10**18) * 5e18 * 2**192 r += 600920179829731861736702779321621459595472258049074101567377883020018308; // base conversion: mul 2**18 / 2**192 r >>= 174; } } /// @dev Will return 0 instead of reverting if y is zero. function unsafeDiv(int256 x, int256 y) pure returns (int256 r) { assembly { // Divide x by y. r := sdiv(x, y) } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; library VRGDAStorage { bytes32 constant VRGDA_STORAGE_POSITION = keccak256("vrgda.v1.storage.location"); struct Layout { /// @notice Target price for a token, to be scaled according to sales pace. /// @dev Represented as an 18 decimal fixed point number. int256 targetPrice; /// @dev Precomputed constant that allows us to rewrite a pow() as an exp(). /// @dev Represented as an 18 decimal fixed point number. int256 decayConstant; } function layout() internal pure returns (Layout storage es) { bytes32 position = VRGDA_STORAGE_POSITION; assembly { es.slot := position } } function _init(Layout storage l, int256 _targetPrice, int256 _decayConstant) internal { // The decay constant must be negative for VRGDAs to work. require(_decayConstant < 0, "NON_NEGATIVE_DECAY_CONSTANT"); l.targetPrice = _targetPrice; l.decayConstant = _decayConstant; } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; import {wadExp, wadLn, wadMul, unsafeWadMul, toWadUnsafe} from "./math/SignedWadMath.sol"; import { VRGDAStorage } from "./VRGDAStorage.sol"; import { CallProtection } from "../shared/Access/CallProtection.sol"; /// @title Variable Rate Gradual Dutch Auction /// @author transmissions11 <[email protected]> /// @author FrankieIsLost <[email protected]> /// @notice Sell tokens roughly according to an issuance schedule. abstract contract VRGDA is CallProtection { using VRGDAStorage for VRGDAStorage.Layout; /// @notice Sets target price and per time unit price decay for the VRGDA. /// @param _targetPrice The target price for a token if sold on pace, scaled by 1e18. /// @param _priceDecayPercent The percent price decays per unit of time with no sales, scaled by 1e18. modifier __VRGDA_init(int256 _targetPrice, int256 _priceDecayPercent) { VRGDAStorage.layout()._init(_targetPrice, wadLn(1e18 - _priceDecayPercent)); _; } /*////////////////////////////////////////////////////////////// PRICING LOGIC //////////////////////////////////////////////////////////////*/ /// @notice Calculate the price of a token according to the VRGDA formula. /// @param timeSinceStart Time passed since the VRGDA began, scaled by 1e18. /// @param sold The total number of tokens that have been sold so far. /// @return The price of a token according to VRGDA, scaled by 1e18. function getVRGDAPrice(int256 timeSinceStart, uint256 sold) public view returns (uint256) { unchecked { // prettier-ignore return uint256(wadMul(VRGDAStorage.layout().targetPrice, wadExp(unsafeWadMul(VRGDAStorage.layout().decayConstant, // Theoretically calling toWadUnsafe with sold can silently overflow but under // any reasonable circumstance it will never be large enough. We use sold + 1 as // the VRGDA formula's n param represents the nth token and sold is the n-1th token. timeSinceStart - getTargetSaleTime(toWadUnsafe(sold + 1)) )))); } } /// @dev Given a number of tokens sold, return the target time that number of tokens should be sold by. /// @param sold A number of tokens sold, scaled by 1e18, to get the corresponding target sale time for. /// @return The target time the tokens should be sold by, scaled by 1e18, where the time is /// relative, such that 0 means the tokens should be sold immediately when the VRGDA begins. function getTargetSaleTime(int256 sold) public view virtual returns (int256); }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; library LinearVRGDAStorage { bytes32 constant LINEAR_VRGDA_STORAGE_POSITION = keccak256("vrgda.linear.v1.storage.location"); struct Layout { /// @dev The total number of tokens to target selling every full unit of time. /// @dev Represented as an 18 decimal fixed point number. int256 perTimeUnit; } function layout() internal pure returns (Layout storage es) { bytes32 position = LINEAR_VRGDA_STORAGE_POSITION; assembly { es.slot := position } } function _init(Layout storage l, int256 _perTimeUnit) internal { l.perTimeUnit = _perTimeUnit; } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; import {unsafeWadDiv} from "./math/SignedWadMath.sol"; import { VRGDA } from "./VRGDA.sol"; import { LinearVRGDAStorage } from "./LinearVRGDAStorage.sol"; /// @title Linear Variable Rate Gradual Dutch Auction /// @author transmissions11 <[email protected]> /// @author FrankieIsLost <[email protected]> /// @notice VRGDA with a linear issuance curve. contract LinearVRGDA is VRGDA { using LinearVRGDAStorage for LinearVRGDAStorage.Layout; /// @notice Sets pricing parameters for the VRGDA. /// @param _targetPrice The target price for a token if sold on pace, scaled by 1e18. /// @param _priceDecayPercent The percent price decays per unit of time with no sales, scaled by 1e18. /// @param _perTimeUnit The number of tokens to target selling in 1 full unit of time, scaled by 1e18. function __linearVRGDA_init( int256 _targetPrice, int256 _priceDecayPercent, int256 _perTimeUnit ) internal protectedCall __VRGDA_init(_targetPrice, _priceDecayPercent){ LinearVRGDAStorage.layout()._init(_perTimeUnit); } /*////////////////////////////////////////////////////////////// PRICING LOGIC //////////////////////////////////////////////////////////////*/ /// @dev Given a number of tokens sold, return the target time that number of tokens should be sold by. /// @param sold A number of tokens sold, scaled by 1e18, to get the corresponding target sale time for. /// @return The target time the tokens should be sold by, scaled by 1e18, where the time is /// relative, such that 0 means the tokens should be sold immediately when the VRGDA begins. function getTargetSaleTime(int256 sold) public view override returns (int256) { return unsafeWadDiv(sold, LinearVRGDAStorage.layout().perTimeUnit); } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; library SpellsStorage { bytes32 constant SPELLS_TOKEN_STORAGE_POSITION = keccak256("spells.token.storage.location"); // Minting sale state enum SaleState { CLOSED, PRESALE, OPEN, ETERNAL } struct Storage { uint256 seedMintPrice; // Token supply uint256 seedSupply; // Mint key limit counter mapping(address => uint256) mintCounts; // Token minting state SaleState saleState; // Spell gate address spellGate; // Godspell (founders) address godspell; // Spell random seeds mapping(uint256 => uint256) tokenSeed; // Last seed value uint256 seed; // Eternal mint start time uint256 eternalStartTime; } function getStorage() internal pure returns (Storage storage es) { bytes32 position = SPELLS_TOKEN_STORAGE_POSITION; assembly { es.slot := position } } function tokenSeed(uint256 _tokenId) internal view returns (uint256) { return getStorage().tokenSeed[_tokenId]; } function initialSpellsCoinOf(uint256 _tokenId) internal view returns (uint256) { uint256 greatness = getStorage().tokenSeed[_tokenId] % 21; return greatness / 4 + 1; } function mineOpCap(uint256 _tokenId) internal view returns (uint256) { uint256 initial = initialSpellsCoinOf(_tokenId); return initial * 2; } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; import "@openzeppelin/contracts/utils/Strings.sol"; import "../../coin/ISpellsCoin.sol"; library SpellsCastStorage { bytes32 constant SPELLS_CAST_STORAGE_POSITION = keccak256("spells.cast.storage.location"); bytes4 public constant _CAST_SELECTOR = bytes4(keccak256("cast")); struct Storage { ISpellsCoin spellsCoin; mapping(uint256 => uint256) tokenSpellsCoinMined; mapping(address => uint256) contractCastings; mapping(uint256 => uint256) factions; uint256 spellsCoinMultiplier; mapping(address => uint256) contractCasts; mapping(address => bool) tys; uint256 tyClaimThreshold; uint256 tyjackpot; uint256 tyfirstSolveBonus; } function getStorage() internal pure returns (Storage storage es) { bytes32 position = SPELLS_CAST_STORAGE_POSITION; assembly { es.slot := position } } function CAST_SELECTOR() internal pure returns (bytes4) { return _CAST_SELECTOR; } function random(string memory input) internal pure returns (uint256) { return uint256(keccak256(abi.encodePacked(input))); } function initialSpellsCoinOf(uint256 seed) internal pure returns (uint256) { uint256 rand = random(Strings.toString(seed)); uint256 greatness = rand % 21; return greatness / 4 + 1; } }
// SPDX-License-Identifier: BSD-3-Clause /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; interface IERC721Checkpointable { /// @notice An event thats emitted when an account changes its delegate event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); }
// SPDX-License-Identifier: BSD-3-Clause /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; library ERC721CheckpointableStorage { bytes32 constant ERC_721_CHECKPOINTABLE_STORAGE_POSITION = keccak256("erc721Checkpointable.storage.location"); /// @notice An event thats emitted when a delegate account's vote balance changes event DelegateVotesChanged(address indexed delegate, uint256 previousBalance, uint256 newBalance); /// @notice A checkpoint for marking number of votes from a given block struct Checkpoint { uint32 fromBlock; uint96 votes; } struct Layout { /// @notice A record of each accounts delegate mapping(address => address) _delegates; /// @notice A record of votes checkpoints for each account, by index mapping(address => mapping(uint32 => ERC721CheckpointableStorage.Checkpoint)) checkpoints; /// @notice The number of checkpoints for each account mapping(address => uint32) numCheckpoints; /// @notice A record of states for signing / validating signatures mapping(address => uint256) nonces; } function layout() internal pure returns (Layout storage es) { bytes32 position = ERC_721_CHECKPOINTABLE_STORAGE_POSITION; assembly { es.slot := position } } function _moveDelegates( address srcRep, address dstRep, uint96 amount ) internal { if (srcRep != dstRep && amount > 0) { if (srcRep != address(0)) { uint32 srcRepNum = layout().numCheckpoints[srcRep]; uint96 srcRepOld = srcRepNum > 0 ? layout().checkpoints[srcRep][srcRepNum - 1].votes : 0; uint96 srcRepNew = sub96(srcRepOld, amount, 'ERC721Checkpointable::_moveDelegates: amount underflows'); _writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew); } if (dstRep != address(0)) { uint32 dstRepNum = layout().numCheckpoints[dstRep]; uint96 dstRepOld = dstRepNum > 0 ? layout().checkpoints[dstRep][dstRepNum - 1].votes : 0; uint96 dstRepNew = add96(dstRepOld, amount, 'ERC721Checkpointable::_moveDelegates: amount overflows'); _writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew); } } } function _writeCheckpoint( address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes ) internal { uint32 blockNumber = safe32( block.number, 'ERC721Checkpointable::_writeCheckpoint: block number exceeds 32 bits' ); if (nCheckpoints > 0 && layout().checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) { layout().checkpoints[delegatee][nCheckpoints - 1].votes = newVotes; } else { layout().checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes); layout().numCheckpoints[delegatee] = nCheckpoints + 1; } emit DelegateVotesChanged(delegatee, oldVotes, newVotes); } function safe32(uint256 n, string memory errorMessage) internal pure returns (uint32) { require(n < 2**32, errorMessage); return uint32(n); } function add96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { uint96 c = a + b; require(c >= a, errorMessage); return c; } function sub96( uint96 a, uint96 b, string memory errorMessage ) internal pure returns (uint96) { require(b <= a, errorMessage); return a - b; } }
// SPDX-License-Identifier: BSD-3-Clause /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ /// @title Vote checkpointing for an ERC-721 token // LICENSE // ERC721Checkpointable.sol uses and modifies part of Noun's DAO's ERC721Checkpointable.sol: // https://github.com/nounsDAO/nouns-monorepo/blob/0a96001abe99751afa20c41a00adb8e5e32e6fda/packages/nouns-contracts/contracts/base/ERC721Checkpointable.sol // // ERC721Checkpointable.sol uses and modifies part of Compound's Comp.sol: // https://github.com/compound-finance/compound-protocol/blob/ae4388e780a8d596d97619d9704a931a2752c2bc/contracts/Governance/Comp.sol // // Comp.sol source code Copyright 2020 Compound Labs, Inc. licensed under the BSD-3-Clause license. // With modifications by Nounders DAO, and further modifications by Hypervisor. // // Additional conditions of BSD-3-Clause can be found here: https://opensource.org/licenses/BSD-3-Clause // // MODIFICATIONS // Checkpointing logic from Comp.sol has been used with the following modifications: // - `delegates` is renamed to `_delegates` and is set to private // - `delegates` is a public function that uses the `_delegates` mapping look-up, but unlike // Comp.sol, returns the delegator's own address if there is no delegate. // This avoids the delegator needing to "delegate to self" with an additional transaction // - `_transferTokens()` is renamed `_beforeTokenTransfer()` and adapted to hook into OpenZeppelin's ERC721 hooks. pragma solidity ^0.8.6; // import {ERC721AQueryableUpgradeable} from '../ERC721A/extensions/ERC721AQueryableUpgradeable.sol'; import {LibERC721AUpgradeable} from '../ERC721A/LibERC721AUpgradeable.sol'; import {ERC721CheckpointableStorage} from './ERC721CheckpointableStorage.sol'; import {IERC721Checkpointable} from './IERC721Checkpointable.sol'; contract ERC721Checkpointable is IERC721Checkpointable { using ERC721CheckpointableStorage for ERC721CheckpointableStorage.Layout; /// @notice Defines decimals as per ERC-20 convention to make integrations with 3rd party governance platforms easier uint8 public constant decimals = 0; /// @notice The EIP-712 typehash for the contract's domain bytes32 public constant DOMAIN_TYPEHASH = keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)'); /// @notice The EIP-712 typehash for the delegation struct used by the contract bytes32 public constant DELEGATION_TYPEHASH = keccak256('Delegation(address delegatee,uint256 nonce,uint256 expiry)'); /** * @notice The votes a delegator can delegate, which is the current balance of the delegator. * @dev Used when calling `_delegate()` */ function votesToDelegate(address delegator) public view returns (uint96) { return safe96(LibERC721AUpgradeable.balanceOf(delegator), 'ERC721Checkpointable::votesToDelegate: amount exceeds 96 bits'); } /** * @notice Overrides the standard `Comp.sol` delegates mapping to return * the delegator's own address if they haven't delegated. * This avoids having to delegate to oneself. */ function delegates(address delegator) public view returns (address) { address current = ERC721CheckpointableStorage.layout()._delegates[delegator]; return current == address(0) ? delegator : current; } /** * @notice Delegate votes from `msg.sender` to `delegatee` * @param delegatee The address to delegate votes to */ function delegate(address delegatee) public { if (delegatee == address(0)) delegatee = msg.sender; return _delegate(msg.sender, delegatee); } /** * @notice Delegates votes from signatory to `delegatee` * @param delegatee The address to delegate votes to * @param nonce The contract state required to match the signature * @param expiry The time at which to expire the signature * @param v The recovery byte of the signature * @param r Half of the ECDSA signature pair * @param s Half of the ECDSA signature pair */ function delegateBySig( address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) public { bytes32 domainSeparator = keccak256( abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(LibERC721AUpgradeable.name())), getChainId(), address(this)) ); bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry)); bytes32 digest = keccak256(abi.encodePacked('\x19\x01', domainSeparator, structHash)); address signatory = ecrecover(digest, v, r, s); require(signatory != address(0), 'ERC721Checkpointable::delegateBySig: invalid signature'); require(nonce == ERC721CheckpointableStorage.layout().nonces[signatory]++, 'ERC721Checkpointable::delegateBySig: invalid nonce'); require(block.timestamp <= expiry, 'ERC721Checkpointable::delegateBySig: signature expired'); return _delegate(signatory, delegatee); } /** * @notice Gets the current votes balance for `account` * @param account The address to get votes balance * @return The number of current votes for `account` */ function getCurrentVotes(address account) external view returns (uint96) { uint32 nCheckpoints = ERC721CheckpointableStorage.layout().numCheckpoints[account]; return nCheckpoints > 0 ? ERC721CheckpointableStorage.layout().checkpoints[account][nCheckpoints - 1].votes : 0; } /** * @notice Determine the prior number of votes for an account as of a block number * @dev Block number must be a finalized block or else this function will revert to prevent misinformation. * @param account The address of the account to check * @param blockNumber The block number to get the vote balance at * @return The number of votes the account had as of the given block */ function getPriorVotes(address account, uint256 blockNumber) public view returns (uint96) { require(blockNumber < block.number, 'ERC721Checkpointable::getPriorVotes: not yet determined'); uint32 nCheckpoints = ERC721CheckpointableStorage.layout().numCheckpoints[account]; if (nCheckpoints == 0) { return 0; } // First check most recent balance if (ERC721CheckpointableStorage.layout().checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) { return ERC721CheckpointableStorage.layout().checkpoints[account][nCheckpoints - 1].votes; } // Next check implicit zero balance if (ERC721CheckpointableStorage.layout().checkpoints[account][0].fromBlock > blockNumber) { return 0; } uint32 lower = 0; uint32 upper = nCheckpoints - 1; while (upper > lower) { uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow ERC721CheckpointableStorage.Checkpoint memory cp = ERC721CheckpointableStorage.layout().checkpoints[account][center]; if (cp.fromBlock == blockNumber) { return cp.votes; } else if (cp.fromBlock < blockNumber) { lower = center; } else { upper = center - 1; } } return ERC721CheckpointableStorage.layout().checkpoints[account][lower].votes; } function _delegate(address delegator, address delegatee) internal { /// @notice differs from `_delegate()` in `Comp.sol` to use `delegates` override method to simulate auto-delegation address currentDelegate = delegates(delegator); ERC721CheckpointableStorage.layout()._delegates[delegator] = delegatee; emit DelegateChanged(delegator, currentDelegate, delegatee); uint96 amount = votesToDelegate(delegator); ERC721CheckpointableStorage._moveDelegates(currentDelegate, delegatee, amount); } function safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } function getChainId() internal view returns (uint256) { uint256 chainId; assembly { chainId := chainid() } return chainId; } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.2 // Creator: Chiru Labs pragma solidity ^0.8.6; import '../IERC721AUpgradeable.sol'; /** * @dev Interface of ERC721AQueryable. */ interface IERC721AQueryableUpgradeable is IERC721AUpgradeable { /** * Invalid query range (`start` >= `stop`). */ error InvalidQueryRange(); /** * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting. * * If the `tokenId` is out of bounds: * * - `addr = address(0)` * - `startTimestamp = 0` * - `burned = false` * - `extraData = 0` * * If the `tokenId` is burned: * * - `addr = <Address of owner before token was burned>` * - `startTimestamp = <Timestamp when token was burned>` * - `burned = true` * - `extraData = <Extra data when token was burned>` * * Otherwise: * * - `addr = <Address of owner>` * - `startTimestamp = <Timestamp of start of ownership>` * - `burned = false` * - `extraData = <Extra data at start of ownership>` */ function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory); /** * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order. * See {ERC721AQueryable-explicitOwnershipOf} */ function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory); /** * @dev Returns an array of token IDs owned by `owner`, * in the range [`start`, `stop`) * (i.e. `start <= tokenId < stop`). * * This function allows for tokens to be queried if the collection * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}. * * Requirements: * * - `start < stop` */ function tokensOfOwnerIn( address owner, uint256 start, uint256 stop ) external view returns (uint256[] memory); /** * @dev Returns an array of token IDs owned by `owner`. * * This function scans the ownership mapping and is O(`totalSupply`) in complexity. * It is meant to be called off-chain. * * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into * multiple smaller scans if the collection is large enough to cause * an out-of-gas error (10K collections should be fine). */ function tokensOfOwner(address owner) external view returns (uint256[] memory); }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.2 // Creator: Chiru Labs pragma solidity ^0.8.6; import './IERC721AQueryableUpgradeable.sol'; import '../ERC721AUpgradeable.sol'; import '../ERC721A__Initializable.sol'; /** * @title ERC721AQueryable. * * @dev ERC721A subclass with convenience query functions. */ abstract contract ERC721AQueryableUpgradeable is ERC721A__Initializable, ERC721AUpgradeable, IERC721AQueryableUpgradeable { function __ERC721AQueryable_init() internal onlyInitializingERC721A { __ERC721AQueryable_init_unchained(); } function __ERC721AQueryable_init_unchained() internal onlyInitializingERC721A {} /** * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting. * * If the `tokenId` is out of bounds: * * - `addr = address(0)` * - `startTimestamp = 0` * - `burned = false` * - `extraData = 0` * * If the `tokenId` is burned: * * - `addr = <Address of owner before token was burned>` * - `startTimestamp = <Timestamp when token was burned>` * - `burned = true` * - `extraData = <Extra data when token was burned>` * * Otherwise: * * - `addr = <Address of owner>` * - `startTimestamp = <Timestamp of start of ownership>` * - `burned = false` * - `extraData = <Extra data at start of ownership>` */ function explicitOwnershipOf(uint256 tokenId) public view virtual override returns (TokenOwnership memory) { TokenOwnership memory ownership; if (tokenId < LibERC721AUpgradeable._startTokenId() || tokenId >= _nextTokenId()) { return ownership; } ownership = _ownershipAt(tokenId); if (ownership.burned) { return ownership; } return _ownershipOf(tokenId); } /** * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order. * See {ERC721AQueryable-explicitOwnershipOf} */ function explicitOwnershipsOf(uint256[] calldata tokenIds) external view virtual override returns (TokenOwnership[] memory) { unchecked { uint256 tokenIdsLength = tokenIds.length; TokenOwnership[] memory ownerships = new TokenOwnership[](tokenIdsLength); for (uint256 i; i != tokenIdsLength; ++i) { ownerships[i] = explicitOwnershipOf(tokenIds[i]); } return ownerships; } } /** * @dev Returns an array of token IDs owned by `owner`, * in the range [`start`, `stop`) * (i.e. `start <= tokenId < stop`). * * This function allows for tokens to be queried if the collection * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}. * * Requirements: * * - `start < stop` */ function tokensOfOwnerIn( address owner, uint256 start, uint256 stop ) external view virtual override returns (uint256[] memory) { unchecked { if (start >= stop) revert InvalidQueryRange(); uint256 tokenIdsIdx; uint256 stopLimit = _nextTokenId(); // Set `start = max(start, _startTokenId())`. if (start < LibERC721AUpgradeable._startTokenId()) { start = LibERC721AUpgradeable._startTokenId(); } // Set `stop = min(stop, stopLimit)`. if (stop > stopLimit) { stop = stopLimit; } uint256 tokenIdsMaxLength = balanceOf(owner); // Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`, // to cater for cases where `balanceOf(owner)` is too big. if (start < stop) { uint256 rangeLength = stop - start; if (rangeLength < tokenIdsMaxLength) { tokenIdsMaxLength = rangeLength; } } else { tokenIdsMaxLength = 0; } uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength); if (tokenIdsMaxLength == 0) { return tokenIds; } // We need to call `explicitOwnershipOf(start)`, // because the slot at `start` may not be initialized. TokenOwnership memory ownership = explicitOwnershipOf(start); address currOwnershipAddr; // If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`. // `ownership.address` will not be zero, as `start` is clamped to the valid token ID range. if (!ownership.burned) { currOwnershipAddr = ownership.addr; } for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) { ownership = _ownershipAt(i); if (ownership.burned) { continue; } if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { tokenIds[tokenIdsIdx++] = i; } } // Downsize the array to fit. assembly { mstore(tokenIds, tokenIdsIdx) } return tokenIds; } } /** * @dev Returns an array of token IDs owned by `owner`. * * This function scans the ownership mapping and is O(`totalSupply`) in complexity. * It is meant to be called off-chain. * * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into * multiple smaller scans if the collection is large enough to cause * an out-of-gas error (10K collections should be fine). */ function tokensOfOwner(address owner) external view virtual override returns (uint256[] memory) { unchecked { uint256 tokenIdsIdx; address currOwnershipAddr; uint256 tokenIdsLength = balanceOf(owner); uint256[] memory tokenIds = new uint256[](tokenIdsLength); TokenOwnership memory ownership; for (uint256 i = LibERC721AUpgradeable._startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) { ownership = _ownershipAt(i); if (ownership.burned) { continue; } if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; } if (currOwnershipAddr == owner) { tokenIds[tokenIdsIdx++] = i; } } return tokenIds; } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; import "./ERC721AStorage.sol"; library LibERC721AUpgradeable { using ERC721AStorage for ERC721AStorage.Layout; // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); function name() internal view returns (string memory) { return ERC721AStorage.layout()._name; } /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) internal view returns (address) { return address(uint160(_packedOwnershipOf(tokenId))); } /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) internal view returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return ERC721AStorage.layout()._packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY; } /** * @dev Returns the starting token ID. * To change the starting token ID, please override this function. */ function _startTokenId() internal pure returns (uint256) { /// 0-index reserved for public wild-card token. return 1; } /** * Returns the packed ownership data of `tokenId`. */ function _packedOwnershipOf(uint256 tokenId) internal view returns (uint256) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr) if (curr < ERC721AStorage.layout()._currentIndex) { uint256 packed = ERC721AStorage.layout()._packedOwnerships[curr]; // If not burned. if (packed & _BITMASK_BURNED == 0) { // Invariant: // There will always be an initialized ownership slot // (i.e. `ownership.addr != address(0) && ownership.burned == false`) // before an unintialized ownership slot // (i.e. `ownership.addr == address(0) && ownership.burned == false`) // Hence, `curr` will not underflow. // // We can directly compare the packed value. // If the address is zero, packed will be zero. while (packed == 0) { packed = ERC721AStorage.layout()._packedOwnerships[--curr]; } return packed; } } } revert OwnerQueryForNonexistentToken(); } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() internal view returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return ERC721AStorage.layout()._currentIndex - ERC721AStorage.layout()._burnCounter - _startTokenId(); } } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.2 // Creator: Chiru Labs pragma solidity ^0.8.6; /** * @dev Interface of ERC721A. */ interface IERC721AUpgradeable { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); /** * The `quantity` minted with ERC2309 exceeds the safety limit. */ error MintERC2309QuantityExceedsLimit(); /** * The `extraData` cannot be set on an unintialized ownership slot. */ error OwnershipNotInitializedForExtraData(); // ============================================================= // STRUCTS // ============================================================= struct TokenOwnership { // The address of the owner. address addr; // Stores the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}. uint24 extraData; bool burned; } // ============================================================= // TOKEN COUNTERS // ============================================================= /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() external view returns (uint256); // ============================================================= // IERC721 // ============================================================= /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables * (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, * checking first that contract recipients are aware of the ERC721 protocol * to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move * this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} * whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) external view returns (bool); // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ // function tokenURI(uint256 tokenId) external view returns (string memory); // ============================================================= // IERC2309 // ============================================================= /** * @dev Emitted when tokens in `fromTokenId` to `toTokenId` * (inclusive) is transferred from `from` to `to`, as defined in the * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard. * * See {_mintERC2309} for more details. */ event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /** * @dev This is a base storage for the initialization function for upgradeable diamond facet contracts **/ library ERC721A__InitializableStorage { struct Layout { /* * Indicates that the contract has been initialized. */ bool _initialized; /* * Indicates that the contract is in the process of being initialized. */ bool _initializing; } bytes32 internal constant STORAGE_SLOT = keccak256('ERC721A.contracts.storage.initializable.facet'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; /** * @dev This is a base contract to aid in writing upgradeable diamond facet contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. */ import {ERC721A__InitializableStorage} from './ERC721A__InitializableStorage.sol'; abstract contract ERC721A__Initializable { using ERC721A__InitializableStorage for ERC721A__InitializableStorage.Layout; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializerERC721A() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require( ERC721A__InitializableStorage.layout()._initializing ? _isConstructor() : !ERC721A__InitializableStorage.layout()._initialized, 'ERC721A__Initializable: contract is already initialized' ); bool isTopLevelCall = !ERC721A__InitializableStorage.layout()._initializing; if (isTopLevelCall) { ERC721A__InitializableStorage.layout()._initializing = true; ERC721A__InitializableStorage.layout()._initialized = true; } _; if (isTopLevelCall) { ERC721A__InitializableStorage.layout()._initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializingERC721A() { require( ERC721A__InitializableStorage.layout()._initializing, 'ERC721A__Initializable: contract is not initializing' ); _; } /// @dev Returns true if and only if the function is running in the constructor function _isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } }
// SPDX-License-Identifier: MIT // ERC721A Contracts v4.2.2 // Creator: Chiru Labs pragma solidity ^0.8.6; import './IERC721AUpgradeable.sol'; import {ERC721AStorage} from './ERC721AStorage.sol'; import './ERC721A__Initializable.sol'; import './LibERC721AUpgradeable.sol'; import {ERC721CheckpointableStorage} from '../ERC721Checkpointable/ERC721CheckpointableStorage.sol'; /** * @dev Interface of ERC721 token receiver. */ interface ERC721A__IERC721ReceiverUpgradeable { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } /** * @title ERC721A * * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721) * Non-Fungible Token Standard, including the Metadata extension. * Optimized for lower gas during batch mints. * * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...) * starting from `_startTokenId()`. * * Assumptions: * * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply. * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256). */ abstract contract ERC721AUpgradeable is ERC721A__Initializable, IERC721AUpgradeable { using ERC721AStorage for ERC721AStorage.Layout; // ============================================================= // CONSTANTS // ============================================================= // Mask of an entry in packed address data. uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1; // The bit position of `numberMinted` in packed address data. uint256 private constant _BITPOS_NUMBER_MINTED = 64; // The bit position of `numberBurned` in packed address data. uint256 private constant _BITPOS_NUMBER_BURNED = 128; // The bit position of `aux` in packed address data. uint256 private constant _BITPOS_AUX = 192; // Mask of all 256 bits in packed address data except the 64 bits for `aux`. uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1; // The bit position of `startTimestamp` in packed ownership. uint256 private constant _BITPOS_START_TIMESTAMP = 160; // The bit mask of the `burned` bit in packed ownership. uint256 private constant _BITMASK_BURNED = 1 << 224; // The bit position of the `nextInitialized` bit in packed ownership. uint256 private constant _BITPOS_NEXT_INITIALIZED = 225; // The bit mask of the `nextInitialized` bit in packed ownership. uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225; // The bit position of `extraData` in packed ownership. uint256 private constant _BITPOS_EXTRA_DATA = 232; // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`. uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1; // The mask of the lower 160 bits for addresses. uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1; // The `Transfer` event signature is given by: // `keccak256(bytes("Transfer(address,address,uint256)"))`. bytes32 private constant _TRANSFER_EVENT_SIGNATURE = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef; // ============================================================= // CONSTRUCTOR // ============================================================= function __ERC721A_init(string memory name_, string memory symbol_) internal onlyInitializingERC721A { ERC721AStorage.layout()._name = name_; ERC721AStorage.layout()._symbol = symbol_; ERC721AStorage.layout()._currentIndex = LibERC721AUpgradeable._startTokenId(); } // ============================================================= // TOKEN COUNTING OPERATIONS // ============================================================= /** * @dev Returns the next token ID to be minted. */ function _nextTokenId() internal view virtual returns (uint256) { return ERC721AStorage.layout()._currentIndex; } /** * @dev Returns the total number of tokens in existence. * Burned tokens will reduce the count. * To get the total number of tokens minted, please see {_totalMinted}. */ function totalSupply() public view virtual override(IERC721AUpgradeable) returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than `_currentIndex - _startTokenId()` times. unchecked { return ERC721AStorage.layout()._currentIndex - ERC721AStorage.layout()._burnCounter - LibERC721AUpgradeable._startTokenId(); } } // ============================================================= // ADDRESS DATA OPERATIONS // ============================================================= /** * @dev Returns the number of tokens in `owner`'s account. */ function balanceOf(address owner) public view virtual override(IERC721AUpgradeable) returns (uint256) { return LibERC721AUpgradeable.balanceOf(owner); } // ============================================================= // IERC721Metadata // ============================================================= /** * @dev Returns the token collection name. */ function name() public view virtual override(IERC721AUpgradeable) returns (string memory) { return ERC721AStorage.layout()._name; } /** * @dev Returns the token collection symbol. */ function symbol() public view virtual override(IERC721AUpgradeable) returns (string memory) { return ERC721AStorage.layout()._symbol; } /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ // function tokenURI(uint256 tokenId) public view virtual override(IERC721AUpgradeable) returns (string memory) { // if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); // string memory baseURI = _baseURI(); // return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : ''; // } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, it can be overridden in child contracts. */ // function _baseURI() internal view virtual returns (string memory) { // return ''; // } // ============================================================= // OWNERSHIPS OPERATIONS // ============================================================= /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) public view virtual override(IERC721AUpgradeable) returns (address) { return LibERC721AUpgradeable.ownerOf(tokenId); } /** * @dev Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around over time. */ function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(LibERC721AUpgradeable._packedOwnershipOf(tokenId)); } /** * @dev Returns the unpacked `TokenOwnership` struct at `index`. */ function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) { return _unpackedOwnership(ERC721AStorage.layout()._packedOwnerships[index]); } /** * @dev Initializes the ownership slot minted at `index` for efficiency purposes. */ function _initializeOwnershipAt(uint256 index) internal virtual { if (ERC721AStorage.layout()._packedOwnerships[index] == 0) { ERC721AStorage.layout()._packedOwnerships[index] = LibERC721AUpgradeable._packedOwnershipOf(index); } } /** * @dev Returns the unpacked `TokenOwnership` struct from `packed`. */ function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) { ownership.addr = address(uint160(packed)); ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP); ownership.burned = packed & _BITMASK_BURNED != 0; ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA); } /** * @dev Packs ownership data into a single uint256. */ function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`. result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)) } } /** * @dev Returns the `nextInitialized` flag set if `quantity` equals 1. */ function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) { // For branchless setting of the `nextInitialized` flag. assembly { // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`. result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1)) } } // ============================================================= // APPROVAL OPERATIONS // ============================================================= /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the * zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); if (_msgSenderERC721A() != owner) if (!isApprovedForAll(owner, _msgSenderERC721A())) { revert ApprovalCallerNotOwnerNorApproved(); } ERC721AStorage.layout()._tokenApprovals[tokenId].value = to; emit Approval(owner, to, tokenId); } /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) public view virtual override(IERC721AUpgradeable) returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return ERC721AStorage.layout()._tokenApprovals[tokenId].value; } /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} * for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) public virtual override(IERC721AUpgradeable) { ERC721AStorage.layout()._operatorApprovals[_msgSenderERC721A()][operator] = approved; emit ApprovalForAll(_msgSenderERC721A(), operator, approved); } /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override(IERC721AUpgradeable) returns (bool) { return ERC721AStorage.layout()._operatorApprovals[owner][operator]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted. See {_mint}. */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return LibERC721AUpgradeable._startTokenId() <= tokenId && tokenId < ERC721AStorage.layout()._currentIndex && // If within bounds, ERC721AStorage.layout()._packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned. } /** * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`. */ function _isSenderApprovedOrOwner( address approvedAddress, address owner, address msgSender ) private pure returns (bool result) { assembly { // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean. owner := and(owner, _BITMASK_ADDRESS) // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean. msgSender := and(msgSender, _BITMASK_ADDRESS) // `msgSender == owner || msgSender == approvedAddress`. result := or(eq(msgSender, owner), eq(msgSender, approvedAddress)) } } /** * @dev Returns the storage slot and value for the approved address of `tokenId`. */ function _getApprovedSlotAndAddress(uint256 tokenId) private view returns (uint256 approvedAddressSlot, address approvedAddress) { ERC721AStorage.TokenApprovalRef storage tokenApproval = ERC721AStorage.layout()._tokenApprovals[tokenId]; // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`. assembly { approvedAddressSlot := tokenApproval.slot approvedAddress := sload(approvedAddressSlot) } } // ============================================================= // TRANSFER OPERATIONS // ============================================================= /** * @dev Transfers `tokenId` from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { uint256 prevOwnershipPacked = LibERC721AUpgradeable._packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --ERC721AStorage.layout()._packedAddressData[from]; // Updates: `balance -= 1`. ++ERC721AStorage.layout()._packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. ERC721AStorage.layout()._packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (ERC721AStorage.layout()._packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != ERC721AStorage.layout()._currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. ERC721AStorage.layout()._packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override(IERC721AUpgradeable) { safeTransferFrom(from, to, tokenId, ''); } /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token * by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override(IERC721AUpgradeable) { transferFrom(from, to, tokenId); if (to.code.length != 0) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @dev Hook that is called before a set of serially-ordered token IDs * are about to be transferred. This includes minting. * And also called before burning one token. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 quantity ) internal virtual { ERC721CheckpointableStorage._moveDelegates(from, to, safe96(quantity, "ERC721A: amount exceeds 96 bits")); } function safe96(uint256 n, string memory errorMessage) internal pure returns (uint96) { require(n < 2**96, errorMessage); return uint96(n); } /** * @dev Hook that is called after a set of serially-ordered token IDs * have been transferred. This includes minting. * And also called after one token has been burned. * * `startTokenId` - the first token ID to be transferred. * `quantity` - the amount to be transferred. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract. * * `from` - Previous owner of the given token ID. * `to` - Target address that will receive the token. * `tokenId` - Token ID to be transferred. * `_data` - Optional data to send along with the call. * * Returns whether the call correctly returned the expected magic value. */ function _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (bytes4 retval) { return retval == ERC721A__IERC721ReceiverUpgradeable(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } // ============================================================= // MINT OPERATIONS // ============================================================= /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event for each mint. */ function _mint(address to, uint256 quantity) internal virtual { uint256 startTokenId = ERC721AStorage.layout()._currentIndex; if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, quantity); // Overflows are incredibly unrealistic. // `balance` and `numberMinted` have a maximum limit of 2**64. // `tokenId` has a maximum limit of 2**256. unchecked { // Updates: // - `balance += quantity`. // - `numberMinted += quantity`. // // We can directly add to the `balance` and `numberMinted`. ERC721AStorage.layout()._packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1); // Updates: // - `address` to the owner. // - `startTimestamp` to the timestamp of minting. // - `burned` to `false`. // - `nextInitialized` to `quantity == 1`. ERC721AStorage.layout()._packedOwnerships[startTokenId] = _packOwnershipData( to, _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0) ); uint256 toMasked; uint256 end = startTokenId + quantity; // Use assembly to loop and emit the `Transfer` event for gas savings. // The duplicated `log4` removes an extra check and reduces stack juggling. // The assembly, together with the surrounding Solidity code, have been // delicately arranged to nudge the compiler into producing optimized opcodes. assembly { // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean. toMasked := and(to, _BITMASK_ADDRESS) // Emit the `Transfer` event. log4( 0, // Start of data (0, since no data). 0, // End of data (0, since no data). _TRANSFER_EVENT_SIGNATURE, // Signature. 0, // `address(0)`. toMasked, // `to`. startTokenId // `tokenId`. ) for { let tokenId := add(startTokenId, 1) } iszero(eq(tokenId, end)) { tokenId := add(tokenId, 1) } { // Emit the `Transfer` event. Similar to above. log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId) } } if (toMasked == 0) revert MintToZeroAddress(); ERC721AStorage.layout()._currentIndex = end; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * See {_mint}. * * Emits a {Transfer} event for each mint. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal virtual { _mint(to, quantity); unchecked { if (to.code.length != 0) { uint256 end = ERC721AStorage.layout()._currentIndex; uint256 index = end - quantity; do { if (!_checkContractOnERC721Received(address(0), to, index++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (index < end); // Reentrancy protection. if (ERC721AStorage.layout()._currentIndex != end) revert(); } } } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal virtual { _safeMint(to, quantity, ''); } /** * @dev Called during each token transfer to set the 24bit `extraData` field. * Intended to be overridden by the cosumer contract. * * `previousExtraData` - the value of `extraData` before transfer. * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _extraData( address from, address to, uint24 previousExtraData ) internal view virtual returns (uint24) {} /** * @dev Returns the next extra data for the packed ownership data. * The returned result is shifted into position. */ function _nextExtraData( address from, address to, uint256 prevOwnershipPacked ) private view returns (uint256) { uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA); return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA; } // ============================================================= // OTHER OPERATIONS // ============================================================= /** * @dev Returns the message sender (defaults to `msg.sender`). * * If you are writing GSN compatible contracts, you need to override this function. */ function _msgSenderERC721A() internal view virtual returns (address) { return msg.sender; } /** * @dev Converts a uint256 to its ASCII string decimal representation. */ function _toString(uint256 value) internal pure virtual returns (string memory str) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. // We will need 1 word for the trailing zeros padding, 1 word for the length, // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0. let m := add(mload(0x40), 0xa0) // Update the free memory pointer to allocate. mstore(0x40, m) // Assign the `str` to the end. str := sub(m, 0x20) // Zeroize the slot after the string. mstore(str, 0) // Cache the end of the memory to calculate the length later. let end := str // We write the string from rightmost digit to leftmost digit. // The following is essentially a do-while loop that also handles the zero case. // prettier-ignore for { let temp := value } 1 {} { str := sub(str, 1) // Write the character to the pointer. // The ASCII index of the '0' character is 48. mstore8(str, add(48, mod(temp, 10))) // Keep dividing `temp` until zero. temp := div(temp, 10) // prettier-ignore if iszero(temp) { break } } let length := sub(end, str) // Move the pointer 32 bytes leftwards to make room for the length. str := sub(str, 0x20) // Store the length. mstore(str, length) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.6; library ERC721AStorage { // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364). struct TokenApprovalRef { address value; } struct Layout { // ============================================================= // STORAGE // ============================================================= // The next token ID to be minted. uint256 _currentIndex; // The number of tokens burned. uint256 _burnCounter; // Token name string _name; // Token symbol string _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. // See {_packedOwnershipOf} implementation for details. // // Bits Layout: // - [0..159] `addr` // - [160..223] `startTimestamp` // - [224] `burned` // - [225] `nextInitialized` // - [232..255] `extraData` mapping(uint256 => uint256) _packedOwnerships; // Mapping owner address to address data. // // Bits Layout: // - [0..63] `balance` // - [64..127] `numberMinted` // - [128..191] `numberBurned` // - [192..255] `aux` mapping(address => uint256) _packedAddressData; // Mapping from token ID to approved address. mapping(uint256 => ERC721AStorage.TokenApprovalRef) _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) _operatorApprovals; } bytes32 internal constant STORAGE_SLOT = keccak256('ERC721A.contracts.storage.ERC721A'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
pragma solidity ^0.8.6; library ECDSA { /* * @dev Verifies if message was signed by owner to give access to _add for this contract. * Assumes Geth signature prefix. * @param _add Address of agent with access * @param _v ECDSA signature parameter v. * @param _r ECDSA signature parameters r. * @param _s ECDSA signature parameters s. * @return Validity of access message for a given address. */ function isValidAccessMessage( address expectedSigner, bytes32 _hash, uint8 _v, bytes32 _r, bytes32 _s ) internal pure returns (bool) { return expectedSigner == ecrecover( keccak256( abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash) ), _v, _r, _s ); } }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; import "./ERC20X/IERC20X.sol"; interface ISpellsCoin is IERC20X { function mint( address _contract, uint256 tokenId, uint256 amount ) external; function mint(address account, uint256 amount) external; function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT /********************************************************* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░ .░░░░░░░░░░░░░░░░░░░░░░░░. ҹ░░░░░░░░░░░░* *░░░░░░░░░░░░░ ∴░░░░░░░░░░░░░░░░░░` ░░․ ░░∴ (░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º ҹ ░ (░░░░░░░░* *░░░░░⁕ .░░░░░░░░░░░░░░░░░░░░░░░ ⁕.. .∴, ⁕░░░░* *░░░░░░ ∴░░░░░░░░░░░░░░░░░░░░░░░ҹ ,(º⁕ҹ ․∴ҹ⁕(. ⁕░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░º` ․░ ⁕, ░░░░░░░░* *░░░░░, .░░░░░░░░░░░░░░░░░░░░░░░░░` ,░░⁕ ∴░░ `░░░░░░* *░░░░░░⁕º░░░░░░░░░░░░░░⁕ ҹ░░░░░░░░░░░░░, %░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░ҹ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░ҹ ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░º(░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░* *********************************************************/ pragma solidity ^0.8.6; import {Address} from "@openzeppelin/contracts/utils/Address.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IERC20X is IERC20 { function totalTokenHeldSupply() external view returns (uint256); function balanceOf(address _contract, uint256 tokenId) external view returns (uint256); function nonce(address _contract, uint256 tokenId) external view returns (uint256); function transfer( address _contract, uint256 tokenId, uint256 amount ) external returns (bool); function transfer( address _contract, uint256 tokenId, address to, uint256 amount ) external returns (bool); function transfer( address _contract, uint256 tokenId, address toContract, uint256 toTokenId, uint256 amount ) external returns (bool); function transferFrom( address from, address toContract, uint256 toTokenId, uint256 amount ) external returns (bool); function transferFrom( address _contract, uint256 tokenId, address to, uint256 amount ) external returns (bool); function transferFrom( address _contract, uint256 tokenId, address toContract, uint256 toTokenId, uint256 amount ) external returns (bool); function approve( address _contract, uint256 tokenId, address spender, uint256 amount ) external returns (bool); function allowance( address _contract, uint256 tokenId, address spender ) external view returns (uint256); function allowance( address tokenOwner, address _contract, uint256 tokenId, address spender ) external view returns (uint256); function increaseAllowance( address _contract, uint256 tokenId, address spender, uint256 addedValue ) external returns (bool); function decreaseAllowance( address _contract, uint256 tokenId, address spender, uint256 subtractedValue ) external returns (bool); function signedTransferFrom( DynamicAddress memory from, DynamicAddress memory to, uint256 amount, uint256 nonce, uint8 _v, bytes32 _r, bytes32 _s ) external; /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event XTransfer( address indexed from, uint256 fromTokenId, address indexed to, uint256 toTokenId, uint256 value ); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event XApproval( address indexed _contract, uint256 tokenId, address indexed spender, uint256 value ); } /// @param _address The address of the entity /// @param _tokenId The token of the object (optional) /// @param _useZeroToken Treat tokenId 0 as a token (default: ignore tokenId 0) struct DynamicAddress { address _address; uint256 _tokenId; bool _useZeroToken; } library DynamicAddressLib { using Address for address; function isToken(DynamicAddress memory _address) internal view returns (bool) { return (_address._address.isContract() && (_address._tokenId > 0 || _address._useZeroToken)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library ERC165Storage { struct Layout { mapping(bytes4 => bool) supportedInterfaces; } bytes32 internal constant STORAGE_SLOT = keccak256('solidstate.contracts.storage.ERC165'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } function isSupportedInterface(Layout storage l, bytes4 interfaceId) internal view returns (bool) { return l.supportedInterfaces[interfaceId]; } function setSupportedInterface( Layout storage l, bytes4 interfaceId, bool status ) internal { require(interfaceId != 0xffffffff, 'ERC165: invalid interface id'); l.supportedInterfaces[interfaceId] = status; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 300 }, "evmVersion": "london", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"ConjureMaxReached","type":"error"},{"inputs":[],"name":"EternalMintNotOpen","type":"error"},{"inputs":[],"name":"InvalidQueryRange","type":"error"},{"inputs":[],"name":"MintClosed","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[{"internalType":"uint256","name":"price","type":"uint256"}],"name":"MintInsufficientPayment","type":"error"},{"inputs":[],"name":"MintMaxReached","type":"error"},{"inputs":[],"name":"MintNotAuthorized","type":"error"},{"inputs":[],"name":"MintQuantityExceedsAllowance","type":"error"},{"inputs":[],"name":"MintQuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"PaymentTransferFailed","type":"error"},{"inputs":[],"name":"SenderNotSpellGate","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"ZeroAmount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_allowed","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"}],"name":"conjure","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"conjure","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"conjure","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"eternalMintActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"explicitOwnershipOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint24","name":"extraData","type":"uint24"},{"internalType":"bool","name":"burned","type":"bool"}],"internalType":"struct IERC721AUpgradeable.TokenOwnership","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"explicitOwnershipsOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"uint24","name":"extraData","type":"uint24"},{"internalType":"bool","name":"burned","type":"bool"}],"internalType":"struct IERC721AUpgradeable.TokenOwnership[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"gate","type":"uint256"}],"name":"gateMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFaction","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"sold","type":"int256"}],"name":"getTargetSaleTime","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"int256","name":"timeSinceStart","type":"int256"},{"internalType":"uint256","name":"sold","type":"uint256"}],"name":"getVRGDAPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"int256","name":"_targetPrice","type":"int256"},{"internalType":"int256","name":"_priceDecayPercent","type":"int256"},{"internalType":"int256","name":"_perTimeUnit","type":"int256"},{"internalType":"uint256","name":"_seedPrice","type":"uint256"},{"internalType":"uint256","name":"_seedSupply","type":"uint256"},{"internalType":"address","name":"_spellGate","type":"address"},{"internalType":"address","name":"_godspell","type":"address"}],"name":"initializeSpellsTokenFacet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenSeed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"tokensOfOwnerIn","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506138f0806100206000396000f3fe6080604052600436106101ac5760003560e01c80636d9d33b7116100ec578063a22cb4651161008a578063c23dc68f11610064578063c23dc68f146104aa578063dc502efd146104d7578063e985e9c514610519578063f466d4ab1461053957600080fd5b8063a22cb4651461041e578063a8a150b81461043e578063b88d4fde1461048a57600080fd5b80639391b537116100c65780639391b537146103cc57806395d89b41146103d457806398d5fdca146103e957806399a2557a146103fe57600080fd5b80636d9d33b71461035f57806370a082311461037f5780638462151c1461039f57600080fd5b8063345a17ab1161015957806342842e0e1161013357806342842e0e146102d25780635bbb2177146102f25780635f5168361461031f5780636352211e1461033f57600080fd5b8063345a17ab1461029957806340471768146102ac57806341b798f3146102bf57600080fd5b8063095ea7b31161018a578063095ea7b31461023657806318160ddd1461025657806323b872dd1461027957600080fd5b806306fdde03146101b157806307c7820d146101dc578063081812fc146101fe575b600080fd5b3480156101bd57600080fd5b506101c6610559565b6040516101d39190612e73565b60405180910390f35b3480156101e857600080fd5b506101fc6101f7366004612f4e565b6105fb565b005b34801561020a57600080fd5b5061021e610219366004613004565b6108b1565b6040516001600160a01b0390911681526020016101d3565b34801561024257600080fd5b506101fc61025136600461301d565b610914565b34801561026257600080fd5b5061026b6109d3565b6040519081526020016101d3565b34801561028557600080fd5b506101fc610294366004613047565b610a0d565b6101fc6102a7366004613083565b610c24565b6101fc6102ba36600461301d565b610de6565b6101fc6102cd366004613004565b610f5d565b3480156102de57600080fd5b506101fc6102ed366004613047565b61102a565b3480156102fe57600080fd5b5061031261030d3660046130d2565b611045565b6040516101d39190613147565b34801561032b57600080fd5b5061026b61033a366004613004565b611113565b34801561034b57600080fd5b5061021e61035a366004613004565b611146565b34801561036b57600080fd5b5061026b61037a366004613004565b611151565b34801561038b57600080fd5b5061026b61039a3660046131c4565b611187565b3480156103ab57600080fd5b506103bf6103ba3660046131c4565b611192565b6040516101d391906131df565b6101fc61129b565b3480156103e057600080fd5b506101c6611346565b3480156103f557600080fd5b5061026b611365565b34801561040a57600080fd5b506103bf610419366004613217565b611387565b34801561042a57600080fd5b506101fc61043936600461324a565b61151c565b34801561044a57600080fd5b5061026b610459366004613004565b60009081527fc0de19833efd7d5b09ceaad2cd6f95a78a4885115f30489321bc7bfaae8c6cc5602052604090205490565b34801561049657600080fd5b506101fc6104a5366004613286565b6115a7565b3480156104b657600080fd5b506104ca6104c5366004613004565b6115eb565b6040516101d39190613302565b3480156104e357600080fd5b507f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc195415155b60405190151581526020016101d3565b34801561052557600080fd5b50610509610534366004613347565b611680565b34801561054557600080fd5b5061026b61055436600461337a565b6116cd565b606060008051602061376a83398151915260020180546105789061339c565b80601f01602080910402602001604051908101604052809291908181526020018280546105a49061339c565b80156105f15780601f106105c6576101008083540402835291602001916105f1565b820191906000526020600020905b8154815290600101906020018083116105d457829003601f168201915b5050505050905090565b60008051602061389b83398151915254610100900460ff166106305760008051602061389b8339815191525460ff1615610634565b303b155b6106ab5760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a656400000000000000000060648201526084015b60405180910390fd5b60008051602061389b83398151915254610100900460ff161580156106e75760008051602061389b833981519152805461ffff19166101011790555b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600301546001600160a01b031633148061072157503330145b61075b5760405162461bcd60e51b815260206004820152600b60248201526a1393d517d0531313d5d15160aa1b60448201526064016106a2565b6107658a8a611751565b610770888888611849565b6107a66380ac58cd60e01b60017f326d0c59a7612f6a9919e2a8ee333c80ba689d8ba2634de89c85cbb04832e7055b9190611934565b6107d9635b5e139f60e01b60017f326d0c59a7612f6a9919e2a8ee333c80ba689d8ba2634de89c85cbb04832e70561079f565b60008051602061374a8339815191528590557f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1384905560008051602061384483398151915280546001600160a01b038581166101000274ffffffffffffffffffffffffffffffffffffffff0019909216919091179091557f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1680546001600160a01b03191691841691909117905580156108a55760008051602061389b833981519152805461ff00191690555b50505050505050505050565b60006108bc826119bc565b6108d9576040516333d1c03960e21b815260040160405180910390fd5b5060009081527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4660205260409020546001600160a01b031690565b600061091f82611146565b9050336001600160a01b038216146109585761093b8133611680565b610958576040516367d9dca160e11b815260040160405180910390fd5b60008281527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c46602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c415460008051602061376a83398151915254036000190190565b6000610a1882611a0b565b9050836001600160a01b0316816001600160a01b031614610a4b5760405162a1148160e81b815260040160405180910390fd5b60008281527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c46602052604090208054338082146001600160a01b03881690911417610ab757610a9a8633611680565b610ab757604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610ade57604051633a954ecd60e21b815260040160405180910390fd5b610aea86866001611aa1565b8015610af557600082555b6001600160a01b0386811660009081527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b1760008581526000805160206138048339815191526020526040812091909155600160e11b84169003610bda5760018401600081815260008051602061380483398151915260205260408120549003610bd85760008051602061376a833981519152548114610bd8576000818152600080516020613804833981519152602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b7ffad169404002d10c88c6f4c5df96a5ae8d3cada85765079fe73839a09bf6887c8054816000610c53836133ec565b909155505080546000805160206138448339815191525460008051602061374a8339815191529060009060ff166003811115610c9157610c91613405565b03610caf5760405163589ed34b60e01b815260040160405180910390fd5b610d267fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600301546040516bffffffffffffffffffffffff193360601b166020820152603481018b90526001600160a01b039091169060540160405160208183030381529060405280519060200120888888611aea565b610d435760405163c5ad1c2d60e01b815260040160405180910390fd5b3360009081526002820160205260409020548881101580610d6c575087610d6a828b61341b565b105b15610d8a5760405163993a3f1960e01b815260040160405180910390fd5b336000908152600283016020526040812080548a9290610dab908490613432565b90915550610dbb90503389611baa565b505081548114610ddd5760405162461bcd60e51b81526004016106a29061344a565b50505050505050565b60008051602061374a8339815191526003015461010090046001600160a01b03163314610e2657604051633693b8ad60e21b815260040160405180910390fd5b7ffad169404002d10c88c6f4c5df96a5ae8d3cada85765079fe73839a09bf6887c8054816000610e55836133ec565b909155505080546000805160206138448339815191525460008051602061374a8339815191529060009060ff166003811115610e9357610e93613405565b03610eb15760405163589ed34b60e01b815260040160405180910390fd5b600381015461010090046001600160a01b03163314610ee357604051633693b8ad60e21b815260040160405180910390fd5b837fc0de19833efd7d5b09ceaad2cd6f95a78a4885115f30489321bc7bfaae8c6cc56000610f0f6109d3565b610f1a906001613432565b8152602081019190915260400160002055610f36856001611baa565b5081548114610f575760405162461bcd60e51b81526004016106a29061344a565b50505050565b7ffad169404002d10c88c6f4c5df96a5ae8d3cada85765079fe73839a09bf6887c8054816000610f8c836133ec565b909155505080546005831115610fb557604051634d7b2b4f60e11b815260040160405180910390fd5b6000805160206138448339815191525460029060ff166003811115610fdc57610fdc613405565b1015610ffb5760405163589ed34b60e01b815260040160405180910390fd5b6110053384611baa565b815481146110255760405162461bcd60e51b81526004016106a29061344a565b505050565b611025838383604051806020016040528060008152506115a7565b60608160008167ffffffffffffffff81111561106357611063612e86565b6040519080825280602002602001820160405280156110b557816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816110815790505b50905060005b828114611108576110e38686838181106110d7576110d761349c565b905060200201356115eb565b8282815181106110f5576110f561349c565b60209081029190910101526001016110bb565b509150505b92915050565b60008181527f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc17602052604081205461110d565b600061110d82611c7b565b7f6274e8f192ab78a829cd26c8af820e69bcc6a3dd6115505f3ba930ecdbf329e354600090670de0b6b3a764000083020561110d565b600061110d82611c86565b606060008060006111a285611187565b905060008167ffffffffffffffff8111156111bf576111bf612e86565b6040519080825280602002602001820160405280156111e8578160200160208202803683370190505b50905061121560408051608081018252600080825260208201819052918101829052606081019190915290565b60015b83861461128f5761122881611cf4565b915081606001516112875781516001600160a01b03161561124857815194505b876001600160a01b0316856001600160a01b031603611287578083878060010198508151811061127a5761127a61349c565b6020026020010181815250505b600101611218565b50909695505050505050565b7ffad169404002d10c88c6f4c5df96a5ae8d3cada85765079fe73839a09bf6887c80548160006112ca836133ec565b909155505080546000805160206138448339815191525460029060ff1660038111156112f8576112f8613405565b10156113175760405163589ed34b60e01b815260040160405180910390fd5b611322336001611baa565b815481146113425760405162461bcd60e51b81526004016106a29061344a565b5050565b606060008051602061376a83398151915260030180546105789061339c565b60006113826113726109d3565b61137d906001613432565b611d3a565b905090565b60608183106113a957604051631960ccad60e11b815260040160405180910390fd5b6000806113c260008051602061376a8339815191525490565b905060018510156113d257600194505b808411156113de578093505b60006113e987611187565b9050848610156114085785850381811015611402578091505b5061140c565b5060005b60008167ffffffffffffffff81111561142757611427612e86565b604051908082528060200260200182016040528015611450578160200160208202803683370190505b5090508160000361146657935061151592505050565b6000611471886115eb565b905060008160600151611482575080515b885b8881141580156114945750848714155b15611509576114a281611cf4565b925082606001516115015782516001600160a01b0316156114c257825191505b8a6001600160a01b0316826001600160a01b03160361150157808488806001019950815181106114f4576114f461349c565b6020026020010181815250505b600101611484565b50505092835250909150505b9392505050565b3360008181527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c47602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6115b2848484610a0d565b6001600160a01b0383163b15610f57576115ce84848484611dea565b610f57576040516368d2bf6b60e11b815260040160405180910390fd5b6040805160808101825260008082526020820181905291810182905260608101919091526040805160808101825260008082526020820181905291810182905260608101919091526001831080611651575060008051602061376a833981519152548310155b1561165c5792915050565b61166583611cf4565b90508060600151156116775792915050565b61151583611ed5565b6001600160a01b0391821660009081527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c476020908152604080832093909416825291909152205460ff1690565b60006115157fa6f742f8f5291196af705ca3ffc8e9f07c6bb403cf29b42dd803d30aa44908185461174c6117477fa6f742f8f5291196af705ca3ffc8e9f07c6bb403cf29b42dd803d30aa44908186001015461173661037a88600101670de0b6b3a76400000290565b8803670de0b6b3a764000091020590565b611f0a565b6120c4565b60008051602061389b83398151915254610100900460ff166117db5760405162461bcd60e51b815260206004820152603460248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f206973206e6f7420696e697469616c697a696e6700000000000000000000000060648201526084016106a2565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4261180683826134f8565b507f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4361183282826134f8565b50600160008051602061376a833981519152555050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600301546001600160a01b031633148061188357503330145b6118bd5760405162461bcd60e51b815260206004820152600b60248201526a1393d517d0531313d5d15160aa1b60448201526064016106a2565b8282611905826118dd6118d884670de0b6b3a76400006135b8565b6120e9565b7fa6f742f8f5291196af705ca3ffc8e9f07c6bb403cf29b42dd803d30aa44908189190612320565b61192d837f6274e8f192ab78a829cd26c8af820e69bcc6a3dd6115505f3ba930ecdbf329e355565b5050505050565b6001600160e01b0319808316900361198e5760405162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e746572666163652069640000000060448201526064016106a2565b6001600160e01b03199190911660009081526020929092526040909120805460ff1916911515919091179055565b6000816001111580156119dd575060008051602061376a8339815191525482105b801561110d57505060009081526000805160206138048339815191526020526040902054600160e01b161590565b60008180600111611a885760008051602061376a83398151915254811015611a88576000818152600080516020613804833981519152602052604081205490600160e01b82169003611a86575b8060000361151557506000190160008181526000805160206138048339815191526020526040902054611a58565b505b604051636f96cda160e11b815260040160405180910390fd5b6110258383611ae5846040518060400160405280601f81526020017f455243373231413a20616d6f756e74206578636565647320393620626974730081525061237b565b6123b3565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101859052600090600190605c0160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015611b81573d6000803e3d6000fd5b505050602060405103516001600160a01b0316866001600160a01b031614905095945050505050565b6000611bb683836125b9565b905080341015611bdc5760405163112f287b60e01b8152600481018290526024016106a2565b8015611025576000611bec612842565b6001600160a01b03166108fc839081150290604051600060405180830381858888f19350505050905080611c3357604051632ee66eed60e01b815260040160405180910390fd5b6000611c3f833461341b565b1115610f5757336108fc611c53843461341b565b6040518115909202916000818181858888f1935050505015801561192d573d6000803e3d6000fd5b600061110d82611a0b565b60006001600160a01b038216611caf576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b031660009081527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c45602052604090205467ffffffffffffffff1690565b6040805160808101825260008082526020808301829052828401829052606083018290528482526000805160206138048339815191529052919091205461110d906128a4565b7f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1354600090821115611dd55761110d611d9e60008051602061374a83398151915260070154611d89904261341b565b62015180670de0b6b3a7640000919091020490565b7f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1354611dcb60018661341b565b610554919061341b565b505060008051602061374a8339815191525490565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290611e1f9033908990889088906004016135f7565b6020604051808303816000875af1925050508015611e5a575060408051601f3d908101601f19168201909252611e5791810190613633565b60015b611eb8573d808015611e88576040519150601f19603f3d011682016040523d82523d6000602084013e611e8d565b606091505b508051600003611eb0576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915261110d611f0583611a0b565b6128a4565b6000680248ce36a70cb26b3e198213611f2557506000919050565b680755bf798b4a1bf1e58212611f6c5760405162461bcd60e51b815260206004820152600c60248201526b4558505f4f564552464c4f5760a01b60448201526064016106a2565b6503782dace9d9604e83901b059150600060606bb17217f7d1cf79abc9e3b39884821b056b80000000000000000000000001901d6bb17217f7d1cf79abc9e3b39881029093036c240c330e9fb2d9cbaf0fd5aafb1981018102606090811d6d0277594991cfc85f6e2461837cd9018202811d6d1a521255e34f6a5061b25ef1c9c319018202811d6db1bbb201f443cf962f1a1d3db4a5018202811d6e02c72388d9f74f51a9331fed693f1419018202811d6e05180bb14799ab47a8a8cb2a527d57016d02d16720577bd19bf614176fe9ea6c10fe68e7fd37d0007b713f765084018402831d9081019084016d01d3967ed30fc4f89c02bab5708119010290911d6e0587f503bb6ea29d25fcb7401964500190910279d835ebba824c98fb31b83b2ca45c000000000000000000000000010574029d9dc38563c32e5c2f6dc192ee70ef65f9978af30260c3939093039290921c92915050565b81810282158382058314176120d857600080fd5b670de0b6b3a7640000900592915050565b60008082136121265760405162461bcd60e51b815260206004820152600960248201526815539111519253915160ba1b60448201526064016106a2565b5060606fffffffffffffffffffffffffffffffff821160071b82811c67ffffffffffffffff1060061b1782811c63ffffffff1060051b1782811c61ffff1060041b1782811c60ff10600390811b90911783811c600f1060021b1783811c909110600190811b90911783811c90911017609f81810383019390931b90921c6c465772b2bbbb5f824b15207a3081018102821d6d0388eaa27412d5aca026815d636e018102821d6d0df99ac502031bf953eff472fdcc018102821d6d13cdffb29d51d99322bdff5f2211018102821d6d0a0f742023def783a307a986912e018102821d6d01920d8043ca89b5239253284e42018102821d6c0b7a86d7375468fac667a0a527016c29508e458543d8aa4df2abee7882018202831d6d0139601a2efabe717e604cbb4894018202831d6d02247f7a7b6594320649aa03aba1018202831d6c8c3f38e95a6b1ff2ab1c3b343619018202831d6d02384773bdf1ac5676facced60901901820290921d6cb9a025d814b29c212b8b1a07cd190102780a09507084cc699bb0e71ea869ffffffffffffffffffffffff190105711340daa0d5f769dba1915cef59f0815a550602605f19919091017d0267a36c0c95b3975ab3ee5b203a7614a3f75373f047d803ae7b6687f2b302017d57115e47018c7177eebf7cd370a3356a1b7863008a5ae8028c72b88642840160ae1d90565b600081126123705760405162461bcd60e51b815260206004820152601b60248201527f4e4f4e5f4e454741544956455f44454341595f434f4e5354414e54000000000060448201526064016106a2565b908255600190910155565b6000816c0100000000000000000000000084106123ab5760405162461bcd60e51b81526004016106a29190612e73565b509192915050565b816001600160a01b0316836001600160a01b0316141580156123de57506000816001600160601b0316115b15611025576001600160a01b038316156124d0576001600160a01b03831660009081527fbf149371ad903781495253afdb39db7e533d0ab4edf7988855c9f8730e36298b602052604081205463ffffffff16908161243d576000612497565b6001600160a01b0385166000908152600080516020613824833981519152602052604081209061246e600185613673565b63ffffffff16815260208101919091526040016000205464010000000090046001600160601b03165b905060006124be8285604051806060016040528060378152602001613864603791396128e9565b90506124cc86848484612933565b5050505b6001600160a01b03821615611025576001600160a01b03821660009081527fbf149371ad903781495253afdb39db7e533d0ab4edf7988855c9f8730e36298b602052604081205463ffffffff16908161252a576000612584565b6001600160a01b0384166000908152600080516020613824833981519152602052604081209061255b600185613673565b63ffffffff16815260208101919091526040016000205464010000000090046001600160601b03165b905060006125ab828560405180606001604052806036815260200161378a60369139612b73565b9050610c1c85848484612933565b6000816000036125dc57604051631f2a200560e01b815260040160405180910390fd5b60008051602061374a8339815191527fc0de19833efd7d5b09ceaad2cd6f95a78a4885115f30489321bc7bfaae8c6cc260006126166109d3565b612621906001613432565b9050826007015460001480156126505750600180840154906126438784613432565b61264d919061341b565b10155b1561266c574260078401556003808401805460ff191690911790555b60008060005b8781101561280c577f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc188054604080516020808201939093526bffffffffffffffffffffffff1960608e811b821683850152605483018a905241901b166074820152426088808301919091528251808303909101815260a890910182528051908301209283905560008781527f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc17909252902055845460048601546001600160a01b039091169063156e29f6903090879061274a82612bc0565b6127549190613698565b6040516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091526044820152606401600060405180830381600087803b1580156127a257600080fd5b505af11580156127b6573d6000803e3d6000fd5b505050506127c384611d3a565b6127cd9083613432565b91506127da600a856136b7565b6000036127ef57826127eb816133ec565b9350505b6127f8846133ec565b935080612804816133ec565b915050612672565b506128178888612c14565b8115612837576004850154612835906001600160a01b0316836125b9565b505b979650505050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b0316806128a157507fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f546001600160a01b031690565b90565b604080516080810182526001600160a01b038316815260a083901c67ffffffffffffffff166020820152600160e01b83161515606082015260e89290921c9082015290565b6000836001600160601b0316836001600160601b0316111582906129205760405162461bcd60e51b81526004016106a29190612e73565b5061292b83856136cb565b949350505050565b6000612957436040518060800160405280604481526020016137c060449139612c2e565b905060008463ffffffff161180156129be57506001600160a01b03851660009081526000805160206138248339815191526020526040812063ffffffff8316916129a2600188613673565b63ffffffff908116825260208201929092526040016000205416145b15612a40576001600160a01b03851660009081526000805160206138248339815191526020526040812083916129f5600188613673565b63ffffffff168152602081019190915260400160002080546001600160601b0392909216640100000000026fffffffffffffffffffffffff0000000019909216919091179055612b1e565b60408051808201825263ffffffff83811682526001600160601b0385811660208085019182526001600160a01b038b16600090815260008051602061382483398151915282528681208b8616825290915294909420925183549451909116640100000000026fffffffffffffffffffffffffffffffff19909416911617919091179055612ace8460016136eb565b6001600160a01b03861660009081527fbf149371ad903781495253afdb39db7e533d0ab4edf7988855c9f8730e36298b60205260409020805463ffffffff191663ffffffff929092169190911790555b604080516001600160601b038086168252841660208201526001600160a01b038716917fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724910160405180910390a25050505050565b600080612b808486613713565b9050846001600160601b0316816001600160601b031610158390612bb75760405162461bcd60e51b81526004016106a29190612e73565b50949350505050565b60008181527f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1760205260408120548190612bfc906015906136b7565b9050612c09600482613735565b611515906001613432565b611342828260405180602001604052806000815250612c56565b60008164010000000084106123ab5760405162461bcd60e51b81526004016106a29190612e73565b612c608383612cd6565b6001600160a01b0383163b156110255760008051602061376a833981519152548281035b612c976000868380600101945086611dea565b612cb4576040516368d2bf6b60e11b815260040160405180910390fd5b818110612c84578160008051602061376a833981519152541461192d57600080fd5b60008051602061376a833981519152546000829003612d085760405163b562e8dd60e01b815260040160405180910390fd5b612d1460008484611aa1565b6001600160a01b03831660008181527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4560209081526040808320805468010000000000000001880201905584835260008051602061380483398151915290915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b818114612def57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101612db7565b5081600003612e1057604051622e076360e81b815260040160405180910390fd5b60008051602061376a8339815191525550505050565b6000815180845260005b81811015612e4c57602081850181015186830182015201612e30565b81811115612e5e576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006115156020830184612e26565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115612eb757612eb7612e86565b604051601f8501601f19908116603f01168101908282118183101715612edf57612edf612e86565b81604052809350858152868686011115612ef857600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112612f2357600080fd5b61151583833560208501612e9c565b80356001600160a01b0381168114612f4957600080fd5b919050565b60008060008060008060008060006101208a8c031215612f6d57600080fd5b893567ffffffffffffffff80821115612f8557600080fd5b612f918d838e01612f12565b9a5060208c0135915080821115612fa757600080fd5b50612fb48c828d01612f12565b98505060408a0135965060608a0135955060808a0135945060a08a0135935060c08a01359250612fe660e08b01612f32565b9150612ff56101008b01612f32565b90509295985092959850929598565b60006020828403121561301657600080fd5b5035919050565b6000806040838503121561303057600080fd5b61303983612f32565b946020939093013593505050565b60008060006060848603121561305c57600080fd5b61306584612f32565b925061307360208501612f32565b9150604084013590509250925092565b600080600080600060a0868803121561309b57600080fd5b8535945060208601359350604086013560ff811681146130ba57600080fd5b94979396509394606081013594506080013592915050565b600080602083850312156130e557600080fd5b823567ffffffffffffffff808211156130fd57600080fd5b818501915085601f83011261311157600080fd5b81358181111561312057600080fd5b8660208260051b850101111561313557600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b8181101561128f576131b18385516001600160a01b03815116825267ffffffffffffffff602082015116602083015262ffffff60408201511660408301526060810151151560608301525050565b9284019260809290920191600101613163565b6000602082840312156131d657600080fd5b61151582612f32565b6020808252825182820181905260009190848201906040850190845b8181101561128f578351835292840192918401916001016131fb565b60008060006060848603121561322c57600080fd5b61323584612f32565b95602085013595506040909401359392505050565b6000806040838503121561325d57600080fd5b61326683612f32565b91506020830135801515811461327b57600080fd5b809150509250929050565b6000806000806080858703121561329c57600080fd5b6132a585612f32565b93506132b360208601612f32565b925060408501359150606085013567ffffffffffffffff8111156132d657600080fd5b8501601f810187136132e757600080fd5b6132f687823560208401612e9c565b91505092959194509250565b81516001600160a01b0316815260208083015167ffffffffffffffff169082015260408083015162ffffff16908201526060808301511515908201526080810161110d565b6000806040838503121561335a57600080fd5b61336383612f32565b915061337160208401612f32565b90509250929050565b6000806040838503121561338d57600080fd5b50508035926020909101359150565b600181811c908216806133b057607f821691505b6020821081036133d057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000600182016133fe576133fe6133d6565b5060010190565b634e487b7160e01b600052602160045260246000fd5b60008282101561342d5761342d6133d6565b500390565b60008219821115613445576134456133d6565b500190565b60208082526032908201527f5265656e74727950726f74656374696f6e46616365742e6e6f5265656e7472796040820152710e881c99595b9d1c9e4819195d1958dd195960721b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b601f82111561102557600081815260208120601f850160051c810160208610156134d95750805b601f850160051c820191505b81811015610c1c578281556001016134e5565b815167ffffffffffffffff81111561351257613512612e86565b61352681613520845461339c565b846134b2565b602080601f83116001811461355b57600084156135435750858301515b600019600386901b1c1916600185901b178555610c1c565b600085815260208120601f198616915b8281101561358a5788860151825594840194600190910190840161356b565b50858210156135a85787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008083128015600160ff1b8501841216156135d6576135d66133d6565b6001600160ff1b03840183138116156135f1576135f16133d6565b50500390565b60006001600160a01b038087168352808616602084015250836040830152608060608301526136296080830184612e26565b9695505050505050565b60006020828403121561364557600080fd5b81516001600160e01b03198116811461151557600080fd5b634e487b7160e01b600052601260045260246000fd5b600063ffffffff83811690831681811015613690576136906133d6565b039392505050565b60008160001904831182151516156136b2576136b26133d6565b500290565b6000826136c6576136c661365d565b500690565b60006001600160601b0383811690831681811015613690576136906133d6565b600063ffffffff80831681851680830382111561370a5761370a6133d6565b01949350505050565b60006001600160601b0380831681851680830382111561370a5761370a6133d6565b6000826137445761374461365d565b50049056fe32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc122569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c40455243373231436865636b706f696e7461626c653a3a5f6d6f766544656c6567617465733a20616d6f756e74206f766572666c6f7773455243373231436865636b706f696e7461626c653a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206578636565647320333220626974732569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c44bf149371ad903781495253afdb39db7e533d0ab4edf7988855c9f8730e36298a32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc15455243373231436865636b706f696e7461626c653a3a5f6d6f766544656c6567617465733a20616d6f756e7420756e646572666c6f7773ee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85fa26469706673582212205c1b28b4a4724a8ee833dd37932bf87fec76af743c7dcd8b750aab240e5b8acc64736f6c634300080f0033
Deployed Bytecode
0x6080604052600436106101ac5760003560e01c80636d9d33b7116100ec578063a22cb4651161008a578063c23dc68f11610064578063c23dc68f146104aa578063dc502efd146104d7578063e985e9c514610519578063f466d4ab1461053957600080fd5b8063a22cb4651461041e578063a8a150b81461043e578063b88d4fde1461048a57600080fd5b80639391b537116100c65780639391b537146103cc57806395d89b41146103d457806398d5fdca146103e957806399a2557a146103fe57600080fd5b80636d9d33b71461035f57806370a082311461037f5780638462151c1461039f57600080fd5b8063345a17ab1161015957806342842e0e1161013357806342842e0e146102d25780635bbb2177146102f25780635f5168361461031f5780636352211e1461033f57600080fd5b8063345a17ab1461029957806340471768146102ac57806341b798f3146102bf57600080fd5b8063095ea7b31161018a578063095ea7b31461023657806318160ddd1461025657806323b872dd1461027957600080fd5b806306fdde03146101b157806307c7820d146101dc578063081812fc146101fe575b600080fd5b3480156101bd57600080fd5b506101c6610559565b6040516101d39190612e73565b60405180910390f35b3480156101e857600080fd5b506101fc6101f7366004612f4e565b6105fb565b005b34801561020a57600080fd5b5061021e610219366004613004565b6108b1565b6040516001600160a01b0390911681526020016101d3565b34801561024257600080fd5b506101fc61025136600461301d565b610914565b34801561026257600080fd5b5061026b6109d3565b6040519081526020016101d3565b34801561028557600080fd5b506101fc610294366004613047565b610a0d565b6101fc6102a7366004613083565b610c24565b6101fc6102ba36600461301d565b610de6565b6101fc6102cd366004613004565b610f5d565b3480156102de57600080fd5b506101fc6102ed366004613047565b61102a565b3480156102fe57600080fd5b5061031261030d3660046130d2565b611045565b6040516101d39190613147565b34801561032b57600080fd5b5061026b61033a366004613004565b611113565b34801561034b57600080fd5b5061021e61035a366004613004565b611146565b34801561036b57600080fd5b5061026b61037a366004613004565b611151565b34801561038b57600080fd5b5061026b61039a3660046131c4565b611187565b3480156103ab57600080fd5b506103bf6103ba3660046131c4565b611192565b6040516101d391906131df565b6101fc61129b565b3480156103e057600080fd5b506101c6611346565b3480156103f557600080fd5b5061026b611365565b34801561040a57600080fd5b506103bf610419366004613217565b611387565b34801561042a57600080fd5b506101fc61043936600461324a565b61151c565b34801561044a57600080fd5b5061026b610459366004613004565b60009081527fc0de19833efd7d5b09ceaad2cd6f95a78a4885115f30489321bc7bfaae8c6cc5602052604090205490565b34801561049657600080fd5b506101fc6104a5366004613286565b6115a7565b3480156104b657600080fd5b506104ca6104c5366004613004565b6115eb565b6040516101d39190613302565b3480156104e357600080fd5b507f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc195415155b60405190151581526020016101d3565b34801561052557600080fd5b50610509610534366004613347565b611680565b34801561054557600080fd5b5061026b61055436600461337a565b6116cd565b606060008051602061376a83398151915260020180546105789061339c565b80601f01602080910402602001604051908101604052809291908181526020018280546105a49061339c565b80156105f15780601f106105c6576101008083540402835291602001916105f1565b820191906000526020600020905b8154815290600101906020018083116105d457829003601f168201915b5050505050905090565b60008051602061389b83398151915254610100900460ff166106305760008051602061389b8339815191525460ff1615610634565b303b155b6106ab5760405162461bcd60e51b815260206004820152603760248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f20697320616c726561647920696e697469616c697a656400000000000000000060648201526084015b60405180910390fd5b60008051602061389b83398151915254610100900460ff161580156106e75760008051602061389b833981519152805461ffff19166101011790555b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600301546001600160a01b031633148061072157503330145b61075b5760405162461bcd60e51b815260206004820152600b60248201526a1393d517d0531313d5d15160aa1b60448201526064016106a2565b6107658a8a611751565b610770888888611849565b6107a66380ac58cd60e01b60017f326d0c59a7612f6a9919e2a8ee333c80ba689d8ba2634de89c85cbb04832e7055b9190611934565b6107d9635b5e139f60e01b60017f326d0c59a7612f6a9919e2a8ee333c80ba689d8ba2634de89c85cbb04832e70561079f565b60008051602061374a8339815191528590557f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1384905560008051602061384483398151915280546001600160a01b038581166101000274ffffffffffffffffffffffffffffffffffffffff0019909216919091179091557f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1680546001600160a01b03191691841691909117905580156108a55760008051602061389b833981519152805461ff00191690555b50505050505050505050565b60006108bc826119bc565b6108d9576040516333d1c03960e21b815260040160405180910390fd5b5060009081527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4660205260409020546001600160a01b031690565b600061091f82611146565b9050336001600160a01b038216146109585761093b8133611680565b610958576040516367d9dca160e11b815260040160405180910390fd5b60008281527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c46602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c415460008051602061376a83398151915254036000190190565b6000610a1882611a0b565b9050836001600160a01b0316816001600160a01b031614610a4b5760405162a1148160e81b815260040160405180910390fd5b60008281527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c46602052604090208054338082146001600160a01b03881690911417610ab757610a9a8633611680565b610ab757604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610ade57604051633a954ecd60e21b815260040160405180910390fd5b610aea86866001611aa1565b8015610af557600082555b6001600160a01b0386811660009081527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b1760008581526000805160206138048339815191526020526040812091909155600160e11b84169003610bda5760018401600081815260008051602061380483398151915260205260408120549003610bd85760008051602061376a833981519152548114610bd8576000818152600080516020613804833981519152602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b7ffad169404002d10c88c6f4c5df96a5ae8d3cada85765079fe73839a09bf6887c8054816000610c53836133ec565b909155505080546000805160206138448339815191525460008051602061374a8339815191529060009060ff166003811115610c9157610c91613405565b03610caf5760405163589ed34b60e01b815260040160405180910390fd5b610d267fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600301546040516bffffffffffffffffffffffff193360601b166020820152603481018b90526001600160a01b039091169060540160405160208183030381529060405280519060200120888888611aea565b610d435760405163c5ad1c2d60e01b815260040160405180910390fd5b3360009081526002820160205260409020548881101580610d6c575087610d6a828b61341b565b105b15610d8a5760405163993a3f1960e01b815260040160405180910390fd5b336000908152600283016020526040812080548a9290610dab908490613432565b90915550610dbb90503389611baa565b505081548114610ddd5760405162461bcd60e51b81526004016106a29061344a565b50505050505050565b60008051602061374a8339815191526003015461010090046001600160a01b03163314610e2657604051633693b8ad60e21b815260040160405180910390fd5b7ffad169404002d10c88c6f4c5df96a5ae8d3cada85765079fe73839a09bf6887c8054816000610e55836133ec565b909155505080546000805160206138448339815191525460008051602061374a8339815191529060009060ff166003811115610e9357610e93613405565b03610eb15760405163589ed34b60e01b815260040160405180910390fd5b600381015461010090046001600160a01b03163314610ee357604051633693b8ad60e21b815260040160405180910390fd5b837fc0de19833efd7d5b09ceaad2cd6f95a78a4885115f30489321bc7bfaae8c6cc56000610f0f6109d3565b610f1a906001613432565b8152602081019190915260400160002055610f36856001611baa565b5081548114610f575760405162461bcd60e51b81526004016106a29061344a565b50505050565b7ffad169404002d10c88c6f4c5df96a5ae8d3cada85765079fe73839a09bf6887c8054816000610f8c836133ec565b909155505080546005831115610fb557604051634d7b2b4f60e11b815260040160405180910390fd5b6000805160206138448339815191525460029060ff166003811115610fdc57610fdc613405565b1015610ffb5760405163589ed34b60e01b815260040160405180910390fd5b6110053384611baa565b815481146110255760405162461bcd60e51b81526004016106a29061344a565b505050565b611025838383604051806020016040528060008152506115a7565b60608160008167ffffffffffffffff81111561106357611063612e86565b6040519080825280602002602001820160405280156110b557816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816110815790505b50905060005b828114611108576110e38686838181106110d7576110d761349c565b905060200201356115eb565b8282815181106110f5576110f561349c565b60209081029190910101526001016110bb565b509150505b92915050565b60008181527f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc17602052604081205461110d565b600061110d82611c7b565b7f6274e8f192ab78a829cd26c8af820e69bcc6a3dd6115505f3ba930ecdbf329e354600090670de0b6b3a764000083020561110d565b600061110d82611c86565b606060008060006111a285611187565b905060008167ffffffffffffffff8111156111bf576111bf612e86565b6040519080825280602002602001820160405280156111e8578160200160208202803683370190505b50905061121560408051608081018252600080825260208201819052918101829052606081019190915290565b60015b83861461128f5761122881611cf4565b915081606001516112875781516001600160a01b03161561124857815194505b876001600160a01b0316856001600160a01b031603611287578083878060010198508151811061127a5761127a61349c565b6020026020010181815250505b600101611218565b50909695505050505050565b7ffad169404002d10c88c6f4c5df96a5ae8d3cada85765079fe73839a09bf6887c80548160006112ca836133ec565b909155505080546000805160206138448339815191525460029060ff1660038111156112f8576112f8613405565b10156113175760405163589ed34b60e01b815260040160405180910390fd5b611322336001611baa565b815481146113425760405162461bcd60e51b81526004016106a29061344a565b5050565b606060008051602061376a83398151915260030180546105789061339c565b60006113826113726109d3565b61137d906001613432565b611d3a565b905090565b60608183106113a957604051631960ccad60e11b815260040160405180910390fd5b6000806113c260008051602061376a8339815191525490565b905060018510156113d257600194505b808411156113de578093505b60006113e987611187565b9050848610156114085785850381811015611402578091505b5061140c565b5060005b60008167ffffffffffffffff81111561142757611427612e86565b604051908082528060200260200182016040528015611450578160200160208202803683370190505b5090508160000361146657935061151592505050565b6000611471886115eb565b905060008160600151611482575080515b885b8881141580156114945750848714155b15611509576114a281611cf4565b925082606001516115015782516001600160a01b0316156114c257825191505b8a6001600160a01b0316826001600160a01b03160361150157808488806001019950815181106114f4576114f461349c565b6020026020010181815250505b600101611484565b50505092835250909150505b9392505050565b3360008181527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c47602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6115b2848484610a0d565b6001600160a01b0383163b15610f57576115ce84848484611dea565b610f57576040516368d2bf6b60e11b815260040160405180910390fd5b6040805160808101825260008082526020820181905291810182905260608101919091526040805160808101825260008082526020820181905291810182905260608101919091526001831080611651575060008051602061376a833981519152548310155b1561165c5792915050565b61166583611cf4565b90508060600151156116775792915050565b61151583611ed5565b6001600160a01b0391821660009081527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c476020908152604080832093909416825291909152205460ff1690565b60006115157fa6f742f8f5291196af705ca3ffc8e9f07c6bb403cf29b42dd803d30aa44908185461174c6117477fa6f742f8f5291196af705ca3ffc8e9f07c6bb403cf29b42dd803d30aa44908186001015461173661037a88600101670de0b6b3a76400000290565b8803670de0b6b3a764000091020590565b611f0a565b6120c4565b60008051602061389b83398151915254610100900460ff166117db5760405162461bcd60e51b815260206004820152603460248201527f455243373231415f5f496e697469616c697a61626c653a20636f6e747261637460448201527f206973206e6f7420696e697469616c697a696e6700000000000000000000000060648201526084016106a2565b7f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4261180683826134f8565b507f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4361183282826134f8565b50600160008051602061376a833981519152555050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600301546001600160a01b031633148061188357503330145b6118bd5760405162461bcd60e51b815260206004820152600b60248201526a1393d517d0531313d5d15160aa1b60448201526064016106a2565b8282611905826118dd6118d884670de0b6b3a76400006135b8565b6120e9565b7fa6f742f8f5291196af705ca3ffc8e9f07c6bb403cf29b42dd803d30aa44908189190612320565b61192d837f6274e8f192ab78a829cd26c8af820e69bcc6a3dd6115505f3ba930ecdbf329e355565b5050505050565b6001600160e01b0319808316900361198e5760405162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e746572666163652069640000000060448201526064016106a2565b6001600160e01b03199190911660009081526020929092526040909120805460ff1916911515919091179055565b6000816001111580156119dd575060008051602061376a8339815191525482105b801561110d57505060009081526000805160206138048339815191526020526040902054600160e01b161590565b60008180600111611a885760008051602061376a83398151915254811015611a88576000818152600080516020613804833981519152602052604081205490600160e01b82169003611a86575b8060000361151557506000190160008181526000805160206138048339815191526020526040902054611a58565b505b604051636f96cda160e11b815260040160405180910390fd5b6110258383611ae5846040518060400160405280601f81526020017f455243373231413a20616d6f756e74206578636565647320393620626974730081525061237b565b6123b3565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101859052600090600190605c0160408051601f198184030181528282528051602091820120600084529083018083525260ff871690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015611b81573d6000803e3d6000fd5b505050602060405103516001600160a01b0316866001600160a01b031614905095945050505050565b6000611bb683836125b9565b905080341015611bdc5760405163112f287b60e01b8152600481018290526024016106a2565b8015611025576000611bec612842565b6001600160a01b03166108fc839081150290604051600060405180830381858888f19350505050905080611c3357604051632ee66eed60e01b815260040160405180910390fd5b6000611c3f833461341b565b1115610f5757336108fc611c53843461341b565b6040518115909202916000818181858888f1935050505015801561192d573d6000803e3d6000fd5b600061110d82611a0b565b60006001600160a01b038216611caf576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b031660009081527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c45602052604090205467ffffffffffffffff1690565b6040805160808101825260008082526020808301829052828401829052606083018290528482526000805160206138048339815191529052919091205461110d906128a4565b7f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1354600090821115611dd55761110d611d9e60008051602061374a83398151915260070154611d89904261341b565b62015180670de0b6b3a7640000919091020490565b7f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1354611dcb60018661341b565b610554919061341b565b505060008051602061374a8339815191525490565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290611e1f9033908990889088906004016135f7565b6020604051808303816000875af1925050508015611e5a575060408051601f3d908101601f19168201909252611e5791810190613633565b60015b611eb8573d808015611e88576040519150601f19603f3d011682016040523d82523d6000602084013e611e8d565b606091505b508051600003611eb0576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b60408051608081018252600080825260208201819052918101829052606081019190915261110d611f0583611a0b565b6128a4565b6000680248ce36a70cb26b3e198213611f2557506000919050565b680755bf798b4a1bf1e58212611f6c5760405162461bcd60e51b815260206004820152600c60248201526b4558505f4f564552464c4f5760a01b60448201526064016106a2565b6503782dace9d9604e83901b059150600060606bb17217f7d1cf79abc9e3b39884821b056b80000000000000000000000001901d6bb17217f7d1cf79abc9e3b39881029093036c240c330e9fb2d9cbaf0fd5aafb1981018102606090811d6d0277594991cfc85f6e2461837cd9018202811d6d1a521255e34f6a5061b25ef1c9c319018202811d6db1bbb201f443cf962f1a1d3db4a5018202811d6e02c72388d9f74f51a9331fed693f1419018202811d6e05180bb14799ab47a8a8cb2a527d57016d02d16720577bd19bf614176fe9ea6c10fe68e7fd37d0007b713f765084018402831d9081019084016d01d3967ed30fc4f89c02bab5708119010290911d6e0587f503bb6ea29d25fcb7401964500190910279d835ebba824c98fb31b83b2ca45c000000000000000000000000010574029d9dc38563c32e5c2f6dc192ee70ef65f9978af30260c3939093039290921c92915050565b81810282158382058314176120d857600080fd5b670de0b6b3a7640000900592915050565b60008082136121265760405162461bcd60e51b815260206004820152600960248201526815539111519253915160ba1b60448201526064016106a2565b5060606fffffffffffffffffffffffffffffffff821160071b82811c67ffffffffffffffff1060061b1782811c63ffffffff1060051b1782811c61ffff1060041b1782811c60ff10600390811b90911783811c600f1060021b1783811c909110600190811b90911783811c90911017609f81810383019390931b90921c6c465772b2bbbb5f824b15207a3081018102821d6d0388eaa27412d5aca026815d636e018102821d6d0df99ac502031bf953eff472fdcc018102821d6d13cdffb29d51d99322bdff5f2211018102821d6d0a0f742023def783a307a986912e018102821d6d01920d8043ca89b5239253284e42018102821d6c0b7a86d7375468fac667a0a527016c29508e458543d8aa4df2abee7882018202831d6d0139601a2efabe717e604cbb4894018202831d6d02247f7a7b6594320649aa03aba1018202831d6c8c3f38e95a6b1ff2ab1c3b343619018202831d6d02384773bdf1ac5676facced60901901820290921d6cb9a025d814b29c212b8b1a07cd190102780a09507084cc699bb0e71ea869ffffffffffffffffffffffff190105711340daa0d5f769dba1915cef59f0815a550602605f19919091017d0267a36c0c95b3975ab3ee5b203a7614a3f75373f047d803ae7b6687f2b302017d57115e47018c7177eebf7cd370a3356a1b7863008a5ae8028c72b88642840160ae1d90565b600081126123705760405162461bcd60e51b815260206004820152601b60248201527f4e4f4e5f4e454741544956455f44454341595f434f4e5354414e54000000000060448201526064016106a2565b908255600190910155565b6000816c0100000000000000000000000084106123ab5760405162461bcd60e51b81526004016106a29190612e73565b509192915050565b816001600160a01b0316836001600160a01b0316141580156123de57506000816001600160601b0316115b15611025576001600160a01b038316156124d0576001600160a01b03831660009081527fbf149371ad903781495253afdb39db7e533d0ab4edf7988855c9f8730e36298b602052604081205463ffffffff16908161243d576000612497565b6001600160a01b0385166000908152600080516020613824833981519152602052604081209061246e600185613673565b63ffffffff16815260208101919091526040016000205464010000000090046001600160601b03165b905060006124be8285604051806060016040528060378152602001613864603791396128e9565b90506124cc86848484612933565b5050505b6001600160a01b03821615611025576001600160a01b03821660009081527fbf149371ad903781495253afdb39db7e533d0ab4edf7988855c9f8730e36298b602052604081205463ffffffff16908161252a576000612584565b6001600160a01b0384166000908152600080516020613824833981519152602052604081209061255b600185613673565b63ffffffff16815260208101919091526040016000205464010000000090046001600160601b03165b905060006125ab828560405180606001604052806036815260200161378a60369139612b73565b9050610c1c85848484612933565b6000816000036125dc57604051631f2a200560e01b815260040160405180910390fd5b60008051602061374a8339815191527fc0de19833efd7d5b09ceaad2cd6f95a78a4885115f30489321bc7bfaae8c6cc260006126166109d3565b612621906001613432565b9050826007015460001480156126505750600180840154906126438784613432565b61264d919061341b565b10155b1561266c574260078401556003808401805460ff191690911790555b60008060005b8781101561280c577f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc188054604080516020808201939093526bffffffffffffffffffffffff1960608e811b821683850152605483018a905241901b166074820152426088808301919091528251808303909101815260a890910182528051908301209283905560008781527f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc17909252902055845460048601546001600160a01b039091169063156e29f6903090879061274a82612bc0565b6127549190613698565b6040516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091526044820152606401600060405180830381600087803b1580156127a257600080fd5b505af11580156127b6573d6000803e3d6000fd5b505050506127c384611d3a565b6127cd9083613432565b91506127da600a856136b7565b6000036127ef57826127eb816133ec565b9350505b6127f8846133ec565b935080612804816133ec565b915050612672565b506128178888612c14565b8115612837576004850154612835906001600160a01b0316836125b9565b505b979650505050505050565b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b0316806128a157507fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131f546001600160a01b031690565b90565b604080516080810182526001600160a01b038316815260a083901c67ffffffffffffffff166020820152600160e01b83161515606082015260e89290921c9082015290565b6000836001600160601b0316836001600160601b0316111582906129205760405162461bcd60e51b81526004016106a29190612e73565b5061292b83856136cb565b949350505050565b6000612957436040518060800160405280604481526020016137c060449139612c2e565b905060008463ffffffff161180156129be57506001600160a01b03851660009081526000805160206138248339815191526020526040812063ffffffff8316916129a2600188613673565b63ffffffff908116825260208201929092526040016000205416145b15612a40576001600160a01b03851660009081526000805160206138248339815191526020526040812083916129f5600188613673565b63ffffffff168152602081019190915260400160002080546001600160601b0392909216640100000000026fffffffffffffffffffffffff0000000019909216919091179055612b1e565b60408051808201825263ffffffff83811682526001600160601b0385811660208085019182526001600160a01b038b16600090815260008051602061382483398151915282528681208b8616825290915294909420925183549451909116640100000000026fffffffffffffffffffffffffffffffff19909416911617919091179055612ace8460016136eb565b6001600160a01b03861660009081527fbf149371ad903781495253afdb39db7e533d0ab4edf7988855c9f8730e36298b60205260409020805463ffffffff191663ffffffff929092169190911790555b604080516001600160601b038086168252841660208201526001600160a01b038716917fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724910160405180910390a25050505050565b600080612b808486613713565b9050846001600160601b0316816001600160601b031610158390612bb75760405162461bcd60e51b81526004016106a29190612e73565b50949350505050565b60008181527f32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc1760205260408120548190612bfc906015906136b7565b9050612c09600482613735565b611515906001613432565b611342828260405180602001604052806000815250612c56565b60008164010000000084106123ab5760405162461bcd60e51b81526004016106a29190612e73565b612c608383612cd6565b6001600160a01b0383163b156110255760008051602061376a833981519152548281035b612c976000868380600101945086611dea565b612cb4576040516368d2bf6b60e11b815260040160405180910390fd5b818110612c84578160008051602061376a833981519152541461192d57600080fd5b60008051602061376a833981519152546000829003612d085760405163b562e8dd60e01b815260040160405180910390fd5b612d1460008484611aa1565b6001600160a01b03831660008181527f2569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c4560209081526040808320805468010000000000000001880201905584835260008051602061380483398151915290915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b818114612def57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101612db7565b5081600003612e1057604051622e076360e81b815260040160405180910390fd5b60008051602061376a8339815191525550505050565b6000815180845260005b81811015612e4c57602081850181015186830182015201612e30565b81811115612e5e576000602083870101525b50601f01601f19169290920160200192915050565b6020815260006115156020830184612e26565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115612eb757612eb7612e86565b604051601f8501601f19908116603f01168101908282118183101715612edf57612edf612e86565b81604052809350858152868686011115612ef857600080fd5b858560208301376000602087830101525050509392505050565b600082601f830112612f2357600080fd5b61151583833560208501612e9c565b80356001600160a01b0381168114612f4957600080fd5b919050565b60008060008060008060008060006101208a8c031215612f6d57600080fd5b893567ffffffffffffffff80821115612f8557600080fd5b612f918d838e01612f12565b9a5060208c0135915080821115612fa757600080fd5b50612fb48c828d01612f12565b98505060408a0135965060608a0135955060808a0135945060a08a0135935060c08a01359250612fe660e08b01612f32565b9150612ff56101008b01612f32565b90509295985092959850929598565b60006020828403121561301657600080fd5b5035919050565b6000806040838503121561303057600080fd5b61303983612f32565b946020939093013593505050565b60008060006060848603121561305c57600080fd5b61306584612f32565b925061307360208501612f32565b9150604084013590509250925092565b600080600080600060a0868803121561309b57600080fd5b8535945060208601359350604086013560ff811681146130ba57600080fd5b94979396509394606081013594506080013592915050565b600080602083850312156130e557600080fd5b823567ffffffffffffffff808211156130fd57600080fd5b818501915085601f83011261311157600080fd5b81358181111561312057600080fd5b8660208260051b850101111561313557600080fd5b60209290920196919550909350505050565b6020808252825182820181905260009190848201906040850190845b8181101561128f576131b18385516001600160a01b03815116825267ffffffffffffffff602082015116602083015262ffffff60408201511660408301526060810151151560608301525050565b9284019260809290920191600101613163565b6000602082840312156131d657600080fd5b61151582612f32565b6020808252825182820181905260009190848201906040850190845b8181101561128f578351835292840192918401916001016131fb565b60008060006060848603121561322c57600080fd5b61323584612f32565b95602085013595506040909401359392505050565b6000806040838503121561325d57600080fd5b61326683612f32565b91506020830135801515811461327b57600080fd5b809150509250929050565b6000806000806080858703121561329c57600080fd5b6132a585612f32565b93506132b360208601612f32565b925060408501359150606085013567ffffffffffffffff8111156132d657600080fd5b8501601f810187136132e757600080fd5b6132f687823560208401612e9c565b91505092959194509250565b81516001600160a01b0316815260208083015167ffffffffffffffff169082015260408083015162ffffff16908201526060808301511515908201526080810161110d565b6000806040838503121561335a57600080fd5b61336383612f32565b915061337160208401612f32565b90509250929050565b6000806040838503121561338d57600080fd5b50508035926020909101359150565b600181811c908216806133b057607f821691505b6020821081036133d057634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b6000600182016133fe576133fe6133d6565b5060010190565b634e487b7160e01b600052602160045260246000fd5b60008282101561342d5761342d6133d6565b500390565b60008219821115613445576134456133d6565b500190565b60208082526032908201527f5265656e74727950726f74656374696f6e46616365742e6e6f5265656e7472796040820152710e881c99595b9d1c9e4819195d1958dd195960721b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b601f82111561102557600081815260208120601f850160051c810160208610156134d95750805b601f850160051c820191505b81811015610c1c578281556001016134e5565b815167ffffffffffffffff81111561351257613512612e86565b61352681613520845461339c565b846134b2565b602080601f83116001811461355b57600084156135435750858301515b600019600386901b1c1916600185901b178555610c1c565b600085815260208120601f198616915b8281101561358a5788860151825594840194600190910190840161356b565b50858210156135a85787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008083128015600160ff1b8501841216156135d6576135d66133d6565b6001600160ff1b03840183138116156135f1576135f16133d6565b50500390565b60006001600160a01b038087168352808616602084015250836040830152608060608301526136296080830184612e26565b9695505050505050565b60006020828403121561364557600080fd5b81516001600160e01b03198116811461151557600080fd5b634e487b7160e01b600052601260045260246000fd5b600063ffffffff83811690831681811015613690576136906133d6565b039392505050565b60008160001904831182151516156136b2576136b26133d6565b500290565b6000826136c6576136c661365d565b500690565b60006001600160601b0383811690831681811015613690576136906133d6565b600063ffffffff80831681851680830382111561370a5761370a6133d6565b01949350505050565b60006001600160601b0380831681851680830382111561370a5761370a6133d6565b6000826137445761374461365d565b50049056fe32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc122569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c40455243373231436865636b706f696e7461626c653a3a5f6d6f766544656c6567617465733a20616d6f756e74206f766572666c6f7773455243373231436865636b706f696e7461626c653a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d626572206578636565647320333220626974732569078dfb4b0305704d3008e7403993ae9601b85f7ae5e742de3de8f8011c44bf149371ad903781495253afdb39db7e533d0ab4edf7988855c9f8730e36298a32b2e02f32560e257eaad13ed8a4f0ffa175bcb89327c67da202bdcd5579cc15455243373231436865636b706f696e7461626c653a3a5f6d6f766544656c6567617465733a20616d6f756e7420756e646572666c6f7773ee151c8401928dc223602bb187aff91b9a56c7cae5476ef1b3287b085a16c85fa26469706673582212205c1b28b4a4724a8ee833dd37932bf87fec76af743c7dcd8b750aab240e5b8acc64736f6c634300080f0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.