Overview
TokenID
2
Total Transfers
-
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
CovenantNFTKudoNode
Compiler Version
v0.8.27+commit.40a35a09
Optimization Enabled:
Yes with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.27; import {CovenantNFT} from "./CovenantNFT.sol"; contract CovenantNFTKudoNode is CovenantNFT { bytes32 constant ROUTER_ROLE = keccak256("ROUTER_ROLE"); constructor(address router, address admin, uint48 initialDelay) CovenantNFT(admin, initialDelay) { _grantRole(ROUTER_ROLE, router); } /// @inheritdoc CovenantNFT function registerCovenant( NftType nftType, string calldata task, address settlementAsset, uint256 settlementAmount, uint256 minAbilityScore, uint256 price, bool shouldWatch, bytes calldata data ) public override returns (bytes32) { bytes32 requestId = keccak256(abi.encodePacked(msg.sender, s_nftId)); s_requestIdToNftId[requestId] = s_nftId; return _handleCovenantRegistration( requestId, nftType, task, settlementAsset, settlementAmount, minAbilityScore, price, shouldWatch, data ); } /// @inheritdoc CovenantNFT function registerCovenant( NftType nftType, string calldata task, uint256 parentCovenantId, address settlementAsset, uint256 settlementAmount, bool shouldWatch, bytes calldata data ) public override returns (bytes32) { bytes32 requestId = keccak256(abi.encodePacked(msg.sender, s_nftId)); s_requestIdToNftId[requestId] = s_nftId; return _handleSubgoalCovenantRegistration( requestId, nftType, task, parentCovenantId, settlementAsset, settlementAmount, shouldWatch, data ); } /// @notice Callback funtion for node to fulfill request /// @param requestId Fulfill requestId /// @param abilityScore Ability score of the agent function fulfillRequest(bytes32 requestId, uint128 abilityScore) external onlyRole(ROUTER_ROLE) { _processCallback(abilityScore, s_requestIdToNftId[requestId]); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.27; import {ERC721, IERC721, IERC721Metadata} from "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {EnumerableSet} from "openzeppelin-contracts/contracts/utils/structs/EnumerableSet.sol"; import { AccessControlDefaultAdminRules, IAccessControlDefaultAdminRules } from "openzeppelin-contracts/contracts/access/extensions/AccessControlDefaultAdminRules.sol"; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; abstract contract CovenantNFT is ERC721, AccessControlDefaultAdminRules { using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.UintSet; /// @notice Covenant NFT Status enum CovenantStatus { IN_PROGRESS, COMPLETED, FAILED } /// @notice Covenant NFT Types enum NftType { EMPLOYMENT, LOAN } /// @notice Covenant NFT id counter uint256 s_nftId; /// @notice Holds every agents id EnumerableSet.AddressSet s_agents; /// @notice Stores agent details mapped by their address mapping(address agentAddress => AgentManagement agentManagementInfo) internal s_agentDetails; /// @notice Maps NFT ID to its corresponding Covenant data mapping(uint256 s_nftId => CovenantData cNFTDetails) public s_nftIdToCovenantData; /// @notice Links a Chainlink request ID to an NFT ID mapping(bytes32 requestId => uint256 nftId) public s_requestIdToNftId; /// @notice Stores settlement data for a given Covenant NFT ID mapping(uint256 cNftId => string settlemenData) public s_nftSettlementData; /// @notice Emitted when new agent is registered /// @param agentWallet Agent registered wallet address /// @param agentName Agent registered name /// @param agentId Agent registered identifier /// @param teeId Agent registered tee identifier event AgentSet(address indexed agentWallet, string agentName, string agentId, string teeId); /// @notice Emitted when a new Covenant NFT is registered /// @param requestId ID for callback identfier /// @param agentWallet The wallet address of the agent who registered the covenant /// @param nftId The ID of the newly registered Covenant NFT event CovenantRegistered(bytes32 requestId, address indexed agentWallet, uint256 indexed nftId); /// @notice Emitted when settlement data is set for a Covenant NFT /// @param nftId The ID of the Covenant NFT /// @param data The settlement data associated with the covenant event SettlementDataSet(uint256 indexed nftId, string data); /// @notice Emitted when the status of a Covenant NFT is updated /// @param nftId The ID of the Covenant NFT /// @param status The new status of the covenant (IN_PROGRESS, COMPLETED, or FAILED) event CovenantStatusSet(uint256 indexed nftId, CovenantStatus status); /// @notice Thrown when the caller is not an authorized agent error CallerIsNotAuthorizedAgent(); /// @notice Thrown when an agent is already registered error AgentRegistered(); /// @notice Thrown when a required condition is not met error ConditionIsNotMet(); /// @notice Covenant NFT details struct CovenantData { /// @notice Agent wallet address address agentWallet; /// @notice The agent ID string agentId; /// @notice The current status of the covenant CovenantStatus status; /// @notice The covenant nft type NftType nftType; /// @notice The description of the goal string goal; /// @notice List of subgoals cNFT id uint256[] subgoalsId; /// @notice The amount needed to purchase the NFT uint256 price; /// @notice Parent goal id uint256 parentGoalId; /// @notice The promised asset at settlement address settlementAsset; /// @notice The promised asset amount at settlement uint256 settlementAmount; /// @notice agent minimum ability score to mint covenant uint256 minAbilityScore; /// @notice The ability score uint256 abilityScore; /// @notice Status of covenant's agent watch status bool shouldWatch; /// @notice Arbitrary data that can be stored alongside the NFT bytes data; } /// @notice Covenant details for getter functions struct CovenantDetails { /// @notice covenant nft id uint256 nftId; /// @notice The covenant nft type NftType nftType; /// @notice Agent wallet address address agentWallet; /// @notice The agent ID string agentId; /// @notice The agent name string agentName; /// @notice The current status of the covenant CovenantStatus status; /// @notice The description of the goal string goal; /// @notice The promised asset at settlement address settlementAsset; /// @notice The owner of the covenant address owner; /// @notice The promised asset amount at settlement uint256 settlementAmount; /// @notice The amount needed to purchase the NFT uint256 price; /// @notice The ability score uint256 abilityScore; /// @notice List of subgoals cNFT id uint256[] subgoalsId; /// @notice Parent goal id uint256 parentGoalId; /// @notice Settlement data string settlementData; /// @notice Status of covenant's agent watch status bool shouldWatch; /// @notice Arbitrary data that can be stored alongside the NFT bytes data; } struct AgentManagement { /// @notice The TEE ID the agent is running in string teeId; /// @notice The ID of the agent string agentId; /// @notice The agent name string agentName; /// @notice The set of agents tasks id; uint256[] taskId; } constructor(address admin, uint48 initialDelay) ERC721("Covenant NFT", "cNFT") AccessControlDefaultAdminRules(initialDelay, admin) {} /// @notice Allows an agent to register themselves /// @param teeId TEE identifier of the agent /// @param agentId Unique identifier for the agent /// @param agentName Name of the agent function registerAgent(string calldata teeId, string calldata agentId, string calldata agentName) public { if (isAgentRegistered(msg.sender)) revert AgentRegistered(); s_agentDetails[msg.sender].teeId = teeId; s_agentDetails[msg.sender].agentId = agentId; s_agentDetails[msg.sender].agentName = agentName; bool status = s_agents.add(msg.sender); if (status) { emit AgentSet(msg.sender, agentName, agentId, teeId); } } /// @notice Allows user to purchase Covenant NFT /// @param nftId The ID of the NFT being purchased function purchase(uint256 nftId) external { CovenantData storage covenant = s_nftIdToCovenantData[nftId]; IERC20(covenant.settlementAsset).safeTransferFrom(msg.sender, _ownerOf(nftId), covenant.price); _update(msg.sender, nftId, address(0)); } /// @notice Registers a new Covenant NFT /// @param nftType The type of NFT /// @param task The covenant NFT goal /// @param settlementAsset The asset used for settlement /// @param settlementAmount The amount required for settlement /// @param minAbilityScore The minimum ability score required /// @param price The price of the Covenant NFT /// @param shouldWatch The covenant status for monitoring /// @param data Additional encoded data related to the covenant function registerCovenant( NftType nftType, string calldata task, address settlementAsset, uint256 settlementAmount, uint256 minAbilityScore, uint256 price, bool shouldWatch, bytes calldata data ) public virtual returns (bytes32); /// @notice Registers as a subgoal for another Covenant NGT /// @param nftType Type of Covenant NFT /// @param task Description of the covenant goal /// @param parentCovenantId The ID of the parent covenant /// @param settlementAsset The asset used for settlement /// @param settlementAmount The amount required for settlement /// @param shouldWatch The covenant status for monitoring /// @param data Additional encoded data related to the covenant function registerCovenant( NftType nftType, string calldata task, uint256 parentCovenantId, address settlementAsset, uint256 settlementAmount, bool shouldWatch, bytes calldata data ) public virtual returns (bytes32); /// @notice Sets settlement data for a specific Covenant NFT /// @param nftId The ID of the Covenant NFT /// @param data Settlement data function setSettlementData(uint256 nftId, string calldata data) public { if (s_nftIdToCovenantData[nftId].agentWallet != msg.sender) { revert CallerIsNotAuthorizedAgent(); } s_nftSettlementData[nftId] = data; emit SettlementDataSet(nftId, data); } /// @notice Updates the status of Covenant NFT /// @param nftId The ID of the Covenant NFT /// @param status The new status of the covenant function setCovenantStatus(uint256 nftId, CovenantStatus status) public { if (s_nftIdToCovenantData[nftId].parentGoalId == nftId) { if (s_nftIdToCovenantData[nftId].agentWallet != msg.sender) { revert CallerIsNotAuthorizedAgent(); } } else { if (s_nftIdToCovenantData[s_nftIdToCovenantData[nftId].parentGoalId].agentWallet != msg.sender) { revert CallerIsNotAuthorizedAgent(); } } s_nftIdToCovenantData[nftId].status = status; if (status == CovenantStatus.COMPLETED) { for (uint256 i; i < s_nftIdToCovenantData[nftId].subgoalsId.length; ++i) { if ( s_nftIdToCovenantData[s_nftIdToCovenantData[nftId].subgoalsId[i]].status != CovenantStatus.COMPLETED ) revert ConditionIsNotMet(); } address agentWallet = s_nftIdToCovenantData[nftId].agentWallet; address settlementAsset = s_nftIdToCovenantData[nftId].settlementAsset; if (settlementAsset != address(0)) { //slither-disable-next-line arbitrary-send-erc20 IERC20(s_nftIdToCovenantData[nftId].settlementAsset).safeTransferFrom( agentWallet, ownerOf(nftId), s_nftIdToCovenantData[nftId].settlementAmount ); } _burn(nftId); } emit CovenantStatusSet(nftId, status); } function _handleCovenantRegistration( bytes32 requestId, NftType nftType, string calldata task, address settlementAsset, uint256 settlementAmount, uint256 minAbilityScore, uint256 price, bool shouldWatch, bytes calldata data ) internal returns (bytes32) { s_requestIdToNftId[requestId] = s_nftId; s_nftIdToCovenantData[s_nftId].agentWallet = msg.sender; s_nftIdToCovenantData[s_nftId].nftType = nftType; s_nftIdToCovenantData[s_nftId].goal = task; s_nftIdToCovenantData[s_nftId].parentGoalId = uint64(s_nftId); s_nftIdToCovenantData[s_nftId].settlementAsset = settlementAsset; s_nftIdToCovenantData[s_nftId].settlementAmount = settlementAmount; s_nftIdToCovenantData[s_nftId].data = data; s_nftIdToCovenantData[s_nftId].minAbilityScore = minAbilityScore; s_nftIdToCovenantData[s_nftId].status = CovenantStatus.IN_PROGRESS; s_nftIdToCovenantData[s_nftId].shouldWatch = shouldWatch; s_nftIdToCovenantData[s_nftId].price = uint128(price); s_agentDetails[msg.sender].taskId.push(s_nftId); _mint(address(this), s_nftId); emit CovenantRegistered(requestId, msg.sender, s_nftId); s_nftId++; return requestId; } function _handleSubgoalCovenantRegistration( bytes32 requestId, NftType nftType, string calldata task, uint256 parentCovenantId, address settlementAsset, uint256 settlementAmount, bool shouldWatch, bytes calldata data ) internal returns (bytes32) { s_requestIdToNftId[requestId] = s_nftId; s_nftIdToCovenantData[s_nftId].agentWallet = msg.sender; s_nftIdToCovenantData[s_nftId].status = CovenantStatus.IN_PROGRESS; s_nftIdToCovenantData[s_nftId].nftType = nftType; s_nftIdToCovenantData[s_nftId].goal = task; s_nftIdToCovenantData[s_nftId].parentGoalId = uint64(parentCovenantId); s_nftIdToCovenantData[s_nftId].settlementAsset = settlementAsset; s_nftIdToCovenantData[s_nftId].settlementAmount = settlementAmount; s_nftIdToCovenantData[s_nftId].data = data; s_nftIdToCovenantData[s_nftId].shouldWatch = shouldWatch; _mint(address(this), s_nftId); emit CovenantRegistered(requestId, msg.sender, s_nftId); s_nftId++; return requestId; } function _processCallback(uint128 abilityScore, uint256 nftId) internal { if (abilityScore < s_nftIdToCovenantData[s_nftIdToCovenantData[nftId].parentGoalId].minAbilityScore) { _burn(nftId); return; } s_nftIdToCovenantData[nftId].abilityScore = abilityScore; if (nftId != s_nftIdToCovenantData[nftId].parentGoalId) { s_nftIdToCovenantData[s_nftIdToCovenantData[nftId].parentGoalId].subgoalsId.push(uint64(nftId)); s_agentDetails[s_nftIdToCovenantData[nftId].agentWallet].taskId.push(nftId); } _transfer(address(this), s_nftIdToCovenantData[nftId].agentWallet, nftId); } /// @notice Checks if an agent is registered /// @param agent The address of the agent to verify /// @return Returns agent register status function isAgentRegistered(address agent) public view returns (bool) { return s_agents.contains(agent); } /// @notice Retrieves details of a registered agent /// @param agent The address of the agent wallet /// @return string The unique identifier of the agent tee id /// @return uint256[] An array of Covenant NFT IDs associated with the agent function getAgentDetails(address agent) public view returns (string memory, uint256[] memory) { return (s_agentDetails[agent].teeId, s_agentDetails[agent].taskId); } function getAgentCovenantsData(address agent) public view returns (CovenantDetails[] memory) { uint256 agentTaskAmt = s_agentDetails[agent].taskId.length; CovenantDetails[] memory data = new CovenantDetails[](agentTaskAmt); string memory agentId = s_agentDetails[agent].agentId; string memory agentName = s_agentDetails[agent].agentName; for (uint256 i; i < agentTaskAmt; ++i) { uint256 currentNftId = s_agentDetails[agent].taskId[i]; data[i].agentName = agentName; data[i].agentId = agentId; data[i].nftId = currentNftId; data[i].nftType = s_nftIdToCovenantData[currentNftId].nftType; data[i].agentWallet = s_nftIdToCovenantData[currentNftId].agentWallet; data[i].goal = s_nftIdToCovenantData[currentNftId].goal; data[i].settlementAsset = s_nftIdToCovenantData[currentNftId].settlementAsset; data[i].settlementAmount = s_nftIdToCovenantData[currentNftId].settlementAmount; data[i].data = s_nftIdToCovenantData[currentNftId].data; data[i].status = s_nftIdToCovenantData[currentNftId].status; data[i].shouldWatch = s_nftIdToCovenantData[currentNftId].shouldWatch; data[i].price = s_nftIdToCovenantData[currentNftId].price; data[i].subgoalsId = s_nftIdToCovenantData[currentNftId].subgoalsId; data[i].abilityScore = s_nftIdToCovenantData[currentNftId].abilityScore; data[i].owner = _ownerOf(currentNftId); data[i].settlementData = s_nftSettlementData[currentNftId]; } return data; } function getCovenantsDetails() public view returns (CovenantDetails[] memory) { CovenantDetails[] memory data = new CovenantDetails[](s_nftId); for (uint256 i; i < s_nftId; ++i) { address agentWallet = s_nftIdToCovenantData[i].agentWallet; string memory agentId = s_agentDetails[agentWallet].agentId; string memory agentName = s_agentDetails[agentWallet].agentName; data[i].nftId = i; data[i].agentName = agentName; data[i].agentId = agentId; data[i].nftType = s_nftIdToCovenantData[i].nftType; data[i].agentWallet = agentWallet; data[i].goal = s_nftIdToCovenantData[i].goal; data[i].settlementAsset = s_nftIdToCovenantData[i].settlementAsset; data[i].settlementAmount = s_nftIdToCovenantData[i].settlementAmount; data[i].status = s_nftIdToCovenantData[i].status; data[i].shouldWatch = s_nftIdToCovenantData[i].shouldWatch; data[i].price = s_nftIdToCovenantData[i].price; data[i].abilityScore = s_nftIdToCovenantData[i].abilityScore; data[i].parentGoalId = s_nftIdToCovenantData[i].parentGoalId; data[i].subgoalsId = s_nftIdToCovenantData[i].subgoalsId; data[i].owner = _ownerOf(i); data[i].settlementData = s_nftSettlementData[i]; data[i].data = s_nftIdToCovenantData[i].data; } return data; } /// @notice Retrieves details of a specific Covenant NFT /// @param nftId The ID of the Covenant NFT /// @return CovenantData Covenant NFT details function getCovenant(uint256 nftId) external view returns (CovenantData memory) { return s_nftIdToCovenantData[nftId]; } /// @notice Checks if the contract supports a specific interface /// @param interfaceId The ID of the interface to check /// @return Returns whether the interface is supported function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControlDefaultAdminRules, ERC721) returns (bool) { return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.20; import {IERC721} from "./IERC721.sol"; import {IERC721Metadata} from "./extensions/IERC721Metadata.sol"; import {ERC721Utils} from "./utils/ERC721Utils.sol"; import {Context} from "../../utils/Context.sol"; import {Strings} from "../../utils/Strings.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors { using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; mapping(uint256 tokenId => address) private _owners; mapping(address owner => uint256) private _balances; mapping(uint256 tokenId => address) private _tokenApprovals; mapping(address owner => mapping(address operator => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual returns (uint256) { if (owner == address(0)) { revert ERC721InvalidOwner(address(0)); } return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual returns (address) { return _requireOwned(tokenId); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual returns (string memory) { _requireOwned(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual { _approve(to, tokenId, _msgSender()); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual returns (address) { _requireOwned(tokenId); return _getApproved(tokenId); } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here. address previousOwner = _update(to, tokenId, _msgSender()); if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual { transferFrom(from, to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist * * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the * core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`. */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted. */ function _getApproved(uint256 tokenId) internal view virtual returns (address) { return _tokenApprovals[tokenId]; } /** * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in * particular (ignoring whether it is owned by `owner`). * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) { return spender != address(0) && (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender); } /** * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner. * Reverts if: * - `spender` does not have approval from `owner` for `tokenId`. * - `spender` does not have approval to manage all of `owner`'s assets. * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual { if (!_isAuthorized(owner, spender, tokenId)) { if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } else { revert ERC721InsufficientApproval(spender, tokenId); } } } /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that * a uint256 would ever overflow from increments when these increments are bounded to uint128 values. * * WARNING: Increasing an account's balance using this function tends to be paired with an override of the * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership * remain consistent with one another. */ function _increaseBalance(address account, uint128 value) internal virtual { unchecked { _balances[account] += value; } } /** * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update. * * The `auth` argument is optional. If the value passed is non 0, then this function will check that * `auth` is either the owner of the token, or approved to operate on the token (by the owner). * * Emits a {Transfer} event. * * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}. */ function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) { address from = _ownerOf(tokenId); // Perform (optional) operator check if (auth != address(0)) { _checkAuthorized(from, auth, tokenId); } // Execute the update if (from != address(0)) { // Clear approval. No need to re-authorize or emit the Approval event _approve(address(0), tokenId, address(0), false); unchecked { _balances[from] -= 1; } } if (to != address(0)) { unchecked { _balances[to] += 1; } } _owners[tokenId] = to; emit Transfer(from, to, tokenId); return from; } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner != address(0)) { revert ERC721InvalidSender(address(0)); } } /** * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal { address previousOwner = _update(address(0), tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } else if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients * are aware of the ERC-721 standard to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is like {safeTransferFrom} in the sense that it invokes * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `tokenId` token must exist and be owned by `from`. * - `to` cannot be the zero address. * - `from` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId) internal { _safeTransfer(from, to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data); } /** * @dev Approve `to` to operate on `tokenId` * * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is * either the owner of the token, or approved to operate on all tokens held by this owner. * * Emits an {Approval} event. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address to, uint256 tokenId, address auth) internal { _approve(to, tokenId, auth, true); } /** * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not * emitted in the context of transfers. */ function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual { // Avoid reading the owner unless necessary if (emitEvent || auth != address(0)) { address owner = _requireOwned(tokenId); // We do not use _isAuthorized because single-token approvals should not be able to call approve if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) { revert ERC721InvalidApprover(auth); } if (emitEvent) { emit Approval(owner, to, tokenId); } } _tokenApprovals[tokenId] = to; } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Requirements: * - operator can't be the address zero. * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC721InvalidOperator(operator); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned). * Returns the owner. * * Overrides to ownership logic should be done to {_ownerOf}. */ function _requireOwned(uint256 tokenId) internal view returns (address) { address owner = _ownerOf(tokenId); if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } return owner; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.2.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) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlDefaultAdminRules.sol) pragma solidity ^0.8.20; import {IAccessControlDefaultAdminRules} from "./IAccessControlDefaultAdminRules.sol"; import {AccessControl, IAccessControl} from "../AccessControl.sol"; import {SafeCast} from "../../utils/math/SafeCast.sol"; import {Math} from "../../utils/math/Math.sol"; import {IERC5313} from "../../interfaces/IERC5313.sol"; /** * @dev Extension of {AccessControl} that allows specifying special rules to manage * the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions * over other roles that may potentially have privileged rights in the system. * * If a specific role doesn't have an admin role assigned, the holder of the * `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it. * * This contract implements the following risk mitigations on top of {AccessControl}: * * * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced. * * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account. * * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted. * * The delay can be changed by scheduling, see {changeDefaultAdminDelay}. * * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`. * * Example usage: * * ```solidity * contract MyToken is AccessControlDefaultAdminRules { * constructor() AccessControlDefaultAdminRules( * 3 days, * msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder * ) {} * } * ``` */ abstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRules, IERC5313, AccessControl { // pending admin pair read/written together frequently address private _pendingDefaultAdmin; uint48 private _pendingDefaultAdminSchedule; // 0 == unset uint48 private _currentDelay; address private _currentDefaultAdmin; // pending delay pair read/written together frequently uint48 private _pendingDelay; uint48 private _pendingDelaySchedule; // 0 == unset /** * @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address. */ constructor(uint48 initialDelay, address initialDefaultAdmin) { if (initialDefaultAdmin == address(0)) { revert AccessControlInvalidDefaultAdmin(address(0)); } _currentDelay = initialDelay; _grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC5313-owner}. */ function owner() public view virtual returns (address) { return defaultAdmin(); } /// /// Override AccessControl role management /// /** * @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super.grantRole(role, account); } /** * @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super.revokeRole(role, account); } /** * @dev See {AccessControl-renounceRole}. * * For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling * {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule * has also passed when calling this function. * * After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions. * * NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin}, * thereby disabling any functionality that is only available for it, and the possibility of reassigning a * non-administrated role. */ function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) { if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) { (address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin(); if (newDefaultAdmin != address(0) || !_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) { revert AccessControlEnforcedDefaultAdminDelay(schedule); } delete _pendingDefaultAdminSchedule; } super.renounceRole(role, account); } /** * @dev See {AccessControl-_grantRole}. * * For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the * role has been previously renounced. * * NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE` * assignable again. Make sure to guarantee this is the expected behavior in your implementation. */ function _grantRole(bytes32 role, address account) internal virtual override returns (bool) { if (role == DEFAULT_ADMIN_ROLE) { if (defaultAdmin() != address(0)) { revert AccessControlEnforcedDefaultAdminRules(); } _currentDefaultAdmin = account; } return super._grantRole(role, account); } /** * @dev See {AccessControl-_revokeRole}. */ function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) { if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) { delete _currentDefaultAdmin; } return super._revokeRole(role, account); } /** * @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override { if (role == DEFAULT_ADMIN_ROLE) { revert AccessControlEnforcedDefaultAdminRules(); } super._setRoleAdmin(role, adminRole); } /// /// AccessControlDefaultAdminRules accessors /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdmin() public view virtual returns (address) { return _currentDefaultAdmin; } /** * @inheritdoc IAccessControlDefaultAdminRules */ function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) { return (_pendingDefaultAdmin, _pendingDefaultAdminSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdminDelay() public view virtual returns (uint48) { uint48 schedule = _pendingDelaySchedule; return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? _pendingDelay : _currentDelay; } /** * @inheritdoc IAccessControlDefaultAdminRules */ function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) { schedule = _pendingDelaySchedule; return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? (_pendingDelay, schedule) : (0, 0); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) { return 5 days; } /// /// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _beginDefaultAdminTransfer(newAdmin); } /** * @dev See {beginDefaultAdminTransfer}. * * Internal function without access restriction. */ function _beginDefaultAdminTransfer(address newAdmin) internal virtual { uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay(); _setPendingDefaultAdmin(newAdmin, newSchedule); emit DefaultAdminTransferScheduled(newAdmin, newSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _cancelDefaultAdminTransfer(); } /** * @dev See {cancelDefaultAdminTransfer}. * * Internal function without access restriction. */ function _cancelDefaultAdminTransfer() internal virtual { _setPendingDefaultAdmin(address(0), 0); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function acceptDefaultAdminTransfer() public virtual { (address newDefaultAdmin, ) = pendingDefaultAdmin(); if (_msgSender() != newDefaultAdmin) { // Enforce newDefaultAdmin explicit acceptance. revert AccessControlInvalidDefaultAdmin(_msgSender()); } _acceptDefaultAdminTransfer(); } /** * @dev See {acceptDefaultAdminTransfer}. * * Internal function without access restriction. */ function _acceptDefaultAdminTransfer() internal virtual { (address newAdmin, uint48 schedule) = pendingDefaultAdmin(); if (!_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) { revert AccessControlEnforcedDefaultAdminDelay(schedule); } _revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin()); _grantRole(DEFAULT_ADMIN_ROLE, newAdmin); delete _pendingDefaultAdmin; delete _pendingDefaultAdminSchedule; } /// /// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay /// /** * @inheritdoc IAccessControlDefaultAdminRules */ function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _changeDefaultAdminDelay(newDelay); } /** * @dev See {changeDefaultAdminDelay}. * * Internal function without access restriction. */ function _changeDefaultAdminDelay(uint48 newDelay) internal virtual { uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay); _setPendingDelay(newDelay, newSchedule); emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule); } /** * @inheritdoc IAccessControlDefaultAdminRules */ function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) { _rollbackDefaultAdminDelay(); } /** * @dev See {rollbackDefaultAdminDelay}. * * Internal function without access restriction. */ function _rollbackDefaultAdminDelay() internal virtual { _setPendingDelay(0, 0); } /** * @dev Returns the amount of seconds to wait after the `newDelay` will * become the new {defaultAdminDelay}. * * The value returned guarantees that if the delay is reduced, it will go into effect * after a wait that honors the previously set delay. * * See {defaultAdminDelayIncreaseWait}. */ function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) { uint48 currentDelay = defaultAdminDelay(); // When increasing the delay, we schedule the delay change to occur after a period of "new delay" has passed, up // to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day // to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new // delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like // using milliseconds instead of seconds. // // When decreasing the delay, we wait the difference between "current delay" and "new delay". This guarantees // that an admin transfer cannot be made faster than "current delay" at the time the delay change is scheduled. // For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days. return newDelay > currentDelay ? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48 : currentDelay - newDelay; } /// /// Private setters /// /** * @dev Setter of the tuple for pending admin and its schedule. * * May emit a DefaultAdminTransferCanceled event. */ function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private { (, uint48 oldSchedule) = pendingDefaultAdmin(); _pendingDefaultAdmin = newAdmin; _pendingDefaultAdminSchedule = newSchedule; // An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted. if (_isScheduleSet(oldSchedule)) { // Emit for implicit cancellations when another default admin was scheduled. emit DefaultAdminTransferCanceled(); } } /** * @dev Setter of the tuple for pending delay and its schedule. * * May emit a DefaultAdminDelayChangeCanceled event. */ function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private { uint48 oldSchedule = _pendingDelaySchedule; if (_isScheduleSet(oldSchedule)) { if (_hasSchedulePassed(oldSchedule)) { // Materialize a virtual delay _currentDelay = _pendingDelay; } else { // Emit for implicit cancellations when another delay was scheduled. emit DefaultAdminDelayChangeCanceled(); } } _pendingDelay = newDelay; _pendingDelaySchedule = newSchedule; } /// /// Private helpers /// /** * @dev Defines if an `schedule` is considered set. For consistency purposes. */ function _isScheduleSet(uint48 schedule) private pure returns (bool) { return schedule != 0; } /** * @dev Defines if an `schedule` is considered passed. For consistency purposes. */ function _hasSchedulePassed(uint48 schedule) private view returns (bool) { return schedule < block.timestamp; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC1363} from "../../../interfaces/IERC1363.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.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/utils/ERC721Utils.sol) pragma solidity ^0.8.20; import {IERC721Receiver} from "../IERC721Receiver.sol"; import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol"; /** * @dev Library that provide common ERC-721 utility functions. * * See https://eips.ethereum.org/EIPS/eip-721[ERC-721]. * * _Available since v5.1._ */ library ERC721Utils { /** * @dev Performs an acceptance check for the provided `operator` by calling {IERC721-onERC721Received} * 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 {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC721Received( address operator, address from, address to, uint256 tokenId, bytes memory data ) internal { if (to.code.length > 0) { try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) { if (retval != IERC721Receiver.onERC721Received.selector) { // Token rejected revert IERC721Errors.ERC721InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC721Receiver implementer revert IERC721Errors.ERC721InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } }
// 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.2.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SafeCast} from "./math/SafeCast.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { using SafeCast for *; 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 The string being parsed contains characters that are not in scope of the given base. */ error StringsInvalidChar(); /** * @dev The string being parsed is not a properly formatted address. */ error StringsInvalidAddressFormat(); /** * @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)); } /** * @dev Parse a decimal string and returns the value as a `uint256`. * * Requirements: * - The string must be formatted as `[0-9]*` * - The result must fit into an `uint256` type */ function parseUint(string memory input) internal pure returns (uint256) { return parseUint(input, 0, bytes(input).length); } /** * @dev Variant of {parseUint} that parses a substring of `input` located between position `begin` (included) and * `end` (excluded). * * Requirements: * - The substring must be formatted as `[0-9]*` * - The result must fit into an `uint256` type */ function parseUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) { (bool success, uint256 value) = tryParseUint(input, begin, end); if (!success) revert StringsInvalidChar(); return value; } /** * @dev Variant of {parseUint-string} that returns false if the parsing fails because of an invalid character. * * NOTE: This function will revert if the result does not fit in a `uint256`. */ function tryParseUint(string memory input) internal pure returns (bool success, uint256 value) { return _tryParseUintUncheckedBounds(input, 0, bytes(input).length); } /** * @dev Variant of {parseUint-string-uint256-uint256} that returns false if the parsing fails because of an invalid * character. * * NOTE: This function will revert if the result does not fit in a `uint256`. */ function tryParseUint( string memory input, uint256 begin, uint256 end ) internal pure returns (bool success, uint256 value) { if (end > bytes(input).length || begin > end) return (false, 0); return _tryParseUintUncheckedBounds(input, begin, end); } /** * @dev Implementation of {tryParseUint} that does not check bounds. Caller should make sure that * `begin <= end <= input.length`. Other inputs would result in undefined behavior. */ function _tryParseUintUncheckedBounds( string memory input, uint256 begin, uint256 end ) private pure returns (bool success, uint256 value) { bytes memory buffer = bytes(input); uint256 result = 0; for (uint256 i = begin; i < end; ++i) { uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i))); if (chr > 9) return (false, 0); result *= 10; result += chr; } return (true, result); } /** * @dev Parse a decimal string and returns the value as a `int256`. * * Requirements: * - The string must be formatted as `[-+]?[0-9]*` * - The result must fit in an `int256` type. */ function parseInt(string memory input) internal pure returns (int256) { return parseInt(input, 0, bytes(input).length); } /** * @dev Variant of {parseInt-string} that parses a substring of `input` located between position `begin` (included) and * `end` (excluded). * * Requirements: * - The substring must be formatted as `[-+]?[0-9]*` * - The result must fit in an `int256` type. */ function parseInt(string memory input, uint256 begin, uint256 end) internal pure returns (int256) { (bool success, int256 value) = tryParseInt(input, begin, end); if (!success) revert StringsInvalidChar(); return value; } /** * @dev Variant of {parseInt-string} that returns false if the parsing fails because of an invalid character or if * the result does not fit in a `int256`. * * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`. */ function tryParseInt(string memory input) internal pure returns (bool success, int256 value) { return _tryParseIntUncheckedBounds(input, 0, bytes(input).length); } uint256 private constant ABS_MIN_INT256 = 2 ** 255; /** * @dev Variant of {parseInt-string-uint256-uint256} that returns false if the parsing fails because of an invalid * character or if the result does not fit in a `int256`. * * NOTE: This function will revert if the absolute value of the result does not fit in a `uint256`. */ function tryParseInt( string memory input, uint256 begin, uint256 end ) internal pure returns (bool success, int256 value) { if (end > bytes(input).length || begin > end) return (false, 0); return _tryParseIntUncheckedBounds(input, begin, end); } /** * @dev Implementation of {tryParseInt} that does not check bounds. Caller should make sure that * `begin <= end <= input.length`. Other inputs would result in undefined behavior. */ function _tryParseIntUncheckedBounds( string memory input, uint256 begin, uint256 end ) private pure returns (bool success, int256 value) { bytes memory buffer = bytes(input); // Check presence of a negative sign. bytes1 sign = begin == end ? bytes1(0) : bytes1(_unsafeReadBytesOffset(buffer, begin)); // don't do out-of-bound (possibly unsafe) read if sub-string is empty bool positiveSign = sign == bytes1("+"); bool negativeSign = sign == bytes1("-"); uint256 offset = (positiveSign || negativeSign).toUint(); (bool absSuccess, uint256 absValue) = tryParseUint(input, begin + offset, end); if (absSuccess && absValue < ABS_MIN_INT256) { return (true, negativeSign ? -int256(absValue) : int256(absValue)); } else if (absSuccess && negativeSign && absValue == ABS_MIN_INT256) { return (true, type(int256).min); } else return (false, 0); } /** * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as a `uint256`. * * Requirements: * - The string must be formatted as `(0x)?[0-9a-fA-F]*` * - The result must fit in an `uint256` type. */ function parseHexUint(string memory input) internal pure returns (uint256) { return parseHexUint(input, 0, bytes(input).length); } /** * @dev Variant of {parseHexUint} that parses a substring of `input` located between position `begin` (included) and * `end` (excluded). * * Requirements: * - The substring must be formatted as `(0x)?[0-9a-fA-F]*` * - The result must fit in an `uint256` type. */ function parseHexUint(string memory input, uint256 begin, uint256 end) internal pure returns (uint256) { (bool success, uint256 value) = tryParseHexUint(input, begin, end); if (!success) revert StringsInvalidChar(); return value; } /** * @dev Variant of {parseHexUint-string} that returns false if the parsing fails because of an invalid character. * * NOTE: This function will revert if the result does not fit in a `uint256`. */ function tryParseHexUint(string memory input) internal pure returns (bool success, uint256 value) { return _tryParseHexUintUncheckedBounds(input, 0, bytes(input).length); } /** * @dev Variant of {parseHexUint-string-uint256-uint256} that returns false if the parsing fails because of an * invalid character. * * NOTE: This function will revert if the result does not fit in a `uint256`. */ function tryParseHexUint( string memory input, uint256 begin, uint256 end ) internal pure returns (bool success, uint256 value) { if (end > bytes(input).length || begin > end) return (false, 0); return _tryParseHexUintUncheckedBounds(input, begin, end); } /** * @dev Implementation of {tryParseHexUint} that does not check bounds. Caller should make sure that * `begin <= end <= input.length`. Other inputs would result in undefined behavior. */ function _tryParseHexUintUncheckedBounds( string memory input, uint256 begin, uint256 end ) private pure returns (bool success, uint256 value) { bytes memory buffer = bytes(input); // skip 0x prefix if present bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(buffer, begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty uint256 offset = hasPrefix.toUint() * 2; uint256 result = 0; for (uint256 i = begin + offset; i < end; ++i) { uint8 chr = _tryParseChr(bytes1(_unsafeReadBytesOffset(buffer, i))); if (chr > 15) return (false, 0); result *= 16; unchecked { // Multiplying by 16 is equivalent to a shift of 4 bits (with additional overflow check). // This guaratees that adding a value < 16 will not cause an overflow, hence the unchecked. result += chr; } } return (true, result); } /** * @dev Parse a hexadecimal string (with or without "0x" prefix), and returns the value as an `address`. * * Requirements: * - The string must be formatted as `(0x)?[0-9a-fA-F]{40}` */ function parseAddress(string memory input) internal pure returns (address) { return parseAddress(input, 0, bytes(input).length); } /** * @dev Variant of {parseAddress} that parses a substring of `input` located between position `begin` (included) and * `end` (excluded). * * Requirements: * - The substring must be formatted as `(0x)?[0-9a-fA-F]{40}` */ function parseAddress(string memory input, uint256 begin, uint256 end) internal pure returns (address) { (bool success, address value) = tryParseAddress(input, begin, end); if (!success) revert StringsInvalidAddressFormat(); return value; } /** * @dev Variant of {parseAddress-string} that returns false if the parsing fails because the input is not a properly * formatted address. See {parseAddress} requirements. */ function tryParseAddress(string memory input) internal pure returns (bool success, address value) { return tryParseAddress(input, 0, bytes(input).length); } /** * @dev Variant of {parseAddress-string-uint256-uint256} that returns false if the parsing fails because input is not a properly * formatted address. See {parseAddress} requirements. */ function tryParseAddress( string memory input, uint256 begin, uint256 end ) internal pure returns (bool success, address value) { if (end > bytes(input).length || begin > end) return (false, address(0)); bool hasPrefix = (end > begin + 1) && bytes2(_unsafeReadBytesOffset(bytes(input), begin)) == bytes2("0x"); // don't do out-of-bound (possibly unsafe) read if sub-string is empty uint256 expectedLength = 40 + hasPrefix.toUint() * 2; // check that input is the correct length if (end - begin == expectedLength) { // length guarantees that this does not overflow, and value is at most type(uint160).max (bool s, uint256 v) = _tryParseHexUintUncheckedBounds(input, begin, end); return (s, address(uint160(v))); } else { return (false, address(0)); } } function _tryParseChr(bytes1 chr) private pure returns (uint8) { uint8 value = uint8(chr); // Try to parse `chr`: // - Case 1: [0-9] // - Case 2: [a-f] // - Case 3: [A-F] // - otherwise not supported unchecked { if (value > 47 && value < 58) value -= 48; else if (value > 96 && value < 103) value -= 87; else if (value > 64 && value < 71) value -= 55; else return type(uint8).max; } return value; } /** * @dev Reads a bytes32 from a bytes array without bounds checking. * * NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the * assembly block as such would prevent some optimizations. */ function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value) { // This is not memory safe in the general case, but all calls to this private function are within bounds. assembly ("memory-safe") { value := mload(add(buffer, add(0x20, offset))) } } }
// 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) (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) (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/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) (access/extensions/IAccessControlDefaultAdminRules.sol) pragma solidity ^0.8.20; import {IAccessControl} from "../IAccessControl.sol"; /** * @dev External interface of AccessControlDefaultAdminRules declared to support ERC-165 detection. */ interface IAccessControlDefaultAdminRules is IAccessControl { /** * @dev The new default admin is not a valid default admin. */ error AccessControlInvalidDefaultAdmin(address defaultAdmin); /** * @dev At least one of the following rules was violated: * * - The `DEFAULT_ADMIN_ROLE` must only be managed by itself. * - The `DEFAULT_ADMIN_ROLE` must only be held by one account at the time. * - Any `DEFAULT_ADMIN_ROLE` transfer must be in two delayed steps. */ error AccessControlEnforcedDefaultAdminRules(); /** * @dev The delay for transferring the default admin delay is enforced and * the operation must wait until `schedule`. * * NOTE: `schedule` can be 0 indicating there's no transfer scheduled. */ error AccessControlEnforcedDefaultAdminDelay(uint48 schedule); /** * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule` * passes. */ event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule); /** * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule. */ event DefaultAdminTransferCanceled(); /** * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next * delay to be applied between default admin transfer after `effectSchedule` has passed. */ event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule); /** * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass. */ event DefaultAdminDelayChangeCanceled(); /** * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder. */ function defaultAdmin() external view returns (address); /** * @dev Returns a tuple of a `newAdmin` and an accept schedule. * * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role * by calling {acceptDefaultAdminTransfer}, completing the role transfer. * * A zero value only in `acceptSchedule` indicates no pending admin transfer. * * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced. */ function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule); /** * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started. * * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set * the acceptance schedule. * * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this * function returns the new delay. See {changeDefaultAdminDelay}. */ function defaultAdminDelay() external view returns (uint48); /** * @dev Returns a tuple of `newDelay` and an effect schedule. * * After the `schedule` passes, the `newDelay` will get into effect immediately for every * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}. * * A zero value only in `effectSchedule` indicates no pending delay change. * * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay} * will be zero after the effect schedule. */ function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule); /** * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance * after the current timestamp plus a {defaultAdminDelay}. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * Emits a DefaultAdminRoleChangeStarted event. */ function beginDefaultAdminTransfer(address newAdmin) external; /** * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. * * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * May emit a DefaultAdminTransferCanceled event. */ function cancelDefaultAdminTransfer() external; /** * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}. * * After calling the function: * * - `DEFAULT_ADMIN_ROLE` should be granted to the caller. * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder. * - {pendingDefaultAdmin} should be reset to zero values. * * Requirements: * * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`. * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed. */ function acceptDefaultAdminTransfer() external; /** * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting * into effect after the current timestamp plus a {defaultAdminDelay}. * * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay} * set before calling. * * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin} * complete transfer (including acceptance). * * The schedule is designed for two scenarios: * * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by * {defaultAdminDelayIncreaseWait}. * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`. * * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event. */ function changeDefaultAdminDelay(uint48 newDelay) external; /** * @dev Cancels a scheduled {defaultAdminDelay} change. * * Requirements: * * - Only can be called by the current {defaultAdmin}. * * May emit a DefaultAdminDelayChangeCanceled event. */ function rollbackDefaultAdminDelay() external; /** * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay}) * to take effect. Default to 5 days. * * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds) * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can * be overrode for a custom {defaultAdminDelay} increase scheduling. * * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise, * there's a risk of setting a high new delay that goes into effect almost immediately without the * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds). */ function defaultAdminDelayIncreaseWait() external view returns (uint48); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol) pragma solidity ^0.8.20; import {IAccessControl} from "./IAccessControl.sol"; import {Context} from "../utils/Context.sol"; import {ERC165} from "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ```solidity * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ```solidity * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address account => bool) hasRole; bytes32 adminRole; } mapping(bytes32 role => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with an {AccessControlUnauthorizedAccount} error including the required role. */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual returns (bool) { return _roles[role].hasRole[account]; } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()` * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier. */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account` * is missing `role`. */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert AccessControlUnauthorizedAccount(account, role); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address callerConfirmation) public virtual { if (callerConfirmation != _msgSender()) { revert AccessControlBadConfirmation(); } _revokeRole(role, callerConfirmation); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual returns (bool) { if (!hasRole(role, account)) { _roles[role].hasRole[account] = true; emit RoleGranted(role, account, _msgSender()); return true; } else { return false; } } /** * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual returns (bool) { if (hasRole(role, account)) { _roles[role].hasRole[account] = false; emit RoleRevoked(role, account, _msgSender()); return true; } else { return false; } } }
// 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/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.0.0) (interfaces/IERC5313.sol) pragma solidity ^0.8.20; /** * @dev Interface for the Light Contract Ownership Standard. * * A standardized minimal interface required to identify an account that controls a contract */ interface IERC5313 { /** * @dev Gets the address of the owner. */ function owner() external view returns (address); }
// 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.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) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC-721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC-721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// 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) (access/IAccessControl.sol) pragma solidity ^0.8.20; /** * @dev External interface of AccessControl declared to support ERC-165 detection. */ interface IAccessControl { /** * @dev The `account` is missing a role. */ error AccessControlUnauthorizedAccount(address account, bytes32 neededRole); /** * @dev The caller of a function is not the expected one. * * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}. */ error AccessControlBadConfirmation(); /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role). * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `callerConfirmation`. */ function renounceRole(bytes32 role, address callerConfirmation) external; }
// 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.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.0.0) (interfaces/IERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "../utils/introspection/IERC165.sol";
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "chainlink/=lib/chainlink/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"router","type":"address"},{"internalType":"address","name":"admin","type":"address"},{"internalType":"uint48","name":"initialDelay","type":"uint48"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"uint48","name":"schedule","type":"uint48"}],"name":"AccessControlEnforcedDefaultAdminDelay","type":"error"},{"inputs":[],"name":"AccessControlEnforcedDefaultAdminRules","type":"error"},{"inputs":[{"internalType":"address","name":"defaultAdmin","type":"address"}],"name":"AccessControlInvalidDefaultAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"AgentRegistered","type":"error"},{"inputs":[],"name":"CallerIsNotAuthorizedAgent","type":"error"},{"inputs":[],"name":"ConditionIsNotMet","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"agentWallet","type":"address"},{"indexed":false,"internalType":"string","name":"agentName","type":"string"},{"indexed":false,"internalType":"string","name":"agentId","type":"string"},{"indexed":false,"internalType":"string","name":"teeId","type":"string"}],"name":"AgentSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"requestId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"agentWallet","type":"address"},{"indexed":true,"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"CovenantRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"enum CovenantNFT.CovenantStatus","name":"status","type":"uint8"}],"name":"CovenantStatusSet","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminDelayChangeCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint48","name":"newDelay","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"effectSchedule","type":"uint48"}],"name":"DefaultAdminDelayChangeScheduled","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"uint48","name":"acceptSchedule","type":"uint48"}],"name":"DefaultAdminTransferScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"string","name":"data","type":"string"}],"name":"SettlementDataSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"requestId","type":"bytes32"},{"internalType":"uint128","name":"abilityScore","type":"uint128"}],"name":"fulfillRequest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"agent","type":"address"}],"name":"getAgentCovenantsData","outputs":[{"components":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"enum CovenantNFT.NftType","name":"nftType","type":"uint8"},{"internalType":"address","name":"agentWallet","type":"address"},{"internalType":"string","name":"agentId","type":"string"},{"internalType":"string","name":"agentName","type":"string"},{"internalType":"enum CovenantNFT.CovenantStatus","name":"status","type":"uint8"},{"internalType":"string","name":"goal","type":"string"},{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"abilityScore","type":"uint256"},{"internalType":"uint256[]","name":"subgoalsId","type":"uint256[]"},{"internalType":"uint256","name":"parentGoalId","type":"uint256"},{"internalType":"string","name":"settlementData","type":"string"},{"internalType":"bool","name":"shouldWatch","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct CovenantNFT.CovenantDetails[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"agent","type":"address"}],"name":"getAgentDetails","outputs":[{"internalType":"string","name":"","type":"string"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"getCovenant","outputs":[{"components":[{"internalType":"address","name":"agentWallet","type":"address"},{"internalType":"string","name":"agentId","type":"string"},{"internalType":"enum CovenantNFT.CovenantStatus","name":"status","type":"uint8"},{"internalType":"enum CovenantNFT.NftType","name":"nftType","type":"uint8"},{"internalType":"string","name":"goal","type":"string"},{"internalType":"uint256[]","name":"subgoalsId","type":"uint256[]"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"parentGoalId","type":"uint256"},{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"internalType":"uint256","name":"minAbilityScore","type":"uint256"},{"internalType":"uint256","name":"abilityScore","type":"uint256"},{"internalType":"bool","name":"shouldWatch","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct CovenantNFT.CovenantData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCovenantsDetails","outputs":[{"components":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"enum CovenantNFT.NftType","name":"nftType","type":"uint8"},{"internalType":"address","name":"agentWallet","type":"address"},{"internalType":"string","name":"agentId","type":"string"},{"internalType":"string","name":"agentName","type":"string"},{"internalType":"enum CovenantNFT.CovenantStatus","name":"status","type":"uint8"},{"internalType":"string","name":"goal","type":"string"},{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"abilityScore","type":"uint256"},{"internalType":"uint256[]","name":"subgoalsId","type":"uint256[]"},{"internalType":"uint256","name":"parentGoalId","type":"uint256"},{"internalType":"string","name":"settlementData","type":"string"},{"internalType":"bool","name":"shouldWatch","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct CovenantNFT.CovenantDetails[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"agent","type":"address"}],"name":"isAgentRegistered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"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":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdmin","outputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdminDelay","outputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftId","type":"uint256"}],"name":"purchase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"teeId","type":"string"},{"internalType":"string","name":"agentId","type":"string"},{"internalType":"string","name":"agentName","type":"string"}],"name":"registerAgent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum CovenantNFT.NftType","name":"nftType","type":"uint8"},{"internalType":"string","name":"task","type":"string"},{"internalType":"uint256","name":"parentCovenantId","type":"uint256"},{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"internalType":"bool","name":"shouldWatch","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"registerCovenant","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum CovenantNFT.NftType","name":"nftType","type":"uint8"},{"internalType":"string","name":"task","type":"string"},{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"internalType":"uint256","name":"minAbilityScore","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"bool","name":"shouldWatch","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"registerCovenant","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"s_nftId","type":"uint256"}],"name":"s_nftIdToCovenantData","outputs":[{"internalType":"address","name":"agentWallet","type":"address"},{"internalType":"string","name":"agentId","type":"string"},{"internalType":"enum CovenantNFT.CovenantStatus","name":"status","type":"uint8"},{"internalType":"enum CovenantNFT.NftType","name":"nftType","type":"uint8"},{"internalType":"string","name":"goal","type":"string"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"parentGoalId","type":"uint256"},{"internalType":"address","name":"settlementAsset","type":"address"},{"internalType":"uint256","name":"settlementAmount","type":"uint256"},{"internalType":"uint256","name":"minAbilityScore","type":"uint256"},{"internalType":"uint256","name":"abilityScore","type":"uint256"},{"internalType":"bool","name":"shouldWatch","type":"bool"},{"internalType":"bytes","name":"data","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"cNftId","type":"uint256"}],"name":"s_nftSettlementData","outputs":[{"internalType":"string","name":"settlemenData","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"requestId","type":"bytes32"}],"name":"s_requestIdToNftId","outputs":[{"internalType":"uint256","name":"nftId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"enum CovenantNFT.CovenantStatus","name":"status","type":"uint8"}],"name":"setCovenantStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"string","name":"data","type":"string"}],"name":"setSettlementData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561000f575f5ffd5b50604051614bf2380380614bf283398101604081905261002e9161025b565b818180826040518060400160405280600c81526020016b10dbdd995b985b9d0813919560a21b8152506040518060400160405280600481526020016318d3919560e21b815250815f90816100829190610341565b50600161008f8282610341565b5050506001600160a01b0381166100bf57604051636116401160e11b81525f600482015260240160405180910390fd5b600780546001600160d01b0316600160d01b65ffffffffffff8516021790556100e85f82610126565b505050505061011d7f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb28461012660201b60201c565b505050506103fb565b5f82610182575f61013f6008546001600160a01b031690565b6001600160a01b03161461016657604051631fe1e13d60e11b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b0384161790555b61018c8383610195565b90505b92915050565b5f8281526006602090815260408083206001600160a01b038516845290915281205460ff16610239575f8381526006602090815260408083206001600160a01b03861684529091529020805460ff191660011790556101f13390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a450600161018f565b505f61018f565b80516001600160a01b0381168114610256575f5ffd5b919050565b5f5f5f6060848603121561026d575f5ffd5b61027684610240565b925061028460208501610240565b9150604084015165ffffffffffff8116811461029e575f5ffd5b809150509250925092565b634e487b7160e01b5f52604160045260245ffd5b600181811c908216806102d157607f821691505b6020821081036102ef57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f82111561033c57805f5260205f20601f840160051c8101602085101561031a5750805b601f840160051c820191505b81811015610339575f8155600101610326565b50505b505050565b81516001600160401b0381111561035a5761035a6102a9565b61036e8161036884546102bd565b846102f5565b6020601f8211600181146103a0575f83156103895750848201515b5f19600385901b1c1916600184901b178455610339565b5f84815260208120601f198516915b828110156103cf57878501518255602094850194600190920191016103af565b50848210156103ec57868401515f19600387901b60f8161c191681555b50505050600190811b01905550565b6147ea806104085f395ff3fe608060405234801561000f575f5ffd5b5060043610610276575f3560e01c806391d1485411610156578063c5a17513116100ca578063d602b9fd11610084578063d602b9fd146105c9578063de518f8d146105d1578063e52062de146105e4578063e985e9c514610610578063efef39a114610623578063fcca86ad14610636575f5ffd5b8063c5a1751314610552578063c87b56dd14610565578063cc8463c814610578578063cefc142914610580578063cf6eefb714610588578063d547741f146105b6575f5ffd5b8063a22cb4651161011b578063a22cb465146104c5578063b126635d146104d8578063b1c005fa146104eb578063b3eb7bf21461050b578063b88d4fde1461051e578063b8c0567114610531575f5ffd5b806391d148541461046957806395d89b411461047c5780639df08fb214610484578063a1eda53c14610497578063a217fddf146104be575f5ffd5b806342842e0e116101ed578063649a5ec7116101b2578063649a5ec714610404578063689b6c441461041757806370a082311461042a57806378601fc51461043d57806384ef8ffc146104505780638da5cb5b14610461575f5ffd5b806342842e0e146103a357806356a2d660146103b65780635ebf5a42146103c9578063634e93da146103de5780636352211e146103f1575f5ffd5b80630aa6220b1161023e5780630aa6220b146103135780631a5660e21461031b57806323b872dd14610348578063248a9ca31461035b5780632f2ff15d1461037d57806336568abe14610390575f5ffd5b806301ffc9a71461027a578063022d63fb146102a257806306fdde03146102be578063081812fc146102d3578063095ea7b3146102fe575b5f5ffd5b61028d610288366004613ad6565b610649565b60405190151581526020015b60405180910390f35b620697805b60405165ffffffffffff9091168152602001610299565b6102c661069a565b6040516102999190613b1f565b6102e66102e1366004613b31565b610729565b6040516001600160a01b039091168152602001610299565b61031161030c366004613b63565b610750565b005b61031161075f565b61033a610329366004613b31565b600e6020525f908152604090205481565b604051908152602001610299565b610311610356366004613b8b565b610774565b61033a610369366004613b31565b5f9081526006602052604090206001015490565b61031161038b366004613bc5565b610802565b61031161039e366004613bc5565b61082a565b6103116103b1366004613b8b565b6108d0565b6103116103c4366004613c33565b6108ef565b6103d16109d3565b6040516102999190613d41565b6103116103ec366004613f04565b611189565b6102e66103ff366004613b31565b61119c565b610311610412366004613f1d565b6111a6565b61028d610425366004613f04565b6111b9565b61033a610438366004613f04565b6111c5565b6103d161044b366004613f04565b61120a565b6008546001600160a01b03166102e6565b6102e66119e8565b61028d610477366004613bc5565b611a00565b6102c6611a2a565b610311610492366004613f42565b611a39565b61049f611a7c565b6040805165ffffffffffff938416815292909116602083015201610299565b61033a5f81565b6103116104d3366004613f8a565b611ace565b61033a6104e6366004613fc0565b611ad9565b6104fe6104f9366004613b31565b611b52565b6040516102999190614072565b61031161051936600461419e565b611ec4565b61031161052c3660046141f9565b611f52565b61054461053f366004613f04565b611f6a565b6040516102999291906142d3565b6102c6610560366004613b31565b61206f565b6102c6610573366004613b31565b612106565b6102a7612177565b6103116121d5565b610590612214565b604080516001600160a01b03909316835265ffffffffffff909116602083015201610299565b6103116105c4366004613bc5565b612235565b61031161225d565b6103116105df36600461432b565b61226f565b6105f76105f2366004613b31565b612498565b6040516102999d9c9b9a99989796959493929190614351565b61028d61061e366004614410565b6126b2565b610311610631366004613b31565b6126df565b61033a610644366004614438565b612734565b5f6001600160e01b031982166318a4c3c360e11b148061067957506001600160e01b031982166380ac58cd60e01b145b8061069457506001600160e01b03198216635b5e139f60e01b145b92915050565b60605f80546106a8906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546106d4906144f6565b801561071f5780601f106106f65761010080835404028352916020019161071f565b820191905f5260205f20905b81548152906001019060200180831161070257829003601f168201915b5050505050905090565b5f610733826127af565b505f828152600460205260409020546001600160a01b0316610694565b61075b8282336127e7565b5050565b5f610769816127f4565b6107716127fe565b50565b6001600160a01b0382166107a257604051633250574960e11b81525f60048201526024015b60405180910390fd5b5f6107ae83833361280a565b9050836001600160a01b0316816001600160a01b0316146107fc576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610799565b50505050565b8161082057604051631fe1e13d60e11b815260040160405180910390fd5b61075b82826128fc565b8115801561084557506008546001600160a01b038281169116145b156108c6575f5f610854612214565b90925090506001600160a01b038216151580610876575065ffffffffffff8116155b8061088957504265ffffffffffff821610155b156108b1576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610799565b50506007805465ffffffffffff60a01b191690555b61075b8282612920565b6108ea83838360405180602001604052805f815250611f52565b505050565b6108f8336111b9565b1561091657604051633d298d3760e01b815260040160405180910390fd5b335f908152600c6020526040902061092f86888361456c565b50335f908152600c6020526040902060010161094c84868361456c565b50335f908152600c6020526040902060020161096982848361456c565b505f610976600a33612953565b905080156109ca57336001600160a01b03167f13c3a0592cb67210effbe7da26200eea5555e64ffcf026284a6d967f3ae60f8a848488888c8c6040516109c19695949392919061464d565b60405180910390a25b50505050505050565b60605f6009546001600160401b038111156109f0576109f06141e5565b604051908082528060200260200182016040528015610a2957816020015b610a16613a2f565b815260200190600190039081610a0e5790505b5090505f5b600954811015611183575f818152600d60209081526040808320546001600160a01b0316808452600c90925282206001018054919291610a6d906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054610a99906144f6565b8015610ae45780601f10610abb57610100808354040283529160200191610ae4565b820191905f5260205f20905b815481529060010190602001808311610ac757829003601f168201915b5050506001600160a01b0385165f908152600c6020526040812060020180549495509093909250610b1591506144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054610b41906144f6565b8015610b8c5780601f10610b6357610100808354040283529160200191610b8c565b820191905f5260205f20905b815481529060010190602001808311610b6f57829003601f168201915b5050505050905083858581518110610ba657610ba6614695565b60200260200101515f01818152505080858581518110610bc857610bc8614695565b60200260200101516080018190525081858581518110610bea57610bea614695565b602002602001015160600181905250600d5f8581526020019081526020015f2060020160019054906101000a900460ff16858581518110610c2d57610c2d614695565b6020026020010151602001906001811115610c4a57610c4a613ccf565b90816001811115610c5d57610c5d613ccf565b8152505082858581518110610c7457610c74614695565b6020908102919091018101516001600160a01b039092166040928301525f868152600d909152206003018054610ca9906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054610cd5906144f6565b8015610d205780601f10610cf757610100808354040283529160200191610d20565b820191905f5260205f20905b815481529060010190602001808311610d0357829003601f168201915b5050505050858581518110610d3757610d37614695565b602002602001015160c00181905250600d5f8581526020019081526020015f206007015f9054906101000a90046001600160a01b0316858581518110610d7f57610d7f614695565b602002602001015160e001906001600160a01b031690816001600160a01b031681525050600d5f8581526020019081526020015f2060080154858581518110610dca57610dca614695565b60209081029190910181015161012001919091525f858152600d9091526040902060020154855160ff90911690869086908110610e0957610e09614695565b602002602001015160a001906002811115610e2657610e26613ccf565b90816002811115610e3957610e39613ccf565b9052505f848152600d60205260409020600b0154855160ff90911690869086908110610e6757610e67614695565b60200260200101516101e0019015159081151581525050600d5f8581526020019081526020015f2060050154858581518110610ea557610ea5614695565b6020026020010151610140018181525050600d5f8581526020019081526020015f20600a0154858581518110610edd57610edd614695565b6020026020010151610160018181525050600d5f8581526020019081526020015f2060060154858581518110610f1557610f15614695565b60200260200101516101a0018181525050600d5f8581526020019081526020015f20600401805480602002602001604051908101604052809291908181526020018280548015610f8257602002820191905f5260205f20905b815481526020019060010190808311610f6e575b5050505050858581518110610f9957610f99614695565b60200260200101516101800181905250610fc7845f908152600260205260409020546001600160a01b031690565b858581518110610fd957610fd9614695565b602002602001015161010001906001600160a01b031690816001600160a01b031681525050600f5f8581526020019081526020015f20805461101a906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611046906144f6565b80156110915780601f1061106857610100808354040283529160200191611091565b820191905f5260205f20905b81548152906001019060200180831161107457829003601f168201915b50505050508585815181106110a8576110a8614695565b60200260200101516101c00181905250600d5f8581526020019081526020015f20600c0180546110d7906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611103906144f6565b801561114e5780601f106111255761010080835404028352916020019161114e565b820191905f5260205f20905b81548152906001019060200180831161113157829003601f168201915b505050505085858151811061116557611165614695565b60200260200101516102000181905250505050806001019050610a2e565b50919050565b5f611193816127f4565b61075b82612967565b5f610694826127af565b5f6111b0816127f4565b61075b826129d2565b5f610694600a83612a41565b5f6001600160a01b0382166111ef576040516322718ad960e21b81525f6004820152602401610799565b506001600160a01b03165f9081526003602052604090205490565b6001600160a01b0381165f908152600c6020526040812060030154606091816001600160401b03811115611240576112406141e5565b60405190808252806020026020018201604052801561127957816020015b611266613a2f565b81526020019060019003908161125e5790505b506001600160a01b0385165f908152600c60205260408120600101805492935090916112a4906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546112d0906144f6565b801561131b5780601f106112f25761010080835404028352916020019161131b565b820191905f5260205f20905b8154815290600101906020018083116112fe57829003601f168201915b5050506001600160a01b0388165f908152600c602052604081206002018054949550909390925061134c91506144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611378906144f6565b80156113c35780601f1061139a576101008083540402835291602001916113c3565b820191905f5260205f20905b8154815290600101906020018083116113a657829003601f168201915b505050505090505f5b848110156119dd576001600160a01b0387165f908152600c6020526040812060030180548390811061140057611400614695565b905f5260205f20015490508285838151811061141e5761141e614695565b6020026020010151608001819052508385838151811061144057611440614695565b6020026020010151606001819052508085838151811061146257611462614695565b60200260200101515f018181525050600d5f8281526020019081526020015f2060020160019054906101000a900460ff168583815181106114a5576114a5614695565b60200260200101516020019060018111156114c2576114c2613ccf565b908160018111156114d5576114d5613ccf565b9052505f818152600d602052604090205485516001600160a01b039091169086908490811061150657611506614695565b6020908102919091018101516001600160a01b039092166040928301525f838152600d90915220600301805461153b906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611567906144f6565b80156115b25780601f10611589576101008083540402835291602001916115b2565b820191905f5260205f20905b81548152906001019060200180831161159557829003601f168201915b50505050508583815181106115c9576115c9614695565b602002602001015160c00181905250600d5f8281526020019081526020015f206007015f9054906101000a90046001600160a01b031685838151811061161157611611614695565b602002602001015160e001906001600160a01b031690816001600160a01b031681525050600d5f8281526020019081526020015f206008015485838151811061165c5761165c614695565b6020026020010151610120018181525050600d5f8281526020019081526020015f20600c01805461168c906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546116b8906144f6565b80156117035780601f106116da57610100808354040283529160200191611703565b820191905f5260205f20905b8154815290600101906020018083116116e657829003601f168201915b505050505085838151811061171a5761171a614695565b60200260200101516102000181905250600d5f8281526020019081526020015f206002015f9054906101000a900460ff1685838151811061175d5761175d614695565b602002602001015160a00190600281111561177a5761177a613ccf565b9081600281111561178d5761178d613ccf565b9052505f818152600d60205260409020600b0154855160ff909116908690849081106117bb576117bb614695565b60200260200101516101e0019015159081151581525050600d5f8281526020019081526020015f20600501548583815181106117f9576117f9614695565b6020026020010151610140018181525050600d5f8281526020019081526020015f2060040180548060200260200160405190810160405280929190818152602001828054801561186657602002820191905f5260205f20905b815481526020019060010190808311611852575b505050505085838151811061187d5761187d614695565b60200260200101516101800181905250600d5f8281526020019081526020015f20600a01548583815181106118b4576118b4614695565b60200260200101516101600181815250506118e3815f908152600260205260409020546001600160a01b031690565b8583815181106118f5576118f5614695565b602002602001015161010001906001600160a01b031690816001600160a01b031681525050600f5f8281526020019081526020015f208054611936906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611962906144f6565b80156119ad5780601f10611984576101008083540402835291602001916119ad565b820191905f5260205f20905b81548152906001019060200180831161199057829003601f168201915b50505050508583815181106119c4576119c4614695565b60209081029190910101516101c00152506001016113cc565b509195945050505050565b5f6119fb6008546001600160a01b031690565b905090565b5f9182526006602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600180546106a8906144f6565b7f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2611a63816127f4565b5f838152600e60205260409020546108ea908390612a62565b6008545f90600160d01b900465ffffffffffff168015158015611aa757504265ffffffffffff821610155b611ab2575f5f611ac6565b600854600160a01b900465ffffffffffff16815b915091509091565b61075b338383612b3e565b6009546040516bffffffffffffffffffffffff193360601b16602082015260348101919091525f90819060540160408051601f1981840301815291815281516020928301206009545f828152600e90945291909220559050611b43818c8c8c8c8c8c8c8c8c612bdc565b9b9a5050505050505050505050565b611bc6604080516101c0810182525f80825260606020830152909182019081526020015f815260200160608152602001606081526020015f81526020015f81526020015f6001600160a01b031681526020015f81526020015f81526020015f81526020015f15158152602001606081525090565b5f828152600d602090815260409182902082516101c0810190935280546001600160a01b031683526001810180549192840191611c02906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611c2e906144f6565b8015611c795780601f10611c5057610100808354040283529160200191611c79565b820191905f5260205f20905b815481529060010190602001808311611c5c57829003601f168201915b505050918352505060028281015460209092019160ff1690811115611ca057611ca0613ccf565b6002811115611cb157611cb1613ccf565b81526020016002820160019054906101000a900460ff166001811115611cd957611cd9613ccf565b6001811115611cea57611cea613ccf565b8152602001600382018054611cfe906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611d2a906144f6565b8015611d755780601f10611d4c57610100808354040283529160200191611d75565b820191905f5260205f20905b815481529060010190602001808311611d5857829003601f168201915b5050505050815260200160048201805480602002602001604051908101604052809291908181526020018280548015611dcb57602002820191905f5260205f20905b815481526020019060010190808311611db7575b5050509183525050600582015460208201526006820154604082015260078201546001600160a01b0316606082015260088201546080820152600982015460a0820152600a82015460c0820152600b82015460ff16151560e0820152600c8201805461010090920191611e3d906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611e69906144f6565b8015611eb45780601f10611e8b57610100808354040283529160200191611eb4565b820191905f5260205f20905b815481529060010190602001808311611e9757829003601f168201915b5050505050815250509050919050565b5f838152600d60205260409020546001600160a01b03163314611efa5760405163394c0b4360e01b815260040160405180910390fd5b5f838152600f60205260409020611f1282848361456c565b50827f6d705e4f4c89957f76eca680e7aa0abc92f3598a342f163b8a6501921916b9ad8383604051611f459291906146a9565b60405180910390a2505050565b611f5d848484610774565b6107fc3385858585612d5b565b6001600160a01b0381165f908152600c602052604090208054606091829160038201908290611f98906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611fc4906144f6565b801561200f5780601f10611fe65761010080835404028352916020019161200f565b820191905f5260205f20905b815481529060010190602001808311611ff257829003601f168201915b505050505091508080548060200260200160405190810160405280929190818152602001828054801561205f57602002820191905f5260205f20905b81548152602001906001019080831161204b575b5050505050905091509150915091565b600f6020525f908152604090208054612087906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546120b3906144f6565b80156120fe5780601f106120d5576101008083540402835291602001916120fe565b820191905f5260205f20905b8154815290600101906020018083116120e157829003601f168201915b505050505081565b6060612111826127af565b505f61212760408051602081019091525f815290565b90505f8151116121455760405180602001604052805f815250612170565b8061214f84612e83565b6040516020016121609291906146d3565b6040516020818303038152906040525b9392505050565b6008545f90600160d01b900465ffffffffffff1680151580156121a157504265ffffffffffff8216105b6121bc57600754600160d01b900465ffffffffffff166121cf565b600854600160a01b900465ffffffffffff165b91505090565b5f6121de612214565b509050336001600160a01b0382161461220c57604051636116401160e11b8152336004820152602401610799565b610771612f12565b6007546001600160a01b03811691600160a01b90910465ffffffffffff1690565b8161225357604051631fe1e13d60e11b815260040160405180910390fd5b61075b8282612fa8565b5f612267816127f4565b610771612fcc565b5f828152600d60205260409020600601548290036122c2575f828152600d60205260409020546001600160a01b031633146122bd5760405163394c0b4360e01b815260040160405180910390fd5b612301565b5f828152600d60205260408082206006015482529020546001600160a01b031633146123015760405163394c0b4360e01b815260040160405180910390fd5b5f828152600d6020526040902060029081018054839260ff1990911690600190849081111561233257612332613ccf565b0217905550600181600281111561234b5761234b613ccf565b0361245c575f5b5f838152600d60205260409020600401548110156123f1576001600d5f600d5f8781526020019081526020015f20600401848154811061239457612394614695565b905f5260205f20015481526020019081526020015f206002015f9054906101000a900460ff1660028111156123cb576123cb613ccf565b146123e95760405163f480469b60e01b815260040160405180910390fd5b600101612352565b505f828152600d6020526040902080546007909101546001600160a01b039182169116801561245057612450826124278661119c565b5f878152600d6020526040902060088101546007909101546001600160a01b0316929190612fd6565b61245984613030565b50505b817fcd548536efa80a296ff47b1a4d9c0283d0de58b3d22580549d5becc7a7ebc1b58260405161248c91906146e7565b60405180910390a25050565b600d6020525f9081526040902080546001820180546001600160a01b0390921692916124c3906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546124ef906144f6565b801561253a5780601f106125115761010080835404028352916020019161253a565b820191905f5260205f20905b81548152906001019060200180831161251d57829003601f168201915b505050506002830154600384018054939460ff8084169561010090940416935091612564906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054612590906144f6565b80156125db5780601f106125b2576101008083540402835291602001916125db565b820191905f5260205f20905b8154815290600101906020018083116125be57829003601f168201915b50505060058401546006850154600786015460088701546009880154600a890154600b8a0154600c8b0180549a9b979a9699506001600160a01b03909516975092959194909360ff9093169290612631906144f6565b80601f016020809104026020016040519081016040528092919081815260200182805461265d906144f6565b80156126a85780601f1061267f576101008083540402835291602001916126a8565b820191905f5260205f20905b81548152906001019060200180831161268b57829003601f168201915b505050505090508d565b6001600160a01b039182165f90815260056020908152604080832093909416825291909152205460ff1690565b5f818152600d602052604090206127293361270e845f908152600260205260409020546001600160a01b031690565b600584015460078501546001600160a01b0316929190612fd6565b6108ea33835f61280a565b6009546040516bffffffffffffffffffffffff193360601b16602082015260348101919091525f90819060540160408051601f1981840301815291815281516020928301206009545f828152600e9094529190922055905061279f818d8d8d8d8d8d8d8d8d8d613068565b9c9b505050505050505050505050565b5f818152600260205260408120546001600160a01b03168061069457604051637e27328960e01b815260048101849052602401610799565b6108ea8383836001613233565b6107718133613337565b6128085f5f613370565b565b5f828152600260205260408120546001600160a01b03908116908316156128365761283681848661342f565b6001600160a01b03811615612870576128515f855f5f613233565b6001600160a01b0381165f90815260036020526040902080545f190190555b6001600160a01b0385161561289e576001600160a01b0385165f908152600360205260409020805460010190555b5f8481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b5f82815260066020526040902060010154612916816127f4565b6107fc8383613493565b6001600160a01b03811633146129495760405163334bd91960e11b815260040160405180910390fd5b6108ea82826134f9565b5f612170836001600160a01b038416613535565b5f612970612177565b61297942613581565b6129839190614709565b905061298f82826135b7565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200161248c565b5f6129dc82613634565b6129e542613581565b6129ef9190614709565b90506129fb8282613370565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b910160405180910390a15050565b6001600160a01b0381165f9081526001830160205260408120541515612170565b5f818152600d60205260408082206006015482529020600901546001600160801b0383161015612a955761075b81613030565b5f818152600d602052604090206001600160801b038316600a820155600601548114612b1b575f818152600d60209081526040808320600681015484528184206004018054600181810183559186528486206001600160401b03881691015590546001600160a01b03168452600c83529083206003018054918201815583529120018190555b5f818152600d602052604090205461075b9030906001600160a01b031683613685565b6001600160a01b038216612b7057604051630b61174360e31b81526001600160a01b0383166004820152602401610799565b6001600160a01b038381165f81815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b600980545f8c8152600e60209081526040808320849055928252600d905281812080546001600160a01b03191633179055825481528181206002908101805460ff191690559254815290812090910180548b919061ff001916610100836001811115612c4a57612c4a613ccf565b02179055506009545f908152600d60205260409020600301612c6d898b8361456c565b50600980545f908152600d60205260408082206001600160401b038b166006909101558254825280822060070180546001600160a01b0319166001600160a01b038b16179055825482528082206008018890559154815220600c01612cd383858361456c565b50600980545f908152600d60205260409020600b01805460ff191686151517905554612d00903090613732565b6009546040518c815233907f865661d2f0776bab3773009180fbca291828cf328bd30432af221cb37f916e709060200160405180910390a360098054905f612d4783614727565b909155509a9b9a5050505050505050505050565b6001600160a01b0383163b15612e7c57604051630a85bd0160e11b81526001600160a01b0384169063150b7a0290612d9d90889088908790879060040161473f565b6020604051808303815f875af1925050508015612dd7575060408051601f3d908101601f19168201909252612dd49181019061477b565b60015b612e3e573d808015612e04576040519150601f19603f3d011682016040523d82523d5f602084013e612e09565b606091505b5080515f03612e3657604051633250574960e11b81526001600160a01b0385166004820152602401610799565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b14612e7a57604051633250574960e11b81526001600160a01b0385166004820152602401610799565b505b5050505050565b60605f612e8f83613793565b60010190505f816001600160401b03811115612ead57612ead6141e5565b6040519080825280601f01601f191660200182016040528015612ed7576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084612ee157509392505050565b5f5f612f1c612214565b91509150612f318165ffffffffffff16151590565b1580612f4557504265ffffffffffff821610155b15612f6d576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610799565b612f885f612f836008546001600160a01b031690565b6134f9565b50612f935f83613493565b5050600780546001600160d01b031916905550565b5f82815260066020526040902060010154612fc2816127f4565b6107fc83836134f9565b6128085f5f6135b7565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526107fc90859061386a565b5f61303c5f835f61280a565b90506001600160a01b03811661075b57604051637e27328960e01b815260048101839052602401610799565b600980545f8d8152600e60209081526040808320849055928252600d905281812080546001600160a01b0319163317905591548252812060020180548c919061ff0019166101008360018111156130c1576130c1613ccf565b02179055506009545f908152600d602052604090206003016130e48a8c8361456c565b50600980545f818152600d60205260408082206001600160401b039093166006909301929092558254815281812060070180546001600160a01b0319166001600160a01b038d16179055825481528181206008018a9055915482529020600c0161314f83858361456c565b50600980545f908152600d6020908152604080832084018a905583548352808320600201805460ff1990811690915584548452818420600b018054909116891515179055835483528083206001600160801b038a16600590910155338352600c82528220835460039091018054600181018255908452919092200155546131d7903090613732565b6009546040518d815233907f865661d2f0776bab3773009180fbca291828cf328bd30432af221cb37f916e709060200160405180910390a360098054905f61321e83614727565b909155509b9c9b505050505050505050505050565b808061324757506001600160a01b03821615155b15613308575f613256846127af565b90506001600160a01b038316158015906132825750826001600160a01b0316816001600160a01b031614155b8015613295575061329381846126b2565b155b156132be5760405163a9fbf51f60e01b81526001600160a01b0384166004820152602401610799565b81156133065783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50505f90815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b6133418282611a00565b61075b5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610799565b600854600160d01b900465ffffffffffff1680156133f2574265ffffffffffff821610156133c957600854600780546001600160d01b0316600160a01b90920465ffffffffffff16600160d01b029190911790556133f2565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec5905f90a15b50600880546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b61343a8383836138d6565b6108ea576001600160a01b03831661346857604051637e27328960e01b815260048101829052602401610799565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401610799565b5f826134ef575f6134ac6008546001600160a01b031690565b6001600160a01b0316146134d357604051631fe1e13d60e11b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b0384161790555b612170838361393a565b5f8215801561351557506008546001600160a01b038381169116145b1561352b57600880546001600160a01b03191690555b61217083836139c4565b5f81815260018301602052604081205461357a57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610694565b505f610694565b5f65ffffffffffff8211156135b3576040516306dfcc6560e41b81526030600482015260248101839052604401610799565b5090565b5f6135c0612214565b6007805465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b03881617179055915061360290508165ffffffffffff16151590565b156108ea576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a9605109905f90a1505050565b5f5f61363e612177565b90508065ffffffffffff168365ffffffffffff1611613666576136618382614796565b612170565b61217065ffffffffffff8416620697805f828218828410028218612170565b6001600160a01b0382166136ae57604051633250574960e11b81525f6004820152602401610799565b5f6136ba83835f61280a565b90506001600160a01b0381166136e657604051637e27328960e01b815260048101839052602401610799565b836001600160a01b0316816001600160a01b0316146107fc576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610799565b6001600160a01b03821661375b57604051633250574960e11b81525f6004820152602401610799565b5f61376783835f61280a565b90506001600160a01b038116156108ea576040516339e3563760e11b81525f6004820152602401610799565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106137d15772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106137fd576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061381b57662386f26fc10000830492506010015b6305f5e1008310613833576305f5e100830492506008015b612710831061384757612710830492506004015b60648310613859576064830492506002015b600a83106106945760010192915050565b5f5f60205f8451602086015f885af180613889576040513d5f823e3d81fd5b50505f513d915081156138a05780600114156138ad565b6001600160a01b0384163b155b156107fc57604051635274afe760e01b81526001600160a01b0385166004820152602401610799565b5f6001600160a01b038316158015906139325750826001600160a01b0316846001600160a01b0316148061390f575061390f84846126b2565b8061393257505f828152600460205260409020546001600160a01b038481169116145b949350505050565b5f6139458383611a00565b61357a575f8381526006602090815260408083206001600160a01b03861684529091529020805460ff1916600117905561397c3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610694565b5f6139cf8383611a00565b1561357a575f8381526006602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610694565b6040805161022081019091525f808252602082019081525f60208201819052606060408301819052808301526080909101908152602001606081526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f81526020015f81526020015f8152602001606081526020015f8152602001606081526020015f15158152602001606081525090565b6001600160e01b031981168114610771575f5ffd5b5f60208284031215613ae6575f5ffd5b813561217081613ac1565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6121706020830184613af1565b5f60208284031215613b41575f5ffd5b5035919050565b80356001600160a01b0381168114613b5e575f5ffd5b919050565b5f5f60408385031215613b74575f5ffd5b613b7d83613b48565b946020939093013593505050565b5f5f5f60608486031215613b9d575f5ffd5b613ba684613b48565b9250613bb460208501613b48565b929592945050506040919091013590565b5f5f60408385031215613bd6575f5ffd5b82359150613be660208401613b48565b90509250929050565b5f5f83601f840112613bff575f5ffd5b5081356001600160401b03811115613c15575f5ffd5b602083019150836020828501011115613c2c575f5ffd5b9250929050565b5f5f5f5f5f5f60608789031215613c48575f5ffd5b86356001600160401b03811115613c5d575f5ffd5b613c6989828a01613bef565b90975095505060208701356001600160401b03811115613c87575f5ffd5b613c9389828a01613bef565b90955093505060408701356001600160401b03811115613cb1575f5ffd5b613cbd89828a01613bef565b979a9699509497509295939492505050565b634e487b7160e01b5f52602160045260245ffd5b60028110613cf357613cf3613ccf565b9052565b60038110613cf357613cf3613ccf565b5f8151808452602084019350602083015f5b82811015613d37578151865260209586019590910190600101613d19565b5093949350505050565b5f602082016020835280845180835260408501915060408160051b8601019250602086015f5b82811015613ef857603f198786030184528151805186526020810151613d906020880182613ce3565b506040810151613dab60408801826001600160a01b03169052565b5060608101516102206060880152613dc7610220880182613af1565b905060808201518782036080890152613de08282613af1565b91505060a0820151613df560a0890182613cf7565b5060c082015187820360c0890152613e0d8282613af1565b91505060e0820151613e2a60e08901826001600160a01b03169052565b50610100820151613e476101008901826001600160a01b03169052565b50610120820151610120880152610140820151610140880152610160820151610160880152610180820151878203610180890152613e858282613d07565b9150506101a08201516101a08801526101c08201518782036101c0890152613ead8282613af1565b9150506101e0820151613ec56101e089018215159052565b506102008201519150868103610200880152613ee18183613af1565b965050506020938401939190910190600101613d67565b50929695505050505050565b5f60208284031215613f14575f5ffd5b61217082613b48565b5f60208284031215613f2d575f5ffd5b813565ffffffffffff81168114612170575f5ffd5b5f5f60408385031215613f53575f5ffd5b8235915060208301356001600160801b0381168114613f70575f5ffd5b809150509250929050565b80358015158114613b5e575f5ffd5b5f5f60408385031215613f9b575f5ffd5b613fa483613b48565b9150613be660208401613f7b565b803560028110613b5e575f5ffd5b5f5f5f5f5f5f5f5f5f60e08a8c031215613fd8575f5ffd5b613fe18a613fb2565b985060208a01356001600160401b03811115613ffb575f5ffd5b6140078c828d01613bef565b90995097505060408a0135955061402060608b01613b48565b945060808a0135935061403560a08b01613f7b565b925060c08a01356001600160401b0381111561404f575f5ffd5b61405b8c828d01613bef565b915080935050809150509295985092959850929598565b6020815261408c6020820183516001600160a01b03169052565b5f60208301516101c060408401526140a86101e0840182613af1565b905060408401516140bc6060850182613cf7565b5060608401516140cf6080850182613ce3565b506080840151838203601f190160a08501526140eb8282613af1565b91505060a0840151601f198483030160c08501526141098282613d07565b91505060c084015160e084015260e084015161010084015261010084015161413d6101208501826001600160a01b03169052565b506101208401516101408401526101408401516101608401526101608401516101808401526101808401516141776101a085018215159052565b506101a0840151838203601f19016101c08501526141958282613af1565b95945050505050565b5f5f5f604084860312156141b0575f5ffd5b8335925060208401356001600160401b038111156141cc575f5ffd5b6141d886828701613bef565b9497909650939450505050565b634e487b7160e01b5f52604160045260245ffd5b5f5f5f5f6080858703121561420c575f5ffd5b61421585613b48565b935061422360208601613b48565b92506040850135915060608501356001600160401b03811115614244575f5ffd5b8501601f81018713614254575f5ffd5b80356001600160401b0381111561426d5761426d6141e5565b604051601f8201601f19908116603f011681016001600160401b038111828210171561429b5761429b6141e5565b6040528181528282016020018910156142b2575f5ffd5b816020840160208301375f6020838301015280935050505092959194509250565b604081525f6142e56040830185613af1565b82810360208401528084518083526020830191506020860192505f5b8181101561431f578351835260209384019390920191600101614301565b50909695505050505050565b5f5f6040838503121561433c575f5ffd5b82359150602083013560038110613f70575f5ffd5b6001600160a01b038e1681526101a0602082018190525f906143759083018f613af1565b614382604084018f613cf7565b61438f606084018e613ce3565b82810360808401526143a1818d613af1565b90508a60a08401528960c08401526143c460e084018a6001600160a01b03169052565b8761010084015286610120840152856101408401526143e861016084018615159052565b8281036101808401526143fb8185613af1565b9150509e9d5050505050505050505050505050565b5f5f60408385031215614421575f5ffd5b61442a83613b48565b9150613be660208401613b48565b5f5f5f5f5f5f5f5f5f5f6101008b8d031215614452575f5ffd5b61445b8b613fb2565b995060208b01356001600160401b03811115614475575f5ffd5b6144818d828e01613bef565b909a509850614494905060408c01613b48565b965060608b0135955060808b0135945060a08b013593506144b760c08c01613f7b565b925060e08b01356001600160401b038111156144d1575f5ffd5b6144dd8d828e01613bef565b915080935050809150509295989b9194979a5092959850565b600181811c9082168061450a57607f821691505b60208210810361118357634e487b7160e01b5f52602260045260245ffd5b601f8211156108ea57805f5260205f20601f840160051c8101602085101561454d5750805b601f840160051c820191505b81811015612e7c575f8155600101614559565b6001600160401b03831115614583576145836141e5565b6145978361459183546144f6565b83614528565b5f601f8411600181146145c8575f85156145b15750838201355b5f19600387901b1c1916600186901b178355612e7c565b5f83815260208120601f198716915b828110156145f757868501358255602094850194600190920191016145d7565b5086821015614613575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b606081525f61466060608301888a614625565b8281036020840152614673818789614625565b90508281036040840152614688818587614625565b9998505050505050505050565b634e487b7160e01b5f52603260045260245ffd5b602081525f613932602083018486614625565b5f81518060208401855e5f93019283525090919050565b5f6139326146e183866146bc565b846146bc565b602081016106948284613cf7565b634e487b7160e01b5f52601160045260245ffd5b65ffffffffffff8181168382160190811115610694576106946146f5565b5f60018201614738576147386146f5565b5060010190565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f9061477190830184613af1565b9695505050505050565b5f6020828403121561478b575f5ffd5b815161217081613ac1565b65ffffffffffff8281168282160390811115610694576106946146f556fea2646970667358221220eff0d659f267edc26a316225e30b6fb41e20787240754c489ba471f50beb729b64736f6c634300081b003300000000000000000000000061ed4e612b981e739fc0bbb57218d64be6e7d0ff0000000000000000000000004231520ad0e2fe4f4a514ef1155a8fd5400ad809000000000000000000000000000000000000000000000000000000000000003c
Deployed Bytecode
0x608060405234801561000f575f5ffd5b5060043610610276575f3560e01c806391d1485411610156578063c5a17513116100ca578063d602b9fd11610084578063d602b9fd146105c9578063de518f8d146105d1578063e52062de146105e4578063e985e9c514610610578063efef39a114610623578063fcca86ad14610636575f5ffd5b8063c5a1751314610552578063c87b56dd14610565578063cc8463c814610578578063cefc142914610580578063cf6eefb714610588578063d547741f146105b6575f5ffd5b8063a22cb4651161011b578063a22cb465146104c5578063b126635d146104d8578063b1c005fa146104eb578063b3eb7bf21461050b578063b88d4fde1461051e578063b8c0567114610531575f5ffd5b806391d148541461046957806395d89b411461047c5780639df08fb214610484578063a1eda53c14610497578063a217fddf146104be575f5ffd5b806342842e0e116101ed578063649a5ec7116101b2578063649a5ec714610404578063689b6c441461041757806370a082311461042a57806378601fc51461043d57806384ef8ffc146104505780638da5cb5b14610461575f5ffd5b806342842e0e146103a357806356a2d660146103b65780635ebf5a42146103c9578063634e93da146103de5780636352211e146103f1575f5ffd5b80630aa6220b1161023e5780630aa6220b146103135780631a5660e21461031b57806323b872dd14610348578063248a9ca31461035b5780632f2ff15d1461037d57806336568abe14610390575f5ffd5b806301ffc9a71461027a578063022d63fb146102a257806306fdde03146102be578063081812fc146102d3578063095ea7b3146102fe575b5f5ffd5b61028d610288366004613ad6565b610649565b60405190151581526020015b60405180910390f35b620697805b60405165ffffffffffff9091168152602001610299565b6102c661069a565b6040516102999190613b1f565b6102e66102e1366004613b31565b610729565b6040516001600160a01b039091168152602001610299565b61031161030c366004613b63565b610750565b005b61031161075f565b61033a610329366004613b31565b600e6020525f908152604090205481565b604051908152602001610299565b610311610356366004613b8b565b610774565b61033a610369366004613b31565b5f9081526006602052604090206001015490565b61031161038b366004613bc5565b610802565b61031161039e366004613bc5565b61082a565b6103116103b1366004613b8b565b6108d0565b6103116103c4366004613c33565b6108ef565b6103d16109d3565b6040516102999190613d41565b6103116103ec366004613f04565b611189565b6102e66103ff366004613b31565b61119c565b610311610412366004613f1d565b6111a6565b61028d610425366004613f04565b6111b9565b61033a610438366004613f04565b6111c5565b6103d161044b366004613f04565b61120a565b6008546001600160a01b03166102e6565b6102e66119e8565b61028d610477366004613bc5565b611a00565b6102c6611a2a565b610311610492366004613f42565b611a39565b61049f611a7c565b6040805165ffffffffffff938416815292909116602083015201610299565b61033a5f81565b6103116104d3366004613f8a565b611ace565b61033a6104e6366004613fc0565b611ad9565b6104fe6104f9366004613b31565b611b52565b6040516102999190614072565b61031161051936600461419e565b611ec4565b61031161052c3660046141f9565b611f52565b61054461053f366004613f04565b611f6a565b6040516102999291906142d3565b6102c6610560366004613b31565b61206f565b6102c6610573366004613b31565b612106565b6102a7612177565b6103116121d5565b610590612214565b604080516001600160a01b03909316835265ffffffffffff909116602083015201610299565b6103116105c4366004613bc5565b612235565b61031161225d565b6103116105df36600461432b565b61226f565b6105f76105f2366004613b31565b612498565b6040516102999d9c9b9a99989796959493929190614351565b61028d61061e366004614410565b6126b2565b610311610631366004613b31565b6126df565b61033a610644366004614438565b612734565b5f6001600160e01b031982166318a4c3c360e11b148061067957506001600160e01b031982166380ac58cd60e01b145b8061069457506001600160e01b03198216635b5e139f60e01b145b92915050565b60605f80546106a8906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546106d4906144f6565b801561071f5780601f106106f65761010080835404028352916020019161071f565b820191905f5260205f20905b81548152906001019060200180831161070257829003601f168201915b5050505050905090565b5f610733826127af565b505f828152600460205260409020546001600160a01b0316610694565b61075b8282336127e7565b5050565b5f610769816127f4565b6107716127fe565b50565b6001600160a01b0382166107a257604051633250574960e11b81525f60048201526024015b60405180910390fd5b5f6107ae83833361280a565b9050836001600160a01b0316816001600160a01b0316146107fc576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610799565b50505050565b8161082057604051631fe1e13d60e11b815260040160405180910390fd5b61075b82826128fc565b8115801561084557506008546001600160a01b038281169116145b156108c6575f5f610854612214565b90925090506001600160a01b038216151580610876575065ffffffffffff8116155b8061088957504265ffffffffffff821610155b156108b1576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610799565b50506007805465ffffffffffff60a01b191690555b61075b8282612920565b6108ea83838360405180602001604052805f815250611f52565b505050565b6108f8336111b9565b1561091657604051633d298d3760e01b815260040160405180910390fd5b335f908152600c6020526040902061092f86888361456c565b50335f908152600c6020526040902060010161094c84868361456c565b50335f908152600c6020526040902060020161096982848361456c565b505f610976600a33612953565b905080156109ca57336001600160a01b03167f13c3a0592cb67210effbe7da26200eea5555e64ffcf026284a6d967f3ae60f8a848488888c8c6040516109c19695949392919061464d565b60405180910390a25b50505050505050565b60605f6009546001600160401b038111156109f0576109f06141e5565b604051908082528060200260200182016040528015610a2957816020015b610a16613a2f565b815260200190600190039081610a0e5790505b5090505f5b600954811015611183575f818152600d60209081526040808320546001600160a01b0316808452600c90925282206001018054919291610a6d906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054610a99906144f6565b8015610ae45780601f10610abb57610100808354040283529160200191610ae4565b820191905f5260205f20905b815481529060010190602001808311610ac757829003601f168201915b5050506001600160a01b0385165f908152600c6020526040812060020180549495509093909250610b1591506144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054610b41906144f6565b8015610b8c5780601f10610b6357610100808354040283529160200191610b8c565b820191905f5260205f20905b815481529060010190602001808311610b6f57829003601f168201915b5050505050905083858581518110610ba657610ba6614695565b60200260200101515f01818152505080858581518110610bc857610bc8614695565b60200260200101516080018190525081858581518110610bea57610bea614695565b602002602001015160600181905250600d5f8581526020019081526020015f2060020160019054906101000a900460ff16858581518110610c2d57610c2d614695565b6020026020010151602001906001811115610c4a57610c4a613ccf565b90816001811115610c5d57610c5d613ccf565b8152505082858581518110610c7457610c74614695565b6020908102919091018101516001600160a01b039092166040928301525f868152600d909152206003018054610ca9906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054610cd5906144f6565b8015610d205780601f10610cf757610100808354040283529160200191610d20565b820191905f5260205f20905b815481529060010190602001808311610d0357829003601f168201915b5050505050858581518110610d3757610d37614695565b602002602001015160c00181905250600d5f8581526020019081526020015f206007015f9054906101000a90046001600160a01b0316858581518110610d7f57610d7f614695565b602002602001015160e001906001600160a01b031690816001600160a01b031681525050600d5f8581526020019081526020015f2060080154858581518110610dca57610dca614695565b60209081029190910181015161012001919091525f858152600d9091526040902060020154855160ff90911690869086908110610e0957610e09614695565b602002602001015160a001906002811115610e2657610e26613ccf565b90816002811115610e3957610e39613ccf565b9052505f848152600d60205260409020600b0154855160ff90911690869086908110610e6757610e67614695565b60200260200101516101e0019015159081151581525050600d5f8581526020019081526020015f2060050154858581518110610ea557610ea5614695565b6020026020010151610140018181525050600d5f8581526020019081526020015f20600a0154858581518110610edd57610edd614695565b6020026020010151610160018181525050600d5f8581526020019081526020015f2060060154858581518110610f1557610f15614695565b60200260200101516101a0018181525050600d5f8581526020019081526020015f20600401805480602002602001604051908101604052809291908181526020018280548015610f8257602002820191905f5260205f20905b815481526020019060010190808311610f6e575b5050505050858581518110610f9957610f99614695565b60200260200101516101800181905250610fc7845f908152600260205260409020546001600160a01b031690565b858581518110610fd957610fd9614695565b602002602001015161010001906001600160a01b031690816001600160a01b031681525050600f5f8581526020019081526020015f20805461101a906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611046906144f6565b80156110915780601f1061106857610100808354040283529160200191611091565b820191905f5260205f20905b81548152906001019060200180831161107457829003601f168201915b50505050508585815181106110a8576110a8614695565b60200260200101516101c00181905250600d5f8581526020019081526020015f20600c0180546110d7906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611103906144f6565b801561114e5780601f106111255761010080835404028352916020019161114e565b820191905f5260205f20905b81548152906001019060200180831161113157829003601f168201915b505050505085858151811061116557611165614695565b60200260200101516102000181905250505050806001019050610a2e565b50919050565b5f611193816127f4565b61075b82612967565b5f610694826127af565b5f6111b0816127f4565b61075b826129d2565b5f610694600a83612a41565b5f6001600160a01b0382166111ef576040516322718ad960e21b81525f6004820152602401610799565b506001600160a01b03165f9081526003602052604090205490565b6001600160a01b0381165f908152600c6020526040812060030154606091816001600160401b03811115611240576112406141e5565b60405190808252806020026020018201604052801561127957816020015b611266613a2f565b81526020019060019003908161125e5790505b506001600160a01b0385165f908152600c60205260408120600101805492935090916112a4906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546112d0906144f6565b801561131b5780601f106112f25761010080835404028352916020019161131b565b820191905f5260205f20905b8154815290600101906020018083116112fe57829003601f168201915b5050506001600160a01b0388165f908152600c602052604081206002018054949550909390925061134c91506144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611378906144f6565b80156113c35780601f1061139a576101008083540402835291602001916113c3565b820191905f5260205f20905b8154815290600101906020018083116113a657829003601f168201915b505050505090505f5b848110156119dd576001600160a01b0387165f908152600c6020526040812060030180548390811061140057611400614695565b905f5260205f20015490508285838151811061141e5761141e614695565b6020026020010151608001819052508385838151811061144057611440614695565b6020026020010151606001819052508085838151811061146257611462614695565b60200260200101515f018181525050600d5f8281526020019081526020015f2060020160019054906101000a900460ff168583815181106114a5576114a5614695565b60200260200101516020019060018111156114c2576114c2613ccf565b908160018111156114d5576114d5613ccf565b9052505f818152600d602052604090205485516001600160a01b039091169086908490811061150657611506614695565b6020908102919091018101516001600160a01b039092166040928301525f838152600d90915220600301805461153b906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611567906144f6565b80156115b25780601f10611589576101008083540402835291602001916115b2565b820191905f5260205f20905b81548152906001019060200180831161159557829003601f168201915b50505050508583815181106115c9576115c9614695565b602002602001015160c00181905250600d5f8281526020019081526020015f206007015f9054906101000a90046001600160a01b031685838151811061161157611611614695565b602002602001015160e001906001600160a01b031690816001600160a01b031681525050600d5f8281526020019081526020015f206008015485838151811061165c5761165c614695565b6020026020010151610120018181525050600d5f8281526020019081526020015f20600c01805461168c906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546116b8906144f6565b80156117035780601f106116da57610100808354040283529160200191611703565b820191905f5260205f20905b8154815290600101906020018083116116e657829003601f168201915b505050505085838151811061171a5761171a614695565b60200260200101516102000181905250600d5f8281526020019081526020015f206002015f9054906101000a900460ff1685838151811061175d5761175d614695565b602002602001015160a00190600281111561177a5761177a613ccf565b9081600281111561178d5761178d613ccf565b9052505f818152600d60205260409020600b0154855160ff909116908690849081106117bb576117bb614695565b60200260200101516101e0019015159081151581525050600d5f8281526020019081526020015f20600501548583815181106117f9576117f9614695565b6020026020010151610140018181525050600d5f8281526020019081526020015f2060040180548060200260200160405190810160405280929190818152602001828054801561186657602002820191905f5260205f20905b815481526020019060010190808311611852575b505050505085838151811061187d5761187d614695565b60200260200101516101800181905250600d5f8281526020019081526020015f20600a01548583815181106118b4576118b4614695565b60200260200101516101600181815250506118e3815f908152600260205260409020546001600160a01b031690565b8583815181106118f5576118f5614695565b602002602001015161010001906001600160a01b031690816001600160a01b031681525050600f5f8281526020019081526020015f208054611936906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611962906144f6565b80156119ad5780601f10611984576101008083540402835291602001916119ad565b820191905f5260205f20905b81548152906001019060200180831161199057829003601f168201915b50505050508583815181106119c4576119c4614695565b60209081029190910101516101c00152506001016113cc565b509195945050505050565b5f6119fb6008546001600160a01b031690565b905090565b5f9182526006602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600180546106a8906144f6565b7f7a05a596cb0ce7fdea8a1e1ec73be300bdb35097c944ce1897202f7a13122eb2611a63816127f4565b5f838152600e60205260409020546108ea908390612a62565b6008545f90600160d01b900465ffffffffffff168015158015611aa757504265ffffffffffff821610155b611ab2575f5f611ac6565b600854600160a01b900465ffffffffffff16815b915091509091565b61075b338383612b3e565b6009546040516bffffffffffffffffffffffff193360601b16602082015260348101919091525f90819060540160408051601f1981840301815291815281516020928301206009545f828152600e90945291909220559050611b43818c8c8c8c8c8c8c8c8c612bdc565b9b9a5050505050505050505050565b611bc6604080516101c0810182525f80825260606020830152909182019081526020015f815260200160608152602001606081526020015f81526020015f81526020015f6001600160a01b031681526020015f81526020015f81526020015f81526020015f15158152602001606081525090565b5f828152600d602090815260409182902082516101c0810190935280546001600160a01b031683526001810180549192840191611c02906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611c2e906144f6565b8015611c795780601f10611c5057610100808354040283529160200191611c79565b820191905f5260205f20905b815481529060010190602001808311611c5c57829003601f168201915b505050918352505060028281015460209092019160ff1690811115611ca057611ca0613ccf565b6002811115611cb157611cb1613ccf565b81526020016002820160019054906101000a900460ff166001811115611cd957611cd9613ccf565b6001811115611cea57611cea613ccf565b8152602001600382018054611cfe906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611d2a906144f6565b8015611d755780601f10611d4c57610100808354040283529160200191611d75565b820191905f5260205f20905b815481529060010190602001808311611d5857829003601f168201915b5050505050815260200160048201805480602002602001604051908101604052809291908181526020018280548015611dcb57602002820191905f5260205f20905b815481526020019060010190808311611db7575b5050509183525050600582015460208201526006820154604082015260078201546001600160a01b0316606082015260088201546080820152600982015460a0820152600a82015460c0820152600b82015460ff16151560e0820152600c8201805461010090920191611e3d906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611e69906144f6565b8015611eb45780601f10611e8b57610100808354040283529160200191611eb4565b820191905f5260205f20905b815481529060010190602001808311611e9757829003601f168201915b5050505050815250509050919050565b5f838152600d60205260409020546001600160a01b03163314611efa5760405163394c0b4360e01b815260040160405180910390fd5b5f838152600f60205260409020611f1282848361456c565b50827f6d705e4f4c89957f76eca680e7aa0abc92f3598a342f163b8a6501921916b9ad8383604051611f459291906146a9565b60405180910390a2505050565b611f5d848484610774565b6107fc3385858585612d5b565b6001600160a01b0381165f908152600c602052604090208054606091829160038201908290611f98906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054611fc4906144f6565b801561200f5780601f10611fe65761010080835404028352916020019161200f565b820191905f5260205f20905b815481529060010190602001808311611ff257829003601f168201915b505050505091508080548060200260200160405190810160405280929190818152602001828054801561205f57602002820191905f5260205f20905b81548152602001906001019080831161204b575b5050505050905091509150915091565b600f6020525f908152604090208054612087906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546120b3906144f6565b80156120fe5780601f106120d5576101008083540402835291602001916120fe565b820191905f5260205f20905b8154815290600101906020018083116120e157829003601f168201915b505050505081565b6060612111826127af565b505f61212760408051602081019091525f815290565b90505f8151116121455760405180602001604052805f815250612170565b8061214f84612e83565b6040516020016121609291906146d3565b6040516020818303038152906040525b9392505050565b6008545f90600160d01b900465ffffffffffff1680151580156121a157504265ffffffffffff8216105b6121bc57600754600160d01b900465ffffffffffff166121cf565b600854600160a01b900465ffffffffffff165b91505090565b5f6121de612214565b509050336001600160a01b0382161461220c57604051636116401160e11b8152336004820152602401610799565b610771612f12565b6007546001600160a01b03811691600160a01b90910465ffffffffffff1690565b8161225357604051631fe1e13d60e11b815260040160405180910390fd5b61075b8282612fa8565b5f612267816127f4565b610771612fcc565b5f828152600d60205260409020600601548290036122c2575f828152600d60205260409020546001600160a01b031633146122bd5760405163394c0b4360e01b815260040160405180910390fd5b612301565b5f828152600d60205260408082206006015482529020546001600160a01b031633146123015760405163394c0b4360e01b815260040160405180910390fd5b5f828152600d6020526040902060029081018054839260ff1990911690600190849081111561233257612332613ccf565b0217905550600181600281111561234b5761234b613ccf565b0361245c575f5b5f838152600d60205260409020600401548110156123f1576001600d5f600d5f8781526020019081526020015f20600401848154811061239457612394614695565b905f5260205f20015481526020019081526020015f206002015f9054906101000a900460ff1660028111156123cb576123cb613ccf565b146123e95760405163f480469b60e01b815260040160405180910390fd5b600101612352565b505f828152600d6020526040902080546007909101546001600160a01b039182169116801561245057612450826124278661119c565b5f878152600d6020526040902060088101546007909101546001600160a01b0316929190612fd6565b61245984613030565b50505b817fcd548536efa80a296ff47b1a4d9c0283d0de58b3d22580549d5becc7a7ebc1b58260405161248c91906146e7565b60405180910390a25050565b600d6020525f9081526040902080546001820180546001600160a01b0390921692916124c3906144f6565b80601f01602080910402602001604051908101604052809291908181526020018280546124ef906144f6565b801561253a5780601f106125115761010080835404028352916020019161253a565b820191905f5260205f20905b81548152906001019060200180831161251d57829003601f168201915b505050506002830154600384018054939460ff8084169561010090940416935091612564906144f6565b80601f0160208091040260200160405190810160405280929190818152602001828054612590906144f6565b80156125db5780601f106125b2576101008083540402835291602001916125db565b820191905f5260205f20905b8154815290600101906020018083116125be57829003601f168201915b50505060058401546006850154600786015460088701546009880154600a890154600b8a0154600c8b0180549a9b979a9699506001600160a01b03909516975092959194909360ff9093169290612631906144f6565b80601f016020809104026020016040519081016040528092919081815260200182805461265d906144f6565b80156126a85780601f1061267f576101008083540402835291602001916126a8565b820191905f5260205f20905b81548152906001019060200180831161268b57829003601f168201915b505050505090508d565b6001600160a01b039182165f90815260056020908152604080832093909416825291909152205460ff1690565b5f818152600d602052604090206127293361270e845f908152600260205260409020546001600160a01b031690565b600584015460078501546001600160a01b0316929190612fd6565b6108ea33835f61280a565b6009546040516bffffffffffffffffffffffff193360601b16602082015260348101919091525f90819060540160408051601f1981840301815291815281516020928301206009545f828152600e9094529190922055905061279f818d8d8d8d8d8d8d8d8d8d613068565b9c9b505050505050505050505050565b5f818152600260205260408120546001600160a01b03168061069457604051637e27328960e01b815260048101849052602401610799565b6108ea8383836001613233565b6107718133613337565b6128085f5f613370565b565b5f828152600260205260408120546001600160a01b03908116908316156128365761283681848661342f565b6001600160a01b03811615612870576128515f855f5f613233565b6001600160a01b0381165f90815260036020526040902080545f190190555b6001600160a01b0385161561289e576001600160a01b0385165f908152600360205260409020805460010190555b5f8481526002602052604080822080546001600160a01b0319166001600160a01b0389811691821790925591518793918516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4949350505050565b5f82815260066020526040902060010154612916816127f4565b6107fc8383613493565b6001600160a01b03811633146129495760405163334bd91960e11b815260040160405180910390fd5b6108ea82826134f9565b5f612170836001600160a01b038416613535565b5f612970612177565b61297942613581565b6129839190614709565b905061298f82826135b7565b60405165ffffffffffff821681526001600160a01b038316907f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed69060200161248c565b5f6129dc82613634565b6129e542613581565b6129ef9190614709565b90506129fb8282613370565b6040805165ffffffffffff8085168252831660208201527ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b910160405180910390a15050565b6001600160a01b0381165f9081526001830160205260408120541515612170565b5f818152600d60205260408082206006015482529020600901546001600160801b0383161015612a955761075b81613030565b5f818152600d602052604090206001600160801b038316600a820155600601548114612b1b575f818152600d60209081526040808320600681015484528184206004018054600181810183559186528486206001600160401b03881691015590546001600160a01b03168452600c83529083206003018054918201815583529120018190555b5f818152600d602052604090205461075b9030906001600160a01b031683613685565b6001600160a01b038216612b7057604051630b61174360e31b81526001600160a01b0383166004820152602401610799565b6001600160a01b038381165f81815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b600980545f8c8152600e60209081526040808320849055928252600d905281812080546001600160a01b03191633179055825481528181206002908101805460ff191690559254815290812090910180548b919061ff001916610100836001811115612c4a57612c4a613ccf565b02179055506009545f908152600d60205260409020600301612c6d898b8361456c565b50600980545f908152600d60205260408082206001600160401b038b166006909101558254825280822060070180546001600160a01b0319166001600160a01b038b16179055825482528082206008018890559154815220600c01612cd383858361456c565b50600980545f908152600d60205260409020600b01805460ff191686151517905554612d00903090613732565b6009546040518c815233907f865661d2f0776bab3773009180fbca291828cf328bd30432af221cb37f916e709060200160405180910390a360098054905f612d4783614727565b909155509a9b9a5050505050505050505050565b6001600160a01b0383163b15612e7c57604051630a85bd0160e11b81526001600160a01b0384169063150b7a0290612d9d90889088908790879060040161473f565b6020604051808303815f875af1925050508015612dd7575060408051601f3d908101601f19168201909252612dd49181019061477b565b60015b612e3e573d808015612e04576040519150601f19603f3d011682016040523d82523d5f602084013e612e09565b606091505b5080515f03612e3657604051633250574960e11b81526001600160a01b0385166004820152602401610799565b805181602001fd5b6001600160e01b03198116630a85bd0160e11b14612e7a57604051633250574960e11b81526001600160a01b0385166004820152602401610799565b505b5050505050565b60605f612e8f83613793565b60010190505f816001600160401b03811115612ead57612ead6141e5565b6040519080825280601f01601f191660200182016040528015612ed7576020820181803683370190505b5090508181016020015b5f19016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084612ee157509392505050565b5f5f612f1c612214565b91509150612f318165ffffffffffff16151590565b1580612f4557504265ffffffffffff821610155b15612f6d576040516319ca5ebb60e01b815265ffffffffffff82166004820152602401610799565b612f885f612f836008546001600160a01b031690565b6134f9565b50612f935f83613493565b5050600780546001600160d01b031916905550565b5f82815260066020526040902060010154612fc2816127f4565b6107fc83836134f9565b6128085f5f6135b7565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790526107fc90859061386a565b5f61303c5f835f61280a565b90506001600160a01b03811661075b57604051637e27328960e01b815260048101839052602401610799565b600980545f8d8152600e60209081526040808320849055928252600d905281812080546001600160a01b0319163317905591548252812060020180548c919061ff0019166101008360018111156130c1576130c1613ccf565b02179055506009545f908152600d602052604090206003016130e48a8c8361456c565b50600980545f818152600d60205260408082206001600160401b039093166006909301929092558254815281812060070180546001600160a01b0319166001600160a01b038d16179055825481528181206008018a9055915482529020600c0161314f83858361456c565b50600980545f908152600d6020908152604080832084018a905583548352808320600201805460ff1990811690915584548452818420600b018054909116891515179055835483528083206001600160801b038a16600590910155338352600c82528220835460039091018054600181018255908452919092200155546131d7903090613732565b6009546040518d815233907f865661d2f0776bab3773009180fbca291828cf328bd30432af221cb37f916e709060200160405180910390a360098054905f61321e83614727565b909155509b9c9b505050505050505050505050565b808061324757506001600160a01b03821615155b15613308575f613256846127af565b90506001600160a01b038316158015906132825750826001600160a01b0316816001600160a01b031614155b8015613295575061329381846126b2565b155b156132be5760405163a9fbf51f60e01b81526001600160a01b0384166004820152602401610799565b81156133065783856001600160a01b0316826001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45b505b50505f90815260046020526040902080546001600160a01b0319166001600160a01b0392909216919091179055565b6133418282611a00565b61075b5760405163e2517d3f60e01b81526001600160a01b038216600482015260248101839052604401610799565b600854600160d01b900465ffffffffffff1680156133f2574265ffffffffffff821610156133c957600854600780546001600160d01b0316600160a01b90920465ffffffffffff16600160d01b029190911790556133f2565b6040517f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec5905f90a15b50600880546001600160a01b0316600160a01b65ffffffffffff948516026001600160d01b031617600160d01b9290931691909102919091179055565b61343a8383836138d6565b6108ea576001600160a01b03831661346857604051637e27328960e01b815260048101829052602401610799565b60405163177e802f60e01b81526001600160a01b038316600482015260248101829052604401610799565b5f826134ef575f6134ac6008546001600160a01b031690565b6001600160a01b0316146134d357604051631fe1e13d60e11b815260040160405180910390fd5b600880546001600160a01b0319166001600160a01b0384161790555b612170838361393a565b5f8215801561351557506008546001600160a01b038381169116145b1561352b57600880546001600160a01b03191690555b61217083836139c4565b5f81815260018301602052604081205461357a57508154600181810184555f848152602080822090930184905584548482528286019093526040902091909155610694565b505f610694565b5f65ffffffffffff8211156135b3576040516306dfcc6560e41b81526030600482015260248101839052604401610799565b5090565b5f6135c0612214565b6007805465ffffffffffff8616600160a01b026001600160d01b03199091166001600160a01b03881617179055915061360290508165ffffffffffff16151590565b156108ea576040517f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a9605109905f90a1505050565b5f5f61363e612177565b90508065ffffffffffff168365ffffffffffff1611613666576136618382614796565b612170565b61217065ffffffffffff8416620697805f828218828410028218612170565b6001600160a01b0382166136ae57604051633250574960e11b81525f6004820152602401610799565b5f6136ba83835f61280a565b90506001600160a01b0381166136e657604051637e27328960e01b815260048101839052602401610799565b836001600160a01b0316816001600160a01b0316146107fc576040516364283d7b60e01b81526001600160a01b0380861660048301526024820184905282166044820152606401610799565b6001600160a01b03821661375b57604051633250574960e11b81525f6004820152602401610799565b5f61376783835f61280a565b90506001600160a01b038116156108ea576040516339e3563760e11b81525f6004820152602401610799565b5f8072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106137d15772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106137fd576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061381b57662386f26fc10000830492506010015b6305f5e1008310613833576305f5e100830492506008015b612710831061384757612710830492506004015b60648310613859576064830492506002015b600a83106106945760010192915050565b5f5f60205f8451602086015f885af180613889576040513d5f823e3d81fd5b50505f513d915081156138a05780600114156138ad565b6001600160a01b0384163b155b156107fc57604051635274afe760e01b81526001600160a01b0385166004820152602401610799565b5f6001600160a01b038316158015906139325750826001600160a01b0316846001600160a01b0316148061390f575061390f84846126b2565b8061393257505f828152600460205260409020546001600160a01b038481169116145b949350505050565b5f6139458383611a00565b61357a575f8381526006602090815260408083206001600160a01b03861684529091529020805460ff1916600117905561397c3390565b6001600160a01b0316826001600160a01b0316847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a4506001610694565b5f6139cf8383611a00565b1561357a575f8381526006602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610694565b6040805161022081019091525f808252602082019081525f60208201819052606060408301819052808301526080909101908152602001606081526020015f6001600160a01b031681526020015f6001600160a01b031681526020015f81526020015f81526020015f8152602001606081526020015f8152602001606081526020015f15158152602001606081525090565b6001600160e01b031981168114610771575f5ffd5b5f60208284031215613ae6575f5ffd5b813561217081613ac1565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b602081525f6121706020830184613af1565b5f60208284031215613b41575f5ffd5b5035919050565b80356001600160a01b0381168114613b5e575f5ffd5b919050565b5f5f60408385031215613b74575f5ffd5b613b7d83613b48565b946020939093013593505050565b5f5f5f60608486031215613b9d575f5ffd5b613ba684613b48565b9250613bb460208501613b48565b929592945050506040919091013590565b5f5f60408385031215613bd6575f5ffd5b82359150613be660208401613b48565b90509250929050565b5f5f83601f840112613bff575f5ffd5b5081356001600160401b03811115613c15575f5ffd5b602083019150836020828501011115613c2c575f5ffd5b9250929050565b5f5f5f5f5f5f60608789031215613c48575f5ffd5b86356001600160401b03811115613c5d575f5ffd5b613c6989828a01613bef565b90975095505060208701356001600160401b03811115613c87575f5ffd5b613c9389828a01613bef565b90955093505060408701356001600160401b03811115613cb1575f5ffd5b613cbd89828a01613bef565b979a9699509497509295939492505050565b634e487b7160e01b5f52602160045260245ffd5b60028110613cf357613cf3613ccf565b9052565b60038110613cf357613cf3613ccf565b5f8151808452602084019350602083015f5b82811015613d37578151865260209586019590910190600101613d19565b5093949350505050565b5f602082016020835280845180835260408501915060408160051b8601019250602086015f5b82811015613ef857603f198786030184528151805186526020810151613d906020880182613ce3565b506040810151613dab60408801826001600160a01b03169052565b5060608101516102206060880152613dc7610220880182613af1565b905060808201518782036080890152613de08282613af1565b91505060a0820151613df560a0890182613cf7565b5060c082015187820360c0890152613e0d8282613af1565b91505060e0820151613e2a60e08901826001600160a01b03169052565b50610100820151613e476101008901826001600160a01b03169052565b50610120820151610120880152610140820151610140880152610160820151610160880152610180820151878203610180890152613e858282613d07565b9150506101a08201516101a08801526101c08201518782036101c0890152613ead8282613af1565b9150506101e0820151613ec56101e089018215159052565b506102008201519150868103610200880152613ee18183613af1565b965050506020938401939190910190600101613d67565b50929695505050505050565b5f60208284031215613f14575f5ffd5b61217082613b48565b5f60208284031215613f2d575f5ffd5b813565ffffffffffff81168114612170575f5ffd5b5f5f60408385031215613f53575f5ffd5b8235915060208301356001600160801b0381168114613f70575f5ffd5b809150509250929050565b80358015158114613b5e575f5ffd5b5f5f60408385031215613f9b575f5ffd5b613fa483613b48565b9150613be660208401613f7b565b803560028110613b5e575f5ffd5b5f5f5f5f5f5f5f5f5f60e08a8c031215613fd8575f5ffd5b613fe18a613fb2565b985060208a01356001600160401b03811115613ffb575f5ffd5b6140078c828d01613bef565b90995097505060408a0135955061402060608b01613b48565b945060808a0135935061403560a08b01613f7b565b925060c08a01356001600160401b0381111561404f575f5ffd5b61405b8c828d01613bef565b915080935050809150509295985092959850929598565b6020815261408c6020820183516001600160a01b03169052565b5f60208301516101c060408401526140a86101e0840182613af1565b905060408401516140bc6060850182613cf7565b5060608401516140cf6080850182613ce3565b506080840151838203601f190160a08501526140eb8282613af1565b91505060a0840151601f198483030160c08501526141098282613d07565b91505060c084015160e084015260e084015161010084015261010084015161413d6101208501826001600160a01b03169052565b506101208401516101408401526101408401516101608401526101608401516101808401526101808401516141776101a085018215159052565b506101a0840151838203601f19016101c08501526141958282613af1565b95945050505050565b5f5f5f604084860312156141b0575f5ffd5b8335925060208401356001600160401b038111156141cc575f5ffd5b6141d886828701613bef565b9497909650939450505050565b634e487b7160e01b5f52604160045260245ffd5b5f5f5f5f6080858703121561420c575f5ffd5b61421585613b48565b935061422360208601613b48565b92506040850135915060608501356001600160401b03811115614244575f5ffd5b8501601f81018713614254575f5ffd5b80356001600160401b0381111561426d5761426d6141e5565b604051601f8201601f19908116603f011681016001600160401b038111828210171561429b5761429b6141e5565b6040528181528282016020018910156142b2575f5ffd5b816020840160208301375f6020838301015280935050505092959194509250565b604081525f6142e56040830185613af1565b82810360208401528084518083526020830191506020860192505f5b8181101561431f578351835260209384019390920191600101614301565b50909695505050505050565b5f5f6040838503121561433c575f5ffd5b82359150602083013560038110613f70575f5ffd5b6001600160a01b038e1681526101a0602082018190525f906143759083018f613af1565b614382604084018f613cf7565b61438f606084018e613ce3565b82810360808401526143a1818d613af1565b90508a60a08401528960c08401526143c460e084018a6001600160a01b03169052565b8761010084015286610120840152856101408401526143e861016084018615159052565b8281036101808401526143fb8185613af1565b9150509e9d5050505050505050505050505050565b5f5f60408385031215614421575f5ffd5b61442a83613b48565b9150613be660208401613b48565b5f5f5f5f5f5f5f5f5f5f6101008b8d031215614452575f5ffd5b61445b8b613fb2565b995060208b01356001600160401b03811115614475575f5ffd5b6144818d828e01613bef565b909a509850614494905060408c01613b48565b965060608b0135955060808b0135945060a08b013593506144b760c08c01613f7b565b925060e08b01356001600160401b038111156144d1575f5ffd5b6144dd8d828e01613bef565b915080935050809150509295989b9194979a5092959850565b600181811c9082168061450a57607f821691505b60208210810361118357634e487b7160e01b5f52602260045260245ffd5b601f8211156108ea57805f5260205f20601f840160051c8101602085101561454d5750805b601f840160051c820191505b81811015612e7c575f8155600101614559565b6001600160401b03831115614583576145836141e5565b6145978361459183546144f6565b83614528565b5f601f8411600181146145c8575f85156145b15750838201355b5f19600387901b1c1916600186901b178355612e7c565b5f83815260208120601f198716915b828110156145f757868501358255602094850194600190920191016145d7565b5086821015614613575f1960f88860031b161c19848701351681555b505060018560011b0183555050505050565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b606081525f61466060608301888a614625565b8281036020840152614673818789614625565b90508281036040840152614688818587614625565b9998505050505050505050565b634e487b7160e01b5f52603260045260245ffd5b602081525f613932602083018486614625565b5f81518060208401855e5f93019283525090919050565b5f6139326146e183866146bc565b846146bc565b602081016106948284613cf7565b634e487b7160e01b5f52601160045260245ffd5b65ffffffffffff8181168382160190811115610694576106946146f5565b5f60018201614738576147386146f5565b5060010190565b6001600160a01b03858116825284166020820152604081018390526080606082018190525f9061477190830184613af1565b9695505050505050565b5f6020828403121561478b575f5ffd5b815161217081613ac1565b65ffffffffffff8281168282160390811115610694576106946146f556fea2646970667358221220eff0d659f267edc26a316225e30b6fb41e20787240754c489ba471f50beb729b64736f6c634300081b0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000061ed4e612b981e739fc0bbb57218d64be6e7d0ff0000000000000000000000004231520ad0e2fe4f4a514ef1155a8fd5400ad809000000000000000000000000000000000000000000000000000000000000003c
-----Decoded View---------------
Arg [0] : router (address): 0x61eD4E612b981E739Fc0BBb57218d64bE6E7d0FF
Arg [1] : admin (address): 0x4231520aD0E2fe4F4a514Ef1155A8fd5400AD809
Arg [2] : initialDelay (uint48): 60
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000061ed4e612b981e739fc0bbb57218d64be6e7d0ff
Arg [1] : 0000000000000000000000004231520ad0e2fe4f4a514ef1155a8fd5400ad809
Arg [2] : 000000000000000000000000000000000000000000000000000000000000003c
[ 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.