ERC-1155
Overview
Max Total Supply
1,000,000,000 ~
Holders
132
Total Transfers
-
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
EverEvolvingChromieSquiggle10000
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: LGPL-3.0-only pragma solidity ^0.8.22; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "./AddressChunks.sol"; import "./Interfaces.sol"; contract EverEvolvingChromieSquiggle10000 is ERC20, ERC1155, Ownable { error LiquidityAlreadyLoaded(); error MustSendETHToAddLiquidity(); error SquiggleAlreadyClaimed(); error InvalidTokenID(); error NotSquiggleOwner(); error NotAuthorizedTransfer(); error CannotModifyPoolStatus(); address public uniswapV3Pair; bool public liquidityLoaded; uint256 public positionId; bool private isWethToken0; uint24 internal constant LP_FEE = 10000; int24 internal constant LP_TICK_LOWER = -887200; int24 internal constant LP_TICK_UPPER = 887200; uint256 public constant MAX_SUPPLY = 1_000_000_000 * 10 ** 18; // 1 billion tokens uint256 public constant TOKENS_PER_SQUIGGLE = 50_000 * 10 ** 18; // 50,000 tokens uint256 private constant TOKENS_FOR_1155 = 1 * 10 ** 18; // 1 token uint256 public squiggleUpdateBlocks = 1; // Default to 1 block mapping(address => bool) private _isHolder; address private constant NON_FUNGIBLE_POSITIONS_MANAGER = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88; address private constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; address private constant ARTBLOCKS_CONTRACT = 0x059EDD72Cd353dF5106D2B9cC5ab83a52287aC3a; address private constant DELEGATE_REGISTRY = 0x00000000000000447e69651d841bD8D104Bed493; address private DEPENDENCY_REGISTRY = 0x37861f95882ACDba2cCD84F5bFc4598e2ECDDdAF; address private UNIVERSAL_BYTECODE_STORAGE_READER = 0x000000000000A791ABed33872C44a3D215a3743B; address private GENERATOR = 0x953D288708bB771F969FCfD9BA0819eF506Ac718; address private GUNZIP_SCRIPT_BYTECODE_ADDRESS = 0xB33eF4b9e1B2C72e0C9DdF49CEB82d1BaAaf8043; address private SCRIPTY_BUILDER_ADDRESS = 0xD7587F110E08F4D120A231bA97d3B577A81Df022; uint256 private constant MAX_SQUIGGLE_ID = 9999; mapping(uint256 => bool) public squiggleClaimed; uint256 public constant CHROMIE_SQUIGGLE_10000 = 10000; bool private _mintERC1155 = true; mapping(address => bool) public hasHolderToken; mapping(address => bool) public ignoreWalletForHolderToken; bytes32 public currentHash; uint256 private lastUpdatedBlock; event HashUpdated(bytes32 newHash); constructor() ERC20("The Ever-Evolving Chromie Squiggle #10000", "~") ERC1155("") Ownable(msg.sender) { ignoreWalletForHolderToken[address(0)] = true; ignoreWalletForHolderToken[address(this)] = true; ERC20._mint(address(this), MAX_SUPPLY); hasHolderToken[msg.sender] = true; ERC1155._mint(msg.sender, CHROMIE_SQUIGGLE_10000, 1, ""); currentHash = keccak256(abi.encodePacked("~")); lastUpdatedBlock = block.number; } function loadLiquidity() external payable onlyOwner { if (liquidityLoaded) revert LiquidityAlreadyLoaded(); if (msg.value == 0) revert MustSendETHToAddLiquidity(); uint256 tokenAmount = MAX_SUPPLY / 2; // Convert ETH to WETH uint256 ethLiquidity = msg.value; IWETH(WETH).deposit{value: ethLiquidity}(); // Determine the token0, token1, and sqrtPriceX96 values for the Uniswap V3 pool isWethToken0 = WETH < address(this); address token0 = isWethToken0 ? WETH : address(this); address token1 = isWethToken0 ? address(this) : WETH; uint256 amount0 = isWethToken0 ? ethLiquidity : tokenAmount; uint256 amount1 = isWethToken0 ? tokenAmount : ethLiquidity; // Calculate initial price with overflow protection uint160 sqrtPriceX96; if (isWethToken0) { sqrtPriceX96 = uint160(sqrt((tokenAmount << 192) / ethLiquidity)); } else { sqrtPriceX96 = uint160(sqrt((ethLiquidity << 192) / tokenAmount)); } // Create and initialize the Uniswap V3 pool uniswapV3Pair = INonfungiblePositionManager( NON_FUNGIBLE_POSITIONS_MANAGER ).createAndInitializePoolIfNecessary( token0, token1, LP_FEE, sqrtPriceX96 ); // Add pool to ignored wallets for holder token ignoreWalletForHolderToken[uniswapV3Pair] = true; // Approve the nonfungible position manager to transfer the WETH and tokens SafeERC20.safeIncreaseAllowance( IERC20(WETH), NON_FUNGIBLE_POSITIONS_MANAGER, ethLiquidity ); SafeERC20.safeIncreaseAllowance( this, NON_FUNGIBLE_POSITIONS_MANAGER, tokenAmount ); // Set up the liquidity position mint parameters INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams({ token0: token0, token1: token1, fee: LP_FEE, tickLower: LP_TICK_LOWER, tickUpper: LP_TICK_UPPER, amount0Desired: amount0, amount1Desired: amount1, amount0Min: 0, amount1Min: 0, recipient: msg.sender, deadline: block.timestamp }); // Mint the liquidity position to the owner (positionId, , , ) = INonfungiblePositionManager( NON_FUNGIBLE_POSITIONS_MANAGER ).mint(params); liquidityLoaded = true; } function sqrt(uint256 x) internal pure returns (uint256) { if (x == 0) return 0; uint256 z = (x + 1) / 2; uint256 y = x; while (z < y) { y = z; z = (x / z + z) / 2; } return y; } function setIgnoreWalletForHolderToken( address wallet, bool ignoreStatus ) external onlyOwner { if (wallet == uniswapV3Pair) revert CannotModifyPoolStatus(); ignoreWalletForHolderToken[wallet] = ignoreStatus; } function setSquiggleUpdateBlocks( uint256 _squiggleUpdateBlocks ) external onlyOwner { squiggleUpdateBlocks = _squiggleUpdateBlocks; } function setDependencyRegistry( address _dependencyRegistry ) external onlyOwner { DEPENDENCY_REGISTRY = _dependencyRegistry; } function setUniversalBytecodeStorageReader( address _reader ) external onlyOwner { UNIVERSAL_BYTECODE_STORAGE_READER = _reader; } function setGenerator(address _generator) external onlyOwner { GENERATOR = _generator; } function setGunzipScriptBytecodeAddress( address _gunzipAddress ) external onlyOwner { GUNZIP_SCRIPT_BYTECODE_ADDRESS = _gunzipAddress; } function setScriptyBuilderAddress( address _scriptyBuilder ) external onlyOwner { SCRIPTY_BUILDER_ADDRESS = _scriptyBuilder; } function squiggleHolderClaim(uint256[] calldata originalTokenIds) external { for (uint256 i = 0; i < originalTokenIds.length; ++i) { uint256 tokenId = originalTokenIds[i]; if (tokenId > MAX_SQUIGGLE_ID) revert InvalidTokenID(); if (squiggleClaimed[tokenId]) revert SquiggleAlreadyClaimed(); address tokenOwner = IERC721(ARTBLOCKS_CONTRACT).ownerOf(tokenId); if ( msg.sender == tokenOwner || IDelegateRegistry(DELEGATE_REGISTRY).checkDelegateForERC721( msg.sender, tokenOwner, address(ARTBLOCKS_CONTRACT), tokenId, "" ) ) { squiggleClaimed[tokenId] = true; _transfer(address(this), msg.sender, TOKENS_PER_SQUIGGLE); } else { revert NotSquiggleOwner(); } } } function getTokenHtml() external view returns (string memory) { HTMLRequest memory htmlRequest = _getTokenHtmlRequest(); string memory html = IScriptyBuilderV2(SCRIPTY_BUILDER_ADDRESS) .getHTMLString(htmlRequest); return html; } function getTokenHtmlBase64EncodedDataUri() public view returns (string memory) { HTMLRequest memory htmlRequest = _getTokenHtmlRequest(); string memory base64EncodedHTMLDataURI = IScriptyBuilderV2( SCRIPTY_BUILDER_ADDRESS ).getEncodedHTMLString(htmlRequest); return base64EncodedHTMLDataURI; } function _getTokenHtmlRequest() internal view returns (HTMLRequest memory) { bytes32 dependencyNameAndVersion = bytes32("[email protected]"); HTMLTag[] memory headTags = new HTMLTag[](3); headTags[0].tagOpen = "<style>"; headTags[0] .tagContent = "html{height:100%}body{min-height:100%;margin:0;padding:0}canvas{padding:0;margin:auto;display:block;position:absolute;top:0;bottom:0;left:0;right:0}"; headTags[0].tagClose = "</style>"; headTags[1].tagContent = abi.encodePacked( 'let tokenData = {"tokenId":10000,"hashes":["', Strings.toHexString(uint256(currentHash)), '"]}' ); headTags[1].tagType = HTMLTagType.script; // Create body tags HTMLTag[] memory bodyTags = new HTMLTag[](3); bytes memory dependencyScript = _getDependencyScriptBytes( dependencyNameAndVersion ); bodyTags[0].tagContent = dependencyScript; bodyTags[0].tagType = HTMLTagType.scriptGZIPBase64DataURI; bodyTags[1].name = "gunzipScripts-0.0.1.js"; bodyTags[1].tagType = HTMLTagType.scriptBase64DataURI; bodyTags[1].tagContent = bytes( IUniversalBytecodeStorageReader(UNIVERSAL_BYTECODE_STORAGE_READER) .readFromBytecode(GUNZIP_SCRIPT_BYTECODE_ADDRESS) ); bytes memory projectScript = bytes( IGenArt721GeneratorV0(GENERATOR).getProjectScript( ARTBLOCKS_CONTRACT, 0 ) ); HTMLTag memory projectScriptTag = HTMLTag({ tagOpen: bytes("<script>"), tagClose: bytes("</script>"), tagType: HTMLTagType.useTagOpenAndClose, name: "", contractAddress: address(0), contractData: "", tagContent: projectScript }); bodyTags[2] = projectScriptTag; HTMLRequest memory htmlRequest; htmlRequest.headTags = headTags; htmlRequest.bodyTags = bodyTags; return htmlRequest; } function _getDependencyScriptBytes( bytes32 dependencyNameAndVersion ) internal view returns (bytes memory) { uint256 scriptCount = 10; address[] memory scriptBytecodeAddresses = new address[](scriptCount); for (uint256 i = 0; i < scriptCount; i++) { scriptBytecodeAddresses[i] = IDependencyRegistry( DEPENDENCY_REGISTRY ).getDependencyScriptBytecodeAddress(dependencyNameAndVersion, i); } return AddressChunks.mergeChunks( scriptBytecodeAddresses, UNIVERSAL_BYTECODE_STORAGE_READER ); } function uri(uint256 tokenId) public view override returns (string memory) { if (tokenId != CHROMIE_SQUIGGLE_10000) { revert InvalidTokenID(); } string memory htmlDataUri = getTokenHtmlBase64EncodedDataUri(); // Create the JSON metadata bytes memory dataURI = abi.encodePacked( "{", '"name": "Chromie Squiggle #10000",', '"description": "The squiggle displayed updates based on the current $~ price.",', '"animation_url": "', htmlDataUri, '"', "}" ); return string( abi.encodePacked( "data:application/json;base64,", Base64.encode(dataURI) ) ); } function _update( address from, address to, uint256 value ) internal virtual override { if (!liquidityLoaded) { super._update(from, to, value); return; } // In case of a bug, we can set squiggleUpdateBlocks extremely high. if (block.number >= lastUpdatedBlock + squiggleUpdateBlocks) { currentHash = getPriceHash(); lastUpdatedBlock = block.number; emit HashUpdated(currentHash); } // In case we've killed the 1155 functionality. if (!_mintERC1155) { super._update(from, to, value); return; } if ( !ignoreWalletForHolderToken[to] && !hasHolderToken[to] && balanceOf(to) + value >= TOKENS_FOR_1155 ) { hasHolderToken[to] = true; ERC1155._mint(to, CHROMIE_SQUIGGLE_10000, 1, ""); } if ( !ignoreWalletForHolderToken[from] && hasHolderToken[from] && balanceOf(from) - value < TOKENS_FOR_1155 ) { hasHolderToken[from] = false; ERC1155._burn(from, CHROMIE_SQUIGGLE_10000, 1); } super._update(from, to, value); } function safeTransferFrom( address, address, uint256, uint256, bytes memory ) public virtual override { revert NotAuthorizedTransfer(); } function safeBatchTransferFrom( address, address, uint256[] memory, uint256[] memory, bytes memory ) public virtual override { revert NotAuthorizedTransfer(); } function setApprovalForAll(address, bool) public virtual override { revert NotAuthorizedTransfer(); } function isApprovedForAll( address, address ) public view virtual override returns (bool) { return false; } function getPriceHash() public view returns (bytes32) { (uint160 sqrtPriceX96, , , , , , ) = IUniswapV3Pool(uniswapV3Pair) .slot0(); uint256 price; if (isWethToken0) { price = (uint256(sqrtPriceX96) * uint256(sqrtPriceX96)) >> (96 * 2); } else { price = (1 << (96 * 2)) / (uint256(sqrtPriceX96) * uint256(sqrtPriceX96)); } price = price * 1e18; return keccak256(abi.encodePacked(price)); } /* Owner function just in case minting/burning 1155s become a gas issue. */ function emergencyKillERC1155() external onlyOwner { _mintERC1155 = false; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC165} from "./IERC165.sol"; /** * @title IERC1363 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363]. * * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction. */ interface IERC1363 is IERC20, IERC165 { /* * Note: the ERC-165 identifier for this interface is 0xb0202a11. * 0xb0202a11 === * bytes4(keccak256('transferAndCall(address,uint256)')) ^ * bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^ * bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^ * bytes4(keccak256('approveAndCall(address,uint256)')) ^ * bytes4(keccak256('approveAndCall(address,uint256,bytes)')) */ /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from the caller's account to `to` * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism * and then calls {IERC1363Receiver-onTransferReceived} on `to`. * @param from The address which you want to send tokens from. * @param to The address which you want to transfer to. * @param value The amount of tokens to be transferred. * @param data Additional data with no specified format, sent in call to `to`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value) external returns (bool); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`. * @param spender The address which will spend the funds. * @param value The amount of tokens to be spent. * @param data Additional data with no specified format, sent in call to `spender`. * @return A boolean value indicating whether the operation succeeded unless throwing. */ function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.20; import {IERC1155} from "./IERC1155.sol"; import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol"; import {ERC1155Utils} from "./utils/ERC1155Utils.sol"; import {Context} from "../../utils/Context.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {Arrays} from "../../utils/Arrays.sol"; import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 */ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors { using Arrays for uint256[]; using Arrays for address[]; mapping(uint256 id => mapping(address account => uint256)) private _balances; mapping(address account => mapping(address operator => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256 /* id */) public view virtual returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. */ function balanceOf(address account, uint256 id) public view virtual returns (uint256) { return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual returns (uint256[] memory) { if (accounts.length != ids.length) { revert ERC1155InvalidArrayLength(ids.length, accounts.length); } uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i)); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeTransferFrom(from, to, id, value, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeBatchTransferFrom(from, to, ids, values, data); } /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from` * (or `to`) is the zero address. * * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise. * * Requirements: * * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} * or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. * - `ids` and `values` must have the same length. * * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead. */ function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual { if (ids.length != values.length) { revert ERC1155InvalidArrayLength(ids.length, values.length); } address operator = _msgSender(); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids.unsafeMemoryAccess(i); uint256 value = values.unsafeMemoryAccess(i); if (from != address(0)) { uint256 fromBalance = _balances[id][from]; if (fromBalance < value) { revert ERC1155InsufficientBalance(from, fromBalance, value, id); } unchecked { // Overflow not possible: value <= fromBalance _balances[id][from] = fromBalance - value; } } if (to != address(0)) { _balances[id][to] += value; } } if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); emit TransferSingle(operator, from, to, id, value); } else { emit TransferBatch(operator, from, to, ids, values); } } /** * @dev Version of {_update} that performs the token acceptance check by calling * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it * contains code (eg. is a smart contract at the moment of execution). * * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any * update to the contract state after this function would break the check-effect-interaction pattern. Consider * overriding {_update} instead. */ function _updateWithAcceptanceCheck( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal virtual { _update(from, to, ids, values); if (to != address(0)) { address operator = _msgSender(); if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); ERC1155Utils.checkOnERC1155Received(operator, from, to, id, value, data); } else { ERC1155Utils.checkOnERC1155BatchReceived(operator, from, to, ids, values, data); } } } /** * @dev Transfers a `value` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. * - `ids` and `values` must have the same length. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the ERC]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the values in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `values` must have the same length. * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev Destroys a `value` amount of tokens of type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. */ function _burn(address from, uint256 id, uint256 value) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. * - `ids` and `values` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC1155InvalidOperator(address(0)); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Creates an array in memory with only one value for each of the elements provided. */ function _asSingletonArrays( uint256 element1, uint256 element2 ) private pure returns (uint256[] memory array1, uint256[] memory array2) { assembly ("memory-safe") { // Load the free memory pointer array1 := mload(0x40) // Set array length to 1 mstore(array1, 1) // Store the single element at the next word after the length (where content starts) mstore(add(array1, 0x20), element1) // Repeat for next array locating it right after the first array array2 := add(array1, 0x40) mstore(array2, 1) mstore(add(array2, 0x20), element2) // Update the free memory pointer by pointing after the second array mstore(0x40, add(array2, 0x40)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.20; import {IERC1155} from "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[ERC]. */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC-1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[ERC]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the value of tokens of token type `id` owned by `account`. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Interface that must be implemented by smart contracts in order to receive * ERC-1155 token transfers. */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC-1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC-1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/utils/ERC1155Utils.sol) pragma solidity ^0.8.20; import {IERC1155Receiver} from "../IERC1155Receiver.sol"; import {IERC1155Errors} from "../../../interfaces/draft-IERC6093.sol"; /** * @dev Library that provide common ERC-1155 utility functions. * * See https://eips.ethereum.org/EIPS/eip-1155[ERC-1155]. * * _Available since v5.1._ */ library ERC1155Utils { /** * @dev Performs an acceptance check for the provided `operator` by calling {IERC1155-onERC1155Received} * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`). * * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA). * Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC1155Received( address operator, address from, address to, uint256 id, uint256 value, bytes memory data ) internal { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { // Tokens rejected revert IERC1155Errors.ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC1155Receiver implementer revert IERC1155Errors.ERC1155InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Performs a batch acceptance check for the provided `operator` by calling {IERC1155-onERC1155BatchReceived} * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`). * * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA). * Otherwise, the recipient must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC1155BatchReceived( address operator, address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { // Tokens rejected revert IERC1155Errors.ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC1155Receiver implementer revert IERC1155Errors.ERC1155InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC-20 * applications. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Skips emitting an {Approval} event indicating an allowance update. This is not * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve]. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * * ```solidity * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC-20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC-20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { /** * @dev An operation with an ERC-20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. * * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client" * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. * * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being * set here. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { safeTransfer(token, to, value); } else if (!token.transferAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * Reverts if the returned value is other than `true`. */ function transferFromAndCallRelaxed( IERC1363 token, address from, address to, uint256 value, bytes memory data ) internal { if (to.code.length == 0) { safeTransferFrom(token, from, to, value); } else if (!token.transferFromAndCall(from, to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when * targeting contracts. * * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}. * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall} * once without retrying, and relies on the returned value to be true. * * Reverts if the returned value is other than `true`. */ function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal { if (to.code.length == 0) { forceApprove(token, to, value); } else if (!token.approveAndCall(to, value, data)) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements. */ function _callOptionalReturn(IERC20 token, bytes memory data) private { uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) // bubble errors if iszero(success) { let ptr := mload(0x40) returndatacopy(ptr, 0, returndatasize()) revert(ptr, returndatasize()) } returnSize := returndatasize() returnValue := mload(0) } if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { bool success; uint256 returnSize; uint256 returnValue; assembly ("memory-safe") { success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20) returnSize := returndatasize() returnValue := mload(0) } return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC-721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC-721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Address.sol) pragma solidity ^0.8.20; import {Errors} from "./Errors.sol"; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert Errors.InsufficientBalance(address(this).balance, amount); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert Errors.FailedCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {Errors.FailedCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert Errors.InsufficientBalance(address(this).balance, value); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case * of an unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {Errors.FailedCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly ("memory-safe") { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert Errors.FailedCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Arrays.sol) // This file was procedurally generated from scripts/generate/templates/Arrays.js. pragma solidity ^0.8.20; import {Comparators} from "./Comparators.sol"; import {SlotDerivation} from "./SlotDerivation.sol"; import {StorageSlot} from "./StorageSlot.sol"; import {Math} from "./math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { using SlotDerivation for bytes32; using StorageSlot for bytes32; /** * @dev Sort an array of uint256 (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( uint256[] memory array, function(uint256, uint256) pure returns (bool) comp ) internal pure returns (uint256[] memory) { _quickSort(_begin(array), _end(array), comp); return array; } /** * @dev Variant of {sort} that sorts an array of uint256 in increasing order. */ function sort(uint256[] memory array) internal pure returns (uint256[] memory) { sort(array, Comparators.lt); return array; } /** * @dev Sort an array of address (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( address[] memory array, function(address, address) pure returns (bool) comp ) internal pure returns (address[] memory) { sort(_castToUint256Array(array), _castToUint256Comp(comp)); return array; } /** * @dev Variant of {sort} that sorts an array of address in increasing order. */ function sort(address[] memory array) internal pure returns (address[] memory) { sort(_castToUint256Array(array), Comparators.lt); return array; } /** * @dev Sort an array of bytes32 (in memory) following the provided comparator function. * * This function does the sorting "in place", meaning that it overrides the input. The object is returned for * convenience, but that returned value can be discarded safely if the caller has a memory pointer to the array. * * NOTE: this function's cost is `O(n · log(n))` in average and `O(n²)` in the worst case, with n the length of the * array. Using it in view functions that are executed through `eth_call` is safe, but one should be very careful * when executing this as part of a transaction. If the array being sorted is too large, the sort operation may * consume more gas than is available in a block, leading to potential DoS. * * IMPORTANT: Consider memory side-effects when using custom comparator functions that access memory in an unsafe way. */ function sort( bytes32[] memory array, function(bytes32, bytes32) pure returns (bool) comp ) internal pure returns (bytes32[] memory) { sort(_castToUint256Array(array), _castToUint256Comp(comp)); return array; } /** * @dev Variant of {sort} that sorts an array of bytes32 in increasing order. */ function sort(bytes32[] memory array) internal pure returns (bytes32[] memory) { sort(_castToUint256Array(array), Comparators.lt); return array; } /** * @dev Performs a quick sort of a segment of memory. The segment sorted starts at `begin` (inclusive), and stops * at end (exclusive). Sorting follows the `comp` comparator. * * Invariant: `begin <= end`. This is the case when initially called by {sort} and is preserved in subcalls. * * IMPORTANT: Memory locations between `begin` and `end` are not validated/zeroed. This function should * be used only if the limits are within a memory array. */ function _quickSort(uint256 begin, uint256 end, function(uint256, uint256) pure returns (bool) comp) private pure { unchecked { if (end - begin < 0x40) return; // Use first element as pivot uint256 pivot = _mload(begin); // Position where the pivot should be at the end of the loop uint256 pos = begin; for (uint256 it = begin + 0x20; it < end; it += 0x20) { if (comp(_mload(it), pivot)) { // If the value stored at the iterator's position comes before the pivot, we increment the // position of the pivot and move the value there. pos += 0x20; _swap(pos, it); } } _swap(begin, pos); // Swap pivot into place _quickSort(begin, pos, comp); // Sort the left side of the pivot _quickSort(pos + 0x20, end, comp); // Sort the right side of the pivot } } /** * @dev Pointer to the memory location of the first element of `array`. */ function _begin(uint256[] memory array) private pure returns (uint256 ptr) { assembly ("memory-safe") { ptr := add(array, 0x20) } } /** * @dev Pointer to the memory location of the first memory word (32bytes) after `array`. This is the memory word * that comes just after the last element of the array. */ function _end(uint256[] memory array) private pure returns (uint256 ptr) { unchecked { return _begin(array) + array.length * 0x20; } } /** * @dev Load memory word (as a uint256) at location `ptr`. */ function _mload(uint256 ptr) private pure returns (uint256 value) { assembly { value := mload(ptr) } } /** * @dev Swaps the elements memory location `ptr1` and `ptr2`. */ function _swap(uint256 ptr1, uint256 ptr2) private pure { assembly { let value1 := mload(ptr1) let value2 := mload(ptr2) mstore(ptr1, value2) mstore(ptr2, value1) } } /// @dev Helper: low level cast address memory array to uint256 memory array function _castToUint256Array(address[] memory input) private pure returns (uint256[] memory output) { assembly { output := input } } /// @dev Helper: low level cast bytes32 memory array to uint256 memory array function _castToUint256Array(bytes32[] memory input) private pure returns (uint256[] memory output) { assembly { output := input } } /// @dev Helper: low level cast address comp function to uint256 comp function function _castToUint256Comp( function(address, address) pure returns (bool) input ) private pure returns (function(uint256, uint256) pure returns (bool) output) { assembly { output := input } } /// @dev Helper: low level cast bytes32 comp function to uint256 comp function function _castToUint256Comp( function(bytes32, bytes32) pure returns (bool) input ) private pure returns (function(uint256, uint256) pure returns (bool) output) { assembly { output := input } } /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * NOTE: The `array` is expected to be sorted in ascending order, and to * contain no repeated elements. * * IMPORTANT: Deprecated. This implementation behaves as {lowerBound} but lacks * support for repeated elements in the array. The {lowerBound} function should * be used instead. */ function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { low = mid + 1; } } // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. if (low > 0 && unsafeAccess(array, low - 1).value == element) { return low - 1; } else { return low; } } /** * @dev Searches an `array` sorted in ascending order and returns the first * index that contains a value greater or equal than `element`. If no such index * exists (i.e. all values in the array are strictly less than `element`), the array * length is returned. Time complexity O(log n). * * See C++'s https://en.cppreference.com/w/cpp/algorithm/lower_bound[lower_bound]. */ function lowerBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value < element) { // this cannot overflow because mid < high unchecked { low = mid + 1; } } else { high = mid; } } return low; } /** * @dev Searches an `array` sorted in ascending order and returns the first * index that contains a value strictly greater than `element`. If no such index * exists (i.e. all values in the array are strictly less than `element`), the array * length is returned. Time complexity O(log n). * * See C++'s https://en.cppreference.com/w/cpp/algorithm/upper_bound[upper_bound]. */ function upperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { // this cannot overflow because mid < high unchecked { low = mid + 1; } } } return low; } /** * @dev Same as {lowerBound}, but with an array in memory. */ function lowerBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeMemoryAccess(array, mid) < element) { // this cannot overflow because mid < high unchecked { low = mid + 1; } } else { high = mid; } } return low; } /** * @dev Same as {upperBound}, but with an array in memory. */ function upperBoundMemory(uint256[] memory array, uint256 element) internal pure returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeMemoryAccess(array, mid) > element) { high = mid; } else { // this cannot overflow because mid < high unchecked { low = mid + 1; } } } return low; } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) { bytes32 slot; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).getAddressSlot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) { bytes32 slot; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).getBytes32Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) { bytes32 slot; assembly ("memory-safe") { slot := arr.slot } return slot.deriveArray().offset(pos).getUint256Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(bytes32[] memory arr, uint256 pos) internal pure returns (bytes32 res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(address[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(bytes32[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } /** * @dev Helper to set the length of an dynamic array. Directly writing to `.length` is forbidden. * * WARNING: this does not clear elements if length is reduced, of initialize elements if length is increased. */ function unsafeSetLength(uint256[] storage array, uint256 len) internal { assembly ("memory-safe") { sstore(array.slot, len) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Base64.sol) pragma solidity ^0.8.20; /** * @dev Provides a set of functions to operate with Base64 strings. */ library Base64 { /** * @dev Base64 Encoding/Decoding Table * See sections 4 and 5 of https://datatracker.ietf.org/doc/html/rfc4648 */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; string internal constant _TABLE_URL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { return _encode(data, _TABLE, true); } /** * @dev Converts a `bytes` to its Bytes64Url `string` representation. * Output is not padded with `=` as specified in https://www.rfc-editor.org/rfc/rfc4648[rfc4648]. */ function encodeURL(bytes memory data) internal pure returns (string memory) { return _encode(data, _TABLE_URL, false); } /** * @dev Internal table-agnostic conversion */ function _encode(bytes memory data, string memory table, bool withPadding) private pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // If padding is enabled, the final length should be `bytes` data length divided by 3 rounded up and then // multiplied by 4 so that it leaves room for padding the last chunk // - `data.length + 2` -> Prepare for division rounding up // - `/ 3` -> Number of 3-bytes chunks (rounded up) // - `4 *` -> 4 characters for each chunk // This is equivalent to: 4 * Math.ceil(data.length / 3) // // If padding is disabled, the final length should be `bytes` data length multiplied by 4/3 rounded up as // opposed to when padding is required to fill the last chunk. // - `4 * data.length` -> 4 characters for each chunk // - ` + 2` -> Prepare for division rounding up // - `/ 3` -> Number of 3-bytes chunks (rounded up) // This is equivalent to: Math.ceil((4 * data.length) / 3) uint256 resultLength = withPadding ? 4 * ((data.length + 2) / 3) : (4 * data.length + 2) / 3; string memory result = new string(resultLength); assembly ("memory-safe") { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 0x20) let dataPtr := data let endPtr := add(data, mload(data)) // In some cases, the last iteration will read bytes after the end of the data. We cache the value, and // set it to zero to make sure no dirty bytes are read in that section. let afterPtr := add(endPtr, 0x20) let afterCache := mload(afterPtr) mstore(afterPtr, 0x00) // Run over the input, 3 bytes at a time for { } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 byte (24 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F to bitmask the least significant 6 bits. // Use this as an index into the lookup table, mload an entire word // so the desired character is in the least significant byte, and // mstore8 this least significant byte into the result and continue. mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // Reset the value that was cached mstore(afterPtr, afterCache) if withPadding { // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Comparators.sol) pragma solidity ^0.8.20; /** * @dev Provides a set of functions to compare values. * * _Available since v5.1._ */ library Comparators { function lt(uint256 a, uint256 b) internal pure returns (bool) { return a < b; } function gt(uint256 a, uint256 b) internal pure returns (bool) { return a > b; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol) pragma solidity ^0.8.20; /** * @dev Collection of common custom errors used in multiple contracts * * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library. * It is recommended to avoid relying on the error API for critical functionality. * * _Available since v5.1._ */ library Errors { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error InsufficientBalance(uint256 balance, uint256 needed); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedCall(); /** * @dev The deployment failed. */ error FailedDeployment(); /** * @dev A necessary precompile is missing. */ error MissingPrecompile(address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol) pragma solidity ^0.8.20; import {Panic} from "../Panic.sol"; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero). */ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * SafeCast.toUint(condition)); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a < b, a, b); } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. Panic.panic(Panic.DIVISION_BY_ZERO); } // The following calculation ensures accurate ceiling division without overflow. // Since a is non-zero, (a - 1) / b will not overflow. // The largest possible result occurs when (a - 1) / b is type(uint256).max, // but the largest value we can obtain is type(uint256).max - 1, which happens // when a = type(uint256).max and b = 1. unchecked { return SafeCast.toUint(a > 0) * ((a - 1) / b + 1); } } /** * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2²⁵⁶ + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW)); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2²⁵⁶ / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv ≡ 1 mod 2⁴. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2⁸ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶ inverse *= 2 - denominator * inverse; // inverse mod 2³² inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶ // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2²⁵⁶. Since the preconditions guarantee that the outcome is // less than 2²⁵⁶, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @dev Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0); } /** * @dev Calculate the modular multiplicative inverse of a number in Z/nZ. * * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0. * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible. * * If the input value is not inversible, 0 is returned. * * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}. */ function invMod(uint256 a, uint256 n) internal pure returns (uint256) { unchecked { if (n == 0) return 0; // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version) // Used to compute integers x and y such that: ax + ny = gcd(a, n). // When the gcd is 1, then the inverse of a modulo n exists and it's x. // ax + ny = 1 // ax = 1 + (-y)n // ax ≡ 1 (mod n) # x is the inverse of a modulo n // If the remainder is 0 the gcd is n right away. uint256 remainder = a % n; uint256 gcd = n; // Therefore the initial coefficients are: // ax + ny = gcd(a, n) = n // 0a + 1n = n int256 x = 0; int256 y = 1; while (remainder != 0) { uint256 quotient = gcd / remainder; (gcd, remainder) = ( // The old remainder is the next gcd to try. remainder, // Compute the next remainder. // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd // where gcd is at most n (capped to type(uint256).max) gcd - remainder * quotient ); (x, y) = ( // Increment the coefficient of a. y, // Decrement the coefficient of n. // Can overflow, but the result is casted to uint256 so that the // next value of y is "wrapped around" to a value between 0 and n - 1. x - y * int256(quotient) ); } if (gcd != 1) return 0; // No inverse exists. return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative. } } /** * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`. * * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that * `a**(p-2)` is the modular multiplicative inverse of a in Fp. * * NOTE: this function does NOT check that `p` is a prime greater than `2`. */ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) { unchecked { return Math.modExp(a, p - 2, p); } } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) * * Requirements: * - modulus can't be zero * - underlying staticcall to precompile must succeed * * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make * sure the chain you're using it on supports the precompiled contract for modular exponentiation * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, * the underlying function will succeed given the lack of a revert, but the result may be incorrectly * interpreted as 0. */ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) { (bool success, uint256 result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying * to operate modulo 0 or if the underlying precompile reverted. * * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack * of a revert, but the result may be incorrectly interpreted as 0. */ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) { if (m == 0) return (false, 0); assembly ("memory-safe") { let ptr := mload(0x40) // | Offset | Content | Content (Hex) | // |-----------|------------|--------------------------------------------------------------------| // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x60:0x7f | value of b | 0x<.............................................................b> | // | 0x80:0x9f | value of e | 0x<.............................................................e> | // | 0xa0:0xbf | value of m | 0x<.............................................................m> | mstore(ptr, 0x20) mstore(add(ptr, 0x20), 0x20) mstore(add(ptr, 0x40), 0x20) mstore(add(ptr, 0x60), b) mstore(add(ptr, 0x80), e) mstore(add(ptr, 0xa0), m) // Given the result < m, it's guaranteed to fit in 32 bytes, // so we can use the memory scratch space located at offset 0. success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20) result := mload(0x00) } } /** * @dev Variant of {modExp} that supports inputs of arbitrary length. */ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) { (bool success, bytes memory result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Variant of {tryModExp} that supports inputs of arbitrary length. */ function tryModExp( bytes memory b, bytes memory e, bytes memory m ) internal view returns (bool success, bytes memory result) { if (_zeroBytes(m)) return (false, new bytes(0)); uint256 mLen = m.length; // Encode call args in result and move the free memory pointer result = abi.encodePacked(b.length, e.length, mLen, b, e, m); assembly ("memory-safe") { let dataPtr := add(result, 0x20) // Write result on top of args to avoid allocating extra memory. success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen) // Overwrite the length. // result.length > returndatasize() is guaranteed because returndatasize() == m.length mstore(result, mLen) // Set the memory pointer after the returned data. mstore(0x40, add(dataPtr, mLen)) } } /** * @dev Returns whether the provided byte array is zero. */ function _zeroBytes(bytes memory byteArray) private pure returns (bool) { for (uint256 i = 0; i < byteArray.length; ++i) { if (byteArray[i] != 0) { return false; } } return true; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * This method is based on Newton's method for computing square roots; the algorithm is restricted to only * using integer operations. */ function sqrt(uint256 a) internal pure returns (uint256) { unchecked { // Take care of easy edge cases when a == 0 or a == 1 if (a <= 1) { return a; } // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between // the current value as `ε_n = | x_n - sqrt(a) |`. // // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is // bigger than any uint256. // // By noticing that // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)` // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar // to the msb function. uint256 aa = a; uint256 xn = 1; if (aa >= (1 << 128)) { aa >>= 128; xn <<= 64; } if (aa >= (1 << 64)) { aa >>= 64; xn <<= 32; } if (aa >= (1 << 32)) { aa >>= 32; xn <<= 16; } if (aa >= (1 << 16)) { aa >>= 16; xn <<= 8; } if (aa >= (1 << 8)) { aa >>= 8; xn <<= 4; } if (aa >= (1 << 4)) { aa >>= 4; xn <<= 2; } if (aa >= (1 << 2)) { xn <<= 1; } // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1). // // We can refine our estimation by noticing that the middle of that interval minimizes the error. // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2). // This is going to be our x_0 (and ε_0) xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2) // From here, Newton's method give us: // x_{n+1} = (x_n + a / x_n) / 2 // // One should note that: // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a // = ((x_n² + a) / (2 * x_n))² - a // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²) // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²) // = (x_n² - a)² / (2 * x_n)² // = ((x_n² - a) / (2 * x_n))² // ≥ 0 // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n // // This gives us the proof of quadratic convergence of the sequence: // ε_{n+1} = | x_{n+1} - sqrt(a) | // = | (x_n + a / x_n) / 2 - sqrt(a) | // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) | // = | (x_n - sqrt(a))² / (2 * x_n) | // = | ε_n² / (2 * x_n) | // = ε_n² / | (2 * x_n) | // // For the first iteration, we have a special case where x_0 is known: // ε_1 = ε_0² / | (2 * x_0) | // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2))) // ≤ 2**(2*e-4) / (3 * 2**(e-1)) // ≤ 2**(e-3) / 3 // ≤ 2**(e-3-log2(3)) // ≤ 2**(e-4.5) // // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n: // ε_{n+1} = ε_n² / | (2 * x_n) | // ≤ (2**(e-k))² / (2 * 2**(e-1)) // ≤ 2**(2*e-2*k) / 2**e // ≤ 2**(e-2*k) xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5 xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9 xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18 xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36 xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72 // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either // sqrt(a) or sqrt(a) + 1. return xn - SafeCast.toUint(xn > a / xn); } } /** * @dev Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 exp; unchecked { exp = 128 * SafeCast.toUint(value > (1 << 128) - 1); value >>= exp; result += exp; exp = 64 * SafeCast.toUint(value > (1 << 64) - 1); value >>= exp; result += exp; exp = 32 * SafeCast.toUint(value > (1 << 32) - 1); value >>= exp; result += exp; exp = 16 * SafeCast.toUint(value > (1 << 16) - 1); value >>= exp; result += exp; exp = 8 * SafeCast.toUint(value > (1 << 8) - 1); value >>= exp; result += exp; exp = 4 * SafeCast.toUint(value > (1 << 4) - 1); value >>= exp; result += exp; exp = 2 * SafeCast.toUint(value > (1 << 2) - 1); value >>= exp; result += exp; result += SafeCast.toUint(value > 1); } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 isGt; unchecked { isGt = SafeCast.toUint(value > (1 << 128) - 1); value >>= isGt * 128; result += isGt * 16; isGt = SafeCast.toUint(value > (1 << 64) - 1); value >>= isGt * 64; result += isGt * 8; isGt = SafeCast.toUint(value > (1 << 32) - 1); value >>= isGt * 32; result += isGt * 4; isGt = SafeCast.toUint(value > (1 << 16) - 1); value >>= isGt * 16; result += isGt * 2; result += SafeCast.toUint(value > (1 << 8) - 1); } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * int256(SafeCast.toUint(condition))); } } /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return ternary(a < b, a, b); } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson. // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift, // taking advantage of the most significant (or "sign" bit) in two's complement representation. // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result, // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative). int256 mask = n >> 255; // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it. return uint256((n + mask) ^ mask); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol) pragma solidity ^0.8.20; /** * @dev Helper library for emitting standardized panic codes. * * ```solidity * contract Example { * using Panic for uint256; * * // Use any of the declared internal constants * function foo() { Panic.GENERIC.panic(); } * * // Alternatively * function foo() { Panic.panic(Panic.GENERIC); } * } * ``` * * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. * * _Available since v5.1._ */ // slither-disable-next-line unused-state library Panic { /// @dev generic / unspecified error uint256 internal constant GENERIC = 0x00; /// @dev used by the assert() builtin uint256 internal constant ASSERT = 0x01; /// @dev arithmetic underflow or overflow uint256 internal constant UNDER_OVERFLOW = 0x11; /// @dev division or modulo by zero uint256 internal constant DIVISION_BY_ZERO = 0x12; /// @dev enum conversion error uint256 internal constant ENUM_CONVERSION_ERROR = 0x21; /// @dev invalid encoding in storage uint256 internal constant STORAGE_ENCODING_ERROR = 0x22; /// @dev empty array pop uint256 internal constant EMPTY_ARRAY_POP = 0x31; /// @dev array out of bounds access uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; /// @dev resource error (too large allocation or too large array) uint256 internal constant RESOURCE_ERROR = 0x41; /// @dev calling invalid internal function uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51; /// @dev Reverts with a panic code. Recommended to use with /// the internal constants with predefined codes. function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) mstore(0x20, code) revert(0x1c, 0x24) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/SlotDerivation.sol) // This file was procedurally generated from scripts/generate/templates/SlotDerivation.js. pragma solidity ^0.8.20; /** * @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots * corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by * the solidity language / compiler. * * See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.]. * * Example usage: * ```solidity * contract Example { * // Add the library methods * using StorageSlot for bytes32; * using SlotDerivation for bytes32; * * // Declare a namespace * string private constant _NAMESPACE = "<namespace>" // eg. OpenZeppelin.Slot * * function setValueInNamespace(uint256 key, address newValue) internal { * _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue; * } * * function getValueInNamespace(uint256 key) internal view returns (address) { * return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value; * } * } * ``` * * TIP: Consider using this library along with {StorageSlot}. * * NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking * upgrade safety will ignore the slots accessed through this library. * * _Available since v5.1._ */ library SlotDerivation { /** * @dev Derive an ERC-7201 slot from a string (namespace). */ function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) { assembly ("memory-safe") { mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1)) slot := and(keccak256(0x00, 0x20), not(0xff)) } } /** * @dev Add an offset to a slot to get the n-th element of a structure or an array. */ function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) { unchecked { return bytes32(uint256(slot) + pos); } } /** * @dev Derive the location of the first element in an array from the slot where the length is stored. */ function deriveArray(bytes32 slot) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, slot) result := keccak256(0x00, 0x20) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, and(key, shr(96, not(0)))) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, iszero(iszero(key))) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) { assembly ("memory-safe") { mstore(0x00, key) mstore(0x20, slot) result := keccak256(0x00, 0x40) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) { assembly ("memory-safe") { let length := mload(key) let begin := add(key, 0x20) let end := add(begin, length) let cache := mload(end) mstore(end, slot) result := keccak256(begin, add(length, 0x20)) mstore(end, cache) } } /** * @dev Derive the location of a mapping element from the key. */ function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) { assembly ("memory-safe") { let length := mload(key) let begin := add(key, 0x20) let end := add(begin, length) let cache := mload(end) mstore(end, slot) result := keccak256(begin, add(length, 0x20)) mstore(end, cache) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC-1967 implementation slot: * ```solidity * contract ERC1967 { * // Define the slot. Alternatively, use the SlotDerivation library to derive the slot. * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * TIP: Consider using this library along with {SlotDerivation}. */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct Int256Slot { int256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `Int256Slot` with member `value` located at `slot`. */ function getInt256Slot(bytes32 slot) internal pure returns (Int256Slot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns a `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } /** * @dev Returns a `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { assembly ("memory-safe") { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; assembly ("memory-safe") { ptr := add(buffer, add(32, length)) } while (true) { ptr--; assembly ("memory-safe") { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal * representation, according to EIP-55. */ function toChecksumHexString(address addr) internal pure returns (string memory) { bytes memory buffer = bytes(toHexString(addr)); // hash the hex part of buffer (skip length + 2 bytes, length 40) uint256 hashValue; assembly ("memory-safe") { hashValue := shr(96, keccak256(add(buffer, 0x22), 40)) } for (uint256 i = 41; i > 1; --i) { // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f) if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) { // case shift by xoring with 0x20 buffer[i] ^= 0x20; } hashValue >>= 4; } return string(buffer); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// Forked from https://github.com/intartnft/scripty.sol/blob/28cc612d7dc3a709f35c534c981bfc6bbfce4209/contracts/scripty/utils/AddressChunks.sol // with adjustment to data offset for compatibility with Art Blocks BytecodeStorage.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; library AddressChunks { /** * @notice Merge multiple chunks of contract code into a single bytes array. * Offloads details of reading contract code to UniversalBytecodeStorageReader contract, but efficiently * merges staticcall responses into a single bytes array using assembly. * @dev This could become more gas efficient by implementing logic in the bytecode storage reader contracts * here instead of moving large amounts of data through return data, but this implementation is much simpler * and maintainable. * @param chunks Array of contract addresses to merge * @param universalReaderContract Address of the UniversalBytecodeStorageReader contract to use for reading * stored bytecode (Art Blocks BytecodeStorage library) * @return o_code Merged contract code */ function mergeChunks( address[] memory chunks, address universalReaderContract ) internal view returns (bytes memory o_code) { unchecked { assembly ("memory-safe") { // part 1: provision memory for calldata to universal reader's readFromBytecode function // 4 bytes for function selector, 32 bytes for address let readerCalldata := mload(0x40) mstore(readerCalldata, 0x75662f38) // function selector for readFromBytecode(address) // calldata in memory will look like: // 0000000000000000000000000000000000000000000000000000000075662f38 // 000000000000000000000000<-------------chunk-address------------> // @dev do not populate address yet - do in call loop // update free memory pointer two words ahead, past end reserved for calldata mstore(0x40, add(readerCalldata, 0x40)) // update calldata to point to the start of the function selector readerCalldata := add(readerCalldata, 28) // part 2: reserve space 0x20 bytes representing the returned string length data for each call in loop let returnDataStringLength := mload(0x40) // update free memory pointer one word ahead, past end of returnDataStringLength mstore(0x40, add(returnDataStringLength, 0x20)) // part 3: build o_code while looping through chunks let len := mload(chunks) let totalSize := 0x20 o_code := mload(0x40) // loop through all chunk addresses // - get address // - get data size // - get code and add to o_code // - update total size let targetChunk := 0 for { let i := 0 } lt(i, len) { i := add(i, 1) } { targetChunk := mload(add(chunks, add(0x20, mul(i, 0x20)))) // update calldata with targetChunk address mstore(add(readerCalldata, 0x04), targetChunk) // offset by 4-byte function selector // call the readFromBytecode(address) function of contract targetChunk and don't store the result if iszero( staticcall( gas(), // forward all gas universalReaderContract, // target address with the data stored as bytecode readerCalldata, // start of calldata 0x24, // calldata size is 0x04 (function selector) + 0x20 (abi-encoded address) 0x00, // 0x00 (do not store return data) 0x00 // 0x00 (do not store return data) ) ) { revert(0, 0) // call failed, revert } // store return data string length returndatacopy( returnDataStringLength, 0x20, // start of return data's string length (ABI spec) 0x20 // size of length data (ABI spec) ) // store the return string data in memory starting at o_code + totalSize // first 0x20 bytes of return data points to the location of the string data (ABI spec) // second 0x20 bytes of return data is the length of the data (ABI spec) // the actual string data contents begin at returndata + 0x40 let storedReturnSize := mload(returnDataStringLength) returndatacopy( add(o_code, totalSize), // offset by totalSize 0x40, // skip the 0x40 bytes of length data at the start of the expected return data storedReturnSize // return data size, as gathered above ) totalSize := add(totalSize, storedReturnSize) // update total size } // update o_code length in memory mstore(o_code, sub(totalSize, 0x20)) // new "memory end" including padding mstore( 0x40, add(o_code, and(add(add(totalSize, 0x20), 0x1f), not(0x1f))) ) } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.7.5; pragma abicoder v2; struct HTMLRequest { HTMLTag[] headTags; HTMLTag[] bodyTags; } enum HTMLTagType { useTagOpenAndClose, script, scriptBase64DataURI, scriptGZIPBase64DataURI, scriptPNGBase64DataURI } struct HTMLTag { string name; address contractAddress; bytes contractData; HTMLTagType tagType; bytes tagOpen; bytes tagClose; bytes tagContent; } interface IUniswapV3Pool { function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); function liquidity() external view returns (uint128); function observe( uint32[] calldata secondsAgos ) external view returns ( int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s ); function initialize(uint160 sqrtPriceX96) external; } interface IUniswapV3Factory { function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool); function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); } interface ISwapRouter { struct ExactInputSingleParams { address tokenIn; address tokenOut; uint24 fee; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; uint160 sqrtPriceLimitX96; } function exactInputSingle( ExactInputSingleParams calldata params ) external payable returns (uint256 amountOut); struct ExactInputParams { bytes path; address recipient; uint256 deadline; uint256 amountIn; uint256 amountOutMinimum; } function exactInput( ExactInputParams calldata params ) external payable returns (uint256 amountOut); } interface INonfungiblePositionManager { struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } function mint( MintParams calldata params ) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool); function ownerOf(uint256 tokenId) external view returns (address owner); } interface IDelegateRegistry { function checkDelegateForERC721( address to, address from, address contract_, uint256 tokenId, bytes32 rights ) external view returns (bool valid); } interface IGenArt721GeneratorV0 { event DependencyRegistryUpdated(address indexed _dependencyRegistry); event GunzipScriptBytecodeAddressUpdated( address indexed _gunzipScriptBytecodeAddress ); event Initialized(uint8 version); event ScriptyBuilderUpdated(address indexed _scriptyBuilder); event UniversalBytecodeStorageReaderUpdated( address indexed _universalBytecodeStorageReader ); function dependencyRegistry() external view returns (address); function getDependencyScript( string calldata dependencyNameAndVersion ) external view returns (string memory); function getProjectScript( address coreContract, uint256 projectId ) external view returns (string memory); function getTokenHtml( address coreContract, uint256 tokenId ) external view returns (string memory); function getTokenHtmlBase64EncodedDataUri( address coreContract, uint256 tokenId ) external view returns (string memory); function gunzipScriptBytecodeAddress() external view returns (address); function initialize( address _dependencyRegistry, address _scriptyBuilder, address _gunzipScriptBytecodeAddress, address _universalBytecodeStorageReader ) external; function scriptyBuilder() external view returns (address); function universalBytecodeStorageReader() external view returns (address); function updateDependencyRegistry(address _dependencyRegistry) external; function updateGunzipScriptBytecodeAddress( address _gunzipScriptBytecodeAddress ) external; function updateScriptyBuilder(address _scriptyBuilder) external; function updateUniversalBytecodeStorageReader( address _universalBytecodeStorageReader ) external; } interface IDependencyRegistry { function getDependencyScriptBytecodeAddress( bytes32 dependencyNameAndVersion, uint256 index ) external view returns (address); } interface IUniversalBytecodeStorageReader { function readFromBytecode( address address_ ) external view returns (string memory); } interface IScriptyBuilderV2 { function getEncodedHTMLString( HTMLRequest memory htmlRequest ) external view returns (string memory); function getHTMLString( HTMLRequest memory htmlRequest ) external view returns (string memory); } interface IWETH { function deposit() external payable; function approve(address spender, uint256 amount) external returns (bool); }
{ "viaIR": true, "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CannotModifyPoolStatus","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC1155InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC1155InvalidApprover","type":"error"},{"inputs":[{"internalType":"uint256","name":"idsLength","type":"uint256"},{"internalType":"uint256","name":"valuesLength","type":"uint256"}],"name":"ERC1155InvalidArrayLength","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC1155InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC1155InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC1155InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC1155MissingApprovalForAll","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"InvalidTokenID","type":"error"},{"inputs":[],"name":"LiquidityAlreadyLoaded","type":"error"},{"inputs":[],"name":"MustSendETHToAddLiquidity","type":"error"},{"inputs":[],"name":"NotAuthorizedTransfer","type":"error"},{"inputs":[],"name":"NotSquiggleOwner","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"SquiggleAlreadyClaimed","type":"error"},{"inputs":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"StringsInsufficientHexLength","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","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":false,"internalType":"bytes32","name":"newHash","type":"bytes32"}],"name":"HashUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"inputs":[],"name":"CHROMIE_SQUIGGLE_10000","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TOKENS_PER_SQUIGGLE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyKillERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getPriceHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokenHtml","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTokenHtmlBase64EncodedDataUri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"hasHolderToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ignoreWalletForHolderToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"liquidityLoaded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"loadLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_dependencyRegistry","type":"address"}],"name":"setDependencyRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_generator","type":"address"}],"name":"setGenerator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_gunzipAddress","type":"address"}],"name":"setGunzipScriptBytecodeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"bool","name":"ignoreStatus","type":"bool"}],"name":"setIgnoreWalletForHolderToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_scriptyBuilder","type":"address"}],"name":"setScriptyBuilderAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_squiggleUpdateBlocks","type":"uint256"}],"name":"setSquiggleUpdateBlocks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_reader","type":"address"}],"name":"setUniversalBytecodeStorageReader","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"squiggleClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"originalTokenIds","type":"uint256[]"}],"name":"squiggleHolderClaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"squiggleUpdateBlocks","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV3Pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234620001d85762000034620000186200021d565b6200002262000241565b6200002c6200029d565b9133620002cb565b6200003f6001600c55565b600e80546001600160a01b0319167337861f95882acdba2ccd84f5bfc4598e2ecdddaf179055600f80546001600160a01b0319166da791abed33872c44a3d215a3743b179055601080546001600160a01b03191673953d288708bb771f969fcfd9ba0819ef506ac718179055601180546001600160a01b03191673b33ef4b9e1b2c72e0c9ddf49ceb82d1baaaf8043179055601280546001600160a01b03191673d7587f110e08f4d120a231ba97d3b577a81df0221790556200010a600160ff196014541617601455565b6000805260166020526200013560008051602062004c198339815191525b805460ff19166001179055565b3060009081526016602052604090206200014f9062000128565b6200015a306200065d565b336000908152601560205260409020620001749062000128565b62000189620001826200021d565b3362000691565b604051603f60f91b60208201908152620001be91620001b681602181015b03601f198101835282620001f3565b519020601755565b620001c843601855565b604051613a189081620011e18239f35b600080fd5b634e487b7160e01b600052604160045260246000fd5b601f909101601f19168101906001600160401b038211908210176200021757604052565b620001dd565b60405190602082016001600160401b03811183821017620002175760405260008252565b60405190606082016001600160401b038111838210176200021757604052602982526806c65202331303030360bc1b6040837f54686520457665722d45766f6c76696e67204368726f6d69652053717569676760208201520152565b60408051919082016001600160401b03811183821017620002175760405260018252603f60f91b6020830152565b8251909391926001600160401b0382116200021757620002f882620002f260035462000421565b6200045e565b602090816001601f8511146200038a57508262000342936200034896959362000339936000926200037e575b50508160011b916000199060031b1c19161790565b6003556200056f565b62000899565b6001600160a01b038116156200036557620003639062000850565b565b604051631e4fbdf760e01b815260006004820152602490fd5b01519050388062000324565b60036000529190601f1984167fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b936000905b8282106200040857505092600192859262000342966200034899989610620003ee575b505050811b016003556200056f565b015160001960f88460031b161c19169055388080620003df565b80600186978294978701518155019601940190620003bc565b90600182811c9216801562000453575b60208310146200043d57565b634e487b7160e01b600052602260045260246000fd5b91607f169162000431565b601f81116200046b575050565b60009060036000526020600020906020601f850160051c83019410620004ae575b601f0160051c01915b828110620004a257505050565b81815560010162000495565b90925082906200048c565b601f8111620004c6575050565b60009060076000526020600020906020601f850160051c8301941062000509575b601f0160051c01915b828110620004fd57505050565b818155600101620004f0565b9092508290620004e7565b601f811162000521575050565b60009060046000526020600020906020601f850160051c8301941062000564575b601f0160051c01915b8281106200055857505050565b8181556001016200054b565b909250829062000542565b80519091906001600160401b03811162000217576200059b816200059560045462000421565b62000514565b602080601f8311600114620005d557508190620005d093946000926200037e5750508160011b916000199060031b1c19161790565b600455565b6004600052601f198316949091907f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b926000905b878210620006445750508360019596106200062a575b505050811b01600455565b015160001960f88460031b161c191690553880806200061f565b8060018596829496860151815501950193019062000609565b6001600160a01b0381161562000678576200036390620009e6565b60405163ec442f0560e01b815260006004820152602490fd5b6001600160a01b03811691908215620008375760405160019384825260209160208101956127108752604082019281845260609460608401958387526080850180604052855187518082036200081b57505050908391826000905b620007b3575b5050508351146000146200077457600088517fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6262000746885160405191829133958360209093929193604081019481520152565b0390a45b8151036200076457505062000363935190519133620011a8565b9150916200036394503362001068565b60006040517f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb339180620007aa89898362000f47565b0390a46200074a565b8651811015620008155780849160051b88016200080b620008028d620007eb8789860151950151946000526005602052604060002090565b9060018060a01b0316600052602052604060002090565b918254620009bd565b90550183620006ec565b620006f2565b635b05999160e01b8352608488019190915260a4870152604490fd5b604051632bfa23e760e11b815260006004820152602490fd5b600880546001600160a01b039283166001600160a01b0319821681179092559091167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3565b80519091906001600160401b0381116200021757620008c581620008bf60075462000421565b620004b9565b602080601f8311600114620008ff57508190620008fa93946000926200037e5750508160011b916000199060031b1c19161790565b600755565b6007600052601f198316949091907fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688926000905b8782106200096e57505083600195961062000954575b505050811b01600755565b015160001960f88460031b161c1916905538808062000949565b8060018596829496860151815501950193019062000933565b634e487b7160e01b600052601160045260246000fd5b906b033b2e3c9fd0803ce80000008201809211620009b757565b62000987565b91908201809211620009b757565b6b033b2e3c9fd0803ce7ffffff19810191908211620009b757565b600954620009fc9060a01c60ff161590565b1590565b62000bf75762000a12601854600c5490620009bd565b43101562000c02575b62000a2c620009f860145460ff1690565b62000bf7576001600160a01b038116600090815260166020526040902062000a5b90620009f8905b5460ff1690565b8062000bc8575b8062000b8e575b62000b50575b60008052601660205262000a96620009f860008051602062004c1983398151915262000a54565b8062000b26575b8062000ae1575b62000ab457620003639062000c54565b60008052601560205262000adb60008051602062004bf9833981519152805460ff19169055565b62000ef9565b506000808052602052670de0b6b3a764000062000b1f7fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb554620009cb565b1062000aa4565b5060008052601560205262000b4a60008051602062004bf983398151915262000a54565b62000a9d565b6001600160a01b038116600090815260156020526040902062000b739062000128565b62000b8862000b816200021d565b8262000691565b62000a6f565b50670de0b6b3a764000062000bc062000bb98360018060a01b03166000526000602052604060002090565b546200099d565b101562000a69565b506001600160a01b038116600090815260156020526040902062000bf190620009f89062000a54565b62000a62565b620003639062000c54565b62000c1562000c1062000df1565b601755565b62000c1f43601855565b6017546040519081527f8860ccaec8f1de4786a9099984cdb7544072d42beec6181fd67eee2caee9b2d190602090a162000a1b565b6002546b033b2e3c9fd0803ce8000000808201809211620009b75760207fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9160009360025560018060a01b038516948515851462000ccc57506b033b2e3c9fd0803ce7ffffff19600254016002555b604051908152a3565b6001600160a01b0316600090815260208190526040902081815401905562000cc3565b519061ffff82168203620001d857565b51908115158203620001d857565b908160e0910312620001d85780516001600160a01b0381168103620001d8579160208201518060020b8103620001d8579162000d4c6040820162000cef565b9162000d5b6060830162000cef565b9162000d6a6080820162000cef565b9160a082015160ff81168103620001d85760c062000d8a91930162000cff565b90565b6040513d6000823e3d90fd5b90670de0b6b3a764000091828102928184041490151715620009b757565b81810292918115918404141715620009b757565b801562000ddb57600160c01b0490565b634e487b7160e01b600052601260045260246000fd5b60095460049060e09062000e1c9062000e10906001600160a01b031681565b6001600160a01b031690565b60405192838092633850c7bd851b82525afa801562000ef35762000e769160009162000eb7575b50600b5460ff161562000e975762000e709062000e6a906001600160a01b03168062000db7565b60c01c90565b62000d99565b60405162000e9181620001a760208201948560209181520190565b51902090565b62000e709062000eb1906001600160a01b03168062000db7565b62000dcb565b62000ede915060e03d60e01162000eeb575b62000ed58183620001f3565b81019062000d0d565b5050505050503862000e43565b503d62000ec9565b62000d8d565b604051626a0d4560e21b815260006004820152602490fd5b90815180825260208080930193019160005b82811062000f32575050505090565b83518552938101939281019260010162000f23565b909162000f6162000d8a9360408452604084019062000f11565b91602081840391015262000f11565b90816020910312620001d857516001600160e01b031981168103620001d85790565b919082519283825260005b84811062000fbf575050826000602080949584010152601f8019910116010190565b60208183018101518483018201520162000f9d565b926200100762000d8a9593620010169360018060a01b031686526000602087015260a0604087015260a086019062000f11565b90848203606086015262000f11565b91608081840391015262000f92565b3d1562001063573d906001600160401b03821162000217576040519162001057601f8201601f191660200184620001f3565b82523d6000602084013e565b606090565b9293919093843b6200107c575b5050505050565b602091620010a1604051948593849363bc197c8160e01b988986526004860162000fd4565b038160006001600160a01b0388165af1600091816200113d575b50620010fe5782620010cc62001025565b8051919082620010f757604051632bfa23e760e11b81526001600160a01b0383166004820152602490fd5b9050602001fd5b6001600160e01b031916036200111a5750388080808062001075565b604051632bfa23e760e11b81526001600160a01b03919091166004820152602490fd5b6200116591925060203d6020116200116d575b6200115c8183620001f3565b81019062000f70565b9038620010bb565b503d62001150565b909260a09262000d8a9594600180861b031683526000602084015260408301526060820152816080820152019062000f92565b9293919093843b620011bb575050505050565b602091620010a1604051948593849363f23a6e6160e01b98898652600486016200117556fe6080604052600436101561001257600080fd5b60003560e01c8062fdd58e146102d657806301ffc9a7146102d157806306fdde03146102cc578063095ea7b3146102c75780630e89341c146102c257806318160ddd146102bd5780631c6a04d8146102b857806323b872dd146102b357806324c642af146102ae5780632e8a1716146102a95780632eb2c2d6146102a4578063313ce5671461029f57806332cb6b0c1461029a578063390b19db1461029557806346a98b01146102905780634a7c7e4b1461028b5780634dc709f7146102865780634e1273f4146102815780636342e0a61461027c578063635d79eb1461027757806366cad83a146102725780636e32daf71461026d5780636e7dab9214610268578063704b81c51461026357806370a082311461025e578063715018a61461025957806371640de314610254578063722b3b591461024f57806372ba8fef1461024a5780637d24f4771461024557806384a4a75314610240578063885229981461023b5780638da5cb5b1461023657806395d89b411461023157806396f4205a1461022c578063a22cb46514610227578063a9059cbb14610222578063aede920c1461021d578063bd12407d14610218578063dd62ed3e14610213578063e985e9c51461020e578063ede8f7e014610209578063f242432a146102045763f2fde38b146101ff57600080fd5b611957565b611911565b6118e0565b6118c5565b611889565b611843565b61181e565b6117e9565b6117d4565b61178d565b6116c7565b61169e565b611675565b611650565b61162d565b61140c565b6113ca565b6113ac565b61134e565b611311565b61127e565b611258565b61123b565b61121d565b6111d6565b61118f565b6110d3565b611047565b611000565b610fa0565b610f41565b610f1a565b610efe565b610e7f565b610c95565b610c53565b610b9f565b6107b9565b61079b565b610606565b610538565b610429565b610354565b6102f1565b6001600160a01b038116036102ec57565b600080fd5b346102ec5760403660031901126102ec576020610339600435610313816102db565b6024356000526005835260406000209060018060a01b0316600052602052604060002090565b54604051908152f35b6001600160e01b03198116036102ec57565b346102ec5760203660031901126102ec57602060043561037381610342565b63ffffffff60e01b16636cdb3d1360e11b81149081156103b1575b81156103a0575b506040519015158152f35b6301ffc9a760e01b14905038610395565b6303a24d0760e21b8114915061038e565b60009103126102ec57565b60005b8381106103e05750506000910152565b81810151838201526020016103d0565b90602091610409815180928185528580860191016103cd565b601f01601f1916010190565b9060206104269281815201906103f0565b90565b346102ec57600080600319360112610535576040519080600354906001918060011c926001821692831561052b575b6020926020861085146105175785885260208801949081156104f6575060011461049d575b6104998761048d81890382610d69565b60405191829182610415565b0390f35b600360005294509192917fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8386106104e5575050509101905061048d82610499388061047d565b8054858701529482019481016104c9565b60ff191685525050505090151560051b01905061048d82610499388061047d565b634e487b7160e01b82526022600452602482fd5b93607f1693610458565b80fd5b346102ec5760403660031901126102ec57600435610555816102db565b60243533156105ed576001600160a01b0382169182156105d457336000908152600160205260409020829161059c915b9060018060a01b0316600052602052604060002090565b556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b604051634a1406b160e11b815260006004820152602490fd5b60405163e602df0560e01b815260006004820152602490fd5b346102ec5760203660031901126102ec57612710600435036107895761049961077d61048d61070c610748610639611c75565b604051607b60f81b60208201527f226e616d65223a20224368726f6d6965205371756967676c6520233130303030602182015261088b60f21b60418201527f226465736372697074696f6e223a2022546865207371756967676c652064697360438201527f706c617965642075706461746573206261736564206f6e20746865206375727260638201526e195b9d08091f881c1c9a58d94b888b608a1b6083820152711130b734b6b0ba34b7b72fbab936111d101160711b6092820152928391610726916107199160a485015b90611a15565b601160f91b815260010190565b607d60f81b815260010190565b039161073a601f1993848101835282610d69565b610742611fd9565b90612983565b6040517f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000006020820152938491603d8301610706565b03908101835282610d69565b604051636aa2a93760e01b8152600490fd5b346102ec5760003660031901126102ec576020600254604051908152f35b600080600319360112610535576107ce612048565b60095460a01c60ff16610b8d573415610b7b5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2803b15610b7757604051630d0e30db60e41b8152828160048134865af18015610add57610b5e575b5061083730821060ff8019600b54169115151617600b55565b600b5460ff168015610b5757815b8115610b4d57506108d430915b8015610b3a5734935b8115610b33576b019d971e4fe8401e74000000915b15610b115761089561088961088434611a67565b6120b4565b6001600160a01b031690565b6040516309f56ab160e11b81526001600160a01b0380841660048301528087166024830152612710604483015290911660648201529283906084820190565b039160208473c36442b4a4522e871399cd717abdd847ab11fe8894818a875af1958615610add5761099c6080966109348a99610a7a988b91610ae2575b5060018060a01b03166bffffffffffffffffffffffff60a01b6009541617600955565b6009546001600160a01b03166000908152601660205260409020610960905b805460ff19166001179055565b61096934612116565b6109723061225b565b61098c61097d610d8a565b6001600160a01b039096168652565b6001600160a01b03166020850152565b6127106040848101918252620d899f1960608601908152620d89a08987015260a0860193845260c0860194855260e086018a815261010087018b8152336101208901908152426101408a019081529451634418b22b60e11b815289516001600160a01b03908116600483015260208b015181166024830152965162ffffff1660448201529351600290810b606486015260809099015190980b6084840152945160a4830152945160c4820152935160e48501529151610104840152925190921661012482015290516101448201529384928391908290610164820190565b03925af18015610add57610a95918391610aab575b50600a55565b6009805460ff60a01b1916600160a01b17905580f35b610acd915060803d608011610ad6575b610ac58183610d69565b810190611a9b565b50505038610a8f565b503d610abb565b611a7a565b610b04915060203d602011610b0a575b610afc8183610d69565b810190611a86565b38610911565b503d610af2565b610b2e6108896b019d971e4fe8401e740000003460c01b046120b4565b610895565b3491610870565b6b019d971e4fe8401e740000009361085b565b6108d49091610852565b3091610845565b80610b6b610b7192610cc9565b806103c2565b3861081e565b5080fd5b60405163664d342360e01b8152600490fd5b604051639483839160e01b8152600490fd5b346102ec5760603660031901126102ec57600435610bbc816102db565b602435610bc8816102db565b6001600160a01b038216600090815260016020908152604080832033845290915290206044359190549260018401610c11575b610c059350612408565b60405160018152602090f35b828410610c2d57610c2883610c0595033383612917565b610bfb565b604051637dc7a0d960e11b81523360048201526024810185905260448101849052606490fd5b346102ec5760203660031901126102ec57600435610c70816102db565b60018060a01b03166000526016602052602060ff604060002054166040519015158152f35b346102ec5760003660031901126102ec576020601754604051908152f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b038111610cdc57604052565b610cb3565b60e081019081106001600160401b03821117610cdc57604052565b61016081019081106001600160401b03821117610cdc57604052565b602081019081106001600160401b03821117610cdc57604052565b608081019081106001600160401b03821117610cdc57604052565b604081019081106001600160401b03821117610cdc57604052565b90601f801991011681019081106001600160401b03821117610cdc57604052565b60405190610d9782610cfc565b565b60405190610d9782610ce1565b6001600160401b038111610cdc5760051b60200190565b9080601f830112156102ec576020908235610dd781610da6565b93610de56040519586610d69565b81855260208086019260051b8201019283116102ec57602001905b828210610e0e575050505090565b81358152908301908301610e00565b6001600160401b038111610cdc57601f01601f191660200190565b81601f820112156102ec57803590610e4f82610e1d565b92610e5d6040519485610d69565b828452602083830101116102ec57816000926020809301838601378301015290565b346102ec5760a03660031901126102ec57610e9b6004356102db565b610ea66024356102db565b6001600160401b036044358181116102ec57610ec6903690600401610dbd565b506064358181116102ec57610edf903690600401610dbd565b506084359081116102ec57610ef8903690600401610e38565b50611acd565b346102ec5760003660031901126102ec57602060405160128152f35b346102ec5760003660031901126102ec5760206040516b033b2e3c9fd0803ce80000008152f35b346102ec5760003660031901126102ec57610499610f5d611c75565b6040519182916020835260208301906103f0565b801515036102ec57565b60409060031901126102ec57600435610f93816102db565b9060243561042681610f71565b346102ec57610fae36610f7b565b90610fb7612048565b6009546001600160a01b0391821691168114610fee57600052601660205260406000209060ff801983541691151516179055600080f35b60405163239c8a8360e21b8152600490fd5b346102ec5760203660031901126102ec5760043561101d816102db565b611025612048565b601080546001600160a01b0319166001600160a01b0392909216919091179055005b346102ec5760203660031901126102ec57600435611064816102db565b61106c612048565b601280546001600160a01b0319166001600160a01b0392909216919091179055005b90815180825260208080930193019160005b8281106110ae575050505090565b8351855293810193928101926001016110a0565b90602061042692818152019061108e565b346102ec5760403660031901126102ec576004356001600160401b038082116102ec57366023830112156102ec57816004013561110f81610da6565b9261111d6040519485610d69565b8184526020916024602086019160051b830101913683116102ec57602401905b82821061117657856024358681116102ec576104999161116461116a923690600401610dbd565b90611d2f565b604051918291826110c2565b8380918335611184816102db565b81520191019061113d565b346102ec5760203660031901126102ec576004356111ac816102db565b6111b4612048565b601180546001600160a01b0319166001600160a01b0392909216919091179055005b346102ec5760203660031901126102ec576004356111f3816102db565b6111fb612048565b600f80546001600160a01b0319166001600160a01b0392909216919091179055005b346102ec5760003660031901126102ec576020600c54604051908152f35b346102ec5760003660031901126102ec5760206040516127108152f35b346102ec5760003660031901126102ec57602060ff60095460a01c166040519015158152f35b346102ec57600080600319360112610535576112c28161129c612659565b60018060a01b03601254166040518080958194636af6c46760e11b835260048301611c40565b03915afa908115610add578261049993926112ee575b50506040519182916020835260208301906103f0565b61130a92503d8091833e6113028183610d69565b810190611adf565b38806112d8565b346102ec5760203660031901126102ec5760043561132e816102db565b60018060a01b031660005260006020526020604060002054604051908152f35b346102ec5760008060031936011261053557611368612048565b600880546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346102ec5760003660031901126102ec576020600a54604051908152f35b346102ec5760203660031901126102ec576004356113e7816102db565b60018060a01b03166000526015602052602060ff604060002054166040519015158152f35b346102ec576020806003193601126102ec5760048035906001600160401b038083116102ec57366023840112156102ec57828201359081116102ec576024830192602436918360051b0101116102ec5760005b81811061146857005b611473818386611dd4565b3561270f811161161c5761149b611494826000526013602052604060002090565b5460ff1690565b61160b57604080516331a9108f60e11b8152858101838152889082908190602001038173059edd72cd353df5106d2b9cc5ab83a52287ac3a5afa908115610add576000916115ee575b50336001600160a01b0382161490889084908315611541575b5050506000146115325750906115226109536001936000526013602052604060002090565b61152c33306123b5565b0161145f565b51630a170a8f60e31b81528490fd5b8451632e7cda1d60e21b8152338a82019081526001600160a01b03909216602083015273059edd72cd353df5106d2b9cc5ab83a52287ac3a60408301526060820192909252600060808201529092508290819060a00103816c447e69651d841bd8d104bed4935afa908115610add576000916115c1575b508783386114fd565b6115e19150883d8a116115e7575b6115d98183610d69565b810190611de4565b386115b8565b503d6115cf565b6116059150883d8a11610b0a57610afc8183610d69565b386114e4565b604051630baa526f60e11b81528490fd5b604051636aa2a93760e01b81528490fd5b346102ec5760003660031901126102ec576020611648611ed9565b604051908152f35b346102ec5760003660031901126102ec576020604051690a968163f0a57b4000008152f35b346102ec5760003660031901126102ec576009546040516001600160a01b039091168152602090f35b346102ec5760003660031901126102ec576008546040516001600160a01b039091168152602090f35b346102ec57600080600319360112610535576040519080600454906001918060011c9260018216928315611783575b6020926020861085146105175785885260208801949081156104f6575060011461172a576104998761048d81890382610d69565b600460005294509192917f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b838610611772575050509101905061048d82610499388061047d565b805485870152948201948101611756565b93607f16936116f6565b346102ec5760203660031901126102ec576004356117aa816102db565b6117b2612048565b600e80546001600160a01b0319166001600160a01b0392909216919091179055005b346102ec576117e236610f7b565b5050611acd565b346102ec5760403660031901126102ec57611813600435611809816102db565b6024359033612408565b602060405160018152f35b346102ec5760003660031901126102ec57611837612048565b6014805460ff19169055005b346102ec5760203660031901126102ec5761185c612048565b600435600c55005b60409060031901126102ec5760043561187c816102db565b90602435610426816102db565b346102ec57602061033961189c36611864565b6001600160a01b0391821660009081526001855260408082209290931681526020919091522090565b346102ec576118d336611864565b5050602060405160008152f35b346102ec5760203660031901126102ec576004356000526013602052602060ff604060002054166040519015158152f35b346102ec5760a03660031901126102ec5761192d6004356102db565b6119386024356102db565b6084356001600160401b0381116102ec57610ef8903690600401610e38565b346102ec5760203660031901126102ec57600435611974816102db565b61197c612048565b6001600160a01b039081169081156119d057600854826bffffffffffffffffffffffff60a01b821617600855167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b611a1191600052600560205260406000209060018060a01b0316600052602052604060002090565b5490565b90611a28602092828151948592016103cd565b0190565b634e487b7160e01b600052601160045260246000fd5b8015611a5157600160c01b0490565b634e487b7160e01b600052601260045260246000fd5b8015611a51576413fa10079d60da1b0490565b6040513d6000823e3d90fd5b908160209103126102ec5751610426816102db565b91908260809103126102ec5781519160208101516001600160801b03811681036102ec57916060604083015192015190565b604051638b4c470960e01b8152600490fd5b6020818303126102ec578051906001600160401b0382116102ec570181601f820112156102ec578051611b1181610e1d565b92611b1f6040519485610d69565b818452602082840101116102ec5761042691602080850191016103cd565b906005821015611b4a5752565b634e487b7160e01b600052602160045260246000fd5b908082519081815260208091019281808460051b8301019501936000915b848310611b8e5750505050505090565b9091929394958480611c30600193601f198682030187528a51611c1d611c0a611be5611bc360e08551908088528701906103f0565b898060a01b0388860151168887015260408086015190878303908801526103f0565b611bf760608086015190870190611b3d565b60808085015190868303908701526103f0565b60a08084015190858303908601526103f0565b9160c080920151918184039101526103f0565b9801930193019194939290611b7e565b9061042691602081526020611c6083516040838501526060840190611b60565b920151906040601f1982850301910152611b60565b611ca86000611c82612659565b60018060a01b03601254166040518080958194635448d9af60e11b835260048301611c40565b03915afa908115610add57600091611cbe575090565b61042691503d806000833e6113028183610d69565b634e487b7160e01b600052603260045260246000fd5b805115611cf65760200190565b611cd3565b805160011015611cf65760400190565b805160021015611cf65760600190565b8051821015611cf65760209160051b010190565b91909180518351808203611db2575050805190611d64611d4e83610da6565b92611d5c6040519485610d69565b808452610da6565b60209190601f1901368484013760005b8151811015611daa5780611d9960019260051b85808287010151918a010151906119e9565b611da38287611d1b565b5201611d74565b509193505050565b604051635b05999160e01b815260048101919091526024810191909152604490fd5b9190811015611cf65760051b0190565b908160209103126102ec575161042681610f71565b519061ffff821682036102ec57565b908160e09103126102ec578051611e1e816102db565b9160208201518060020b81036102ec5791611e3b60408201611df9565b91611e4860608301611df9565b91611e5560808201611df9565b9160a082015160ff811681036102ec5760c09092015161042681610f71565b90670de0b6b3a764000091828102928184041490151715611e9157565b611a2c565b600281901b91906001600160fe1b03811603611e9157565b600181901b91906001600160ff1b03811603611e9157565b81810292918115918404141715611e9157565b60095460049060e090611ef690610889906001600160a01b031681565b60405192838092633850c7bd851b82525afa8015610add57611f4891600091611f91575b50600b5460ff1615611f7557611f4390611f3d906001600160a01b031680611ec6565b60c01c90565b611e74565b604051611f6f81611f6160208201948560209181520190565b03601f198101835282610d69565b51902090565b611f4390611f8c906001600160a01b031680611ec6565b611a42565b611fb3915060e03d60e011611fbf575b611fab8183610d69565b810190611e08565b50505050505038611f1a565b503d611fa1565b60405190611fd382610d18565b60008252565b60405190606082018281106001600160401b03821117610cdc57604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b6008546001600160a01b0316330361205c57565b60405163118cdaa760e01b8152336004820152602490fd5b9060028201809211611e9157565b9060018201809211611e9157565b90690a968163f0a57b4000008201809211611e9157565b91908201809211611e9157565b8015612110576001808201808311611e915760011c9082905b8383106120da5750505090565b919250908280156120fb57808304908101809111611e9157811c91906120cd565b60246000634e487b7160e01b81526012600452fd5b50600090565b604051636eb1769f60e11b815230600482015273c36442b4a4522e871399cd717abdd847ab11fe886024820181905260209273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2908484604481855afa938415610add5760009461222c575b508301809311611e9157836000604051948286019063095ea7b360e01b9586835260248801526044870152604486526121ad86610d33565b85519082855af1903d600051908361220d575b505050156121cd57505050565b6040519283015273c36442b4a4522e871399cd717abdd847ab11fe88602483015260006044830152610d979161220890818160648101611f61565b6130d6565b9192509061222257503b15155b3880806121c0565b600191501461221a565b9093508481813d8311612254575b6122448183610d69565b810103126102ec57519238612175565b503d61223a565b604051636eb1769f60e11b815230600482015273c36442b4a4522e871399cd717abdd847ab11fe8860248201819052602092906001600160a01b0382168484604481845afa938415610add57600094612386575b506b019d971e4fe8401e740000008401809411611e9157846000604051958287019063095ea7b360e01b9586835260248901526044880152604487526122f487610d33565b86519082875af1903d6000519083612367575b50505015612316575b50505050565b6040519384015273c36442b4a4522e871399cd717abdd847ab11fe8860248401526000604484015261235e92612359906123538160648101611f61565b82613132565b613132565b38808080612310565b9192509061237c57503b15155b388080612307565b6001915014612374565b9093508481813d83116123ae575b61239e8183610d69565b810103126102ec575192386122af565b503d612394565b906001600160a01b03808316156123ef578116156123d657610d9791612a89565b60405163ec442f0560e01b815260006004820152602490fd5b604051634b637e8f60e11b815260006004820152602490fd5b91906001600160a01b03808416156123ef578116156123d657610d9792612cbb565b60405190604082018281106001600160401b03821117610cdc5760405260606020838281520152565b604080519161246183610d33565b60038352829160009160005b6060808210156124b65783516020929161248682610ce1565b80825283908782840152808784015287818401528060808401528060a084015260c083015282890101520161246d565b50509293505050565b604051906124cc82610d4e565b60078252661e39ba3cb6329f60c91b6020830152565b6040519060c082018281106001600160401b03821117610cdc5760405260948252736f6d3a303b6c6566743a303b72696768743a307d60601b60a0837f68746d6c7b6865696768743a313030257d626f64797b6d696e2d68656967687460208201527f3a313030253b6d617267696e3a303b70616464696e673a307d63616e7661737b60408201527f70616464696e673a303b6d617267696e3a6175746f3b646973706c61793a626c60608201527f6f636b3b706f736974696f6e3a6162736f6c7574653b746f703a303b626f747460808201520152565b604051906125c782610d4e565b60088252671e17b9ba3cb6329f60c11b6020830152565b604051906125eb82610d4e565b601682527567756e7a6970536372697074732d302e302e312e6a7360501b6020830152565b6040519061261d82610d4e565b60088252671e39b1b934b83a1f60c11b6020830152565b6040519061264182610d4e565b60098252681e17b9b1b934b83a1f60b91b6020830152565b61266161242a565b5061266a612453565b608061267582611ce9565b510161267f6124bf565b905260c061268c82611ce9565b51016126966124e2565b905260a06126a382611ce9565b51016126ad6125ba565b905261270f61271e6126c0601754612edb565b611f6160405193849261070660208501602c907f6c657420746f6b656e44617461203d207b22746f6b656e4964223a313030303081526b16113430b9b432b9911d2d9160a11b60208201520190565b62225d7d60e81b815260030190565b60c061272983611cfb565b510152612742606061273a83611cfb565b510160019052565b61274a612453565b61275261300c565b60c061275d83611ce9565b510152612776606061276e83611ce9565b510160039052565b61277f81611cfb565b516127886125de565b90526127a0606061279883611cfb565b510160029052565b600f546127f0906127bb90610889906001600160a01b031681565b601154604051630eacc5e760e31b81526001600160a01b03909116600482015260009290918391839190829081906024820190565b03915afa908115610add5782916128fd575b5060c061280e84611cfb565b51015260105461282890610889906001600160a01b031681565b604051635e0f356560e11b815273059edd72cd353df5106d2b9cc5ab83a52287ac3a600482015260006024820152908290829060449082905afa908115610add5782916128e3575b50612879612610565b612881612634565b9061288a610d99565b93612893611fc6565b85528060208601526128a3611fc6565b60408601526060850152608084015260a083015260c08201526128c582611d0b565b526128cf81611d0b565b506128d861242a565b918252602082015290565b6128f791503d8084833e6113028183610d69565b38612870565b61291191503d8084833e6113028183610d69565b38612802565b906001600160a01b03808316156105ed578116156105d45761058561294e9260018060a01b03166000526001602052604060002090565b55565b9061295b82610e1d565b6129686040519182610d69565b8281528092612979601f1991610e1d565b0190602036910137565b90815115612a5a576129af6129aa6129a561299e8551612074565b6003900490565b611e96565b612951565b91602083019181825183016020810191825193600084525b828210612a0857505050525160039006600181146129f5576002146129ea575090565b603d90600019015390565b50603d9081600019820153600119015390565b9091956004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c16880101516002860153168501015190820153019591906129c7565b5050610426611fc6565b690a968163f0a57b3fffff19810191908211611e9157565b91908203918211611e9157565b90612aa1612a9d60095460ff9060a01c1690565b1590565b612c6557612ab4601854600c54906120a7565b431015612c6e575b612acb612a9d60145460ff1690565b612c6557610d9791612af5612a9d6114948460018060a01b03166000526016602052604060002090565b80612c3a575b80612c04575b612bcd575b6001600160a01b0381166000908152601660205260409020612b2b90612a9d90611494565b80612ba6575b80612b71575b1561318e576001600160a01b0381166000908152601560205260409020612b63905b805460ff19169055565b612b6c8161355f565b61318e565b50670de0b6b3a7640000612ba0612b9a8360018060a01b03166000526000602052604060002090565b54612a64565b10612b37565b506001600160a01b0381166000908152601560205260409020612bc890611494565b612b31565b6001600160a01b0382166000908152601560205260409020612bee90610953565b612bff612bf9611fc6565b836133fb565b612b06565b50670de0b6b3a7640000612c33612c2d8460018060a01b03166000526000602052604060002090565b54612090565b1015612b01565b506001600160a01b0382166000908152601560205260409020612c6090612a9d90611494565b612afb565b610d979161318e565b612c7e612c79611ed9565b601755565b612c8743601855565b6017546040519081527f8860ccaec8f1de4786a9099984cdb7544072d42beec6181fd67eee2caee9b2d190602090a1612abc565b9190612cd0612a9d60095460ff9060a01c1690565b612e8a57612ce3601854600c54906120a7565b431015612e93575b612cfa612a9d60145460ff1690565b612e8a57610d9792612d24612a9d6114948460018060a01b03166000526016602052604060002090565b80612e5f575b80612e28575b612df7575b6001600160a01b0381166000908152601660205260409020612d5a90612a9d90611494565b80612dd0575b80612d9a575b156132cf576001600160a01b0381166000908152601560205260409020612d8c90612b59565b612d958161355f565b6132cf565b50670de0b6b3a7640000612dca84612dc48460018060a01b03166000526000602052604060002090565b54612a7c565b10612d66565b506001600160a01b0381166000908152601560205260409020612df290611494565b612d60565b6001600160a01b0382166000908152601560205260409020612e1890610953565b612e23612bf9611fc6565b612d35565b50670de0b6b3a7640000612e5884612e528560018060a01b03166000526000602052604060002090565b546120a7565b1015612d30565b506001600160a01b0382166000908152601560205260409020612e8590612a9d90611494565b612d2a565b610d97926132cf565b612e9e612c79611ed9565b612ea743601855565b6017546040519081527f8860ccaec8f1de4786a9099984cdb7544072d42beec6181fd67eee2caee9b2d190602090a1612ceb565b6001600160801b038111818160071b1c9160016004926001600160401b038511948560061b1c63ffffffff8111908160051b1c9561ffff87119260ff85988560041b1c1193851b9260021b9160031b9060041b0101010101918190612f4a6129aa612f4586611eae565b612074565b946030612f5687611ce9565b536078612f62876136f9565b53612f74612f6f86611eae565b612082565b915b818311612fab57505050612f8957505090565b60405163e22e27eb60e01b815260048101919091526024810191909152604490fd5b909192600f8116906010821015611cf657612fe9916f181899199a1a9b1b9c1cb0b131b232b360811b901a612fe0868a613709565b53821c9361371a565b9190612f76565b60405190612ffd82610cfc565b600a8252610140366020840137565b613014612ff0565b600e54600090819061303090610889906001600160a01b031681565b905b600a8110613054575050600f546104269291506001600160a01b031690613727565b60405163dfa3be5360e01b8152670703540312e302e360c41b6004820152602481018290529060208083604481875afa8015610add576001936130b39287926130b9575b50506130a48388611d1b565b6001600160a01b039091169052565b01613032565b6130cf9250803d10610b0a57610afc8183610d69565b3880613098565b6020600082518273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2940182855af115611a7a576000513d6131295750803b155b6131115750565b60249060405190635274afe760e01b82526004820152fd5b6001141561310a565b906000602091828151910182855af115611a7a576000513d61318557506001600160a01b0381163b155b6131635750565b604051635274afe760e01b81526001600160a01b039091166004820152602490fd5b6001141561315c565b6001600160a01b03818116918261323d57506131b36131ae600254612090565b600255565b8216918261321157506131d4690a968163f0a57b3fffff1960025401600255565b604051690a968163f0a57b40000081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080602081015b0390a3565b6001600160a01b03166000908152602081905260409020690a968163f0a57b40000081540190556131d4565b6001600160a01b038116600090815260208190526040902054690a968163f0a57b40000081106132975761329190690a968163f0a57b3fffff19019160018060a01b03166000526000602052604060002090565b556131b3565b60405163391434e360e21b81526001600160a01b039290921660048301526024820152690a968163f0a57b4000006044820152606490fd5b90916001600160a01b03808316928361336057508161320c916133186131ae7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef956002546120a7565b8516948561333e575061332e8160025403600255565b6040519081529081906020820190565b6001600160a01b0316600090815260208190526040902081815401905561332e565b6001600160a01b0381166000908152602081905260409020548381106133cc579183916133c67fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9561320c95039160018060a01b03166000526000602052604060002090565b55613318565b60405163391434e360e21b81526001600160a01b03929092166004830152602482015260448101839052606490fd5b6001600160a01b0381169190821561354657613439604051906001825261271060208301526040820190600182526001606084015260808301604052565b928151845190818103611db257505060005b8251811015613493578060019160051b61348b61348387610585602080868b010151958c010151946000526005602052604060002090565b9182546120a7565b90550161344b565b50929193600182511460001461350a5760208281015184820151604080519283529282015260009133917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f629190a45b80516001036135005790602080610d979593015191015191336139ad565b610d979333613880565b60006040517f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb33918061353e8888836137cb565b0390a46134e2565b604051632bfa23e760e11b815260006004820152602490fd5b6001600160a01b0381169081156136e15761359c604051906001825261271060208301526040820190600182526001606084015260808301604052565b919060409460006040516135af81610d18565b528151845190818103611db257505060005b8251811015613657578060051b602080828601015191870101516135f386610585846000526005602052604060002090565b548181106136215786610585600195949361361a9303936000526005602052604060002090565b55016135c1565b89516303dee4c560e01b81526001600160a01b038816600482015260248101919091526044810182905260648101839052608490fd5b509450600093929150600181511484146136ae5760209081015191810151604080519384529183015233917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6291819081015b0390a4565b60405133927f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb9282916136a991836137cb565b604051626a0d4560e21b815260006004820152602490fd5b805160011015611cf65760210190565b908151811015611cf6570160200190565b8015611e91576000190190565b91604092604051906375662f3882526040820190601c83019560609060608501938460405283519160209986996000968c8a01905b86891061378557505050505050505050603f6060939495601f1992838201905201160101604052565b90919293949596979c60208e60051b830101518352600080602487875afa156102ec57600190602080893e87519081888e83018d013e019d01979695949392919061375c565b90916137e26104269360408452604084019061108e565b91602081840391015261108e565b908160209103126102ec575161042681610342565b9261383461042695936138429360018060a01b031686526000602087015260a0604087015260a086019061108e565b90848203606086015261108e565b9160808184039101526103f0565b3d1561387b573d9061386182610e1d565b9161386f6040519384610d69565b82523d6000602084013e565b606090565b9293919093843b613893575b5050505050565b6020916138b6604051948593849363bc197c8160e01b9889865260048601613805565b038160006001600160a01b0388165af16000918161394b575b5061390e57826138dd613850565b805191908261390757604051632bfa23e760e11b81526001600160a01b0383166004820152602490fd5b9050602001fd5b6001600160e01b031916036139285750388080808061388c565b604051632bfa23e760e11b81526001600160a01b03919091166004820152602490fd5b61396e91925060203d602011613975575b6139668183610d69565b8101906137f0565b90386138cf565b503d61395c565b909260a0926104269594600180861b03168352600060208401526040830152606082015281608082015201906103f0565b9293919093843b6139bf575050505050565b6020916138b6604051948593849363f23a6e6160e01b988986526004860161397c56fea2646970667358221220aaa568dd1997a4c0a8531cc6b3d9f1752af3614e906a58b89fd6aa7c70fbb22464736f6c63430008160033a31547ce6245cdb9ecea19cf8c7eb9f5974025bb4075011409251ae855b30aed0263c2b778d062355049effc2dece97bc6547ff8a88a3258daa512061c2153dd
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c8062fdd58e146102d657806301ffc9a7146102d157806306fdde03146102cc578063095ea7b3146102c75780630e89341c146102c257806318160ddd146102bd5780631c6a04d8146102b857806323b872dd146102b357806324c642af146102ae5780632e8a1716146102a95780632eb2c2d6146102a4578063313ce5671461029f57806332cb6b0c1461029a578063390b19db1461029557806346a98b01146102905780634a7c7e4b1461028b5780634dc709f7146102865780634e1273f4146102815780636342e0a61461027c578063635d79eb1461027757806366cad83a146102725780636e32daf71461026d5780636e7dab9214610268578063704b81c51461026357806370a082311461025e578063715018a61461025957806371640de314610254578063722b3b591461024f57806372ba8fef1461024a5780637d24f4771461024557806384a4a75314610240578063885229981461023b5780638da5cb5b1461023657806395d89b411461023157806396f4205a1461022c578063a22cb46514610227578063a9059cbb14610222578063aede920c1461021d578063bd12407d14610218578063dd62ed3e14610213578063e985e9c51461020e578063ede8f7e014610209578063f242432a146102045763f2fde38b146101ff57600080fd5b611957565b611911565b6118e0565b6118c5565b611889565b611843565b61181e565b6117e9565b6117d4565b61178d565b6116c7565b61169e565b611675565b611650565b61162d565b61140c565b6113ca565b6113ac565b61134e565b611311565b61127e565b611258565b61123b565b61121d565b6111d6565b61118f565b6110d3565b611047565b611000565b610fa0565b610f41565b610f1a565b610efe565b610e7f565b610c95565b610c53565b610b9f565b6107b9565b61079b565b610606565b610538565b610429565b610354565b6102f1565b6001600160a01b038116036102ec57565b600080fd5b346102ec5760403660031901126102ec576020610339600435610313816102db565b6024356000526005835260406000209060018060a01b0316600052602052604060002090565b54604051908152f35b6001600160e01b03198116036102ec57565b346102ec5760203660031901126102ec57602060043561037381610342565b63ffffffff60e01b16636cdb3d1360e11b81149081156103b1575b81156103a0575b506040519015158152f35b6301ffc9a760e01b14905038610395565b6303a24d0760e21b8114915061038e565b60009103126102ec57565b60005b8381106103e05750506000910152565b81810151838201526020016103d0565b90602091610409815180928185528580860191016103cd565b601f01601f1916010190565b9060206104269281815201906103f0565b90565b346102ec57600080600319360112610535576040519080600354906001918060011c926001821692831561052b575b6020926020861085146105175785885260208801949081156104f6575060011461049d575b6104998761048d81890382610d69565b60405191829182610415565b0390f35b600360005294509192917fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8386106104e5575050509101905061048d82610499388061047d565b8054858701529482019481016104c9565b60ff191685525050505090151560051b01905061048d82610499388061047d565b634e487b7160e01b82526022600452602482fd5b93607f1693610458565b80fd5b346102ec5760403660031901126102ec57600435610555816102db565b60243533156105ed576001600160a01b0382169182156105d457336000908152600160205260409020829161059c915b9060018060a01b0316600052602052604060002090565b556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b604051634a1406b160e11b815260006004820152602490fd5b60405163e602df0560e01b815260006004820152602490fd5b346102ec5760203660031901126102ec57612710600435036107895761049961077d61048d61070c610748610639611c75565b604051607b60f81b60208201527f226e616d65223a20224368726f6d6965205371756967676c6520233130303030602182015261088b60f21b60418201527f226465736372697074696f6e223a2022546865207371756967676c652064697360438201527f706c617965642075706461746573206261736564206f6e20746865206375727260638201526e195b9d08091f881c1c9a58d94b888b608a1b6083820152711130b734b6b0ba34b7b72fbab936111d101160711b6092820152928391610726916107199160a485015b90611a15565b601160f91b815260010190565b607d60f81b815260010190565b039161073a601f1993848101835282610d69565b610742611fd9565b90612983565b6040517f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000006020820152938491603d8301610706565b03908101835282610d69565b604051636aa2a93760e01b8152600490fd5b346102ec5760003660031901126102ec576020600254604051908152f35b600080600319360112610535576107ce612048565b60095460a01c60ff16610b8d573415610b7b5773c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2803b15610b7757604051630d0e30db60e41b8152828160048134865af18015610add57610b5e575b5061083730821060ff8019600b54169115151617600b55565b600b5460ff168015610b5757815b8115610b4d57506108d430915b8015610b3a5734935b8115610b33576b019d971e4fe8401e74000000915b15610b115761089561088961088434611a67565b6120b4565b6001600160a01b031690565b6040516309f56ab160e11b81526001600160a01b0380841660048301528087166024830152612710604483015290911660648201529283906084820190565b039160208473c36442b4a4522e871399cd717abdd847ab11fe8894818a875af1958615610add5761099c6080966109348a99610a7a988b91610ae2575b5060018060a01b03166bffffffffffffffffffffffff60a01b6009541617600955565b6009546001600160a01b03166000908152601660205260409020610960905b805460ff19166001179055565b61096934612116565b6109723061225b565b61098c61097d610d8a565b6001600160a01b039096168652565b6001600160a01b03166020850152565b6127106040848101918252620d899f1960608601908152620d89a08987015260a0860193845260c0860194855260e086018a815261010087018b8152336101208901908152426101408a019081529451634418b22b60e11b815289516001600160a01b03908116600483015260208b015181166024830152965162ffffff1660448201529351600290810b606486015260809099015190980b6084840152945160a4830152945160c4820152935160e48501529151610104840152925190921661012482015290516101448201529384928391908290610164820190565b03925af18015610add57610a95918391610aab575b50600a55565b6009805460ff60a01b1916600160a01b17905580f35b610acd915060803d608011610ad6575b610ac58183610d69565b810190611a9b565b50505038610a8f565b503d610abb565b611a7a565b610b04915060203d602011610b0a575b610afc8183610d69565b810190611a86565b38610911565b503d610af2565b610b2e6108896b019d971e4fe8401e740000003460c01b046120b4565b610895565b3491610870565b6b019d971e4fe8401e740000009361085b565b6108d49091610852565b3091610845565b80610b6b610b7192610cc9565b806103c2565b3861081e565b5080fd5b60405163664d342360e01b8152600490fd5b604051639483839160e01b8152600490fd5b346102ec5760603660031901126102ec57600435610bbc816102db565b602435610bc8816102db565b6001600160a01b038216600090815260016020908152604080832033845290915290206044359190549260018401610c11575b610c059350612408565b60405160018152602090f35b828410610c2d57610c2883610c0595033383612917565b610bfb565b604051637dc7a0d960e11b81523360048201526024810185905260448101849052606490fd5b346102ec5760203660031901126102ec57600435610c70816102db565b60018060a01b03166000526016602052602060ff604060002054166040519015158152f35b346102ec5760003660031901126102ec576020601754604051908152f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b038111610cdc57604052565b610cb3565b60e081019081106001600160401b03821117610cdc57604052565b61016081019081106001600160401b03821117610cdc57604052565b602081019081106001600160401b03821117610cdc57604052565b608081019081106001600160401b03821117610cdc57604052565b604081019081106001600160401b03821117610cdc57604052565b90601f801991011681019081106001600160401b03821117610cdc57604052565b60405190610d9782610cfc565b565b60405190610d9782610ce1565b6001600160401b038111610cdc5760051b60200190565b9080601f830112156102ec576020908235610dd781610da6565b93610de56040519586610d69565b81855260208086019260051b8201019283116102ec57602001905b828210610e0e575050505090565b81358152908301908301610e00565b6001600160401b038111610cdc57601f01601f191660200190565b81601f820112156102ec57803590610e4f82610e1d565b92610e5d6040519485610d69565b828452602083830101116102ec57816000926020809301838601378301015290565b346102ec5760a03660031901126102ec57610e9b6004356102db565b610ea66024356102db565b6001600160401b036044358181116102ec57610ec6903690600401610dbd565b506064358181116102ec57610edf903690600401610dbd565b506084359081116102ec57610ef8903690600401610e38565b50611acd565b346102ec5760003660031901126102ec57602060405160128152f35b346102ec5760003660031901126102ec5760206040516b033b2e3c9fd0803ce80000008152f35b346102ec5760003660031901126102ec57610499610f5d611c75565b6040519182916020835260208301906103f0565b801515036102ec57565b60409060031901126102ec57600435610f93816102db565b9060243561042681610f71565b346102ec57610fae36610f7b565b90610fb7612048565b6009546001600160a01b0391821691168114610fee57600052601660205260406000209060ff801983541691151516179055600080f35b60405163239c8a8360e21b8152600490fd5b346102ec5760203660031901126102ec5760043561101d816102db565b611025612048565b601080546001600160a01b0319166001600160a01b0392909216919091179055005b346102ec5760203660031901126102ec57600435611064816102db565b61106c612048565b601280546001600160a01b0319166001600160a01b0392909216919091179055005b90815180825260208080930193019160005b8281106110ae575050505090565b8351855293810193928101926001016110a0565b90602061042692818152019061108e565b346102ec5760403660031901126102ec576004356001600160401b038082116102ec57366023830112156102ec57816004013561110f81610da6565b9261111d6040519485610d69565b8184526020916024602086019160051b830101913683116102ec57602401905b82821061117657856024358681116102ec576104999161116461116a923690600401610dbd565b90611d2f565b604051918291826110c2565b8380918335611184816102db565b81520191019061113d565b346102ec5760203660031901126102ec576004356111ac816102db565b6111b4612048565b601180546001600160a01b0319166001600160a01b0392909216919091179055005b346102ec5760203660031901126102ec576004356111f3816102db565b6111fb612048565b600f80546001600160a01b0319166001600160a01b0392909216919091179055005b346102ec5760003660031901126102ec576020600c54604051908152f35b346102ec5760003660031901126102ec5760206040516127108152f35b346102ec5760003660031901126102ec57602060ff60095460a01c166040519015158152f35b346102ec57600080600319360112610535576112c28161129c612659565b60018060a01b03601254166040518080958194636af6c46760e11b835260048301611c40565b03915afa908115610add578261049993926112ee575b50506040519182916020835260208301906103f0565b61130a92503d8091833e6113028183610d69565b810190611adf565b38806112d8565b346102ec5760203660031901126102ec5760043561132e816102db565b60018060a01b031660005260006020526020604060002054604051908152f35b346102ec5760008060031936011261053557611368612048565b600880546001600160a01b0319811690915581906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b346102ec5760003660031901126102ec576020600a54604051908152f35b346102ec5760203660031901126102ec576004356113e7816102db565b60018060a01b03166000526015602052602060ff604060002054166040519015158152f35b346102ec576020806003193601126102ec5760048035906001600160401b038083116102ec57366023840112156102ec57828201359081116102ec576024830192602436918360051b0101116102ec5760005b81811061146857005b611473818386611dd4565b3561270f811161161c5761149b611494826000526013602052604060002090565b5460ff1690565b61160b57604080516331a9108f60e11b8152858101838152889082908190602001038173059edd72cd353df5106d2b9cc5ab83a52287ac3a5afa908115610add576000916115ee575b50336001600160a01b0382161490889084908315611541575b5050506000146115325750906115226109536001936000526013602052604060002090565b61152c33306123b5565b0161145f565b51630a170a8f60e31b81528490fd5b8451632e7cda1d60e21b8152338a82019081526001600160a01b03909216602083015273059edd72cd353df5106d2b9cc5ab83a52287ac3a60408301526060820192909252600060808201529092508290819060a00103816c447e69651d841bd8d104bed4935afa908115610add576000916115c1575b508783386114fd565b6115e19150883d8a116115e7575b6115d98183610d69565b810190611de4565b386115b8565b503d6115cf565b6116059150883d8a11610b0a57610afc8183610d69565b386114e4565b604051630baa526f60e11b81528490fd5b604051636aa2a93760e01b81528490fd5b346102ec5760003660031901126102ec576020611648611ed9565b604051908152f35b346102ec5760003660031901126102ec576020604051690a968163f0a57b4000008152f35b346102ec5760003660031901126102ec576009546040516001600160a01b039091168152602090f35b346102ec5760003660031901126102ec576008546040516001600160a01b039091168152602090f35b346102ec57600080600319360112610535576040519080600454906001918060011c9260018216928315611783575b6020926020861085146105175785885260208801949081156104f6575060011461172a576104998761048d81890382610d69565b600460005294509192917f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b838610611772575050509101905061048d82610499388061047d565b805485870152948201948101611756565b93607f16936116f6565b346102ec5760203660031901126102ec576004356117aa816102db565b6117b2612048565b600e80546001600160a01b0319166001600160a01b0392909216919091179055005b346102ec576117e236610f7b565b5050611acd565b346102ec5760403660031901126102ec57611813600435611809816102db565b6024359033612408565b602060405160018152f35b346102ec5760003660031901126102ec57611837612048565b6014805460ff19169055005b346102ec5760203660031901126102ec5761185c612048565b600435600c55005b60409060031901126102ec5760043561187c816102db565b90602435610426816102db565b346102ec57602061033961189c36611864565b6001600160a01b0391821660009081526001855260408082209290931681526020919091522090565b346102ec576118d336611864565b5050602060405160008152f35b346102ec5760203660031901126102ec576004356000526013602052602060ff604060002054166040519015158152f35b346102ec5760a03660031901126102ec5761192d6004356102db565b6119386024356102db565b6084356001600160401b0381116102ec57610ef8903690600401610e38565b346102ec5760203660031901126102ec57600435611974816102db565b61197c612048565b6001600160a01b039081169081156119d057600854826bffffffffffffffffffffffff60a01b821617600855167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b604051631e4fbdf760e01b815260006004820152602490fd5b611a1191600052600560205260406000209060018060a01b0316600052602052604060002090565b5490565b90611a28602092828151948592016103cd565b0190565b634e487b7160e01b600052601160045260246000fd5b8015611a5157600160c01b0490565b634e487b7160e01b600052601260045260246000fd5b8015611a51576413fa10079d60da1b0490565b6040513d6000823e3d90fd5b908160209103126102ec5751610426816102db565b91908260809103126102ec5781519160208101516001600160801b03811681036102ec57916060604083015192015190565b604051638b4c470960e01b8152600490fd5b6020818303126102ec578051906001600160401b0382116102ec570181601f820112156102ec578051611b1181610e1d565b92611b1f6040519485610d69565b818452602082840101116102ec5761042691602080850191016103cd565b906005821015611b4a5752565b634e487b7160e01b600052602160045260246000fd5b908082519081815260208091019281808460051b8301019501936000915b848310611b8e5750505050505090565b9091929394958480611c30600193601f198682030187528a51611c1d611c0a611be5611bc360e08551908088528701906103f0565b898060a01b0388860151168887015260408086015190878303908801526103f0565b611bf760608086015190870190611b3d565b60808085015190868303908701526103f0565b60a08084015190858303908601526103f0565b9160c080920151918184039101526103f0565b9801930193019194939290611b7e565b9061042691602081526020611c6083516040838501526060840190611b60565b920151906040601f1982850301910152611b60565b611ca86000611c82612659565b60018060a01b03601254166040518080958194635448d9af60e11b835260048301611c40565b03915afa908115610add57600091611cbe575090565b61042691503d806000833e6113028183610d69565b634e487b7160e01b600052603260045260246000fd5b805115611cf65760200190565b611cd3565b805160011015611cf65760400190565b805160021015611cf65760600190565b8051821015611cf65760209160051b010190565b91909180518351808203611db2575050805190611d64611d4e83610da6565b92611d5c6040519485610d69565b808452610da6565b60209190601f1901368484013760005b8151811015611daa5780611d9960019260051b85808287010151918a010151906119e9565b611da38287611d1b565b5201611d74565b509193505050565b604051635b05999160e01b815260048101919091526024810191909152604490fd5b9190811015611cf65760051b0190565b908160209103126102ec575161042681610f71565b519061ffff821682036102ec57565b908160e09103126102ec578051611e1e816102db565b9160208201518060020b81036102ec5791611e3b60408201611df9565b91611e4860608301611df9565b91611e5560808201611df9565b9160a082015160ff811681036102ec5760c09092015161042681610f71565b90670de0b6b3a764000091828102928184041490151715611e9157565b611a2c565b600281901b91906001600160fe1b03811603611e9157565b600181901b91906001600160ff1b03811603611e9157565b81810292918115918404141715611e9157565b60095460049060e090611ef690610889906001600160a01b031681565b60405192838092633850c7bd851b82525afa8015610add57611f4891600091611f91575b50600b5460ff1615611f7557611f4390611f3d906001600160a01b031680611ec6565b60c01c90565b611e74565b604051611f6f81611f6160208201948560209181520190565b03601f198101835282610d69565b51902090565b611f4390611f8c906001600160a01b031680611ec6565b611a42565b611fb3915060e03d60e011611fbf575b611fab8183610d69565b810190611e08565b50505050505038611f1a565b503d611fa1565b60405190611fd382610d18565b60008252565b60405190606082018281106001600160401b03821117610cdc57604052604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b6008546001600160a01b0316330361205c57565b60405163118cdaa760e01b8152336004820152602490fd5b9060028201809211611e9157565b9060018201809211611e9157565b90690a968163f0a57b4000008201809211611e9157565b91908201809211611e9157565b8015612110576001808201808311611e915760011c9082905b8383106120da5750505090565b919250908280156120fb57808304908101809111611e9157811c91906120cd565b60246000634e487b7160e01b81526012600452fd5b50600090565b604051636eb1769f60e11b815230600482015273c36442b4a4522e871399cd717abdd847ab11fe886024820181905260209273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2908484604481855afa938415610add5760009461222c575b508301809311611e9157836000604051948286019063095ea7b360e01b9586835260248801526044870152604486526121ad86610d33565b85519082855af1903d600051908361220d575b505050156121cd57505050565b6040519283015273c36442b4a4522e871399cd717abdd847ab11fe88602483015260006044830152610d979161220890818160648101611f61565b6130d6565b9192509061222257503b15155b3880806121c0565b600191501461221a565b9093508481813d8311612254575b6122448183610d69565b810103126102ec57519238612175565b503d61223a565b604051636eb1769f60e11b815230600482015273c36442b4a4522e871399cd717abdd847ab11fe8860248201819052602092906001600160a01b0382168484604481845afa938415610add57600094612386575b506b019d971e4fe8401e740000008401809411611e9157846000604051958287019063095ea7b360e01b9586835260248901526044880152604487526122f487610d33565b86519082875af1903d6000519083612367575b50505015612316575b50505050565b6040519384015273c36442b4a4522e871399cd717abdd847ab11fe8860248401526000604484015261235e92612359906123538160648101611f61565b82613132565b613132565b38808080612310565b9192509061237c57503b15155b388080612307565b6001915014612374565b9093508481813d83116123ae575b61239e8183610d69565b810103126102ec575192386122af565b503d612394565b906001600160a01b03808316156123ef578116156123d657610d9791612a89565b60405163ec442f0560e01b815260006004820152602490fd5b604051634b637e8f60e11b815260006004820152602490fd5b91906001600160a01b03808416156123ef578116156123d657610d9792612cbb565b60405190604082018281106001600160401b03821117610cdc5760405260606020838281520152565b604080519161246183610d33565b60038352829160009160005b6060808210156124b65783516020929161248682610ce1565b80825283908782840152808784015287818401528060808401528060a084015260c083015282890101520161246d565b50509293505050565b604051906124cc82610d4e565b60078252661e39ba3cb6329f60c91b6020830152565b6040519060c082018281106001600160401b03821117610cdc5760405260948252736f6d3a303b6c6566743a303b72696768743a307d60601b60a0837f68746d6c7b6865696768743a313030257d626f64797b6d696e2d68656967687460208201527f3a313030253b6d617267696e3a303b70616464696e673a307d63616e7661737b60408201527f70616464696e673a303b6d617267696e3a6175746f3b646973706c61793a626c60608201527f6f636b3b706f736974696f6e3a6162736f6c7574653b746f703a303b626f747460808201520152565b604051906125c782610d4e565b60088252671e17b9ba3cb6329f60c11b6020830152565b604051906125eb82610d4e565b601682527567756e7a6970536372697074732d302e302e312e6a7360501b6020830152565b6040519061261d82610d4e565b60088252671e39b1b934b83a1f60c11b6020830152565b6040519061264182610d4e565b60098252681e17b9b1b934b83a1f60b91b6020830152565b61266161242a565b5061266a612453565b608061267582611ce9565b510161267f6124bf565b905260c061268c82611ce9565b51016126966124e2565b905260a06126a382611ce9565b51016126ad6125ba565b905261270f61271e6126c0601754612edb565b611f6160405193849261070660208501602c907f6c657420746f6b656e44617461203d207b22746f6b656e4964223a313030303081526b16113430b9b432b9911d2d9160a11b60208201520190565b62225d7d60e81b815260030190565b60c061272983611cfb565b510152612742606061273a83611cfb565b510160019052565b61274a612453565b61275261300c565b60c061275d83611ce9565b510152612776606061276e83611ce9565b510160039052565b61277f81611cfb565b516127886125de565b90526127a0606061279883611cfb565b510160029052565b600f546127f0906127bb90610889906001600160a01b031681565b601154604051630eacc5e760e31b81526001600160a01b03909116600482015260009290918391839190829081906024820190565b03915afa908115610add5782916128fd575b5060c061280e84611cfb565b51015260105461282890610889906001600160a01b031681565b604051635e0f356560e11b815273059edd72cd353df5106d2b9cc5ab83a52287ac3a600482015260006024820152908290829060449082905afa908115610add5782916128e3575b50612879612610565b612881612634565b9061288a610d99565b93612893611fc6565b85528060208601526128a3611fc6565b60408601526060850152608084015260a083015260c08201526128c582611d0b565b526128cf81611d0b565b506128d861242a565b918252602082015290565b6128f791503d8084833e6113028183610d69565b38612870565b61291191503d8084833e6113028183610d69565b38612802565b906001600160a01b03808316156105ed578116156105d45761058561294e9260018060a01b03166000526001602052604060002090565b55565b9061295b82610e1d565b6129686040519182610d69565b8281528092612979601f1991610e1d565b0190602036910137565b90815115612a5a576129af6129aa6129a561299e8551612074565b6003900490565b611e96565b612951565b91602083019181825183016020810191825193600084525b828210612a0857505050525160039006600181146129f5576002146129ea575090565b603d90600019015390565b50603d9081600019820153600119015390565b9091956004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c16880101516002860153168501015190820153019591906129c7565b5050610426611fc6565b690a968163f0a57b3fffff19810191908211611e9157565b91908203918211611e9157565b90612aa1612a9d60095460ff9060a01c1690565b1590565b612c6557612ab4601854600c54906120a7565b431015612c6e575b612acb612a9d60145460ff1690565b612c6557610d9791612af5612a9d6114948460018060a01b03166000526016602052604060002090565b80612c3a575b80612c04575b612bcd575b6001600160a01b0381166000908152601660205260409020612b2b90612a9d90611494565b80612ba6575b80612b71575b1561318e576001600160a01b0381166000908152601560205260409020612b63905b805460ff19169055565b612b6c8161355f565b61318e565b50670de0b6b3a7640000612ba0612b9a8360018060a01b03166000526000602052604060002090565b54612a64565b10612b37565b506001600160a01b0381166000908152601560205260409020612bc890611494565b612b31565b6001600160a01b0382166000908152601560205260409020612bee90610953565b612bff612bf9611fc6565b836133fb565b612b06565b50670de0b6b3a7640000612c33612c2d8460018060a01b03166000526000602052604060002090565b54612090565b1015612b01565b506001600160a01b0382166000908152601560205260409020612c6090612a9d90611494565b612afb565b610d979161318e565b612c7e612c79611ed9565b601755565b612c8743601855565b6017546040519081527f8860ccaec8f1de4786a9099984cdb7544072d42beec6181fd67eee2caee9b2d190602090a1612abc565b9190612cd0612a9d60095460ff9060a01c1690565b612e8a57612ce3601854600c54906120a7565b431015612e93575b612cfa612a9d60145460ff1690565b612e8a57610d9792612d24612a9d6114948460018060a01b03166000526016602052604060002090565b80612e5f575b80612e28575b612df7575b6001600160a01b0381166000908152601660205260409020612d5a90612a9d90611494565b80612dd0575b80612d9a575b156132cf576001600160a01b0381166000908152601560205260409020612d8c90612b59565b612d958161355f565b6132cf565b50670de0b6b3a7640000612dca84612dc48460018060a01b03166000526000602052604060002090565b54612a7c565b10612d66565b506001600160a01b0381166000908152601560205260409020612df290611494565b612d60565b6001600160a01b0382166000908152601560205260409020612e1890610953565b612e23612bf9611fc6565b612d35565b50670de0b6b3a7640000612e5884612e528560018060a01b03166000526000602052604060002090565b546120a7565b1015612d30565b506001600160a01b0382166000908152601560205260409020612e8590612a9d90611494565b612d2a565b610d97926132cf565b612e9e612c79611ed9565b612ea743601855565b6017546040519081527f8860ccaec8f1de4786a9099984cdb7544072d42beec6181fd67eee2caee9b2d190602090a1612ceb565b6001600160801b038111818160071b1c9160016004926001600160401b038511948560061b1c63ffffffff8111908160051b1c9561ffff87119260ff85988560041b1c1193851b9260021b9160031b9060041b0101010101918190612f4a6129aa612f4586611eae565b612074565b946030612f5687611ce9565b536078612f62876136f9565b53612f74612f6f86611eae565b612082565b915b818311612fab57505050612f8957505090565b60405163e22e27eb60e01b815260048101919091526024810191909152604490fd5b909192600f8116906010821015611cf657612fe9916f181899199a1a9b1b9c1cb0b131b232b360811b901a612fe0868a613709565b53821c9361371a565b9190612f76565b60405190612ffd82610cfc565b600a8252610140366020840137565b613014612ff0565b600e54600090819061303090610889906001600160a01b031681565b905b600a8110613054575050600f546104269291506001600160a01b031690613727565b60405163dfa3be5360e01b8152670703540312e302e360c41b6004820152602481018290529060208083604481875afa8015610add576001936130b39287926130b9575b50506130a48388611d1b565b6001600160a01b039091169052565b01613032565b6130cf9250803d10610b0a57610afc8183610d69565b3880613098565b6020600082518273c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2940182855af115611a7a576000513d6131295750803b155b6131115750565b60249060405190635274afe760e01b82526004820152fd5b6001141561310a565b906000602091828151910182855af115611a7a576000513d61318557506001600160a01b0381163b155b6131635750565b604051635274afe760e01b81526001600160a01b039091166004820152602490fd5b6001141561315c565b6001600160a01b03818116918261323d57506131b36131ae600254612090565b600255565b8216918261321157506131d4690a968163f0a57b3fffff1960025401600255565b604051690a968163f0a57b40000081527fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9080602081015b0390a3565b6001600160a01b03166000908152602081905260409020690a968163f0a57b40000081540190556131d4565b6001600160a01b038116600090815260208190526040902054690a968163f0a57b40000081106132975761329190690a968163f0a57b3fffff19019160018060a01b03166000526000602052604060002090565b556131b3565b60405163391434e360e21b81526001600160a01b039290921660048301526024820152690a968163f0a57b4000006044820152606490fd5b90916001600160a01b03808316928361336057508161320c916133186131ae7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef956002546120a7565b8516948561333e575061332e8160025403600255565b6040519081529081906020820190565b6001600160a01b0316600090815260208190526040902081815401905561332e565b6001600160a01b0381166000908152602081905260409020548381106133cc579183916133c67fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9561320c95039160018060a01b03166000526000602052604060002090565b55613318565b60405163391434e360e21b81526001600160a01b03929092166004830152602482015260448101839052606490fd5b6001600160a01b0381169190821561354657613439604051906001825261271060208301526040820190600182526001606084015260808301604052565b928151845190818103611db257505060005b8251811015613493578060019160051b61348b61348387610585602080868b010151958c010151946000526005602052604060002090565b9182546120a7565b90550161344b565b50929193600182511460001461350a5760208281015184820151604080519283529282015260009133917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f629190a45b80516001036135005790602080610d979593015191015191336139ad565b610d979333613880565b60006040517f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb33918061353e8888836137cb565b0390a46134e2565b604051632bfa23e760e11b815260006004820152602490fd5b6001600160a01b0381169081156136e15761359c604051906001825261271060208301526040820190600182526001606084015260808301604052565b919060409460006040516135af81610d18565b528151845190818103611db257505060005b8251811015613657578060051b602080828601015191870101516135f386610585846000526005602052604060002090565b548181106136215786610585600195949361361a9303936000526005602052604060002090565b55016135c1565b89516303dee4c560e01b81526001600160a01b038816600482015260248101919091526044810182905260648101839052608490fd5b509450600093929150600181511484146136ae5760209081015191810151604080519384529183015233917fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f6291819081015b0390a4565b60405133927f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb9282916136a991836137cb565b604051626a0d4560e21b815260006004820152602490fd5b805160011015611cf65760210190565b908151811015611cf6570160200190565b8015611e91576000190190565b91604092604051906375662f3882526040820190601c83019560609060608501938460405283519160209986996000968c8a01905b86891061378557505050505050505050603f6060939495601f1992838201905201160101604052565b90919293949596979c60208e60051b830101518352600080602487875afa156102ec57600190602080893e87519081888e83018d013e019d01979695949392919061375c565b90916137e26104269360408452604084019061108e565b91602081840391015261108e565b908160209103126102ec575161042681610342565b9261383461042695936138429360018060a01b031686526000602087015260a0604087015260a086019061108e565b90848203606086015261108e565b9160808184039101526103f0565b3d1561387b573d9061386182610e1d565b9161386f6040519384610d69565b82523d6000602084013e565b606090565b9293919093843b613893575b5050505050565b6020916138b6604051948593849363bc197c8160e01b9889865260048601613805565b038160006001600160a01b0388165af16000918161394b575b5061390e57826138dd613850565b805191908261390757604051632bfa23e760e11b81526001600160a01b0383166004820152602490fd5b9050602001fd5b6001600160e01b031916036139285750388080808061388c565b604051632bfa23e760e11b81526001600160a01b03919091166004820152602490fd5b61396e91925060203d602011613975575b6139668183610d69565b8101906137f0565b90386138cf565b503d61395c565b909260a0926104269594600180861b03168352600060208401526040830152606082015281608082015201906103f0565b9293919093843b6139bf575050505050565b6020916138b6604051948593849363f23a6e6160e01b988986526004860161397c56fea2646970667358221220aaa568dd1997a4c0a8531cc6b3d9f1752af3614e906a58b89fd6aa7c70fbb22464736f6c63430008160033
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.