Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
EthboxV2
Compiler Version
v0.8.16+commit.07a7930e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: Unlicensed pragma solidity 0.8.16; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "./strings.sol"; import "./base64.sol"; import "./EthboxStructs.sol"; abstract contract EthboxMetadata { function buildMetadata( address owner, EthboxStructs.UnpackedMessage[] memory messages, uint256 ethboxSize, uint256 ethboxDrip ) public view virtual returns (string memory data); } contract EthboxV2 is ERC165, IERC721, IERC721Metadata, Initializable, OwnableUpgradeable, ReentrancyGuardUpgradeable, UUPSUpgradeable { using Strings for uint256; using strings for *; //--ERC721 Variables--// string private _name; string private _symbol; EthboxMetadata public metadata; /// @notice Mapping to keep track of whether an address has minted an ethbox. /// @dev Using a bool rather than number because an address can only mint one. mapping(address => bool) public minted; //--Messaging Variables--// /// @notice The default size an ethbox is set to at mint /// @dev This size can be increased for a fee, see { expandEthboxSize } uint256 public constant defaultEthboxSize = 3; /// @notice The default time it will take for a message to "expire". For example, /// someone sends a 1 ETH message, in four weeks all that ETH, minus our fee /// will be claimable by the ethbox owner. /// @dev This can be changed by ethbox owners, when their ethbox is empty. /// This change only affects their ethbox. See { changeEthboxDurationTime } uint256 public constant defaultDripTime = 4 weeks; /// @notice Max message length somebody can send, this will not change. uint256 public constant maxMessageLen = 141; /// @notice The initial cost of increasing ethbox size. /// @dev Settable by contract owner here { setSizeIncreaseFee } uint256 public sizeIncreaseFee; /// @notice The BPS increase in fee depending on how many slots the user /// already has /// @dev Settable by contract owner here { setSizeIncreaseFeeBPS } uint256 public sizeIncreaseFeeBPS; /// @notice The BPS fee charged by contract owner per message. /// @dev Settable by contract owner here { setMessageFeeBPS } uint256 public messageFeeBPS; /// @notice The recipient of these fees. /// @dev Settable by contract owner here { setMessageFeeRecipient } address public messageFeeRecipient; /// @notice Mapping to keep track of an address' messages. /// @dev See { EthboxStructs.Message } /// Note: address does not have to mint ethbox to recieve messages. /// An unminted ethbox with messages will claim all value upong minting. mapping(address => EthboxStructs.Message[]) public ethboxMessages; /// @notice Stores ethbox specific information in an address => uint256 mapping /// @dev Bits Layout: /// - [0..159] `payoutRecipient` /// - [160..223] `drip (timestamp)` /// - [224] `isLocked` /// - [225 - 232] `size` /// - [233..255] Currently unused /// See { packEthboxInfo } and { unpackEthboxInfo } for implementation. mapping(address => uint256) packedEthboxInfo; /// @notice Mapping to keep track of remaining eth to be claimed from bumped messages /// An unminted ethbox with messages will claim all value upong minting. mapping(address => uint256) public bumpedClaimValue; //--Packing Constants--// /// @dev Bit position of drip timestamp in { packedEthboxInfo } /// see { unpackEthboxDrip } uint256 private constant BITPOS_ETHBOX_DRIP_TIMESTAMP = 160; /// @dev Bit position of ethbox locked boolean in { packedEthboxInfo } /// see { unpackEthboxLocked } uint256 private constant BITPOS_ETHBOX_LOCKED = 224; /// @dev Bit position of ethbox size in { packedEthboxInfo } /// see { unpackEthboxSize } uint256 private constant BITPOS_ETHBOX_SIZE = 225; // Packed message data bit positions. See { EthboxStructs.Message.data } // See { packMessageData } and { unpackMessageData } for implementation. /// @dev Bit position of timestamp sent in EthboxStructs.Message.data /// See { unpackMessageTimestamp } uint256 private constant BITPOS_MESSAGE_TIMESTAMP = 160; /// @dev Bit position of message index in EthboxStructs.Message.data /// See { unpackMessageIndex } uint256 private constant BITPOS_MESSAGE_INDEX = 224; /// @dev Bit position of message fee BPS in EthboxStructs.Message.data /// See { unpackMessageFeeBPS } uint256 private constant BITPOS_MESSAGE_FEEBPS = 232; /// TODO: Currently not being used. uint256 private constant BITMASK_RECIPIENT = (1 << 160) - 1; function initialize() public initializer { __Ownable_init(); __ReentrancyGuard_init(); _name = "Ethbox"; _symbol = "ETHBOX"; sizeIncreaseFee = 0.05 ether; sizeIncreaseFeeBPS = 2500; messageFeeBPS = 250; messageFeeRecipient = 0x40543d76fb35c60ff578b648d723E14CcAb8b390; } function _authorizeUpgrade(address newImplementation) internal override onlyOwner {} //////////////////////////////////////// // ERC721 functions // //////////////////////////////////////// /// @dev See {ERC721-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); } /// @notice Returns ethbox balance. /// @dev Can only be 1 or 0. As ethboxes are soulbound, if the address /// has minted, we know their balance is 1. /// @param _owner The address to query. /// @return _balance uint256 function balanceOf(address _owner) public view override returns (uint256) { if (minted[_owner]) return 1; return 0; } /// @notice Returns owner of an ethox tokenId. /// @dev TokenId is a uint256 casting of an address, so is unique to that address. /// Here we re-cast the uint256 to an address to get the owner if minted. /// @param _tokenId the tokenId to query. function ownerOf(uint256 _tokenId) public view override returns (address) { address owner = address(uint160(_tokenId)); require(minted[owner], "ERC721: invalid token ID"); return owner; } /// @notice Returns the ethbox tokenId associated with a given address. /// @dev Like { ownerOf } only returns if minted. /// We cast the address to a uint256 to generate a unique tokenId. /// @param _owner the address to query. function ethboxOf(address _owner) public view returns (uint256) { require(minted[_owner], "address has not minted their ethbox"); return uint256(uint160(_owner)); } /// @dev See { ERC721-name }. function name() public view override returns (string memory) { return _name; } /// @dev See { ERC721-symbol }. function symbol() public view override returns (string memory) { return _symbol; } /// @notice Overridden version of { ERC721-tokenURI }. /// @dev First checks if the tokenId has been minted, then gets the owner's /// messages ordered by value and inbox size. Metadata contract uses these /// ordered messages and size to generate the SVG. See { EthboxMetadata }. function tokenURI(uint256 _tokenId) public view override returns (string memory) { require(minted[address(uint160(_tokenId))]); address owner = address(uint160(_tokenId)); EthboxStructs.UnpackedMessage[] memory messages = getOrderedMessages( owner ); uint256 eSize = unpackEthboxSize(owner); uint256 eDrip = unpackEthboxDrip(owner); return metadata.buildMetadata(owner, messages, eSize, eDrip); } /// @dev See { ERC721-getApproved }. function getApproved(uint256 _tokenId) public view override returns (address) { require(minted[address(uint160(_tokenId))]); return address(0); } /// @dev Always returns false as transferring is disabled. function isApprovedForAll(address, address) public pure override returns (bool) { return false; } /// @dev All the following functions are disabled to make ethboxes soulbound. function approve(address, uint256) public pure override { revert("disabled"); } function setApprovalForAll(address, bool) public pure override { revert("disabled"); } function transferFrom( address, address, uint256 ) public pure override { revert("disabled"); } function safeTransferFrom( address, address, uint256 ) public pure override { revert("disabled"); } function safeTransferFrom( address, address, uint256, bytes memory ) public pure override { revert("disabled"); } //////////////////////////////////// // Minting function // //////////////////////////////////// /// @notice Function to mint an ethbox to a given address. /// Only one per address, no max supply. /// @dev We pack the default ethbox info into the { packedEthboxInfo } mapping. /// This saves a lot of gas having to set these values in a struct, or various /// different mappings. function mintMyEthbox() external onlyProxy { address sender = msg.sender; require(!minted[sender], "ethbox already minted"); minted[sender] = true; packedEthboxInfo[sender] = packEthboxInfo( sender, defaultDripTime, defaultEthboxSize, false ); emit Transfer(address(0), sender, uint256(uint160(sender))); if (ethboxMessages[sender].length > 0) { claimAll(); } } ////////////////////////////////////// // Messaging Functions // ////////////////////////////////////// // @notice Set the base cost of increasing ethbox size. /// @param _sizeIncreaseFee The new base increase fee. function setSizeIncreaseFee(uint256 _sizeIncreaseFee) external onlyOwner { sizeIncreaseFee = _sizeIncreaseFee; } /// @notice Set the BPS increase in cost of increasing ethbox size depending /// on how many slots the ethbox has already bought. /// @param _sizeIncreaseFeeBPS The new BPS. function setSizeIncreaseFeeBPS(uint256 _sizeIncreaseFeeBPS) external onlyOwner { sizeIncreaseFeeBPS = _sizeIncreaseFeeBPS; } /// @notice Sets message fee in BPS taken by the messageFeeRecipient. /// @param _messageFeeBPS the new BPS. function setMessageFeeBPS(uint256 _messageFeeBPS) external onlyOwner { messageFeeBPS = _messageFeeBPS; } /// @notice Sets the recipient of the above fees. /// @param _messageFeeRecipient the new recipient. function setMessageFeeRecipient(address _messageFeeRecipient) external onlyOwner { messageFeeRecipient = _messageFeeRecipient; } /// @notice Sets the metadata contract that { tokenURI } points to. /// @dev We want this to be updatable for any future SVG changes or bugfixes. function setMetadataContract(address _metadata) external onlyOwner { metadata = EthboxMetadata(_metadata); } /// @notice Gets the claimable value of a message. /// @dev Using the timestamp the message was sent at, combined with the /// block.timestamp, we calculate how many seconds have elapesed since the /// message was sent. From there we can divide the elapsed seconds by the /// ethbox's duration (given elapsed seconds are smaller) to calculate the BPS. /// Finally we deduct fees from the orignal message value and multiply by BPS /// to get the claimable value of that message. /// @param _message The message struct to calculate value from. /// @param _drip The drip timestamp of the ethbox. function getClaimableValue( EthboxStructs.Message memory _message, uint256 _drip ) public view returns (uint256 _claimableValue) { uint256 elapsedSeconds = block.timestamp - unpackMessageTimestamp(_message.data); if (elapsedSeconds < 1) return 0; if (elapsedSeconds > _drip) return getRemainingOriginalValue(_message); uint256 bps = (elapsedSeconds * 100) / _drip; uint256 subValue = (getOriginalValueMinusFees(_message) * bps) / 100; return (subValue - _message.claimedValue); } /// @notice Deducts fees from the original message value. /// @dev Used in { getClaimableValue } and { getRemainingOriginalValue } /// @param _message The message struct to calculate value from. function getOriginalValueMinusFees(EthboxStructs.Message memory _message) private pure returns (uint256) { return ((_message.originalValue * (10000 - unpackMessageFeeBPS(_message.data))) / 10000); } /// @notice Used to refund message sender any remaining eth in their message /// if their message gets bumped out the inbox. /// @dev Used in { _refundSender } /// @param _message The message struct to calculate value from. function getRemainingOriginalValue(EthboxStructs.Message memory _message) private pure returns (uint256) { return (getOriginalValueMinusFees(_message) - _message.claimedValue); } /// @notice Function to send a message to an ethbox. /// @dev If the message has a high enough value, we bump out the lowest value /// message in the ethbox and replace it. But if the ethbox is not full, we /// just insert it. /// When bumping a message out of an ethbox, if that message has ETH left, /// we refund that ETH to the sender. /// @param _to The ethbox to send the message to. /// @param _message The message content. /// @param _drip The ethbox drip. function sendMessage(address _to, string calldata _message, uint256 _drip) public payable nonReentrant onlyProxy { require(bytes(_message).length < maxMessageLen, "message too long"); EthboxStructs.EthboxInfo memory ethboxInfo = unpackEthboxInfo(_to); uint256 compBoxSize = defaultEthboxSize; uint256 compDrip = defaultDripTime; if (ethboxInfo.size != 0) { compBoxSize = ethboxInfo.size; compDrip = ethboxInfo.drip; } require(!ethboxInfo.locked, "ethbox is locked"); require(msg.value > 10000 || msg.value == 0, "message value incorrect"); require(compDrip == _drip, "message drip incorrect"); EthboxStructs.Message[] memory toMessages = ethboxMessages[_to]; uint256 dynamicBoxSize = toMessages.length; if (dynamicBoxSize < compBoxSize) { _pushMessage( _to, msg.sender, _message, msg.value, dynamicBoxSize ); } else { (bool qualifies, uint256 indexToRemove) = _getIndexToReplace( toMessages, dynamicBoxSize, msg.value ); if (qualifies) { EthboxStructs.Message memory droppedMessage = toMessages[ indexToRemove ]; /// V2 /// instead of always adding the current claimValue to the bumpedClaim mapping, /// we instead only do that step if the ethbox is minted (and thus has a potentially active owner) /// this prevents eth being locked forever (and adding eth to a claimValue mapping) of non- /// active owners /// if the ethbox is not minted, the time spent in ethbox of messages is "virtually" free, unless an /// owner mints (which could still happen at any time.) /// this change also gives more of an incentive for owners to mint/claim when messages are in their box /// if (ethboxInfo.size != 0) { uint256 claimValue = getClaimableValue(droppedMessage, compDrip); droppedMessage.claimedValue += claimValue; bumpedClaimValue[_to] += claimValue; } /// V2 _refundSender(droppedMessage); _insertMessage( _to, msg.sender, _message, msg.value, indexToRemove ); } else { revert("message value too low"); } } _payFees(msg.value); } /// @notice Finds the index to replace with a new message. /// @dev Used in { sendMessage }. /// Also checks if the message even qualifies for replacement - meaning, is /// the value of the message larger than at least one of the existing messages. /// @param _toMessages The existing messages in the ethbox. /// @param _boxSize The size of the ethbox. Used to iterate through. /// @param _value The value of the new message. /// @return qualifies Does the message qualifiy for replacement. /// @return indexToRemove The index to remove and insert the new message into. function _getIndexToReplace( EthboxStructs.Message[] memory _toMessages, uint256 _boxSize, uint256 _value ) private pure returns (bool qualifies, uint256 indexToRemove) { uint256 lowIndex; uint256 lowValue = _toMessages[0].originalValue; uint256 dripedValue; for (uint256 i = 0; i < _boxSize; i++) { dripedValue = _toMessages[i].originalValue; if (dripedValue < lowValue) { lowIndex = i; lowValue = dripedValue; } if (qualifies == false && _value > dripedValue) { qualifies = true; } } return (qualifies, lowIndex); } /// @notice Pushes a message into an ethbox. Used if an ethbox is not full. /// @dev Used in { sendMessage }. /// Packs message data into a "data" field in the Message struct using /// { packMessageData } /// @param _to The ethbox the message is being sent to. /// @param _from The address sending the message. /// @param _message The message content. /// @param _value The value of the message. /// @param _index The index of the message in the ethbox. function _pushMessage( address _to, address _from, string calldata _message, uint256 _value, uint256 _index ) private { EthboxStructs.Message memory message; message.data = packMessageData( _from, block.timestamp, _index, messageFeeBPS ); message.message = _message; message.originalValue = _value; message.claimedValue = 0; ethboxMessages[_to].push(message); } /// @notice Inserts a message into an ethbox. Used if the ethbox is full. /// @dev Used in { sendMessage }. /// Packs message data just like { _pushMessage }. /// Instead of pushing, we insert the message at a given index. // @param _to The ethbox the message is being sent to. /// @param _from The address sending the message. /// @param _message The message content. /// @param _value The value of the message. /// @param _index The index to insert the message at and set in Message.data. function _insertMessage( address _to, address _from, string calldata _message, uint256 _value, uint256 _index ) private { EthboxStructs.Message memory message; message.data = packMessageData( _from, block.timestamp, _index, messageFeeBPS ); message.message = _message; message.originalValue = _value; message.claimedValue = 0; ethboxMessages[_to][_index] = message; } /// @notice Removes a message from an ethbox. /// @dev Used in { removeOne } /// Sets the message to remove to the end of the array and pops it. /// Updates the index of the message that assumes the old index of the message /// we are deleting. We have to unpack and pack here to do this. /// @param _to The ethbox to remove a message from. /// @param _index The index to remove. function _removeMessage(address _to, uint256 _index) private { EthboxStructs.Message[] memory messages = ethboxMessages[_to]; ethboxMessages[_to][_index] = messages[messages.length - 1]; EthboxStructs.MessageData memory messageData = unpackMessageData( ethboxMessages[_to][_index].data ); ethboxMessages[_to][_index].data = packMessageData( messageData.from, messageData.timestamp, _index, messageData.feeBPS ); ethboxMessages[_to].pop(); } /// @notice Removes multiple messages from an ethbox. /// @dev Used in { claimAll } /// Operates the same as { _removeMessage } but in a for loop. /// @param _to The ethbox to remove messages from. /// @param _indexes The indexes to remove. function _removeMessages(address _to, uint256[] memory _indexes) private { EthboxStructs.Message[] memory messages = ethboxMessages[_to]; for (uint256 i = _indexes.length; i > 0; i--) { if (i != messages.length) { EthboxStructs.MessageData memory messageData = unpackMessageData(messages[i].data); ethboxMessages[_to][_indexes[i - 1]] = messages[ messages.length - 1 ]; ethboxMessages[_to][_indexes[i - 1]].data = packMessageData( messageData.from, messageData.timestamp, _indexes[i - 1], messageData.feeBPS ); } ethboxMessages[_to].pop(); } } /// @notice Pays fees to the messageFeeRecipient. /// @dev Used in { sendMessage }. /// We take the value of the message and multiply by fee BPS to get the /// fee owed to the messageFeeRecipient. /// @param _value The value of the message. function _payFees(uint256 _value) private{ (bool successFees, ) = messageFeeRecipient.call{ value: (_value * messageFeeBPS) / 10000 }(""); require(successFees, "could not pay fees"); } /// @notice Pays an ethbox owner some value. /// @dev Used in { claimOne }, { claimAll }, { removeOne } and { removeAll }. /// We need to unpack the fee recipient of the ethbox. /// Sends the value to that recipient. /// @param _value The value of the message. /// @param _to The ethbox owner. function _payRecipient(address _to, uint256 _value) private{ address recipient = unpackEthboxAddress(_to); (bool successRecipient, ) = recipient.call{value: _value}(""); require(successRecipient, "could not pay recipient"); } /// @notice Refunds the sender of a message that has been bumped or removed. /// @dev Used in { removeAll }, { removeOne } and { sendMessage }. /// Need to unpack who sent the message from Message.data. /// @param _message The message used to calculate refundable value and who /// to send value to. function _refundSender(EthboxStructs.Message memory _message) private { uint256 refundValue = getRemainingOriginalValue(_message); address from = unpackMessageFrom(_message.data); (bool successRefund, ) = from.call{value: refundValue}(""); require(successRefund); } /// @notice Orders the messages in an ethbox by value. /// @dev Only used in { tokenURI } for metadata purposes. /// Unpacks the messages into an UnpackedMessage struct. /// See { EthboxStructs.UnpackedMessage }. /// @param _to Ethbox owner to query. /// @return _messages Ordered messages. function getOrderedMessages(address _to) public view returns (EthboxStructs.UnpackedMessage[] memory) { EthboxStructs.Message[] memory messages = ethboxMessages[_to]; for (uint256 i = 1; i < messages.length; i++) { for (uint256 j = 0; j < i; j++) { if (messages[i].originalValue > messages[j].originalValue) { EthboxStructs.Message memory x = messages[i]; messages[i] = messages[j]; messages[j] = x; } } } EthboxStructs.UnpackedMessage[] memory unpackedMessages = new EthboxStructs.UnpackedMessage[]( messages.length ); EthboxStructs.MessageData memory unpackedData; for (uint256 k = 0; k < messages.length; k++) { EthboxStructs.UnpackedMessage memory newMessage; unpackedData = unpackMessageData(messages[k].data); newMessage.message = messages[k].message; newMessage.originalValue = messages[k].originalValue; newMessage.claimedValue = messages[k].claimedValue; newMessage.from = unpackedData.from; newMessage.timestamp = unpackedData.timestamp; newMessage.index = unpackedData.index; newMessage.feeBPS = unpackedData.feeBPS; unpackedMessages[k] = newMessage; } return unpackedMessages; } /// @dev Mimics { getOrderedMessages } without unpacking. function getOrderedPackedMessages(address _to) public view returns (EthboxStructs.Message[] memory) { EthboxStructs.Message[] memory messages = ethboxMessages[_to]; for (uint256 i = 1; i < messages.length; i++) { for (uint256 j = 0; j < i; j++) { if (messages[i].originalValue > messages[j].originalValue) { EthboxStructs.Message memory x = messages[i]; messages[i] = messages[j]; messages[j] = x; } } } return messages; } /// @notice Sets the locked state of an ethbox. If an ethbox is locked it /// cannot recieve messages. /// @dev We unpack and repack the sender's ethbox info with the new value. /// @param _isLocked The locked value to set their ethbox to. function changeEthboxLocked(bool _isLocked) external { EthboxStructs.EthboxInfo memory ethboxInfo = unpackEthboxInfo( msg.sender ); require(ethboxInfo.size != 0, "ethbox needs to be minted"); packedEthboxInfo[msg.sender] = packEthboxInfo( ethboxInfo.recipient, ethboxInfo.drip, ethboxInfo.size, _isLocked ); } /// @notice Sets the payout recipient of the ethbox. Allows people to have /// their ethbox in cold storage, but get paid into a hot wallet. /// @dev We unpack and repack the sender's ethbox info with the new value. /// @param _recipient The new recipient of ethbox funds. function changeEthboxPayoutRecipient(address _recipient) external { EthboxStructs.EthboxInfo memory ethboxInfo = unpackEthboxInfo( msg.sender ); require(ethboxInfo.size != 0, "ethbox needs to be minted"); packedEthboxInfo[msg.sender] = packEthboxInfo( _recipient, ethboxInfo.drip, ethboxInfo.size, ethboxInfo.locked ); } /// @notice Sets the drip time in an ethbox. This can only be done when the /// ethbox is locked and empty. /// @dev We unpack and repack the sender's ethbox info with the new value. /// @param _dripTime The new drip time of the ethbox's messages. function changeEthboxDripTime(uint256 _dripTime) external { EthboxStructs.EthboxInfo memory ethboxInfo = unpackEthboxInfo( msg.sender ); require(ethboxInfo.size != 0, "ethbox needs to be minted"); require( ethboxMessages[msg.sender].length == 0, "ethbox needs to be empty" ); packedEthboxInfo[msg.sender] = packEthboxInfo( ethboxInfo.recipient, _dripTime, ethboxInfo.size, ethboxInfo.locked ); } /// @notice Expands the ethbox size of the sender. /// @dev Sender must have minted. /// See { calculateSizeIncreaseCost } for how size increase is calculated. /// @param _size New ethbox size. function changeEthboxSize(uint256 _size) external payable { EthboxStructs.EthboxInfo memory ethboxInfo = unpackEthboxInfo( msg.sender ); require(ethboxInfo.size != 0, "ethbox needs to be minted"); uint256 total = calculateSizeIncreaseCost(_size, ethboxInfo.size); require(total == msg.value, total.toString()); packedEthboxInfo[msg.sender] = packEthboxInfo( ethboxInfo.recipient, ethboxInfo.drip, _size, ethboxInfo.locked ); (bool successFees, ) = messageFeeRecipient.call{value: msg.value}(""); require(successFees); } /// @notice Calculates the cost of increasing ethbox size to a given value. /// @dev Used in { expandEthboxSize }. /// Uses { sizeIncreaseFee } and { sizeIncreaseFeeBPS } in calculation. /// @param _size The desired ethbox size. /// @param _currentSize The current size of the ethbox. /// @return total Cost of increasing inbox to desired size. function calculateSizeIncreaseCost(uint256 _size, uint256 _currentSize) public view returns (uint256 total) { require(_size > _currentSize, "new size should be larger"); total = 0; for (uint256 i = _currentSize; i < _size; i++) { if (i == defaultEthboxSize) { total += sizeIncreaseFee; } else { total += (sizeIncreaseFee * ((sizeIncreaseFeeBPS + 10000) ** (i - defaultEthboxSize))) / (10000**(i - defaultEthboxSize)); } } return total; } /// @notice Removes all messages from an ethbox. /// @dev An ethbox owner may call this so they can change the drip of their /// box. This calculates how much each message sender is owed and refunds them. /// The ethbox owner claims the remaining ETH. function removeAll() external nonReentrant { require(minted[msg.sender], "ethbox needs to be minted"); uint256 claimValue = 0; uint256 totalValue = 0; EthboxStructs.Message[] memory messages = ethboxMessages[msg.sender]; uint256 boxSize = messages.length; for (uint256 i = 0; i < boxSize; i++) { claimValue = getClaimableValue( messages[i], unpackEthboxDrip(msg.sender) ); totalValue += claimValue; ethboxMessages[msg.sender][i].claimedValue += claimValue; _refundSender(ethboxMessages[msg.sender][i]); } delete ethboxMessages[msg.sender]; _payRecipient(msg.sender, totalValue); } /// @notice Removes one of the messages in the ethbox. /// @dev An ethbox owner may not like a message they have recieved, they can /// use this to delete it. Like { removeAll } this calculates how much they /// can claim, and how much must be refunded. /// We are using the combination of these 3 parameters to guarantee that the ethbox /// owner will remove only the message they really intend to, without running the /// risk of being front-run by a sendMessage transaction. /// @param _index The index of the message to delete. /// @param _messageValue the original value of the message to delete /// @param _from the sender of the message to delete function removeOne(uint256 _index, uint256 _messageValue, address _from) external nonReentrant { require(minted[msg.sender], "ethbox needs to be minted"); EthboxStructs.Message memory message = ethboxMessages[msg.sender][_index]; require(_messageValue == message.originalValue, "message at index does not match value"); EthboxStructs.MessageData memory messageData = unpackMessageData(message.data); require(_from == messageData.from, "message at index does not match sender address"); uint256 claimValue = getClaimableValue( message, unpackEthboxDrip(msg.sender) ); message.claimedValue += claimValue; ethboxMessages[msg.sender][_index] = message; _removeMessage(msg.sender, _index); _refundSender(message); _payRecipient(msg.sender, claimValue); } /// @notice Function to claim all of the ETH owed to the sender's ethbox. /// @dev Calculates how much they are owed for each message and the claims /// the ETH. We update the claimed value of the message in the Message struct /// so that the owner cannot double claim. function claimAll() public nonReentrant { require(minted[msg.sender], "ethbox needs to be minted"); uint256 claimValue = 0; uint256 totalValue = 0; EthboxStructs.Message[] memory messages = ethboxMessages[msg.sender]; uint256 boxSize = messages.length; uint256[] memory removalIndexes = new uint256[](boxSize); uint256 removalCount = 0; uint256 dripTime = unpackEthboxDrip(msg.sender); for (uint256 i = 0; i < boxSize; i++) { EthboxStructs.Message memory message = messages[i]; claimValue = getClaimableValue(message, dripTime); totalValue += claimValue; ethboxMessages[msg.sender][i].claimedValue += claimValue; if ( (unpackMessageTimestamp(message.data) + dripTime) < block.timestamp ) { removalIndexes[removalCount] = i; removalCount++; } } uint256[] memory trimmedIndexes = new uint256[](removalCount); for (uint256 j = 0; j < trimmedIndexes.length; j++) { trimmedIndexes[j] = removalIndexes[j]; } totalValue += bumpedClaimValue[msg.sender]; bumpedClaimValue[msg.sender] = 0; _removeMessages(msg.sender, trimmedIndexes); _payRecipient(msg.sender, totalValue); } /// @notice Allows sender to claim ETH from one of their messages. /// @dev Uses { getClaimable value } on the message struct with the ethbox's /// drip to calculate. /// /// We are using the combination of these 3 parameters to guarantee that the ethbox /// owner will clalim only the message they really intend to, without running the /// risk of being front-run by a sendMessage transaction. /// @param _index Index to claim ETH on. /// @param _messageValue the original value of the message to delete /// @param _from the sender of the message to delete function claimOne(uint256 _index, uint256 _messageValue, address _from) external nonReentrant { EthboxStructs.EthboxInfo memory ethboxInfo = unpackEthboxInfo(msg.sender); require(ethboxInfo.size != 0, "ethbox needs to be minted"); EthboxStructs.Message memory message = ethboxMessages[msg.sender][_index]; require(_messageValue == message.originalValue, "message at index does not match value"); EthboxStructs.MessageData memory messageData = unpackMessageData(message.data); require(_from == messageData.from, "message at index does not match sender address"); uint256 claimValue = getClaimableValue( message, unpackEthboxDrip(msg.sender) ); if (messageData.timestamp + ethboxInfo.drip < block.timestamp){ _removeMessage(msg.sender, messageData.index); }else { ethboxMessages[msg.sender][_index].claimedValue += claimValue; } _payRecipient(msg.sender, claimValue); } /// @notice A view function for external use in app or elsewhere. /// @dev Mimics how { claimAll } works, without making any payments. /// @param _ethboxAddress The ethbox address to query. /// @return value The claimable value of the ethbox. function getClaimableValueOfEthbox(address _ethboxAddress) public view returns (uint256) { EthboxStructs.Message[] memory messages = ethboxMessages[ _ethboxAddress ]; EthboxStructs.EthboxInfo memory ethboxInfo = unpackEthboxInfo(_ethboxAddress); uint256 boxSize = messages.length; uint256 claimValue = 0; uint256 totalValue = 0; uint256 realDrip = ethboxInfo.size == 0 ? defaultDripTime : ethboxInfo.drip; for (uint256 i = 0; i < boxSize; i++) { claimValue = getClaimableValue( messages[i], realDrip ); totalValue += claimValue; } totalValue += bumpedClaimValue[_ethboxAddress]; return totalValue; } ////////////////////////////////////// ////////////////////////////////////// // Packing & Unpacking Functions // ////////////////////////////////////// ////////////////////////////////////// /// @dev Unpacks the recipient in the packedEthboxInfo uint256. /// Used in { _payRecipient } /// @param _address The ethbox to query. /// @return recipient The payout recipient of the ethbox. function unpackEthboxAddress(address _address) private view returns (address) { return address(uint160(packedEthboxInfo[_address])); } /// @dev Unpacks the drip in the packedEthboxInfo uint256. /// Used in { claimOne }, { getClaimableValueOfEthbox }, { claimAll }, /// { removeOne } and { removeAll } /// @param _address The ethbox to query. /// @return timestamp The drip timestamp of the ethbox. function unpackEthboxDrip(address _address) private view returns (uint64) { return uint64(packedEthboxInfo[_address] >> BITPOS_ETHBOX_DRIP_TIMESTAMP); } /// @dev Unpacks the size in the packedEthboxInfo uint256. /// Used in { tokenURI } /// @param _address The ethbox to query. /// @return size The size of the ethbox. function unpackEthboxSize(address _address) private view returns (uint8) { return uint8(packedEthboxInfo[_address] >> BITPOS_ETHBOX_SIZE); } /// @dev Unpacks the locked state in the packedEthboxInfo uint256. /// Not being used currently. /// @param _address The ethbox to query. /// @return isLocked Boolean reflecting whether the ethbox is locked or not. function unpackEthboxLocked(address _address) private view returns (bool) { uint256 flag = (packedEthboxInfo[_address] >> BITPOS_ETHBOX_LOCKED) & uint256(1); return flag != 0; } /// @dev Unpacks the entire packedEthboxInfo uint256 into an EthboxInfo struct. /// See { EthboxStructs.EthboxInfo }. /// Used in { expandEthboxSize }, { changeEthboxDurationTime }, /// { changeEthboxPayoutRecipient }, { setEthboxIsLocked } and { sendMessage }. /// @param _address Address to unpack the ethbox of. /// @return ethbox The ethbox's info. function unpackEthboxInfo(address _address) public view returns (EthboxStructs.EthboxInfo memory ethbox) { uint256 packedEthbox = packedEthboxInfo[_address]; ethbox.recipient = address(uint160(packedEthbox)); ethbox.drip = uint64(packedEthbox >> BITPOS_ETHBOX_DRIP_TIMESTAMP); ethbox.size = uint8(packedEthbox >> BITPOS_ETHBOX_SIZE); ethbox.locked = ((packedEthbox >> BITPOS_ETHBOX_LOCKED) & uint256(1)) != 0; } /// @dev Packs an ethbox's info. /// Does this by casting each input to a specific part of a uint256. /// Used in all the same functions as { unpackEthboxInfo } and used by /// { mintMyEthbox }. /// @param _recipient Payout recipient of the ethbox. /// @param _drip Drip timestamp of the ethbox. /// @param _size Size of the ethbox. /// @param _locked Locked state of the ethbox. /// @return packed The packed ethbox info. function packEthboxInfo( address _recipient, uint256 _drip, uint256 _size, bool _locked ) private pure returns (uint256) { uint256 packedEthbox = uint256(uint160(_recipient)); packedEthbox |= (_drip << BITPOS_ETHBOX_DRIP_TIMESTAMP) | (boolToUint(_locked) << BITPOS_ETHBOX_LOCKED) | (_size << BITPOS_ETHBOX_SIZE); return packedEthbox; } /// @dev Casts a boolean value to a uint256. True -> 1, False -> 0. /// Helper used in { packEthboxInfo } function boolToUint(bool _b) private pure returns (uint256) { uint256 _bInt; assembly { // SAFETY: Simple bool-to-int cast. _bInt := _b } return _bInt; } /// @dev Packs part of the Message struct into a "data" field. /// Used in { _removeMessage/s }, { _insertMessage } and { _pushMessage }. /// Using the same method as { packEthboxInfo }, we cast each input to a /// specific part of the uint256 we return. /// @param _from The from address of the message. /// @param _timestamp The timestamp the message was sent at. /// @param _index The index of the message in the ethbox. /// @param _feeBPS The global feeBPS at the time of the message being sent. /// @return packed The packed message data. function packMessageData( address _from, uint256 _timestamp, uint256 _index, uint256 _feeBPS ) private pure returns (uint256) { uint256 packedEthbox = uint256(uint160(_from)); packedEthbox |= (_timestamp << BITPOS_MESSAGE_TIMESTAMP) | (_index << BITPOS_MESSAGE_INDEX) | (_feeBPS << BITPOS_MESSAGE_FEEBPS); return packedEthbox; } /// @dev Unpacks the message data into a MessageData stuct. /// See { EthboxStructs.MessageData }. /// Used in { _removeMessage/s }. /// Using the same method as { unpackEthboxInfo } we shift bits back to /// where they once were, and apply appropriate data types. /// @param _data Message data to unpack. /// @return messageData Unpacked message data. function unpackMessageData(uint256 _data) private pure returns (EthboxStructs.MessageData memory messageData) { messageData.from = address(uint160(_data)); messageData.timestamp = uint64(_data >> BITPOS_MESSAGE_TIMESTAMP); messageData.index = uint8(_data >> BITPOS_MESSAGE_INDEX); messageData.feeBPS = uint24(_data >> BITPOS_MESSAGE_FEEBPS); } /// @dev Unpacks the sent timestamp in packed message data. /// Used in { claimAll } and { getClaimableValue }. /// @param _data Data to unpack. /// @return timestamp Timestamp the message was sent at. function unpackMessageTimestamp(uint256 _data) private pure returns (uint64) { return uint64(_data >> BITPOS_MESSAGE_TIMESTAMP); } /// @dev Unpacks the feeBPS in packed message data. /// Used in { getOriginalValueMinusFees } /// @param _data Data to unpack. /// @return feeBPS FeeBPS when the message was sent. function unpackMessageFeeBPS(uint256 _data) private pure returns (uint24) { return uint24(_data >> BITPOS_MESSAGE_FEEBPS); } /// @dev Unpacks the index in packed message data. /// Currently not being used. /// @param _data Data to unpack. /// @return index Index of the message in the ethbox. function unpackMessageIndex(uint256 _data) private pure returns (uint8) { return uint8(_data >> BITPOS_MESSAGE_INDEX); } /// @dev Unpacks the message sender in packed message data. /// Used in { _refundSender } /// @param _data Data to unpack. /// @return sender Sender of the message. function unpackMessageFrom(uint256 _data) private pure returns (address) { return address(uint160(_data)); } //--External Unpacking Functions for Use In App and Elsewhere--// /// @dev These do the same as the above functions, but are just external. /// Please refer back to the documentation for { unpackEthboxInfo }. function ethboxDripTime(address _owner) external view returns (uint256) { if (minted[_owner]) return unpackEthboxInfo(_owner).drip; return defaultDripTime; } function ethboxPayoutRecipient(address _owner) external view returns (address) { if (minted[_owner]) return unpackEthboxInfo(_owner).recipient; return _owner; } function ethboxSize(address _owner) external view returns (uint256) { if (minted[_owner]) return unpackEthboxInfo(_owner).size; return defaultEthboxSize; } function ethboxLocked(address _owner) external view returns (bool) { if (minted[_owner]) return unpackEthboxInfo(_owner).locked; return false; } /// @dev Refunds the value of a message if the owner didn't mint /// V2 /// @param _index The index of the message to delete and refund /// @param _messageValue the original value of the message to delete and refund /// @param _to the address of the targeted ethbox function getRefundForMessage(uint256 _index, uint256 _messageValue, address _to) external nonReentrant { require(!minted[_to], "ethbox needs to be not minted"); EthboxStructs.Message memory message = ethboxMessages[_to][_index]; require(_messageValue == message.originalValue, "message at index does not match value"); EthboxStructs.MessageData memory messageData = unpackMessageData(message.data); require(msg.sender == messageData.from, "message at index does not match your address"); uint256 elapsedSeconds = block.timestamp - messageData.timestamp; require(elapsedSeconds > defaultDripTime, "message needs to be expired"); _removeMessage(_to, _index); _refundSender(message); } }
// SPDX-License-Identifier: Unlicensed pragma solidity 0.8.16; library EthboxStructs { struct Message { string message; uint256 originalValue; uint256 claimedValue; uint256 data; } struct MessageData { address from; uint64 timestamp; uint8 index; uint24 feeBPS; } struct UnpackedMessage { string message; uint256 originalValue; uint256 claimedValue; address from; uint64 timestamp; uint8 index; uint24 feeBPS; } struct MessageInfo { address to; string visibility; UnpackedMessage message; uint256 index; uint256 maxSize; } struct EthboxInfo { address recipient; uint8 size; bool locked; uint64 drip; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library Base64 { string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000" hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000" hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000" hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE_ENCODE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { // read 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // write 4 characters mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr( 6, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and( input, 0x3F)))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } function decode(string memory _data) internal pure returns (bytes memory) { bytes memory data = bytes(_data); if (data.length == 0) return new bytes(0); require(data.length % 4 == 0, "invalid base64 decoder input"); // load the table into memory bytes memory table = TABLE_DECODE; // every 4 characters represent 3 bytes uint256 decodedLen = (data.length / 4) * 3; // add some extra buffer at the end required for the writing bytes memory result = new bytes(decodedLen + 32); assembly { // padding with '=' let lastBytes := mload(add(data, mload(data))) if eq(and(lastBytes, 0xFF), 0x3d) { decodedLen := sub(decodedLen, 1) if eq(and(lastBytes, 0xFFFF), 0x3d3d) { decodedLen := sub(decodedLen, 1) } } // set the actual output length mstore(result, decodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 4 characters at a time for {} lt(dataPtr, endPtr) {} { // read 4 characters dataPtr := add(dataPtr, 4) let input := mload(dataPtr) // write 3 bytes let output := add( add( shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)), shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))), add( shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)), and(mload(add(tablePtr, and( input , 0xFF))), 0xFF) ) ) mstore(resultPtr, shl(232, output)) resultPtr := add(resultPtr, 3) } } return result; } }
/* * @title String & slice utility library for Solidity contracts. * @author Nick Johnson <[email protected]> * * @dev Functionality in this library is largely implemented using an * abstraction called a 'slice'. A slice represents a part of a string - * anything from the entire string to a single character, or even no * characters at all (a 0-length slice). Since a slice only has to specify * an offset and a length, copying and manipulating slices is a lot less * expensive than copying and manipulating the strings they reference. * * To further reduce gas costs, most functions on slice that need to return * a slice modify the original one instead of allocating a new one; for * instance, `s.split(".")` will return the text up to the first '.', * modifying s to only contain the remainder of the string after the '.'. * In situations where you do not want to modify the original slice, you * can make a copy first with `.copy()`, for example: * `s.copy().split(".")`. Try and avoid using this idiom in loops; since * Solidity has no memory management, it will result in allocating many * short-lived slices that are later discarded. * * Functions that return two slices come in two versions: a non-allocating * version that takes the second slice as an argument, modifying it in * place, and an allocating version that allocates and returns the second * slice; see `nextRune` for example. * * Functions that have to copy string data will return strings rather than * slices; these can be cast back to slices for further processing if * required. * * For convenience, some functions are provided with non-modifying * variants that create a new slice and return both; for instance, * `s.splitNew('.')` leaves s unmodified, and returns two values * corresponding to the left and right parts of the string. */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library strings { struct slice { uint256 _len; uint256 _ptr; } function memcpy( uint256 dest, uint256 src, uint256 length ) private pure { // Copy word-length chunks while possible for (; length >= 32; length -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint256 mask = type(uint256).max; if (length > 0) { mask = 256**(32 - length) - 1; } assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /* * @dev Returns a slice containing the entire string. * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ function toSlice(string memory self) internal pure returns (slice memory) { uint256 ptr; assembly { ptr := add(self, 0x20) } return slice(bytes(self).length, ptr); } /* * @dev Returns the length of a null-terminated bytes32 string. * @param self The value to find the length of. * @return The length of the string, from 0 to 32. */ function len(bytes32 self) internal pure returns (uint256) { uint256 ret; if (self == 0) return 0; if (uint256(self) & type(uint128).max == 0) { ret += 16; self = bytes32(uint256(self) / 0x100000000000000000000000000000000); } if (uint256(self) & type(uint64).max == 0) { ret += 8; self = bytes32(uint256(self) / 0x10000000000000000); } if (uint256(self) & type(uint32).max == 0) { ret += 4; self = bytes32(uint256(self) / 0x100000000); } if (uint256(self) & type(uint16).max == 0) { ret += 2; self = bytes32(uint256(self) / 0x10000); } if (uint256(self) & type(uint8).max == 0) { ret += 1; } return 32 - ret; } /* * @dev Returns a slice containing the entire bytes32, interpreted as a * null-terminated utf-8 string. * @param self The bytes32 value to convert to a slice. * @return A new slice containing the value of the input argument up to the * first null. */ function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x20), ptr) } ret._len = len(self); } /* * @dev Returns a new slice containing the same data as the current slice. * @param self The slice to copy. * @return A new slice containing the same data as `self`. */ function copy(slice memory self) internal pure returns (slice memory) { return slice(self._len, self._ptr); } /* * @dev Copies a slice to a new string. * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ function toString(slice memory self) internal pure returns (string memory) { string memory ret = new string(self._len); uint256 retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; } /* * @dev Returns the length in runes of the slice. Note that this operation * takes time proportional to the length of the slice; avoid using it * in loops, and call `slice.empty()` if you only need to know whether * the slice is empty or not. * @param self The slice to operate on. * @return The length of the slice in runes. */ function len(slice memory self) internal pure returns (uint256 l) { // Starting at ptr-31 means the LSB will be the byte we care about uint256 ptr = self._ptr - 31; uint256 end = ptr + self._len; for (l = 0; ptr < end; l++) { uint8 b; assembly { b := and(mload(ptr), 0xFF) } if (b < 0x80) { ptr += 1; } else if (b < 0xE0) { ptr += 2; } else if (b < 0xF0) { ptr += 3; } else if (b < 0xF8) { ptr += 4; } else if (b < 0xFC) { ptr += 5; } else { ptr += 6; } } } /* * @dev Returns true if the slice is empty (has a length of 0). * @param self The slice to operate on. * @return True if the slice is empty, False otherwise. */ function empty(slice memory self) internal pure returns (bool) { return self._len == 0; } /* * @dev Returns a positive number if `other` comes lexicographically after * `self`, a negative number if it comes before, or zero if the * contents of the two slices are equal. Comparison is done per-rune, * on unicode codepoints. * @param self The first slice to compare. * @param other The second slice to compare. * @return The result of the comparison. */ function compare(slice memory self, slice memory other) internal pure returns (int256) { uint256 shortest = self._len; if (other._len < self._len) shortest = other._len; uint256 selfptr = self._ptr; uint256 otherptr = other._ptr; for (uint256 idx = 0; idx < shortest; idx += 32) { uint256 a; uint256 b; assembly { a := mload(selfptr) b := mload(otherptr) } if (a != b) { // Mask out irrelevant bytes and check again uint256 mask = type(uint256).max; // 0xffff... if (shortest < 32) { mask = ~(2**(8 * (32 - shortest + idx)) - 1); } unchecked { uint256 diff = (a & mask) - (b & mask); if (diff != 0) return int256(diff); } } selfptr += 32; otherptr += 32; } return int256(self._len) - int256(other._len); } /* * @dev Returns true if the two slices contain the same text. * @param self The first slice to compare. * @param self The second slice to compare. * @return True if the slices are equal, false otherwise. */ function equals(slice memory self, slice memory other) internal pure returns (bool) { return compare(self, other) == 0; } /* * @dev Extracts the first rune in the slice into `rune`, advancing the * slice to point to the next rune and returning `self`. * @param self The slice to operate on. * @param rune The slice that will contain the first rune. * @return `rune`. */ function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) { rune._ptr = self._ptr; if (self._len == 0) { rune._len = 0; return rune; } uint256 l; uint256 b; // Load the first byte of the rune into the LSBs of b assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } if (b < 0x80) { l = 1; } else if (b < 0xE0) { l = 2; } else if (b < 0xF0) { l = 3; } else { l = 4; } // Check for truncated codepoints if (l > self._len) { rune._len = self._len; self._ptr += self._len; self._len = 0; return rune; } self._ptr += l; self._len -= l; rune._len = l; return rune; } /* * @dev Returns the first rune in the slice, advancing the slice to point * to the next rune. * @param self The slice to operate on. * @return A slice containing only the first rune from `self`. */ function nextRune(slice memory self) internal pure returns (slice memory ret) { nextRune(self, ret); } /* * @dev Returns the number of the first codepoint in the slice. * @param self The slice to operate on. * @return The number of the first codepoint in the slice. */ function ord(slice memory self) internal pure returns (uint256 ret) { if (self._len == 0) { return 0; } uint256 word; uint256 length; uint256 divisor = 2**248; // Load the rune into the MSBs of b assembly { word := mload(mload(add(self, 32))) } uint256 b = word / divisor; if (b < 0x80) { ret = b; length = 1; } else if (b < 0xE0) { ret = b & 0x1F; length = 2; } else if (b < 0xF0) { ret = b & 0x0F; length = 3; } else { ret = b & 0x07; length = 4; } // Check for truncated codepoints if (length > self._len) { return 0; } for (uint256 i = 1; i < length; i++) { divisor = divisor / 256; b = (word / divisor) & 0xFF; if (b & 0xC0 != 0x80) { // Invalid UTF-8 sequence return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; } /* * @dev Returns the keccak-256 hash of the slice. * @param self The slice to hash. * @return The hash of the slice. */ function keccak(slice memory self) internal pure returns (bytes32 ret) { assembly { ret := keccak256(mload(add(self, 32)), mload(self)) } } /* * @dev Returns true if `self` starts with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function startsWith(slice memory self, slice memory needle) internal pure returns (bool) { if (self._len < needle._len) { return false; } if (self._ptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq( keccak256(selfptr, length), keccak256(needleptr, length) ) } return equal; } /* * @dev If `self` starts with `needle`, `needle` is removed from the * beginning of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) { if (self._len < needle._len) { return self; } bool equal = true; if (self._ptr != needle._ptr) { assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq( keccak256(selfptr, length), keccak256(needleptr, length) ) } } if (equal) { self._len -= needle._len; self._ptr += needle._len; } return self; } /* * @dev Returns true if the slice ends with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function endsWith(slice memory self, slice memory needle) internal pure returns (bool) { if (self._len < needle._len) { return false; } uint256 selfptr = self._ptr + self._len - needle._len; if (selfptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq( keccak256(selfptr, length), keccak256(needleptr, length) ) } return equal; } /* * @dev If `self` ends with `needle`, `needle` is removed from the * end of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function until(slice memory self, slice memory needle) internal pure returns (slice memory) { if (self._len < needle._len) { return self; } uint256 selfptr = self._ptr + self._len - needle._len; bool equal = true; if (selfptr != needle._ptr) { assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq( keccak256(selfptr, length), keccak256(needleptr, length) ) } } if (equal) { self._len -= needle._len; } return self; } // Returns the memory address of the first byte of the first occurrence of // `needle` in `self`, or the first byte after `self` if not found. function findPtr( uint256 selflen, uint256 selfptr, uint256 needlelen, uint256 needleptr ) private pure returns (uint256) { uint256 ptr = selfptr; uint256 idx; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask; if (needlelen > 0) { mask = bytes32(~(2**(8 * (32 - needlelen)) - 1)); } bytes32 needledata; assembly { needledata := and(mload(needleptr), mask) } uint256 end = selfptr + selflen - needlelen; bytes32 ptrdata; assembly { ptrdata := and(mload(ptr), mask) } while (ptrdata != needledata) { if (ptr >= end) return selfptr + selflen; ptr++; assembly { ptrdata := and(mload(ptr), mask) } } return ptr; } else { // For long needles, use hashing bytes32 hash; assembly { hash := keccak256(needleptr, needlelen) } for (idx = 0; idx <= selflen - needlelen; idx++) { bytes32 testHash; assembly { testHash := keccak256(ptr, needlelen) } if (hash == testHash) return ptr; ptr += 1; } } } return selfptr + selflen; } // Returns the memory address of the first byte after the last occurrence of // `needle` in `self`, or the address of `self` if not found. function rfindPtr( uint256 selflen, uint256 selfptr, uint256 needlelen, uint256 needleptr ) private pure returns (uint256) { uint256 ptr; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask; if (needlelen > 0) { mask = bytes32(~(2**(8 * (32 - needlelen)) - 1)); } bytes32 needledata; assembly { needledata := and(mload(needleptr), mask) } ptr = selfptr + selflen - needlelen; bytes32 ptrdata; assembly { ptrdata := and(mload(ptr), mask) } while (ptrdata != needledata) { if (ptr <= selfptr) return selfptr; ptr--; assembly { ptrdata := and(mload(ptr), mask) } } return ptr + needlelen; } else { // For long needles, use hashing bytes32 hash; assembly { hash := keccak256(needleptr, needlelen) } ptr = selfptr + (selflen - needlelen); while (ptr >= selfptr) { bytes32 testHash; assembly { testHash := keccak256(ptr, needlelen) } if (hash == testHash) return ptr + needlelen; ptr -= 1; } } } return selfptr; } /* * @dev Modifies `self` to contain everything from the first occurrence of * `needle` to the end of the slice. `self` is set to the empty slice * if `needle` is not found. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function find(slice memory self, slice memory needle) internal pure returns (slice memory) { uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; return self; } /* * @dev Modifies `self` to contain the part of the string from the start of * `self` to the end of the first occurrence of `needle`. If `needle` * is not found, `self` is set to the empty slice. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) { uint256 ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); self._len = ptr - self._ptr; return self; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and `token` to everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function split( slice memory self, slice memory needle, slice memory token ) internal pure returns (slice memory) { uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; if (ptr == self._ptr + self._len) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; self._ptr = ptr + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and returning everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { split(self, needle, token); } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and `token` to everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function rsplit( slice memory self, slice memory needle, slice memory token ) internal pure returns (slice memory) { uint256 ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = ptr; token._len = self._len - (ptr - self._ptr); if (ptr == self._ptr) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and returning everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` after the last occurrence of `delim`. */ function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) { rsplit(self, needle, token); } /* * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return The number of occurrences of `needle` found in `self`. */ function count(slice memory self, slice memory needle) internal pure returns (uint256 cnt) { uint256 ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; ptr = findPtr( self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr ) + needle._len; } } /* * @dev Returns True if `self` contains `needle`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return True if `needle` is found in `self`, false otherwise. */ function contains(slice memory self, slice memory needle) internal pure returns (bool) { return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; } /* * @dev Returns a newly allocated string containing the concatenation of * `self` and `other`. * @param self The first slice to concatenate. * @param other The second slice to concatenate. * @return The concatenation of the two strings. */ function concat(slice memory self, slice memory other) internal pure returns (string memory) { string memory ret = new string(self._len + other._len); uint256 retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; } /* * @dev Joins an array of slices, using `self` as a delimiter, returning a * newly allocated string. * @param self The delimiter to use. * @param parts A list of slices to join. * @return A newly allocated string containing all the slices in `parts`, * joined with `self`. */ function join(slice memory self, slice[] memory parts) internal pure returns (string memory) { if (parts.length == 0) return ""; uint256 length = self._len * (parts.length - 1); for (uint256 i = 0; i < parts.length; i++) length += parts[i]._len; string memory ret = new string(length); uint256 retptr; assembly { retptr := add(ret, 32) } for (uint256 i = 0; i < parts.length; i++) { memcpy(retptr, parts[i]._ptr, parts[i]._len); retptr += parts[i]._len; if (i < parts.length - 1) { memcpy(retptr, self._ptr, self._len); retptr += self._len; } } return ret; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.0; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../ERC1967/ERC1967UpgradeUpgradeable.sol"; import "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. * * _Available since v4.1._ */ abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable { function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment address private immutable __self = address(this); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { require(address(this) != __self, "Function must be called through delegatecall"); require(_getImplementation() == __self, "Function must be called through active proxy"); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall"); _; } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate that the this implementation remains valid after an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual override notDelegated returns (bytes32) { return _IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeTo(address newImplementation) external virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, new bytes(0), false); } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data, true); } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeTo} and {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal override onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original * initialization step. This is essential to configure modules that are added through upgrades and that require * initialization. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../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 v4.6.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 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 ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol) pragma solidity ^0.8.2; import "../beacon/IBeaconUpgradeable.sol"; import "../../interfaces/draft-IERC1822Upgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/StorageSlotUpgradeable.sol"; import "../utils/Initializable.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. * * _Available since v4.1._ * * @custom:oz-upgrades-unsafe-allow delegatecall */ abstract contract ERC1967UpgradeUpgradeable is Initializable { function __ERC1967Upgrade_init() internal onlyInitializing { } function __ERC1967Upgrade_init_unchained() internal onlyInitializing { } // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1 bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143; /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Returns the current implementation address. */ function _getImplementation() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract"); StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Perform implementation upgrade * * Emits an {Upgraded} event. */ function _upgradeTo(address newImplementation) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); } /** * @dev Perform implementation upgrade with additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCall( address newImplementation, bytes memory data, bool forceCall ) internal { _upgradeTo(newImplementation); if (data.length > 0 || forceCall) { _functionDelegateCall(newImplementation, data); } } /** * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call. * * Emits an {Upgraded} event. */ function _upgradeToAndCallUUPS( address newImplementation, bytes memory data, bool forceCall ) internal { // Upgrades from old implementations will perform a rollback test. This test requires the new // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing // this special case will break upgrade paths from old UUPS implementation to new ones. if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) { _setImplementation(newImplementation); } else { try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) { require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID"); } catch { revert("ERC1967Upgrade: new implementation is not UUPS"); } _upgradeToAndCall(newImplementation, data, forceCall); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is * validated in the constructor. */ bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Returns the current admin. */ function _getAdmin() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { require(newAdmin != address(0), "ERC1967: new admin is the zero address"); StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {AdminChanged} event. */ function _changeAdmin(address newAdmin) internal { emit AdminChanged(_getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor. */ bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Emitted when the beacon is upgraded. */ event BeaconUpgraded(address indexed beacon); /** * @dev Returns the current beacon. */ function _getBeacon() internal view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract"); require( AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()), "ERC1967: beacon implementation is not a contract" ); StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon; } /** * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that). * * Emits a {BeaconUpgraded} event. */ function _upgradeBeaconToAndCall( address newBeacon, bytes memory data, bool forceCall ) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0 || forceCall) { _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data); } } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) { require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed"); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.0; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822ProxiableUpgradeable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.0; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeaconUpgradeable { /** * @dev Must return an address that can be used as a delegate call target. * * {BeaconProxy} will check that this address is a contract. */ function implementation() external view returns (address); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"pure","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":"","type":"address"}],"name":"bumpedClaimValue","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_size","type":"uint256"},{"internalType":"uint256","name":"_currentSize","type":"uint256"}],"name":"calculateSizeIncreaseCost","outputs":[{"internalType":"uint256","name":"total","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_dripTime","type":"uint256"}],"name":"changeEthboxDripTime","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_isLocked","type":"bool"}],"name":"changeEthboxLocked","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"changeEthboxPayoutRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_size","type":"uint256"}],"name":"changeEthboxSize","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"claimAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_messageValue","type":"uint256"},{"internalType":"address","name":"_from","type":"address"}],"name":"claimOne","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultDripTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultEthboxSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"ethboxDripTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"ethboxLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"ethboxMessages","outputs":[{"internalType":"string","name":"message","type":"string"},{"internalType":"uint256","name":"originalValue","type":"uint256"},{"internalType":"uint256","name":"claimedValue","type":"uint256"},{"internalType":"uint256","name":"data","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"ethboxOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"ethboxPayoutRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"ethboxSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"message","type":"string"},{"internalType":"uint256","name":"originalValue","type":"uint256"},{"internalType":"uint256","name":"claimedValue","type":"uint256"},{"internalType":"uint256","name":"data","type":"uint256"}],"internalType":"struct EthboxStructs.Message","name":"_message","type":"tuple"},{"internalType":"uint256","name":"_drip","type":"uint256"}],"name":"getClaimableValue","outputs":[{"internalType":"uint256","name":"_claimableValue","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ethboxAddress","type":"address"}],"name":"getClaimableValueOfEthbox","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"getOrderedMessages","outputs":[{"components":[{"internalType":"string","name":"message","type":"string"},{"internalType":"uint256","name":"originalValue","type":"uint256"},{"internalType":"uint256","name":"claimedValue","type":"uint256"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint64","name":"timestamp","type":"uint64"},{"internalType":"uint8","name":"index","type":"uint8"},{"internalType":"uint24","name":"feeBPS","type":"uint24"}],"internalType":"struct EthboxStructs.UnpackedMessage[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"}],"name":"getOrderedPackedMessages","outputs":[{"components":[{"internalType":"string","name":"message","type":"string"},{"internalType":"uint256","name":"originalValue","type":"uint256"},{"internalType":"uint256","name":"claimedValue","type":"uint256"},{"internalType":"uint256","name":"data","type":"uint256"}],"internalType":"struct EthboxStructs.Message[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_messageValue","type":"uint256"},{"internalType":"address","name":"_to","type":"address"}],"name":"getRefundForMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"maxMessageLen","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"messageFeeBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"messageFeeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"metadata","outputs":[{"internalType":"contract EthboxMetadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintMyEthbox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"minted","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":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"},{"internalType":"uint256","name":"_messageValue","type":"uint256"},{"internalType":"address","name":"_from","type":"address"}],"name":"removeOne","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"string","name":"_message","type":"string"},{"internalType":"uint256","name":"_drip","type":"uint256"}],"name":"sendMessage","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bool","name":"","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_messageFeeBPS","type":"uint256"}],"name":"setMessageFeeBPS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_messageFeeRecipient","type":"address"}],"name":"setMessageFeeRecipient","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_metadata","type":"address"}],"name":"setMetadataContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_sizeIncreaseFee","type":"uint256"}],"name":"setSizeIncreaseFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_sizeIncreaseFeeBPS","type":"uint256"}],"name":"setSizeIncreaseFeeBPS","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sizeIncreaseFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sizeIncreaseFeeBPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"unpackEthboxInfo","outputs":[{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint8","name":"size","type":"uint8"},{"internalType":"bool","name":"locked","type":"bool"},{"internalType":"uint64","name":"drip","type":"uint64"}],"internalType":"struct EthboxStructs.EthboxInfo","name":"ethbox","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"}]
Contract Creation Code
60a06040523060805234801561001457600080fd5b506080516155086100686000396000818161106a015281816110aa0152818161157c015281816115bc0152818161163801528181612c0f01528181612c4f01528181613444015261348401526155086000f3fe6080604052600436106103815760003560e01c80637fc5f4c8116101d1578063c87b56dd11610102578063e2671c41116100a0578063e985e9c51161006f578063e985e9c514610a43578063f1cda9a514610a66578063f2fde38b14610a86578063fad6722414610aa657600080fd5b8063e2671c41146109b6578063e5187f43146109e3578063e68f51ee14610a03578063e7c6a7ed14610a2357600080fd5b8063d3b6fc62116100dc578063d3b6fc621461094e578063d5743ff81461096e578063dcf58c2c14610983578063e2235c58146109a357600080fd5b8063c87b56dd14610904578063d1058e5914610924578063d2b46f731461093957600080fd5b80639d83e0271161016f578063a22cb46511610149578063a22cb465146108a2578063b2df9221146108bd578063b6f585c0146108d4578063b88d4fde146108e957600080fd5b80639d83e02714610858578063a0b1eec114610878578063a1cb34591461088b57600080fd5b80638da5cb5b116101ab5780638da5cb5b146107e55780638f5682211461080357806395d89b4114610823578063998cc7fd1461083857600080fd5b80637fc5f4c81461079a5780638129fc1c146107ba57806387f46ece146107cf57600080fd5b80632e510ec9116102b65780634f1ef2861161025457806370a082311161022357806370a0823114610725578063715018a61461074557806372488fe41461075a5780637fc1b37d1461077a57600080fd5b80634f1ef286146106ad57806352d1902d146106c05780636352211e146106d55780636de7d45b146106f557600080fd5b80633d27f77a116102905780633d27f77a14610649578063426492be1461066957806342842e0e146105ad57806347c9c76d1461068057600080fd5b80632e510ec9146105e95780633659cfe614610609578063392f37e91461062957600080fd5b806315751142116103235780631e7269c5116102fd5780631e7269c51461055d5780631ef89d6c1461058d57806323b872dd146105ad57806328d47af6146105c857600080fd5b806315751142146104ef5780631c2ade521461050f5780631c9d87d61461052f57600080fd5b8063081812fc1161035f578063081812fc14610447578063095ea7b31461047f5780630f5a1754146104a1578063122bf446146104cf57600080fd5b806301ffc9a7146103865780630658d738146103bb57806306fdde0314610425575b600080fd5b34801561039257600080fd5b506103a66103a13660046147e6565b610abb565b60405190151581526020015b60405180910390f35b3480156103c757600080fd5b506103db6103d636600461482c565b610b0d565b6040516103b2919081516001600160a01b0316815260208083015160ff16908201526040808301511515908201526060918201516001600160401b03169181019190915260800190565b34801561043157600080fd5b5061043a610b78565b6040516103b29190614897565b34801561045357600080fd5b506104676104623660046148aa565b610c0a565b6040516001600160a01b0390911681526020016103b2565b34801561048b57600080fd5b5061049f61049a3660046148c3565b610c37565b005b3480156104ad57600080fd5b506104c16104bc36600461482c565b610c6f565b6040519081526020016103b2565b3480156104db57600080fd5b5061049f6104ea3660046148ed565b610cae565b3480156104fb57600080fd5b5061049f61050a366004614932565b610f1d565b34801561051b57600080fd5b506104c161052a36600461482c565b610f8a565b34801561053b57600080fd5b506104c161054a36600461482c565b6101056020526000908152604090205481565b34801561056957600080fd5b506103a661057836600461482c565b60fe6020526000908152604090205460ff1681565b34801561059957600080fd5b5061049f6105a83660046148aa565b61100b565b3480156105b957600080fd5b5061049f61049a36600461494d565b3480156105d457600080fd5b5061010254610467906001600160a01b031681565b3480156105f557600080fd5b506104c161060436600461482c565b611019565b34801561061557600080fd5b5061049f61062436600461482c565b611060565b34801561063557600080fd5b5060fd54610467906001600160a01b031681565b34801561065557600080fd5b5061049f61066436600461482c565b611128565b34801561067557600080fd5b506104c16101005481565b34801561068c57600080fd5b506106a061069b36600461482c565b611153565b6040516103b29190614a40565b61049f6106bb366004614b46565b611572565b3480156106cc57600080fd5b506104c161162b565b3480156106e157600080fd5b506104676106f03660046148aa565b6116de565b34801561070157600080fd5b506107156107103660046148c3565b611748565b6040516103b29493929190614b93565b34801561073157600080fd5b506104c161074036600461482c565b61181e565b34801561075157600080fd5b5061049f611847565b34801561076657600080fd5b5061049f6107753660046148aa565b61185b565b34801561078657600080fd5b5061049f6107953660046148ed565b611869565b3480156107a657600080fd5b5061049f6107b53660046148aa565b611ac8565b3480156107c657600080fd5b5061049f611b75565b3480156107db57600080fd5b506104c160ff5481565b3480156107f157600080fd5b506033546001600160a01b0316610467565b34801561080f57600080fd5b506104c161081e366004614bc2565b611d22565b34801561082f57600080fd5b5061043a611e15565b34801561084457600080fd5b5061046761085336600461482c565b611e24565b34801561086457600080fd5b506104c161087336600461482c565b611e59565b61049f6108863660046148aa565b612035565b34801561089757600080fd5b506104c16101015481565b3480156108ae57600080fd5b5061049f61049a366004614be4565b3480156108c957600080fd5b506104c16224ea0081565b3480156108e057600080fd5b506104c1600381565b3480156108f557600080fd5b5061049f61049a366004614c17565b34801561091057600080fd5b5061043a61091f3660046148aa565b61214a565b34801561093057600080fd5b5061049f612246565b34801561094557600080fd5b506104c1608d81565b34801561095a57600080fd5b5061049f6109693660046148ed565b6125f5565b34801561097a57600080fd5b5061049f6128a0565b34801561098f57600080fd5b5061049f61099e3660046148aa565b612bd1565b61049f6109b1366004614c7e565b612bde565b3480156109c257600080fd5b506109d66109d136600461482c565b61305b565b6040516103b29190614d06565b3480156109ef57600080fd5b5061049f6109fe36600461482c565b61326e565b348015610a0f57600080fd5b5061049f610a1e36600461482c565b613298565b348015610a2f57600080fd5b506104c1610a3e366004614d91565b6132f0565b348015610a4f57600080fd5b506103a6610a5e366004614e3c565b600092915050565b348015610a7257600080fd5b506103a6610a8136600461482c565b613390565b348015610a9257600080fd5b5061049f610aa136600461482c565b6133c4565b348015610ab257600080fd5b5061049f61343a565b60006001600160e01b031982166380ac58cd60e01b1480610aec57506001600160e01b03198216635b5e139f60e01b145b80610b0757506301ffc9a760e01b6001600160e01b03198316145b92915050565b6040805160808101825260008082526020808301828152838501838152606085018481526001600160a01b039788168552610104909352949092205494851683526001600160401b0360a086901c16905260ff60e185901c16905260e09290921c6001161515905290565b606060fb8054610b8790614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb390614e66565b8015610c005780601f10610bd557610100808354040283529160200191610c00565b820191906000526020600020905b815481529060010190602001808311610be357829003601f168201915b5050505050905090565b6001600160a01b038116600090815260fe602052604081205460ff16610c2f57600080fd5b506000919050565b60405162461bcd60e51b8152602060048201526008602482015267191a5cd8589b195960c21b60448201526064015b60405180910390fd5b6001600160a01b038116600090815260fe602052604081205460ff1615610ca657610c9982610b0d565b6020015160ff1692915050565b506003919050565b600260655403610cd05760405162461bcd60e51b8152600401610c6690614ea0565b600260655533600090815260fe602052604090205460ff16610d045760405162461bcd60e51b8152600401610c6690614ed7565b33600090815261010360205260408120805485908110610d2657610d26614f0e565b9060005260206000209060040201604051806080016040529081600082018054610d4f90614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054610d7b90614e66565b8015610dc85780601f10610d9d57610100808354040283529160200191610dc8565b820191906000526020600020905b815481529060010190602001808311610dab57829003601f168201915b505050505081526020016001820154815260200160028201548152602001600382015481525050905080602001518314610e145760405162461bcd60e51b8152600401610c6690614f24565b6000610e2382606001516135d8565b905080600001516001600160a01b0316836001600160a01b031614610e5a5760405162461bcd60e51b8152600401610c6690614f69565b6000610e7783610e693361361e565b6001600160401b03166132f0565b90508083604001818151610e8b9190614fcd565b90525033600090815261010360205260409020805484919088908110610eb357610eb3614f0e565b600091825260209091208251600490920201908190610ed2908261502e565b506020820151600182015560408201516002820155606090910151600390910155610efd338761363d565b610f068361392a565b610f10338261395b565b5050600160655550505050565b6000610f2833610b0d565b9050806020015160ff16600003610f515760405162461bcd60e51b8152600401610c6690614ed7565b610f75816000015182606001516001600160401b0316836020015160ff1685613a0e565b33600090815261010460205260409020555050565b6001600160a01b038116600090815260fe602052604081205460ff16610ffe5760405162461bcd60e51b815260206004820152602360248201527f6164647265737320686173206e6f74206d696e746564207468656972206574686044820152620c4def60eb1b6064820152608401610c66565b506001600160a01b031690565b611013613a32565b61010155565b6001600160a01b038116600090815260fe602052604081205460ff16156110565761104382610b0d565b606001516001600160401b031692915050565b506224ea00919050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036110a85760405162461bcd60e51b8152600401610c66906150ed565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166110da613a8c565b6001600160a01b0316146111005760405162461bcd60e51b8152600401610c6690615139565b61110981613aa8565b6040805160008082526020820190925261112591839190613ab0565b50565b611130613a32565b61010280546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116600090815261010360209081526040808320805482518185028101850190935280835260609493849084015b8282101561126b57838290600052602060002090600402016040518060800160405290816000820180546111bc90614e66565b80601f01602080910402602001604051908101604052809291908181526020018280546111e890614e66565b80156112355780601f1061120a57610100808354040283529160200191611235565b820191906000526020600020905b81548152906001019060200180831161121857829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190611189565b509293506001925050505b81518110156113665760005b818110156113535782818151811061129c5761129c614f0e565b6020026020010151602001518383815181106112ba576112ba614f0e565b60200260200101516020015111156113415760008383815181106112e0576112e0614f0e565b602002602001015190508382815181106112fc576112fc614f0e565b602002602001015184848151811061131657611316614f0e565b60200260200101819052508084838151811061133457611334614f0e565b6020026020010181905250505b8061134b81615185565b915050611282565b508061135e81615185565b915050611276565b50600081516001600160401b0381111561138257611382614a53565b6040519080825280602002602001820160405280156113ea57816020015b6040805160e0810182526060808252600060208084018290529383018190529082018190526080820181905260a0820181905260c082015282526000199092019101816113a05790505b50905061141760408051608081018252600080825260208201819052918101829052606081019190915290565b60005b8351811015611568576040805160e081018252606080825260006020830181905292820183905281018290526080810182905260a0810182905260c081019190915261148285838151811061147157611471614f0e565b6020026020010151606001516135d8565b925084828151811061149657611496614f0e565b602090810291909101015151815284518590839081106114b8576114b8614f0e565b6020026020010151602001518160200181815250508482815181106114df576114df614f0e565b6020908102919091018101516040908101518382015284516001600160a01b0316606080850191909152918501516001600160401b0316608084015284015160ff1660a083015283015162ffffff1660c08201528351819085908490811061154957611549614f0e565b602002602001018190525050808061156090615185565b91505061141a565b5090949350505050565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036115ba5760405162461bcd60e51b8152600401610c66906150ed565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166115ec613a8c565b6001600160a01b0316146116125760405162461bcd60e51b8152600401610c6690615139565b61161b82613aa8565b61162782826001613ab0565b5050565b6000306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146116cb5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c66565b5060008051602061548c83398151915290565b6001600160a01b038116600090815260fe6020526040812054829060ff16610b075760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610c66565b610103602052816000526040600020818154811061176557600080fd5b90600052602060002090600402016000915091505080600001805461178990614e66565b80601f01602080910402602001604051908101604052809291908181526020018280546117b590614e66565b80156118025780601f106117d757610100808354040283529160200191611802565b820191906000526020600020905b8154815290600101906020018083116117e557829003601f168201915b5050505050908060010154908060020154908060030154905084565b6001600160a01b038116600090815260fe602052604081205460ff1615610c2f57506001919050565b61184f613a32565b6118596000613c20565b565b611863613a32565b61010055565b60026065540361188b5760405162461bcd60e51b8152600401610c6690614ea0565b6002606555600061189b33610b0d565b9050806020015160ff166000036118c45760405162461bcd60e51b8152600401610c6690614ed7565b336000908152610103602052604081208054869081106118e6576118e6614f0e565b906000526020600020906004020160405180608001604052908160008201805461190f90614e66565b80601f016020809104026020016040519081016040528092919081815260200182805461193b90614e66565b80156119885780601f1061195d57610100808354040283529160200191611988565b820191906000526020600020905b81548152906001019060200180831161196b57829003601f168201915b5050505050815260200160018201548152602001600282015481526020016003820154815250509050806020015184146119d45760405162461bcd60e51b8152600401610c6690614f24565b60006119e382606001516135d8565b905080600001516001600160a01b0316846001600160a01b031614611a1a5760405162461bcd60e51b8152600401610c6690614f69565b6000611a2983610e693361361e565b90504284606001518360200151611a40919061519e565b6001600160401b03161015611a6557611a6033836040015160ff1661363d565b611ab0565b33600090815261010360205260409020805482919089908110611a8a57611a8a614f0e565b90600052602060002090600402016002016000828254611aaa9190614fcd565b90915550505b611aba338261395b565b505060016065555050505050565b6000611ad333610b0d565b9050806020015160ff16600003611afc5760405162461bcd60e51b8152600401610c6690614ed7565b336000908152610103602052604090205415611b5a5760405162461bcd60e51b815260206004820152601860248201527f657468626f78206e6565647320746f20626520656d70747900000000000000006044820152606401610c66565b610f75816000015183836020015160ff168460400151613a0e565b600054610100900460ff1615808015611b955750600054600160ff909116105b80611baf5750303b158015611baf575060005460ff166001145b611c125760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c66565b6000805460ff191660011790558015611c35576000805461ff0019166101001790555b611c3d613c72565b611c45613ca1565b60408051808201909152600681526508ae8d0c4def60d31b602082015260fb90611c6f908261502e565b5060408051808201909152600681526508aa890849eb60d31b602082015260fc90611c9a908261502e565b5066b1a2bc2ec5000060ff556109c46101005560fa6101015561010280546001600160a01b0319167340543d76fb35c60ff578b648d723e14ccab8b3901790558015611125576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b6000818311611d735760405162461bcd60e51b815260206004820152601960248201527f6e65772073697a652073686f756c64206265206c6172676572000000000000006044820152606401610c66565b506000815b83811015611e0e5760038103611d9c5760ff54611d959083614fcd565b9150611dfc565b611da76003826151be565b611db3906127106152b5565b611dbe6003836151be565b61010054611dce90612710614fcd565b611dd891906152b5565b60ff54611de591906152c1565b611def91906152f6565b611df99083614fcd565b91505b80611e0681615185565b915050611d78565b5092915050565b606060fc8054610b8790614e66565b6001600160a01b038116600090815260fe602052604081205460ff1615611e5557611e4e82610b0d565b5192915050565b5090565b6001600160a01b03811660009081526101036020908152604080832080548251818502810185019093528083528493849084015b82821015611f6f5783829060005260206000209060040201604051806080016040529081600082018054611ec090614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054611eec90614e66565b8015611f395780601f10611f0e57610100808354040283529160200191611f39565b820191906000526020600020905b815481529060010190602001808311611f1c57829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190611e8d565b5050505090506000611f8084610b0d565b90506000825190506000806000846020015160ff16600014611faf5784606001516001600160401b0316611fb4565b6224ea005b905060005b8481101561200457611fe4878281518110611fd657611fd6614f0e565b6020026020010151836132f0565b9350611ff08484614fcd565b925080611ffc81615185565b915050611fb9565b506001600160a01b038816600090815261010560205260409020546120299083614fcd565b98975050505050505050565b600061204033610b0d565b9050806020015160ff166000036120695760405162461bcd60e51b8152600401610c6690614ed7565b600061207c83836020015160ff16611d22565b905034811461208a82613cd0565b906120a85760405162461bcd60e51b8152600401610c669190614897565b506120ca826000015183606001516001600160401b0316858560400151613a0e565b33600090815261010460205260408082209290925561010254915190916001600160a01b03169034905b60006040518083038185875af1925050503d8060008114612131576040519150601f19603f3d011682016040523d82523d6000602084013e612136565b606091505b505090508061214457600080fd5b50505050565b6001600160a01b038116600090815260fe602052604090205460609060ff1661217257600080fd5b81600061217e82611153565b905060006121a5836001600160a01b03166000908152610104602052604090205460e11c90565b60ff16905060006121b58461361e565b60fd54604051633a36a46560e01b81526001600160401b039290921692506001600160a01b031690633a36a465906121f790879087908790879060040161530a565b600060405180830381865afa158015612214573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261223c9190810190615341565b9695505050505050565b6002606554036122685760405162461bcd60e51b8152600401610c6690614ea0565b600260655533600090815260fe602052604090205460ff1661229c5760405162461bcd60e51b8152600401610c6690614ed7565b33600090815261010360209081526040808320805482518185028101850190935280835284938493929190849084015b828210156123ae57838290600052602060002090600402016040518060800160405290816000820180546122ff90614e66565b80601f016020809104026020016040519081016040528092919081815260200182805461232b90614e66565b80156123785780601f1061234d57610100808354040283529160200191612378565b820191906000526020600020905b81548152906001019060200180831161235b57829003601f168201915b505050505081526020016001820154815260200160028201548152602001600382015481525050815260200190600101906122cc565b5050505090506000815190506000816001600160401b038111156123d4576123d4614a53565b6040519080825280602002602001820160405280156123fd578160200160208202803683370190505b50905060008061240c3361361e565b6001600160401b0316905060005b8481101561250657600086828151811061243657612436614f0e565b6020026020010151905061244a81846132f0565b98506124568989614fcd565b3360009081526101036020526040902080549199508a918490811061247d5761247d614f0e565b9060005260206000209060040201600201600082825461249d9190614fcd565b909155505060608101514290849060a01c6001600160401b03166124c19190614fcd565b10156124f357818585815181106124da576124da614f0e565b6020908102919091010152836124ef81615185565b9450505b50806124fe81615185565b91505061241a565b506000826001600160401b0381111561252157612521614a53565b60405190808252806020026020018201604052801561254a578160200160208202803683370190505b50905060005b81518110156125a25784818151811061256b5761256b614f0e565b602002602001015182828151811061258557612585614f0e565b60209081029190910101528061259a81615185565b915050612550565b5033600090815261010560205260409020546125be9088614fcd565b33600081815261010560205260408120559097506125dc9082613dd8565b6125e6338861395b565b50506001606555505050505050565b6002606554036126175760405162461bcd60e51b8152600401610c6690614ea0565b60026065556001600160a01b038116600090815260fe602052604090205460ff16156126855760405162461bcd60e51b815260206004820152601d60248201527f657468626f78206e6565647320746f206265206e6f74206d696e7465640000006044820152606401610c66565b6001600160a01b0381166000908152610103602052604081208054859081106126b0576126b0614f0e565b90600052602060002090600402016040518060800160405290816000820180546126d990614e66565b80601f016020809104026020016040519081016040528092919081815260200182805461270590614e66565b80156127525780601f1061272757610100808354040283529160200191612752565b820191906000526020600020905b81548152906001019060200180831161273557829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505090508060200151831461279e5760405162461bcd60e51b8152600401610c6690614f24565b60006127ad82606001516135d8565b80519091506001600160a01b0316331461281e5760405162461bcd60e51b815260206004820152602c60248201527f6d65737361676520617420696e64657820646f6573206e6f74206d617463682060448201526b796f7572206164647265737360a01b6064820152608401610c66565b600081602001516001600160401b03164261283991906151be565b90506224ea00811161288d5760405162461bcd60e51b815260206004820152601b60248201527f6d657373616765206e6565647320746f206265206578706972656400000000006044820152606401610c66565b612897848761363d565b610f108361392a565b6002606554036128c25760405162461bcd60e51b8152600401610c6690614ea0565b600260655533600090815260fe602052604090205460ff166128f65760405162461bcd60e51b8152600401610c6690614ed7565b33600090815261010360209081526040808320805482518185028101850190935280835284938493929190849084015b82821015612a08578382906000526020600020906004020160405180608001604052908160008201805461295990614e66565b80601f016020809104026020016040519081016040528092919081815260200182805461298590614e66565b80156129d25780601f106129a7576101008083540402835291602001916129d2565b820191906000526020600020905b8154815290600101906020018083116129b557829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190612926565b5050825192935060009150505b81811015612ba257612a43838281518110612a3257612a32614f0e565b6020026020010151610e693361361e565b9450612a4f8585614fcd565b336000908152610103602052604090208054919550869183908110612a7657612a76614f0e565b90600052602060002090600402016002016000828254612a969190614fcd565b9091555050336000908152610103602052604090208054612b90919083908110612ac257612ac2614f0e565b9060005260206000209060040201604051806080016040529081600082018054612aeb90614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054612b1790614e66565b8015612b645780601f10612b3957610100808354040283529160200191612b64565b820191906000526020600020905b815481529060010190602001808311612b4757829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505061392a565b80612b9a81615185565b915050612a15565b5033600090815261010360205260408120612bbc91614744565b612bc6338461395b565b505060016065555050565b612bd9613a32565b60ff55565b600260655403612c005760405162461bcd60e51b8152600401610c6690614ea0565b60026065556001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163003612c4d5760405162461bcd60e51b8152600401610c66906150ed565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612c7f613a8c565b6001600160a01b031614612ca55760405162461bcd60e51b8152600401610c6690615139565b608d8210612ce85760405162461bcd60e51b815260206004820152601060248201526f6d65737361676520746f6f206c6f6e6760801b6044820152606401610c66565b6000612cf385610b0d565b60208101519091506003906224ea009060ff1615612d2657826020015160ff16915082606001516001600160401b031690505b826040015115612d6b5760405162461bcd60e51b815260206004820152601060248201526f195d1a189bde081a5cc81b1bd8dad95960821b6044820152606401610c66565b612710341180612d79575034155b612dc55760405162461bcd60e51b815260206004820152601760248201527f6d6573736167652076616c756520696e636f72726563740000000000000000006044820152606401610c66565b838114612e0d5760405162461bcd60e51b81526020600482015260166024820152751b595cdcd859d948191c9a5c081a5b98dbdc9c9958dd60521b6044820152606401610c66565b6001600160a01b03871660009081526101036020908152604080832080548251818502810185019093528083529192909190849084015b82821015612f265783829060005260206000209060040201604051806080016040529081600082018054612e7790614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054612ea390614e66565b8015612ef05780601f10612ec557610100808354040283529160200191612ef0565b820191906000526020600020905b815481529060010190602001808311612ed357829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190612e44565b50508251929350505083811015612f4a57612f4589338a8a3486614108565b613042565b600080612f588484346141ee565b915091508115612fff576000848281518110612f7657612f76614f0e565b60200260200101519050876020015160ff16600014612fe2576000612f9b82886132f0565b90508082604001818151612faf9190614fcd565b9052506001600160a01b038d166000908152610105602052604081208054839290612fdb908490614fcd565b9091555050505b612feb8161392a565b612ff98c338d8d348761428b565b5061303f565b60405162461bcd60e51b81526020600482015260156024820152746d6573736167652076616c756520746f6f206c6f7760581b6044820152606401610c66565b50505b61304b34614382565b5050600160655550505050505050565b6001600160a01b038116600090815261010360209081526040808320805482518185028101850190935280835260609493849084015b8282101561317357838290600052602060002090600402016040518060800160405290816000820180546130c490614e66565b80601f01602080910402602001604051908101604052809291908181526020018280546130f090614e66565b801561313d5780601f106131125761010080835404028352916020019161313d565b820191906000526020600020905b81548152906001019060200180831161312057829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190613091565b509293506001925050505b8151811015611e0e5760005b8181101561325b578281815181106131a4576131a4614f0e565b6020026020010151602001518383815181106131c2576131c2614f0e565b60200260200101516020015111156132495760008383815181106131e8576131e8614f0e565b6020026020010151905083828151811061320457613204614f0e565b602002602001015184848151811061321e5761321e614f0e565b60200260200101819052508084838151811061323c5761323c614f0e565b6020026020010181905250505b8061325381615185565b91505061318a565b508061326681615185565b91505061317e565b613276613a32565b60fd80546001600160a01b0319166001600160a01b0392909216919091179055565b60006132a333610b0d565b9050806020015160ff166000036132cc5760405162461bcd60e51b8152600401610c6690614ed7565b610f758282606001516001600160401b0316836020015160ff168460400151613a0e565b600080613301846060015160a01c90565b613314906001600160401b0316426151be565b90506001811015613329576000915050610b07565b828111156133425761333a84614436565b915050610b07565b6000836133508360646152c1565b61335a91906152f6565b9050600060648261336a88614450565b61337491906152c1565b61337e91906152f6565b905085604001518161223c91906151be565b6001600160a01b038116600090815260fe602052604081205460ff1615610c2f576133ba82610b0d565b6040015192915050565b6133cc613a32565b6001600160a01b0381166134315760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c66565b61112581613c20565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001630036134825760405162461bcd60e51b8152600401610c66906150ed565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166134b4613a8c565b6001600160a01b0316146134da5760405162461bcd60e51b8152600401610c6690615139565b33600081815260fe602052604090205460ff16156135325760405162461bcd60e51b8152602060048201526015602482015274195d1a189bde08185b1c9958591e481b5a5b9d1959605a1b6044820152606401610c66565b6001600160a01b038116600090815260fe60205260408120805460ff191660011790556135689082906224ea0090600390613a0e565b6001600160a01b03821660008181526101046020526040808220939093559151909182917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a46001600160a01b038116600090815261010360205260409020541561112557611125612246565b604080516080810182526001600160a01b038316815260a083901c6001600160401b0316602082015260e083901c60ff169181019190915260e89190911c606082015290565b6001600160a01b03166000908152610104602052604090205460a01c90565b6001600160a01b03821660009081526101036020908152604080832080548251818502810185019093528083529192909190849084015b8282101561375657838290600052602060002090600402016040518060800160405290816000820180546136a790614e66565b80601f01602080910402602001604051908101604052809291908181526020018280546136d390614e66565b80156137205780601f106136f557610100808354040283529160200191613720565b820191906000526020600020905b81548152906001019060200180831161370357829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190613674565b505050509050806001825161376b91906151be565b8151811061377b5761377b614f0e565b60200260200101516101036000856001600160a01b03166001600160a01b0316815260200190815260200160002083815481106137ba576137ba614f0e565b6000918252602090912082516004909202019081906137d9908261502e565b50602082015181600101556040820151816002015560608201518160030155905050600061384e6101036000866001600160a01b03166001600160a01b03168152602001908152602001600020848154811061383757613837614f0e565b9060005260206000209060040201600301546135d8565b9050613876816000015182602001516001600160401b031685846060015162ffffff1661448d565b6001600160a01b0385166000908152610103602052604090208054859081106138a1576138a1614f0e565b9060005260206000209060040201600301819055506101036000856001600160a01b03166001600160a01b031681526020019081526020016000208054806138eb576138eb6153ae565b6000828152602081206000199092019160048302019061390b8282614765565b5060006001820181905560028201819055600390910155905550505050565b600061393582614436565b90506000613944836060015190565b90506000816001600160a01b0316836040516120f4565b6001600160a01b0382811660009081526101046020526040808220549051909283169084908381818185875af1925050503d80600081146139b8576040519150601f19603f3d011682016040523d82523d6000602084013e6139bd565b606091505b50509050806121445760405162461bcd60e51b815260206004820152601760248201527f636f756c64206e6f742070617920726563697069656e740000000000000000006044820152606401610c66565b60e01b60a09290921b9190911760e19190911b176001600160a01b03919091161790565b6033546001600160a01b031633146118595760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c66565b60008051602061548c833981519152546001600160a01b031690565b611125613a32565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615613ae857613ae3836144b1565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613b42575060408051601f3d908101601f19168201909252613b3f918101906153c4565b60015b613ba55760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610c66565b60008051602061548c8339815191528114613c145760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610c66565b50613ae383838361454d565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16613c995760405162461bcd60e51b8152600401610c66906153dd565b611859614572565b600054610100900460ff16613cc85760405162461bcd60e51b8152600401610c66906153dd565b6118596145a2565b606081600003613cf75750506040805180820190915260018152600360fc1b602082015290565b8160005b8115613d215780613d0b81615185565b9150613d1a9050600a836152f6565b9150613cfb565b6000816001600160401b03811115613d3b57613d3b614a53565b6040519080825280601f01601f191660200182016040528015613d65576020820181803683370190505b5090505b8415613dd057613d7a6001836151be565b9150613d87600a86615428565b613d92906030614fcd565b60f81b818381518110613da757613da7614f0e565b60200101906001600160f81b031916908160001a905350613dc9600a866152f6565b9450613d69565b949350505050565b6001600160a01b03821660009081526101036020908152604080832080548251818502810185019093528083529192909190849084015b82821015613ef15783829060005260206000209060040201604051806080016040529081600082018054613e4290614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054613e6e90614e66565b8015613ebb5780601f10613e9057610100808354040283529160200191613ebb565b820191906000526020600020905b815481529060010190602001808311613e9e57829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190613e0f565b5050845192935050505b80156121445781518114614095576000613f2083838151811061147157611471614f0e565b90508260018451613f3191906151be565b81518110613f4157613f41614f0e565b60200260200101516101036000876001600160a01b03166001600160a01b0316815260200190815260200160002085600185613f7d91906151be565b81518110613f8d57613f8d614f0e565b602002602001015181548110613fa557613fa5614f0e565b600091825260209091208251600490920201908190613fc4908261502e565b50602082015181600101556040820151816002015560608201518160030155905050614031816000015182602001516001600160401b03168660018661400a91906151be565b8151811061401a5761401a614f0e565b6020026020010151846060015162ffffff1661448d565b6001600160a01b038616600090815261010360205260409020856140566001866151be565b8151811061406657614066614f0e565b60200260200101518154811061407e5761407e614f0e565b906000526020600020906004020160030181905550505b6001600160a01b0384166000908152610103602052604090208054806140bd576140bd6153ae565b600082815260208120600019909201916004830201906140dd8282614765565b50600060018201819055600282018190556003909101559055806141008161543c565b915050613efb565b6141336040518060800160405280606081526020016000815260200160008152602001600081525090565b6141428642846101015461448d565b6060820152604080516020601f87018190048102820181019092528581529086908690819084018382808284376000920182905250938552505050602080830185905260408084018390526001600160a01b038a1683526101038252822080546001810182559083529120825183926004029091019081906141c4908261502e565b50602082015181600101556040820151816002015560608201518160030155505050505050505050565b6000806000808660008151811061420757614207614f0e565b6020026020010151602001519050600080600090505b8781101561427d5788818151811061423757614237614f0e565b602002602001015160200151915082821015614254578093508192505b8515801561426157508187115b1561426b57600195505b8061427581615185565b91505061421d565b509192505050935093915050565b6142b66040518060800160405280606081526020016000815260200160008152602001600081525090565b6142c58642846101015461448d565b6060820152604080516020601f87018190048102820181019092528581529086908690819084018382808284376000920182905250938552505050602080830185905260408084018390526001600160a01b038a168352610103909152902080548291908490811061433957614339614f0e565b600091825260209091208251600490920201908190614358908261502e565b50602082015160018201556040820151600282015560609091015160039091015550505050505050565b61010254610101546000916001600160a01b031690612710906143a590856152c1565b6143af91906152f6565b604051600081818185875af1925050503d80600081146143eb576040519150601f19603f3d011682016040523d82523d6000602084013e6143f0565b606091505b50509050806116275760405162461bcd60e51b8152602060048201526012602482015271636f756c64206e6f7420706179206665657360701b6044820152606401610c66565b6000816040015161444683614450565b610b0791906151be565b6000612710614463836060015160e81c90565b61446f90612710615453565b62ffffff16836020015161448391906152c1565b610b0791906152f6565b60a083901b60e083901b1760e882901b176001600160a01b03851617949350505050565b6001600160a01b0381163b61451e5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c66565b60008051602061548c83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b614556836145d0565b6000825111806145635750805b15613ae3576121448383614610565b600054610100900460ff166145995760405162461bcd60e51b8152600401610c66906153dd565b61185933613c20565b600054610100900460ff166145c95760405162461bcd60e51b8152600401610c66906153dd565b6001606555565b6145d9816144b1565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6146785760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c66565b600080846001600160a01b031684604051614693919061546f565b600060405180830381855af49150503d80600081146146ce576040519150601f19603f3d011682016040523d82523d6000602084013e6146d3565b606091505b50915091506146fb82826040518060600160405280602781526020016154ac60279139614704565b95945050505050565b6060831561471357508161473d565b8251156147235782518084602001fd5b8160405162461bcd60e51b8152600401610c669190614897565b9392505050565b5080546000825560040290600052602060002090810190611125919061479f565b50805461477190614e66565b6000825580601f10614781575050565b601f01602090049060005260206000209081019061112591906147d1565b80821115611e555760006147b38282614765565b5060006001820181905560028201819055600382015560040161479f565b5b80821115611e5557600081556001016147d2565b6000602082840312156147f857600080fd5b81356001600160e01b03198116811461473d57600080fd5b80356001600160a01b038116811461482757600080fd5b919050565b60006020828403121561483e57600080fd5b61473d82614810565b60005b8381101561486257818101518382015260200161484a565b50506000910152565b60008151808452614883816020860160208601614847565b601f01601f19169290920160200192915050565b60208152600061473d602083018461486b565b6000602082840312156148bc57600080fd5b5035919050565b600080604083850312156148d657600080fd5b6148df83614810565b946020939093013593505050565b60008060006060848603121561490257600080fd5b833592506020840135915061491960408501614810565b90509250925092565b8035801515811461482757600080fd5b60006020828403121561494457600080fd5b61473d82614922565b60008060006060848603121561496257600080fd5b61496b84614810565b925061497960208501614810565b9150604084013590509250925092565b600081518084526020808501808196508360051b8101915082860160005b85811015614a33578284038952815160e081518187526149c98288018261486b565b83890151888a0152604080850151908901526060808501516001600160a01b0316908901526080808501516001600160401b03169089015260a08085015160ff169089015260c09384015162ffffff169390970192909252505097840197908401906001016149a7565b5091979650505050505050565b60208152600061473d6020830184614989565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b0381118282101715614a8b57614a8b614a53565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614ab957614ab9614a53565b604052919050565b60006001600160401b03821115614ada57614ada614a53565b50601f01601f191660200190565b6000614afb614af684614ac1565b614a91565b9050828152838383011115614b0f57600080fd5b828260208301376000602084830101529392505050565b600082601f830112614b3757600080fd5b61473d83833560208501614ae8565b60008060408385031215614b5957600080fd5b614b6283614810565b915060208301356001600160401b03811115614b7d57600080fd5b614b8985828601614b26565b9150509250929050565b608081526000614ba6608083018761486b565b6020830195909552506040810192909252606090910152919050565b60008060408385031215614bd557600080fd5b50508035926020909101359150565b60008060408385031215614bf757600080fd5b614c0083614810565b9150614c0e60208401614922565b90509250929050565b60008060008060808587031215614c2d57600080fd5b614c3685614810565b9350614c4460208601614810565b92506040850135915060608501356001600160401b03811115614c6657600080fd5b614c7287828801614b26565b91505092959194509250565b60008060008060608587031215614c9457600080fd5b614c9d85614810565b935060208501356001600160401b0380821115614cb957600080fd5b818701915087601f830112614ccd57600080fd5b813581811115614cdc57600080fd5b886020828501011115614cee57600080fd5b95986020929092019750949560400135945092505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015614d8357603f19898403018552815160808151818652614d538287018261486b565b838b0151878c0152898401518a880152606093840151939096019290925250509386019390860190600101614d2d565b509098975050505050505050565b60008060408385031215614da457600080fd5b82356001600160401b0380821115614dbb57600080fd5b9084019060808287031215614dcf57600080fd5b614dd7614a69565b823582811115614de657600080fd5b83019150601f82018713614df957600080fd5b614e0887833560208501614ae8565b8152602083013560208201526040830135604082015260608301356060820152809450505050602083013590509250929050565b60008060408385031215614e4f57600080fd5b614e5883614810565b9150614c0e60208401614810565b600181811c90821680614e7a57607f821691505b602082108103614e9a57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526019908201527f657468626f78206e6565647320746f206265206d696e74656400000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60208082526025908201527f6d65737361676520617420696e64657820646f6573206e6f74206d617463682060408201526476616c756560d81b606082015260800190565b6020808252602e908201527f6d65737361676520617420696e64657820646f6573206e6f74206d617463682060408201526d73656e646572206164647265737360901b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610b0757610b07614fb7565b601f821115613ae357600081815260208120601f850160051c810160208610156150075750805b601f850160051c820191505b8181101561502657828155600101615013565b505050505050565b81516001600160401b0381111561504757615047614a53565b61505b816150558454614e66565b84614fe0565b602080601f83116001811461509057600084156150785750858301515b600019600386901b1c1916600185901b178555615026565b600085815260208120601f198616915b828110156150bf578886015182559484019460019091019084016150a0565b50858210156150dd5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b60006001820161519757615197614fb7565b5060010190565b6001600160401b03818116838216019080821115611e0e57611e0e614fb7565b81810381811115610b0757610b07614fb7565b600181815b8085111561520c5781600019048211156151f2576151f2614fb7565b808516156151ff57918102915b93841c93908002906151d6565b509250929050565b60008261522357506001610b07565b8161523057506000610b07565b816001811461524657600281146152505761526c565b6001915050610b07565b60ff84111561526157615261614fb7565b50506001821b610b07565b5060208310610133831016604e8410600b841016171561528f575081810a610b07565b61529983836151d1565b80600019048211156152ad576152ad614fb7565b029392505050565b600061473d8383615214565b60008160001904831182151516156152db576152db614fb7565b500290565b634e487b7160e01b600052601260045260246000fd5b600082615305576153056152e0565b500490565b6001600160a01b038516815260806020820181905260009061532e90830186614989565b6040830194909452506060015292915050565b60006020828403121561535357600080fd5b81516001600160401b0381111561536957600080fd5b8201601f8101841361537a57600080fd5b8051615388614af682614ac1565b81815285602083850101111561539d57600080fd5b6146fb826020830160208601614847565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156153d657600080fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082615437576154376152e0565b500690565b60008161544b5761544b614fb7565b506000190190565b62ffffff828116828216039080821115611e0e57611e0e614fb7565b60008251615481818460208701614847565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a22f6c182cf11ce955a1ef6d5ae10f80d419c40143c7ed9eac30d0e47c6a0b7564736f6c63430008100033
Deployed Bytecode
0x6080604052600436106103815760003560e01c80637fc5f4c8116101d1578063c87b56dd11610102578063e2671c41116100a0578063e985e9c51161006f578063e985e9c514610a43578063f1cda9a514610a66578063f2fde38b14610a86578063fad6722414610aa657600080fd5b8063e2671c41146109b6578063e5187f43146109e3578063e68f51ee14610a03578063e7c6a7ed14610a2357600080fd5b8063d3b6fc62116100dc578063d3b6fc621461094e578063d5743ff81461096e578063dcf58c2c14610983578063e2235c58146109a357600080fd5b8063c87b56dd14610904578063d1058e5914610924578063d2b46f731461093957600080fd5b80639d83e0271161016f578063a22cb46511610149578063a22cb465146108a2578063b2df9221146108bd578063b6f585c0146108d4578063b88d4fde146108e957600080fd5b80639d83e02714610858578063a0b1eec114610878578063a1cb34591461088b57600080fd5b80638da5cb5b116101ab5780638da5cb5b146107e55780638f5682211461080357806395d89b4114610823578063998cc7fd1461083857600080fd5b80637fc5f4c81461079a5780638129fc1c146107ba57806387f46ece146107cf57600080fd5b80632e510ec9116102b65780634f1ef2861161025457806370a082311161022357806370a0823114610725578063715018a61461074557806372488fe41461075a5780637fc1b37d1461077a57600080fd5b80634f1ef286146106ad57806352d1902d146106c05780636352211e146106d55780636de7d45b146106f557600080fd5b80633d27f77a116102905780633d27f77a14610649578063426492be1461066957806342842e0e146105ad57806347c9c76d1461068057600080fd5b80632e510ec9146105e95780633659cfe614610609578063392f37e91461062957600080fd5b806315751142116103235780631e7269c5116102fd5780631e7269c51461055d5780631ef89d6c1461058d57806323b872dd146105ad57806328d47af6146105c857600080fd5b806315751142146104ef5780631c2ade521461050f5780631c9d87d61461052f57600080fd5b8063081812fc1161035f578063081812fc14610447578063095ea7b31461047f5780630f5a1754146104a1578063122bf446146104cf57600080fd5b806301ffc9a7146103865780630658d738146103bb57806306fdde0314610425575b600080fd5b34801561039257600080fd5b506103a66103a13660046147e6565b610abb565b60405190151581526020015b60405180910390f35b3480156103c757600080fd5b506103db6103d636600461482c565b610b0d565b6040516103b2919081516001600160a01b0316815260208083015160ff16908201526040808301511515908201526060918201516001600160401b03169181019190915260800190565b34801561043157600080fd5b5061043a610b78565b6040516103b29190614897565b34801561045357600080fd5b506104676104623660046148aa565b610c0a565b6040516001600160a01b0390911681526020016103b2565b34801561048b57600080fd5b5061049f61049a3660046148c3565b610c37565b005b3480156104ad57600080fd5b506104c16104bc36600461482c565b610c6f565b6040519081526020016103b2565b3480156104db57600080fd5b5061049f6104ea3660046148ed565b610cae565b3480156104fb57600080fd5b5061049f61050a366004614932565b610f1d565b34801561051b57600080fd5b506104c161052a36600461482c565b610f8a565b34801561053b57600080fd5b506104c161054a36600461482c565b6101056020526000908152604090205481565b34801561056957600080fd5b506103a661057836600461482c565b60fe6020526000908152604090205460ff1681565b34801561059957600080fd5b5061049f6105a83660046148aa565b61100b565b3480156105b957600080fd5b5061049f61049a36600461494d565b3480156105d457600080fd5b5061010254610467906001600160a01b031681565b3480156105f557600080fd5b506104c161060436600461482c565b611019565b34801561061557600080fd5b5061049f61062436600461482c565b611060565b34801561063557600080fd5b5060fd54610467906001600160a01b031681565b34801561065557600080fd5b5061049f61066436600461482c565b611128565b34801561067557600080fd5b506104c16101005481565b34801561068c57600080fd5b506106a061069b36600461482c565b611153565b6040516103b29190614a40565b61049f6106bb366004614b46565b611572565b3480156106cc57600080fd5b506104c161162b565b3480156106e157600080fd5b506104676106f03660046148aa565b6116de565b34801561070157600080fd5b506107156107103660046148c3565b611748565b6040516103b29493929190614b93565b34801561073157600080fd5b506104c161074036600461482c565b61181e565b34801561075157600080fd5b5061049f611847565b34801561076657600080fd5b5061049f6107753660046148aa565b61185b565b34801561078657600080fd5b5061049f6107953660046148ed565b611869565b3480156107a657600080fd5b5061049f6107b53660046148aa565b611ac8565b3480156107c657600080fd5b5061049f611b75565b3480156107db57600080fd5b506104c160ff5481565b3480156107f157600080fd5b506033546001600160a01b0316610467565b34801561080f57600080fd5b506104c161081e366004614bc2565b611d22565b34801561082f57600080fd5b5061043a611e15565b34801561084457600080fd5b5061046761085336600461482c565b611e24565b34801561086457600080fd5b506104c161087336600461482c565b611e59565b61049f6108863660046148aa565b612035565b34801561089757600080fd5b506104c16101015481565b3480156108ae57600080fd5b5061049f61049a366004614be4565b3480156108c957600080fd5b506104c16224ea0081565b3480156108e057600080fd5b506104c1600381565b3480156108f557600080fd5b5061049f61049a366004614c17565b34801561091057600080fd5b5061043a61091f3660046148aa565b61214a565b34801561093057600080fd5b5061049f612246565b34801561094557600080fd5b506104c1608d81565b34801561095a57600080fd5b5061049f6109693660046148ed565b6125f5565b34801561097a57600080fd5b5061049f6128a0565b34801561098f57600080fd5b5061049f61099e3660046148aa565b612bd1565b61049f6109b1366004614c7e565b612bde565b3480156109c257600080fd5b506109d66109d136600461482c565b61305b565b6040516103b29190614d06565b3480156109ef57600080fd5b5061049f6109fe36600461482c565b61326e565b348015610a0f57600080fd5b5061049f610a1e36600461482c565b613298565b348015610a2f57600080fd5b506104c1610a3e366004614d91565b6132f0565b348015610a4f57600080fd5b506103a6610a5e366004614e3c565b600092915050565b348015610a7257600080fd5b506103a6610a8136600461482c565b613390565b348015610a9257600080fd5b5061049f610aa136600461482c565b6133c4565b348015610ab257600080fd5b5061049f61343a565b60006001600160e01b031982166380ac58cd60e01b1480610aec57506001600160e01b03198216635b5e139f60e01b145b80610b0757506301ffc9a760e01b6001600160e01b03198316145b92915050565b6040805160808101825260008082526020808301828152838501838152606085018481526001600160a01b039788168552610104909352949092205494851683526001600160401b0360a086901c16905260ff60e185901c16905260e09290921c6001161515905290565b606060fb8054610b8790614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb390614e66565b8015610c005780601f10610bd557610100808354040283529160200191610c00565b820191906000526020600020905b815481529060010190602001808311610be357829003601f168201915b5050505050905090565b6001600160a01b038116600090815260fe602052604081205460ff16610c2f57600080fd5b506000919050565b60405162461bcd60e51b8152602060048201526008602482015267191a5cd8589b195960c21b60448201526064015b60405180910390fd5b6001600160a01b038116600090815260fe602052604081205460ff1615610ca657610c9982610b0d565b6020015160ff1692915050565b506003919050565b600260655403610cd05760405162461bcd60e51b8152600401610c6690614ea0565b600260655533600090815260fe602052604090205460ff16610d045760405162461bcd60e51b8152600401610c6690614ed7565b33600090815261010360205260408120805485908110610d2657610d26614f0e565b9060005260206000209060040201604051806080016040529081600082018054610d4f90614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054610d7b90614e66565b8015610dc85780601f10610d9d57610100808354040283529160200191610dc8565b820191906000526020600020905b815481529060010190602001808311610dab57829003601f168201915b505050505081526020016001820154815260200160028201548152602001600382015481525050905080602001518314610e145760405162461bcd60e51b8152600401610c6690614f24565b6000610e2382606001516135d8565b905080600001516001600160a01b0316836001600160a01b031614610e5a5760405162461bcd60e51b8152600401610c6690614f69565b6000610e7783610e693361361e565b6001600160401b03166132f0565b90508083604001818151610e8b9190614fcd565b90525033600090815261010360205260409020805484919088908110610eb357610eb3614f0e565b600091825260209091208251600490920201908190610ed2908261502e565b506020820151600182015560408201516002820155606090910151600390910155610efd338761363d565b610f068361392a565b610f10338261395b565b5050600160655550505050565b6000610f2833610b0d565b9050806020015160ff16600003610f515760405162461bcd60e51b8152600401610c6690614ed7565b610f75816000015182606001516001600160401b0316836020015160ff1685613a0e565b33600090815261010460205260409020555050565b6001600160a01b038116600090815260fe602052604081205460ff16610ffe5760405162461bcd60e51b815260206004820152602360248201527f6164647265737320686173206e6f74206d696e746564207468656972206574686044820152620c4def60eb1b6064820152608401610c66565b506001600160a01b031690565b611013613a32565b61010155565b6001600160a01b038116600090815260fe602052604081205460ff16156110565761104382610b0d565b606001516001600160401b031692915050565b506224ea00919050565b6001600160a01b037f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb1630036110a85760405162461bcd60e51b8152600401610c66906150ed565b7f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb6001600160a01b03166110da613a8c565b6001600160a01b0316146111005760405162461bcd60e51b8152600401610c6690615139565b61110981613aa8565b6040805160008082526020820190925261112591839190613ab0565b50565b611130613a32565b61010280546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b038116600090815261010360209081526040808320805482518185028101850190935280835260609493849084015b8282101561126b57838290600052602060002090600402016040518060800160405290816000820180546111bc90614e66565b80601f01602080910402602001604051908101604052809291908181526020018280546111e890614e66565b80156112355780601f1061120a57610100808354040283529160200191611235565b820191906000526020600020905b81548152906001019060200180831161121857829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190611189565b509293506001925050505b81518110156113665760005b818110156113535782818151811061129c5761129c614f0e565b6020026020010151602001518383815181106112ba576112ba614f0e565b60200260200101516020015111156113415760008383815181106112e0576112e0614f0e565b602002602001015190508382815181106112fc576112fc614f0e565b602002602001015184848151811061131657611316614f0e565b60200260200101819052508084838151811061133457611334614f0e565b6020026020010181905250505b8061134b81615185565b915050611282565b508061135e81615185565b915050611276565b50600081516001600160401b0381111561138257611382614a53565b6040519080825280602002602001820160405280156113ea57816020015b6040805160e0810182526060808252600060208084018290529383018190529082018190526080820181905260a0820181905260c082015282526000199092019101816113a05790505b50905061141760408051608081018252600080825260208201819052918101829052606081019190915290565b60005b8351811015611568576040805160e081018252606080825260006020830181905292820183905281018290526080810182905260a0810182905260c081019190915261148285838151811061147157611471614f0e565b6020026020010151606001516135d8565b925084828151811061149657611496614f0e565b602090810291909101015151815284518590839081106114b8576114b8614f0e565b6020026020010151602001518160200181815250508482815181106114df576114df614f0e565b6020908102919091018101516040908101518382015284516001600160a01b0316606080850191909152918501516001600160401b0316608084015284015160ff1660a083015283015162ffffff1660c08201528351819085908490811061154957611549614f0e565b602002602001018190525050808061156090615185565b91505061141a565b5090949350505050565b6001600160a01b037f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb1630036115ba5760405162461bcd60e51b8152600401610c66906150ed565b7f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb6001600160a01b03166115ec613a8c565b6001600160a01b0316146116125760405162461bcd60e51b8152600401610c6690615139565b61161b82613aa8565b61162782826001613ab0565b5050565b6000306001600160a01b037f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb16146116cb5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610c66565b5060008051602061548c83398151915290565b6001600160a01b038116600090815260fe6020526040812054829060ff16610b075760405162461bcd60e51b815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610c66565b610103602052816000526040600020818154811061176557600080fd5b90600052602060002090600402016000915091505080600001805461178990614e66565b80601f01602080910402602001604051908101604052809291908181526020018280546117b590614e66565b80156118025780601f106117d757610100808354040283529160200191611802565b820191906000526020600020905b8154815290600101906020018083116117e557829003601f168201915b5050505050908060010154908060020154908060030154905084565b6001600160a01b038116600090815260fe602052604081205460ff1615610c2f57506001919050565b61184f613a32565b6118596000613c20565b565b611863613a32565b61010055565b60026065540361188b5760405162461bcd60e51b8152600401610c6690614ea0565b6002606555600061189b33610b0d565b9050806020015160ff166000036118c45760405162461bcd60e51b8152600401610c6690614ed7565b336000908152610103602052604081208054869081106118e6576118e6614f0e565b906000526020600020906004020160405180608001604052908160008201805461190f90614e66565b80601f016020809104026020016040519081016040528092919081815260200182805461193b90614e66565b80156119885780601f1061195d57610100808354040283529160200191611988565b820191906000526020600020905b81548152906001019060200180831161196b57829003601f168201915b5050505050815260200160018201548152602001600282015481526020016003820154815250509050806020015184146119d45760405162461bcd60e51b8152600401610c6690614f24565b60006119e382606001516135d8565b905080600001516001600160a01b0316846001600160a01b031614611a1a5760405162461bcd60e51b8152600401610c6690614f69565b6000611a2983610e693361361e565b90504284606001518360200151611a40919061519e565b6001600160401b03161015611a6557611a6033836040015160ff1661363d565b611ab0565b33600090815261010360205260409020805482919089908110611a8a57611a8a614f0e565b90600052602060002090600402016002016000828254611aaa9190614fcd565b90915550505b611aba338261395b565b505060016065555050505050565b6000611ad333610b0d565b9050806020015160ff16600003611afc5760405162461bcd60e51b8152600401610c6690614ed7565b336000908152610103602052604090205415611b5a5760405162461bcd60e51b815260206004820152601860248201527f657468626f78206e6565647320746f20626520656d70747900000000000000006044820152606401610c66565b610f75816000015183836020015160ff168460400151613a0e565b600054610100900460ff1615808015611b955750600054600160ff909116105b80611baf5750303b158015611baf575060005460ff166001145b611c125760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610c66565b6000805460ff191660011790558015611c35576000805461ff0019166101001790555b611c3d613c72565b611c45613ca1565b60408051808201909152600681526508ae8d0c4def60d31b602082015260fb90611c6f908261502e565b5060408051808201909152600681526508aa890849eb60d31b602082015260fc90611c9a908261502e565b5066b1a2bc2ec5000060ff556109c46101005560fa6101015561010280546001600160a01b0319167340543d76fb35c60ff578b648d723e14ccab8b3901790558015611125576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a150565b6000818311611d735760405162461bcd60e51b815260206004820152601960248201527f6e65772073697a652073686f756c64206265206c6172676572000000000000006044820152606401610c66565b506000815b83811015611e0e5760038103611d9c5760ff54611d959083614fcd565b9150611dfc565b611da76003826151be565b611db3906127106152b5565b611dbe6003836151be565b61010054611dce90612710614fcd565b611dd891906152b5565b60ff54611de591906152c1565b611def91906152f6565b611df99083614fcd565b91505b80611e0681615185565b915050611d78565b5092915050565b606060fc8054610b8790614e66565b6001600160a01b038116600090815260fe602052604081205460ff1615611e5557611e4e82610b0d565b5192915050565b5090565b6001600160a01b03811660009081526101036020908152604080832080548251818502810185019093528083528493849084015b82821015611f6f5783829060005260206000209060040201604051806080016040529081600082018054611ec090614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054611eec90614e66565b8015611f395780601f10611f0e57610100808354040283529160200191611f39565b820191906000526020600020905b815481529060010190602001808311611f1c57829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190611e8d565b5050505090506000611f8084610b0d565b90506000825190506000806000846020015160ff16600014611faf5784606001516001600160401b0316611fb4565b6224ea005b905060005b8481101561200457611fe4878281518110611fd657611fd6614f0e565b6020026020010151836132f0565b9350611ff08484614fcd565b925080611ffc81615185565b915050611fb9565b506001600160a01b038816600090815261010560205260409020546120299083614fcd565b98975050505050505050565b600061204033610b0d565b9050806020015160ff166000036120695760405162461bcd60e51b8152600401610c6690614ed7565b600061207c83836020015160ff16611d22565b905034811461208a82613cd0565b906120a85760405162461bcd60e51b8152600401610c669190614897565b506120ca826000015183606001516001600160401b0316858560400151613a0e565b33600090815261010460205260408082209290925561010254915190916001600160a01b03169034905b60006040518083038185875af1925050503d8060008114612131576040519150601f19603f3d011682016040523d82523d6000602084013e612136565b606091505b505090508061214457600080fd5b50505050565b6001600160a01b038116600090815260fe602052604090205460609060ff1661217257600080fd5b81600061217e82611153565b905060006121a5836001600160a01b03166000908152610104602052604090205460e11c90565b60ff16905060006121b58461361e565b60fd54604051633a36a46560e01b81526001600160401b039290921692506001600160a01b031690633a36a465906121f790879087908790879060040161530a565b600060405180830381865afa158015612214573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261223c9190810190615341565b9695505050505050565b6002606554036122685760405162461bcd60e51b8152600401610c6690614ea0565b600260655533600090815260fe602052604090205460ff1661229c5760405162461bcd60e51b8152600401610c6690614ed7565b33600090815261010360209081526040808320805482518185028101850190935280835284938493929190849084015b828210156123ae57838290600052602060002090600402016040518060800160405290816000820180546122ff90614e66565b80601f016020809104026020016040519081016040528092919081815260200182805461232b90614e66565b80156123785780601f1061234d57610100808354040283529160200191612378565b820191906000526020600020905b81548152906001019060200180831161235b57829003601f168201915b505050505081526020016001820154815260200160028201548152602001600382015481525050815260200190600101906122cc565b5050505090506000815190506000816001600160401b038111156123d4576123d4614a53565b6040519080825280602002602001820160405280156123fd578160200160208202803683370190505b50905060008061240c3361361e565b6001600160401b0316905060005b8481101561250657600086828151811061243657612436614f0e565b6020026020010151905061244a81846132f0565b98506124568989614fcd565b3360009081526101036020526040902080549199508a918490811061247d5761247d614f0e565b9060005260206000209060040201600201600082825461249d9190614fcd565b909155505060608101514290849060a01c6001600160401b03166124c19190614fcd565b10156124f357818585815181106124da576124da614f0e565b6020908102919091010152836124ef81615185565b9450505b50806124fe81615185565b91505061241a565b506000826001600160401b0381111561252157612521614a53565b60405190808252806020026020018201604052801561254a578160200160208202803683370190505b50905060005b81518110156125a25784818151811061256b5761256b614f0e565b602002602001015182828151811061258557612585614f0e565b60209081029190910101528061259a81615185565b915050612550565b5033600090815261010560205260409020546125be9088614fcd565b33600081815261010560205260408120559097506125dc9082613dd8565b6125e6338861395b565b50506001606555505050505050565b6002606554036126175760405162461bcd60e51b8152600401610c6690614ea0565b60026065556001600160a01b038116600090815260fe602052604090205460ff16156126855760405162461bcd60e51b815260206004820152601d60248201527f657468626f78206e6565647320746f206265206e6f74206d696e7465640000006044820152606401610c66565b6001600160a01b0381166000908152610103602052604081208054859081106126b0576126b0614f0e565b90600052602060002090600402016040518060800160405290816000820180546126d990614e66565b80601f016020809104026020016040519081016040528092919081815260200182805461270590614e66565b80156127525780601f1061272757610100808354040283529160200191612752565b820191906000526020600020905b81548152906001019060200180831161273557829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505090508060200151831461279e5760405162461bcd60e51b8152600401610c6690614f24565b60006127ad82606001516135d8565b80519091506001600160a01b0316331461281e5760405162461bcd60e51b815260206004820152602c60248201527f6d65737361676520617420696e64657820646f6573206e6f74206d617463682060448201526b796f7572206164647265737360a01b6064820152608401610c66565b600081602001516001600160401b03164261283991906151be565b90506224ea00811161288d5760405162461bcd60e51b815260206004820152601b60248201527f6d657373616765206e6565647320746f206265206578706972656400000000006044820152606401610c66565b612897848761363d565b610f108361392a565b6002606554036128c25760405162461bcd60e51b8152600401610c6690614ea0565b600260655533600090815260fe602052604090205460ff166128f65760405162461bcd60e51b8152600401610c6690614ed7565b33600090815261010360209081526040808320805482518185028101850190935280835284938493929190849084015b82821015612a08578382906000526020600020906004020160405180608001604052908160008201805461295990614e66565b80601f016020809104026020016040519081016040528092919081815260200182805461298590614e66565b80156129d25780601f106129a7576101008083540402835291602001916129d2565b820191906000526020600020905b8154815290600101906020018083116129b557829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190612926565b5050825192935060009150505b81811015612ba257612a43838281518110612a3257612a32614f0e565b6020026020010151610e693361361e565b9450612a4f8585614fcd565b336000908152610103602052604090208054919550869183908110612a7657612a76614f0e565b90600052602060002090600402016002016000828254612a969190614fcd565b9091555050336000908152610103602052604090208054612b90919083908110612ac257612ac2614f0e565b9060005260206000209060040201604051806080016040529081600082018054612aeb90614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054612b1790614e66565b8015612b645780601f10612b3957610100808354040283529160200191612b64565b820191906000526020600020905b815481529060010190602001808311612b4757829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505061392a565b80612b9a81615185565b915050612a15565b5033600090815261010360205260408120612bbc91614744565b612bc6338461395b565b505060016065555050565b612bd9613a32565b60ff55565b600260655403612c005760405162461bcd60e51b8152600401610c6690614ea0565b60026065556001600160a01b037f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb163003612c4d5760405162461bcd60e51b8152600401610c66906150ed565b7f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb6001600160a01b0316612c7f613a8c565b6001600160a01b031614612ca55760405162461bcd60e51b8152600401610c6690615139565b608d8210612ce85760405162461bcd60e51b815260206004820152601060248201526f6d65737361676520746f6f206c6f6e6760801b6044820152606401610c66565b6000612cf385610b0d565b60208101519091506003906224ea009060ff1615612d2657826020015160ff16915082606001516001600160401b031690505b826040015115612d6b5760405162461bcd60e51b815260206004820152601060248201526f195d1a189bde081a5cc81b1bd8dad95960821b6044820152606401610c66565b612710341180612d79575034155b612dc55760405162461bcd60e51b815260206004820152601760248201527f6d6573736167652076616c756520696e636f72726563740000000000000000006044820152606401610c66565b838114612e0d5760405162461bcd60e51b81526020600482015260166024820152751b595cdcd859d948191c9a5c081a5b98dbdc9c9958dd60521b6044820152606401610c66565b6001600160a01b03871660009081526101036020908152604080832080548251818502810185019093528083529192909190849084015b82821015612f265783829060005260206000209060040201604051806080016040529081600082018054612e7790614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054612ea390614e66565b8015612ef05780601f10612ec557610100808354040283529160200191612ef0565b820191906000526020600020905b815481529060010190602001808311612ed357829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190612e44565b50508251929350505083811015612f4a57612f4589338a8a3486614108565b613042565b600080612f588484346141ee565b915091508115612fff576000848281518110612f7657612f76614f0e565b60200260200101519050876020015160ff16600014612fe2576000612f9b82886132f0565b90508082604001818151612faf9190614fcd565b9052506001600160a01b038d166000908152610105602052604081208054839290612fdb908490614fcd565b9091555050505b612feb8161392a565b612ff98c338d8d348761428b565b5061303f565b60405162461bcd60e51b81526020600482015260156024820152746d6573736167652076616c756520746f6f206c6f7760581b6044820152606401610c66565b50505b61304b34614382565b5050600160655550505050505050565b6001600160a01b038116600090815261010360209081526040808320805482518185028101850190935280835260609493849084015b8282101561317357838290600052602060002090600402016040518060800160405290816000820180546130c490614e66565b80601f01602080910402602001604051908101604052809291908181526020018280546130f090614e66565b801561313d5780601f106131125761010080835404028352916020019161313d565b820191906000526020600020905b81548152906001019060200180831161312057829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190613091565b509293506001925050505b8151811015611e0e5760005b8181101561325b578281815181106131a4576131a4614f0e565b6020026020010151602001518383815181106131c2576131c2614f0e565b60200260200101516020015111156132495760008383815181106131e8576131e8614f0e565b6020026020010151905083828151811061320457613204614f0e565b602002602001015184848151811061321e5761321e614f0e565b60200260200101819052508084838151811061323c5761323c614f0e565b6020026020010181905250505b8061325381615185565b91505061318a565b508061326681615185565b91505061317e565b613276613a32565b60fd80546001600160a01b0319166001600160a01b0392909216919091179055565b60006132a333610b0d565b9050806020015160ff166000036132cc5760405162461bcd60e51b8152600401610c6690614ed7565b610f758282606001516001600160401b0316836020015160ff168460400151613a0e565b600080613301846060015160a01c90565b613314906001600160401b0316426151be565b90506001811015613329576000915050610b07565b828111156133425761333a84614436565b915050610b07565b6000836133508360646152c1565b61335a91906152f6565b9050600060648261336a88614450565b61337491906152c1565b61337e91906152f6565b905085604001518161223c91906151be565b6001600160a01b038116600090815260fe602052604081205460ff1615610c2f576133ba82610b0d565b6040015192915050565b6133cc613a32565b6001600160a01b0381166134315760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610c66565b61112581613c20565b6001600160a01b037f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb1630036134825760405162461bcd60e51b8152600401610c66906150ed565b7f000000000000000000000000750e17f92ebb925adaabcb87850660a160fd54bb6001600160a01b03166134b4613a8c565b6001600160a01b0316146134da5760405162461bcd60e51b8152600401610c6690615139565b33600081815260fe602052604090205460ff16156135325760405162461bcd60e51b8152602060048201526015602482015274195d1a189bde08185b1c9958591e481b5a5b9d1959605a1b6044820152606401610c66565b6001600160a01b038116600090815260fe60205260408120805460ff191660011790556135689082906224ea0090600390613a0e565b6001600160a01b03821660008181526101046020526040808220939093559151909182917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a46001600160a01b038116600090815261010360205260409020541561112557611125612246565b604080516080810182526001600160a01b038316815260a083901c6001600160401b0316602082015260e083901c60ff169181019190915260e89190911c606082015290565b6001600160a01b03166000908152610104602052604090205460a01c90565b6001600160a01b03821660009081526101036020908152604080832080548251818502810185019093528083529192909190849084015b8282101561375657838290600052602060002090600402016040518060800160405290816000820180546136a790614e66565b80601f01602080910402602001604051908101604052809291908181526020018280546136d390614e66565b80156137205780601f106136f557610100808354040283529160200191613720565b820191906000526020600020905b81548152906001019060200180831161370357829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190613674565b505050509050806001825161376b91906151be565b8151811061377b5761377b614f0e565b60200260200101516101036000856001600160a01b03166001600160a01b0316815260200190815260200160002083815481106137ba576137ba614f0e565b6000918252602090912082516004909202019081906137d9908261502e565b50602082015181600101556040820151816002015560608201518160030155905050600061384e6101036000866001600160a01b03166001600160a01b03168152602001908152602001600020848154811061383757613837614f0e565b9060005260206000209060040201600301546135d8565b9050613876816000015182602001516001600160401b031685846060015162ffffff1661448d565b6001600160a01b0385166000908152610103602052604090208054859081106138a1576138a1614f0e565b9060005260206000209060040201600301819055506101036000856001600160a01b03166001600160a01b031681526020019081526020016000208054806138eb576138eb6153ae565b6000828152602081206000199092019160048302019061390b8282614765565b5060006001820181905560028201819055600390910155905550505050565b600061393582614436565b90506000613944836060015190565b90506000816001600160a01b0316836040516120f4565b6001600160a01b0382811660009081526101046020526040808220549051909283169084908381818185875af1925050503d80600081146139b8576040519150601f19603f3d011682016040523d82523d6000602084013e6139bd565b606091505b50509050806121445760405162461bcd60e51b815260206004820152601760248201527f636f756c64206e6f742070617920726563697069656e740000000000000000006044820152606401610c66565b60e01b60a09290921b9190911760e19190911b176001600160a01b03919091161790565b6033546001600160a01b031633146118595760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610c66565b60008051602061548c833981519152546001600160a01b031690565b611125613a32565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615613ae857613ae3836144b1565b505050565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015613b42575060408051601f3d908101601f19168201909252613b3f918101906153c4565b60015b613ba55760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610c66565b60008051602061548c8339815191528114613c145760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610c66565b50613ae383838361454d565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff16613c995760405162461bcd60e51b8152600401610c66906153dd565b611859614572565b600054610100900460ff16613cc85760405162461bcd60e51b8152600401610c66906153dd565b6118596145a2565b606081600003613cf75750506040805180820190915260018152600360fc1b602082015290565b8160005b8115613d215780613d0b81615185565b9150613d1a9050600a836152f6565b9150613cfb565b6000816001600160401b03811115613d3b57613d3b614a53565b6040519080825280601f01601f191660200182016040528015613d65576020820181803683370190505b5090505b8415613dd057613d7a6001836151be565b9150613d87600a86615428565b613d92906030614fcd565b60f81b818381518110613da757613da7614f0e565b60200101906001600160f81b031916908160001a905350613dc9600a866152f6565b9450613d69565b949350505050565b6001600160a01b03821660009081526101036020908152604080832080548251818502810185019093528083529192909190849084015b82821015613ef15783829060005260206000209060040201604051806080016040529081600082018054613e4290614e66565b80601f0160208091040260200160405190810160405280929190818152602001828054613e6e90614e66565b8015613ebb5780601f10613e9057610100808354040283529160200191613ebb565b820191906000526020600020905b815481529060010190602001808311613e9e57829003601f168201915b50505050508152602001600182015481526020016002820154815260200160038201548152505081526020019060010190613e0f565b5050845192935050505b80156121445781518114614095576000613f2083838151811061147157611471614f0e565b90508260018451613f3191906151be565b81518110613f4157613f41614f0e565b60200260200101516101036000876001600160a01b03166001600160a01b0316815260200190815260200160002085600185613f7d91906151be565b81518110613f8d57613f8d614f0e565b602002602001015181548110613fa557613fa5614f0e565b600091825260209091208251600490920201908190613fc4908261502e565b50602082015181600101556040820151816002015560608201518160030155905050614031816000015182602001516001600160401b03168660018661400a91906151be565b8151811061401a5761401a614f0e565b6020026020010151846060015162ffffff1661448d565b6001600160a01b038616600090815261010360205260409020856140566001866151be565b8151811061406657614066614f0e565b60200260200101518154811061407e5761407e614f0e565b906000526020600020906004020160030181905550505b6001600160a01b0384166000908152610103602052604090208054806140bd576140bd6153ae565b600082815260208120600019909201916004830201906140dd8282614765565b50600060018201819055600282018190556003909101559055806141008161543c565b915050613efb565b6141336040518060800160405280606081526020016000815260200160008152602001600081525090565b6141428642846101015461448d565b6060820152604080516020601f87018190048102820181019092528581529086908690819084018382808284376000920182905250938552505050602080830185905260408084018390526001600160a01b038a1683526101038252822080546001810182559083529120825183926004029091019081906141c4908261502e565b50602082015181600101556040820151816002015560608201518160030155505050505050505050565b6000806000808660008151811061420757614207614f0e565b6020026020010151602001519050600080600090505b8781101561427d5788818151811061423757614237614f0e565b602002602001015160200151915082821015614254578093508192505b8515801561426157508187115b1561426b57600195505b8061427581615185565b91505061421d565b509192505050935093915050565b6142b66040518060800160405280606081526020016000815260200160008152602001600081525090565b6142c58642846101015461448d565b6060820152604080516020601f87018190048102820181019092528581529086908690819084018382808284376000920182905250938552505050602080830185905260408084018390526001600160a01b038a168352610103909152902080548291908490811061433957614339614f0e565b600091825260209091208251600490920201908190614358908261502e565b50602082015160018201556040820151600282015560609091015160039091015550505050505050565b61010254610101546000916001600160a01b031690612710906143a590856152c1565b6143af91906152f6565b604051600081818185875af1925050503d80600081146143eb576040519150601f19603f3d011682016040523d82523d6000602084013e6143f0565b606091505b50509050806116275760405162461bcd60e51b8152602060048201526012602482015271636f756c64206e6f7420706179206665657360701b6044820152606401610c66565b6000816040015161444683614450565b610b0791906151be565b6000612710614463836060015160e81c90565b61446f90612710615453565b62ffffff16836020015161448391906152c1565b610b0791906152f6565b60a083901b60e083901b1760e882901b176001600160a01b03851617949350505050565b6001600160a01b0381163b61451e5760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610c66565b60008051602061548c83398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b614556836145d0565b6000825111806145635750805b15613ae3576121448383614610565b600054610100900460ff166145995760405162461bcd60e51b8152600401610c66906153dd565b61185933613c20565b600054610100900460ff166145c95760405162461bcd60e51b8152600401610c66906153dd565b6001606555565b6145d9816144b1565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6146785760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610c66565b600080846001600160a01b031684604051614693919061546f565b600060405180830381855af49150503d80600081146146ce576040519150601f19603f3d011682016040523d82523d6000602084013e6146d3565b606091505b50915091506146fb82826040518060600160405280602781526020016154ac60279139614704565b95945050505050565b6060831561471357508161473d565b8251156147235782518084602001fd5b8160405162461bcd60e51b8152600401610c669190614897565b9392505050565b5080546000825560040290600052602060002090810190611125919061479f565b50805461477190614e66565b6000825580601f10614781575050565b601f01602090049060005260206000209081019061112591906147d1565b80821115611e555760006147b38282614765565b5060006001820181905560028201819055600382015560040161479f565b5b80821115611e5557600081556001016147d2565b6000602082840312156147f857600080fd5b81356001600160e01b03198116811461473d57600080fd5b80356001600160a01b038116811461482757600080fd5b919050565b60006020828403121561483e57600080fd5b61473d82614810565b60005b8381101561486257818101518382015260200161484a565b50506000910152565b60008151808452614883816020860160208601614847565b601f01601f19169290920160200192915050565b60208152600061473d602083018461486b565b6000602082840312156148bc57600080fd5b5035919050565b600080604083850312156148d657600080fd5b6148df83614810565b946020939093013593505050565b60008060006060848603121561490257600080fd5b833592506020840135915061491960408501614810565b90509250925092565b8035801515811461482757600080fd5b60006020828403121561494457600080fd5b61473d82614922565b60008060006060848603121561496257600080fd5b61496b84614810565b925061497960208501614810565b9150604084013590509250925092565b600081518084526020808501808196508360051b8101915082860160005b85811015614a33578284038952815160e081518187526149c98288018261486b565b83890151888a0152604080850151908901526060808501516001600160a01b0316908901526080808501516001600160401b03169089015260a08085015160ff169089015260c09384015162ffffff169390970192909252505097840197908401906001016149a7565b5091979650505050505050565b60208152600061473d6020830184614989565b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b0381118282101715614a8b57614a8b614a53565b60405290565b604051601f8201601f191681016001600160401b0381118282101715614ab957614ab9614a53565b604052919050565b60006001600160401b03821115614ada57614ada614a53565b50601f01601f191660200190565b6000614afb614af684614ac1565b614a91565b9050828152838383011115614b0f57600080fd5b828260208301376000602084830101529392505050565b600082601f830112614b3757600080fd5b61473d83833560208501614ae8565b60008060408385031215614b5957600080fd5b614b6283614810565b915060208301356001600160401b03811115614b7d57600080fd5b614b8985828601614b26565b9150509250929050565b608081526000614ba6608083018761486b565b6020830195909552506040810192909252606090910152919050565b60008060408385031215614bd557600080fd5b50508035926020909101359150565b60008060408385031215614bf757600080fd5b614c0083614810565b9150614c0e60208401614922565b90509250929050565b60008060008060808587031215614c2d57600080fd5b614c3685614810565b9350614c4460208601614810565b92506040850135915060608501356001600160401b03811115614c6657600080fd5b614c7287828801614b26565b91505092959194509250565b60008060008060608587031215614c9457600080fd5b614c9d85614810565b935060208501356001600160401b0380821115614cb957600080fd5b818701915087601f830112614ccd57600080fd5b813581811115614cdc57600080fd5b886020828501011115614cee57600080fd5b95986020929092019750949560400135945092505050565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015614d8357603f19898403018552815160808151818652614d538287018261486b565b838b0151878c0152898401518a880152606093840151939096019290925250509386019390860190600101614d2d565b509098975050505050505050565b60008060408385031215614da457600080fd5b82356001600160401b0380821115614dbb57600080fd5b9084019060808287031215614dcf57600080fd5b614dd7614a69565b823582811115614de657600080fd5b83019150601f82018713614df957600080fd5b614e0887833560208501614ae8565b8152602083013560208201526040830135604082015260608301356060820152809450505050602083013590509250929050565b60008060408385031215614e4f57600080fd5b614e5883614810565b9150614c0e60208401614810565b600181811c90821680614e7a57607f821691505b602082108103614e9a57634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526019908201527f657468626f78206e6565647320746f206265206d696e74656400000000000000604082015260600190565b634e487b7160e01b600052603260045260246000fd5b60208082526025908201527f6d65737361676520617420696e64657820646f6573206e6f74206d617463682060408201526476616c756560d81b606082015260800190565b6020808252602e908201527f6d65737361676520617420696e64657820646f6573206e6f74206d617463682060408201526d73656e646572206164647265737360901b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b80820180821115610b0757610b07614fb7565b601f821115613ae357600081815260208120601f850160051c810160208610156150075750805b601f850160051c820191505b8181101561502657828155600101615013565b505050505050565b81516001600160401b0381111561504757615047614a53565b61505b816150558454614e66565b84614fe0565b602080601f83116001811461509057600084156150785750858301515b600019600386901b1c1916600185901b178555615026565b600085815260208120601f198616915b828110156150bf578886015182559484019460019091019084016150a0565b50858210156150dd5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b60006001820161519757615197614fb7565b5060010190565b6001600160401b03818116838216019080821115611e0e57611e0e614fb7565b81810381811115610b0757610b07614fb7565b600181815b8085111561520c5781600019048211156151f2576151f2614fb7565b808516156151ff57918102915b93841c93908002906151d6565b509250929050565b60008261522357506001610b07565b8161523057506000610b07565b816001811461524657600281146152505761526c565b6001915050610b07565b60ff84111561526157615261614fb7565b50506001821b610b07565b5060208310610133831016604e8410600b841016171561528f575081810a610b07565b61529983836151d1565b80600019048211156152ad576152ad614fb7565b029392505050565b600061473d8383615214565b60008160001904831182151516156152db576152db614fb7565b500290565b634e487b7160e01b600052601260045260246000fd5b600082615305576153056152e0565b500490565b6001600160a01b038516815260806020820181905260009061532e90830186614989565b6040830194909452506060015292915050565b60006020828403121561535357600080fd5b81516001600160401b0381111561536957600080fd5b8201601f8101841361537a57600080fd5b8051615388614af682614ac1565b81815285602083850101111561539d57600080fd5b6146fb826020830160208601614847565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156153d657600080fd5b5051919050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b600082615437576154376152e0565b500690565b60008161544b5761544b614fb7565b506000190190565b62ffffff828116828216039080821115611e0e57611e0e614fb7565b60008251615481818460208701614847565b919091019291505056fe360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a22f6c182cf11ce955a1ef6d5ae10f80d419c40143c7ed9eac30d0e47c6a0b7564736f6c63430008100033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.