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
Contract Name:
TokensAndRamping
Compiler Version
v0.6.12+commit.27d51765
Contract Source Code (Solidity Standard Json-Input format)
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../interactions/StarkExForcedActionState.sol"; import "../../components/ERC721Receiver.sol"; import "../../components/ERC1155Receiver.sol"; import "../../components/Freezable.sol"; import "../../components/KeyGetters.sol"; import "../../components/TokenRegister.sol"; import "../../components/TokenTransfers.sol"; import "../../components/MainGovernance.sol"; import "../../interactions/AcceptModifications.sol"; import "../../interactions/Blocklist.sol"; import "../../interactions/Deposits.sol"; import "../../interactions/TokenAssetData.sol"; import "../../interactions/TokenQuantization.sol"; import "../../interactions/Withdrawals.sol"; import "../../interfaces/SubContractor.sol"; contract TokensAndRamping is ERC1155Receiver, ERC721Receiver, SubContractor, Freezable, MainGovernance, AcceptModifications, StarkExForcedActionState, TokenAssetData, TokenQuantization, TokenRegister, TokenTransfers, KeyGetters, Deposits, Withdrawals, Blocklist { function initialize( bytes calldata /* data */ ) external override { revert("NOT_IMPLEMENTED"); } function initializerSize() external view override returns (uint256) { return 0; } function validatedSelectors() external pure override returns (bytes4[] memory selectors) { uint256 len_ = 7; uint256 index_ = 0; selectors = new bytes4[](len_); selectors[index_++] = Deposits.depositCancel.selector; selectors[index_++] = Deposits.depositWithTokenIdReclaim.selector; selectors[index_++] = Deposits.depositReclaim.selector; selectors[index_++] = Withdrawals.withdraw.selector; selectors[index_++] = Withdrawals.withdrawAndMint.selector; selectors[index_++] = Withdrawals.withdrawWithTokenId.selector; selectors[index_++] = Blocklist.addToBlockedList.selector; require(index_ == len_, "INCORRECT_SELECTORS_ARRAY_LENGTH"); } function identify() external pure override returns (string memory) { return "StarkWare_TokensAndRamping_2024_3"; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../libraries/LibConstants.sol"; import "../interfaces/MAcceptModifications.sol"; import "../interfaces/MTokenQuantization.sol"; import "../components/MainStorage.sol"; /* Interface containing actions a verifier can invoke on the state. The contract containing the state should implement these and verify correctness. */ abstract contract AcceptModifications is MainStorage, LibConstants, MAcceptModifications, MTokenQuantization { event LogWithdrawalAllowed( uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount ); event LogNftWithdrawalAllowed(uint256 ownerKey, uint256 assetId); event LogAssetWithdrawalAllowed(uint256 ownerKey, uint256 assetId, uint256 quantizedAmount); event LogMintableWithdrawalAllowed(uint256 ownerKey, uint256 assetId, uint256 quantizedAmount); /* Transfers funds from the on-chain deposit area to the off-chain area. Implemented in the Deposits contracts. */ function acceptDeposit( uint256 ownerKey, uint256 vaultId, uint256 assetId, uint256 quantizedAmount ) internal virtual override { // Fetch deposit. require( pendingDeposits[ownerKey][assetId][vaultId] >= quantizedAmount, "DEPOSIT_INSUFFICIENT" ); // Subtract accepted quantized amount. pendingDeposits[ownerKey][assetId][vaultId] -= quantizedAmount; } /* Transfers funds from the off-chain area to the on-chain withdrawal area. */ function allowWithdrawal( uint256 ownerKey, uint256 assetId, uint256 quantizedAmount ) internal override { // Fetch withdrawal. uint256 withdrawal = pendingWithdrawals[ownerKey][assetId]; // Add accepted quantized amount. withdrawal += quantizedAmount; require(withdrawal >= quantizedAmount, "WITHDRAWAL_OVERFLOW"); // Store withdrawal. pendingWithdrawals[ownerKey][assetId] = withdrawal; // Log event. uint256 presumedAssetType = assetId; if (registeredAssetType[presumedAssetType]) { emit LogWithdrawalAllowed( ownerKey, presumedAssetType, fromQuantized(presumedAssetType, quantizedAmount), quantizedAmount ); } else if (assetId == ((assetId & MASK_240) | MINTABLE_ASSET_ID_FLAG)) { emit LogMintableWithdrawalAllowed(ownerKey, assetId, quantizedAmount); } else { // Default case is Non-Mintable ERC721 or ERC1155 asset id. // In ERC721 and ERC1155 cases, assetId is not the assetType. require(assetId == assetId & MASK_250, "INVALID_ASSET_ID"); // If withdrawal amount is 1, the asset could be either NFT or SFT. In that case, both // NFT and general events will be emitted so that the listened for event is captured. // When withdrawal is greater than 1, it must be SFT and only one event will be emitted. if (withdrawal <= 1) { emit LogNftWithdrawalAllowed(ownerKey, assetId); } emit LogAssetWithdrawalAllowed(ownerKey, assetId, quantizedAmount); } } // Verifier authorizes withdrawal. function acceptWithdrawal( uint256 ownerKey, uint256 assetId, uint256 quantizedAmount ) internal virtual override { allowWithdrawal(ownerKey, assetId, quantizedAmount); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../components/MainStorage.sol"; import "../libraries/LibConstants.sol"; /* Calculation action hash for the various forced actions in a generic manner. */ contract ActionHash is MainStorage, LibConstants { function getActionHash(string memory actionName, bytes memory packedActionParameters) internal pure returns (bytes32 actionHash) { actionHash = keccak256(abi.encodePacked(actionName, packedActionParameters)); } function setActionHash(bytes32 actionHash, bool premiumCost) internal { // The rate of forced trade requests is restricted. // First restriction is by capping the number of requests in a block. // User can override this cap by requesting with a permium flag set, // in this case, the gas cost is high (~1M) but no "technical" limit is set. // However, the high gas cost creates an obvious limitation due to the block gas limit. if (premiumCost) { for (uint256 i = 0; i < 21129; i++) {} } else { require( forcedRequestsInBlock[block.number] < MAX_FORCED_ACTIONS_REQS_PER_BLOCK, "MAX_REQUESTS_PER_BLOCK_REACHED" ); forcedRequestsInBlock[block.number] += 1; } forcedActionRequests[actionHash] = block.timestamp; actionHashList.push(actionHash); } function getActionCount() external view returns (uint256) { return actionHashList.length; } function getActionHashByIndex(uint256 actionIndex) external view returns (bytes32) { require(actionIndex < actionHashList.length, "ACTION_INDEX_TOO_HIGH"); return actionHashList[actionIndex]; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../components/MainStorage.sol"; import "../interfaces/MBlocklist.sol"; abstract contract Blocklist is MainStorage, MBlocklist { // NOLINTNEXTLINE: external-function. function isBlockListed(uint256 ownerKey) public view override returns (bool) { return blockListed[ownerKey]; } function addToBlockedList(uint256 ownerKey) public override onlyBlockAdmin { if (!isBlockListed(ownerKey)) { emit BlockPlaced(ownerKey); } blockListed[ownerKey] = true; } function removeFromBlockedList(uint256 ownerKey) public override onlyBlockAdmin { if (isBlockListed(ownerKey)) { emit BlockReleased(ownerKey); } blockListed[ownerKey] = false; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; /* Common Utility librarries. I. Addresses (extending address). */ library Addresses { function isContract(address account) internal view returns (bool) { uint256 size; assembly { size := extcodesize(account) } return size > 0; } function performEthTransfer(address recipient, uint256 amount) internal { (bool success, ) = recipient.call{value: amount}(""); // NOLINT: low-level-calls. require(success, "ETH_TRANSFER_FAILED"); } /* Safe wrapper around ERC20/ERC721 calls. This is required because many deployed ERC20 contracts don't return a value. See https://github.com/ethereum/solidity/issues/4116. */ function safeTokenContractCall(address tokenAddress, bytes memory callData) internal { require(isContract(tokenAddress), "BAD_TOKEN_ADDRESS"); // NOLINTNEXTLINE: low-level-calls. (bool success, bytes memory returndata) = tokenAddress.call(callData); require(success, string(returndata)); if (returndata.length > 0) { require(abi.decode(returndata, (bool)), "TOKEN_OPERATION_FAILED"); } } /* Validates that the passed contract address is of a real contract, and that its id hash (as infered fromn identify()) matched the expected one. */ function validateContractId(address contractAddress, bytes32 expectedIdHash) internal { require(isContract(contractAddress), "ADDRESS_NOT_CONTRACT"); (bool success, bytes memory returndata) = contractAddress.call( // NOLINT: low-level-calls. abi.encodeWithSignature("identify()") ); require(success, "FAILED_TO_IDENTIFY_CONTRACT"); string memory realContractId = abi.decode(returndata, (string)); require( keccak256(abi.encodePacked(realContractId)) == expectedIdHash, "UNEXPECTED_CONTRACT_IDENTIFIER" ); } } /* II. StarkExTypes - Common data types. */ library StarkExTypes { // Structure representing a list of verifiers (validity/availability). // A statement is valid only if all the verifiers in the list agree on it. // Adding a verifier to the list is immediate - this is used for fast resolution of // any soundness issues. // Removing from the list is time-locked, to ensure that any user of the system // not content with the announced removal has ample time to leave the system before it is // removed. struct ApprovalChainData { address[] list; // Represents the time after which the verifier with the given address can be removed. // Removal of the verifier with address A is allowed only in the case the value // of unlockedForRemovalTime[A] != 0 and unlockedForRemovalTime[A] < (current time). mapping(address => uint256) unlockedForRemovalTime; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../libraries/LibConstants.sol"; import "../interfaces/MAcceptModifications.sol"; import "../interfaces/MDeposits.sol"; import "../interfaces/MTokenQuantization.sol"; import "../interfaces/MTokenAssetData.sol"; import "../interfaces/MFreezable.sol"; import "../interfaces/MKeyGetters.sol"; import "../interfaces/MTokenTransfers.sol"; import "../components/MainStorage.sol"; /** For a user to perform a deposit to the contract two calls need to take place: 1. A call to an ERC20 contract, authorizing this contract to transfer funds on behalf of the user. 2. A call to :sol:func:`deposit` indicating the starkKey, amount, asset type and target vault ID to which to send the deposit. The amount should be quantized, according to the specific quantization defined for the asset type. The result of the operation, assuming all requirements are met, is that an amount of ERC20 tokens equaling the amount specified in the :sol:func:`deposit` call times the quantization factor is transferred on behalf of the user to the contract. In addition, the contract adds the funds to an accumulator of pending deposits for the provided user, asset ID and vault ID. Once a deposit is made, the exchange may include it in a proof which will result in addition of the amount(s) deposited to the off-chain vault with the specified ID. When the contract receives such valid proof, it deducts the transfered funds from the pending deposits for the specified Stark key, asset ID and vault ID. The exchange will not be able to move the deposited funds to the off-chain vault if the Stark key is not registered in the system. Until that point, the user may cancel the deposit by performing a time-locked cancel-deposit operation consisting of two calls: 1. A call to :sol:func:`depositCancel`, setting a timer to enable reclaiming the deposit. Until this timer expires the user cannot reclaim funds as the exchange may still be processing the deposit for inclusion in the off chain vault. 2. A call to :sol:func:`depositReclaim`, to perform the actual transfer of funds from the contract back to the ERC20 contract. This will only succeed if the timer set in the previous call has expired. The result should be the transfer of all funds not accounted for in proofs for off-chain inclusion, back to the user account on the ERC20 contract. Calling depositCancel and depositReclaim can only be done via an ethKey that is associated with that vault's starkKey. This is enforced by the contract. */ abstract contract Deposits is MainStorage, LibConstants, MAcceptModifications, MDeposits, MTokenQuantization, MTokenAssetData, MFreezable, MKeyGetters, MTokenTransfers { event LogDeposit( address depositorEthKey, uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount ); event LogNftDeposit( address depositorEthKey, uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 tokenId, uint256 assetId ); event LogDepositWithTokenId( address depositorEthKey, uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 tokenId, uint256 assetId, uint256 nonQuantizedAmount, uint256 quantizedAmount ); event LogDepositCancel(uint256 starkKey, uint256 vaultId, uint256 assetId); event LogDepositCancelReclaimed( uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount ); event LogDepositNftCancelReclaimed( uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 tokenId, uint256 assetId ); event LogDepositWithTokenIdCancelReclaimed( uint256 starkKey, uint256 vaultId, uint256 assetType, uint256 tokenId, uint256 assetId, uint256 nonQuantizedAmount, uint256 quantizedAmount ); function getDepositBalance( uint256 starkKey, uint256 assetId, uint256 vaultId ) external view returns (uint256) { uint256 presumedAssetType = assetId; return fromQuantized(presumedAssetType, pendingDeposits[starkKey][assetId][vaultId]); } function getQuantizedDepositBalance( uint256 starkKey, uint256 assetId, uint256 vaultId ) external view returns (uint256) { return pendingDeposits[starkKey][assetId][vaultId]; } function depositNft( uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 tokenId ) external notFrozen { require(isERC721(assetType), "NOT_ERC721_TOKEN"); depositWithTokenId(starkKey, assetType, tokenId, vaultId, 1); } function depositERC1155( uint256 starkKey, uint256 assetType, uint256 tokenId, uint256 vaultId, uint256 quantizedAmount ) external notFrozen { require(isERC1155(assetType), "NOT_ERC1155_TOKEN"); depositWithTokenId(starkKey, assetType, tokenId, vaultId, quantizedAmount); } function depositStateUpdate( uint256 starkKey, uint256 assetId, uint256 vaultId, uint256 quantizedAmount ) private returns (uint256) { // Checks for overflow and updates the pendingDeposits balance. uint256 vaultBalance = pendingDeposits[starkKey][assetId][vaultId]; vaultBalance += quantizedAmount; require(vaultBalance >= quantizedAmount, "DEPOSIT_OVERFLOW"); pendingDeposits[starkKey][assetId][vaultId] = vaultBalance; // Disable the cancellationRequest timeout when users deposit into their own account. if ( isMsgSenderKeyOwner(starkKey) && cancellationRequests[starkKey][assetId][vaultId] != 0 ) { delete cancellationRequests[starkKey][assetId][vaultId]; } // Returns the updated vault balance. return vaultBalance; } function depositWithTokenId( uint256 starkKey, uint256 assetType, uint256 tokenId, uint256 vaultId, uint256 quantizedAmount ) public notFrozen { // The vaultId is not validated but should be in the allowed range supported by the // exchange. If not, it will be ignored by the exchange and the starkKey owner may reclaim // the funds by using depositCancel + depositReclaim. require(isAssetTypeWithTokenId(assetType), "INVALID_ASSET_TYPE"); uint256 assetId = calculateAssetIdWithTokenId(assetType, tokenId); // Updates the pendingDeposits balance and clears cancellationRequests when applicable. uint256 newVaultBalance = depositStateUpdate(starkKey, assetId, vaultId, quantizedAmount); // No need to verify amount > 0, a deposit with amount = 0 can be used to undo cancellation. if (isERC721(assetType)) { require(newVaultBalance <= 1, "ILLEGAL_ERC721_AMOUNT"); emit LogNftDeposit(msg.sender, starkKey, vaultId, assetType, tokenId, assetId); } // Transfer the tokens to the Deposit contract. transferInWithTokenId(assetType, tokenId, quantizedAmount); // Log event. emit LogDepositWithTokenId( msg.sender, starkKey, vaultId, assetType, tokenId, assetId, fromQuantized(assetType, quantizedAmount), quantizedAmount ); } function getCancellationRequest( uint256 starkKey, uint256 assetId, uint256 vaultId ) external view returns (uint256 request) { request = cancellationRequests[starkKey][assetId][vaultId]; } function depositERC20( uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount ) public override { deposit(starkKey, assetType, vaultId, quantizedAmount); } // NOLINTNEXTLINE: locked-ether. function depositEth( uint256 starkKey, uint256 assetType, uint256 vaultId ) public payable override { require(isEther(assetType), "INVALID_ASSET_TYPE"); deposit(starkKey, assetType, vaultId, toQuantized(assetType, msg.value)); } function deposit( uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount ) public notFrozen { // The vaultId is not validated but should be in the allowed range supported by the // exchange. If not, it will be ignored by the exchange and the starkKey owner may reclaim // the funds by using depositCancel + depositReclaim. // No need to verify amount > 0, a deposit with amount = 0 can be used to undo cancellation. require(!isMintableAssetType(assetType), "MINTABLE_ASSET_TYPE"); require(isFungibleAssetType(assetType), "NON_FUNGIBLE_ASSET_TYPE"); uint256 assetId = assetType; // Updates the pendingDeposits balance and clears cancellationRequests when applicable. depositStateUpdate(starkKey, assetId, vaultId, quantizedAmount); // Transfer the tokens to the Deposit contract. transferIn(assetType, quantizedAmount); // Log event. emit LogDeposit( msg.sender, starkKey, vaultId, assetType, fromQuantized(assetType, quantizedAmount), quantizedAmount ); } function deposit( // NOLINT: locked-ether. uint256 starkKey, uint256 assetType, uint256 vaultId ) external payable { require(isEther(assetType), "INVALID_ASSET_TYPE"); deposit(starkKey, assetType, vaultId, toQuantized(assetType, msg.value)); } function depositCancel( uint256 starkKey, uint256 assetId, uint256 vaultId ) external onlyKeyOwner(starkKey) // No notFrozen modifier: This function can always be used, even when frozen. { // Start the timeout. cancellationRequests[starkKey][assetId][vaultId] = block.timestamp; // Log event. emit LogDepositCancel(starkKey, vaultId, assetId); } function clearCancelledDeposit( uint256 starkKey, uint256 assetId, uint256 vaultId ) private returns (uint256) { // Make sure enough time has passed. uint256 requestTime = cancellationRequests[starkKey][assetId][vaultId]; require(requestTime != 0, "DEPOSIT_NOT_CANCELED"); uint256 freeTime = requestTime + DEPOSIT_CANCEL_DELAY; assert(freeTime >= DEPOSIT_CANCEL_DELAY); require(block.timestamp >= freeTime, "DEPOSIT_LOCKED"); // NOLINT: timestamp. // Clear deposit. uint256 quantizedAmount = pendingDeposits[starkKey][assetId][vaultId]; delete pendingDeposits[starkKey][assetId][vaultId]; delete cancellationRequests[starkKey][assetId][vaultId]; // Return the cleared amount so it can be transferred back to the reclaimer. return quantizedAmount; } function depositReclaim( uint256 starkKey, uint256 assetType, uint256 vaultId ) external onlyKeyOwner(starkKey) // No notFrozen modifier: This function can always be used, even when frozen. { require(isFungibleAssetType(assetType), "NON_FUNGIBLE_ASSET_TYPE"); // Clear deposit and attain the cleared amount to be transferred out. uint256 assetId = assetType; uint256 quantizedAmount = clearCancelledDeposit(starkKey, assetId, vaultId); // Refund deposit. transferOut(msg.sender, assetType, quantizedAmount); // Log event. emit LogDepositCancelReclaimed( starkKey, vaultId, assetType, fromQuantized(assetType, quantizedAmount), quantizedAmount ); } function depositWithTokenIdReclaim( uint256 starkKey, uint256 assetType, uint256 tokenId, uint256 vaultId ) public onlyKeyOwner(starkKey) // No notFrozen modifier: This function can always be used, even when frozen. { require(isAssetTypeWithTokenId(assetType), "INVALID_ASSET_TYPE"); // Clear deposit and attain the cleared amount to be transferred out. uint256 assetId = calculateAssetIdWithTokenId(assetType, tokenId); uint256 quantizedAmount = clearCancelledDeposit(starkKey, assetId, vaultId); if (quantizedAmount > 0) { // Refund deposit. transferOutWithTokenId(msg.sender, assetType, tokenId, quantizedAmount); } // Log event. if (isERC721(assetType)) { emit LogDepositNftCancelReclaimed(starkKey, vaultId, assetType, tokenId, assetId); } emit LogDepositWithTokenIdCancelReclaimed( starkKey, vaultId, assetType, tokenId, assetId, fromQuantized(assetType, quantizedAmount), quantizedAmount ); } function depositNftReclaim( uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 tokenId ) external onlyKeyOwner(starkKey) // No notFrozen modifier: This function can always be used, even when frozen. { depositWithTokenIdReclaim(starkKey, assetType, tokenId, vaultId); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../tokens/ERC1155/IERC1155Receiver.sol"; /* ERC1155 token receiver interface. EIP-1155 requires any contract receiving ERC1155 tokens to implement IERC1155Receiver interface. By EIP: 1. safeTransferFrom API of ERC1155 shall call onERC1155Received on the receiving contract. 2. safeBatchTransferFrom API of ERC1155 to call onERC1155BatchReceived on the receiving contract. Have the receiving contract failed to respond as expected, the safe transfer functions shall be reverted. */ contract ERC1155Receiver is IERC1155Receiver { /** Handles the receipt of a single ERC1155 token type. @param `operator` The address which called `safeTransferFrom` function @param `from` The address which previously owned the token @param `id` The identifier of the token which is being transferred @param `value` the amount of token units being transferred @param `data` Additional data with no specified format Returns: When invoked by the receiving contract, satisfying the deposit pattern (i.e. operator == this) `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` is returned. In all other cases returns `bytes4(0)`, which should invoke an error of the form `ERC1155: ERC1155Receiver rejected tokens`. */ function onERC1155Received( address operator, address, // from uint256, // id uint256, // value bytes calldata // data ) external override returns (bytes4) { return (operator == address(this) ? this.onERC1155Received.selector : bytes4(0)); } /** Handles the receipt of multiple ERC1155 token types. @param `operator` The address which called `safeBatchTransferFrom` function @param `from` The address which previously owned the token @param `ids` The identifier of the token which is being transferred @param `values` the amount of token units being transferred @param `data` Additional data with no specified format Returns: When invoked by the receiving contract, satisfying the deposit pattern (i.e. operator == this) `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256,uint256,bytes)"))` is returned. In all other cases returns `bytes4(0)`, which should invoke an error of the form `ERC1155: ERC1155Receiver rejected tokens`. Note: a rejection value `bytes4(0)` is to be expected. Batch deposits are unsupported by StarkEx. */ function onERC1155BatchReceived( address operator, address, // from uint256[] calldata, // ids uint256[] calldata, // values bytes calldata // data ) external override returns (bytes4) { return (operator == address(this) ? this.onERC1155BatchReceived.selector : bytes4(0)); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../tokens/ERC721/IERC721Receiver.sol"; /* ERC721 token receiver interface EIP-721 requires any contract receiving ERC721 tokens to implement IERC721Receiver interface. By EIP, safeTransferFrom API of ERC721 shall call onERC721Received on the receiving contract. Have the receiving contract failed to respond as expected, the safeTransferFrom shall be reverted. Params: `operator` The address which called `safeTransferFrom` function `from` The address which previously owned the token `tokenId` The NFT identifier which is being transferred `data` Additional data with no specified format Returns: When invoked by the main contract, following the deposit pattern: `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`, which indicates success. In all other cases: `bytes4(0)`, which should fail ERC721's safeTransferFrom. */ contract ERC721Receiver is IERC721Receiver { function onERC721Received( address operator, // The address which called `safeTransferFrom` function. address, // from - The address which previously owned the token. uint256, // tokenId - The NFT identifier which is being transferred. bytes calldata // data - Additional data with no specified format. ) external override returns (bytes4) { return (operator == address(this) ? this.onERC721Received.selector : bytes4(0)); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../libraries/LibConstants.sol"; import "../interfaces/MFreezable.sol"; import "../interfaces/MGovernance.sol"; import "./MainStorage.sol"; /* Implements MFreezable. */ abstract contract Freezable is MainStorage, LibConstants, MGovernance, MFreezable { event LogFrozen(); event LogUnFrozen(); function isFrozen() public view override returns (bool) { return stateFrozen; } function validateFreezeRequest(uint256 requestTime) internal override { require(requestTime != 0, "FORCED_ACTION_UNREQUESTED"); // Verify timer on escape request. uint256 freezeTime = requestTime + FREEZE_GRACE_PERIOD; // Prevent wraparound. assert(freezeTime >= FREEZE_GRACE_PERIOD); require(block.timestamp >= freezeTime, "FORCED_ACTION_PENDING"); // NOLINT: timestamp. // Forced action requests placed before freeze, are no longer valid after the un-freeze. require(freezeTime > unFreezeTime, "REFREEZE_ATTEMPT"); } function freeze() internal override notFrozen { unFreezeTime = block.timestamp + UNFREEZE_DELAY; // Update state. stateFrozen = true; // Log event. emit LogFrozen(); } function unFreeze() external onlyFrozen onlyGovernance { require(block.timestamp >= unFreezeTime, "UNFREEZE_NOT_ALLOWED_YET"); // Update state. stateFrozen = false; // Increment roots to invalidate them, w/o losing information. validiumVaultRoot += 1; rollupVaultRoot += 1; orderRoot += 1; // Log event. emit LogUnFrozen(); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../interfaces/MGovernance.sol"; /* Implements Generic Governance, applicable for both proxy and main contract, and possibly others. Notes: The use of the same function names by both the Proxy and a delegated implementation is not possible since calling the implementation functions is done via the default function of the Proxy. For this reason, for example, the implementation of MainContract (MainGovernance) exposes mainIsGovernor, which calls the internal _isGovernor method. */ abstract contract Governance is MGovernance { event LogNominatedGovernor(address nominatedGovernor); event LogNewGovernorAccepted(address acceptedGovernor); event LogRemovedGovernor(address removedGovernor); event LogNominationCancelled(); function getGovernanceInfo() internal view virtual returns (GovernanceInfoStruct storage); /* Current code intentionally prevents governance re-initialization. This may be a problem in an upgrade situation, in a case that the upgrade-to implementation performs an initialization (for real) and within that calls initGovernance(). Possible workarounds: 1. Clearing the governance info altogether by changing the MAIN_GOVERNANCE_INFO_TAG. This will remove existing main governance information. 2. Modify the require part in this function, so that it will exit quietly when trying to re-initialize (uncomment the lines below). */ function initGovernance() internal { GovernanceInfoStruct storage gub = getGovernanceInfo(); require(!gub.initialized, "ALREADY_INITIALIZED"); gub.initialized = true; // to ensure addGovernor() won't fail. // Add the initial governer. addGovernor(msg.sender); } function _isGovernor(address testGovernor) internal view override returns (bool) { GovernanceInfoStruct storage gub = getGovernanceInfo(); return gub.effectiveGovernors[testGovernor]; } /* Cancels the nomination of a governor candidate. */ function _cancelNomination() internal onlyGovernance { GovernanceInfoStruct storage gub = getGovernanceInfo(); gub.candidateGovernor = address(0x0); emit LogNominationCancelled(); } function _nominateNewGovernor(address newGovernor) internal onlyGovernance { GovernanceInfoStruct storage gub = getGovernanceInfo(); require(!_isGovernor(newGovernor), "ALREADY_GOVERNOR"); gub.candidateGovernor = newGovernor; emit LogNominatedGovernor(newGovernor); } /* The addGovernor is called in two cases: 1. by _acceptGovernance when a new governor accepts its role. 2. by initGovernance to add the initial governor. The difference is that the init path skips the nominate step that would fail because of the onlyGovernance modifier. */ function addGovernor(address newGovernor) private { require(!_isGovernor(newGovernor), "ALREADY_GOVERNOR"); GovernanceInfoStruct storage gub = getGovernanceInfo(); gub.effectiveGovernors[newGovernor] = true; } function _acceptGovernance() internal { // The new governor was proposed as a candidate by the current governor. GovernanceInfoStruct storage gub = getGovernanceInfo(); require(msg.sender == gub.candidateGovernor, "ONLY_CANDIDATE_GOVERNOR"); // Update state. addGovernor(gub.candidateGovernor); gub.candidateGovernor = address(0x0); // Send a notification about the change of governor. emit LogNewGovernorAccepted(msg.sender); } /* Remove a governor from office. */ function _removeGovernor(address governorForRemoval) internal onlyGovernance { require(msg.sender != governorForRemoval, "GOVERNOR_SELF_REMOVE"); GovernanceInfoStruct storage gub = getGovernanceInfo(); require(_isGovernor(governorForRemoval), "NOT_GOVERNOR"); gub.effectiveGovernors[governorForRemoval] = false; emit LogRemovedGovernor(governorForRemoval); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../interfaces/MGovernance.sol"; /* Holds the governance slots for ALL entities, including proxy and the main contract. */ contract GovernanceStorage { // A map from a Governor tag to its own GovernanceInfoStruct. mapping(string => GovernanceInfoStruct) internal governanceInfo; //NOLINT uninitialized-state. }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: MIT. pragma solidity ^0.6.12; /** Required interface of an ERC1155 compliant contract, as defined in the https://eips.ethereum.org/EIPS/eip-1155[EIP]. _Available since v3.1. */ interface IERC1155 { /** Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle( address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value ); /** Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. If an {URI} event was emitted for `id`, the standard https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** Returns the amount of tokens of token type `id` owned by `account`. Requirements: - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** Requirements: - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, Emits an {ApprovalForAll} event. Requirements: - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** Returns true if `operator` is approved to transfer ``account``'s tokens. See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** Transfers `amount` tokens of token type `id` from `from` to `to`. Emits a {TransferSingle} event. Requirements: - `to` cannot be the zero address. - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}. - `from` must have a balance of tokens of type `id` of at least `amount`. - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** Emits a {TransferBatch} event. Requirements: - `ids` and `amounts` must have the same length. - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; /** Note: The ERC-165 identifier for this interface is 0x4e2312e0. */ interface IERC1155Receiver { /** Handles the receipt of a single ERC1155 token type. @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeTransferFrom` after the balance has been updated. This function MUST return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61) if it accepts the transfer. This function MUST revert if it rejects the transfer. Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller. @param operator The address which initiated the transfer (i.e. msg.sender) @param from The address which previously owned the token @param id The ID of the token being transferred @param value The amount of tokens being transferred @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` . */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** Handles the receipt of multiple ERC1155 token types. @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updated. This function MUST return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81) if it accepts the transfer(s). This function MUST revert if it rejects the transfer(s). Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller. @param operator The address which initiated the batch transfer (i.e. msg.sender) @param from The address which previously owned the token @param ids An array containing ids of each token being transferred (order and length must match values array) @param values An array containing amounts of each token being transferred (order and length must match ids array) @param data Additional data with no specified format @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` . */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; /* Interface of the ERC20 standard as defined in the EIP. Does not include the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; interface IERC721Receiver { function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; interface Identity { /* Allows a caller, typically another contract, to ensure that the provided address is of the expected type and version. */ function identify() external pure returns (string memory); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../components/MainStorage.sol"; import "../interfaces/MKeyGetters.sol"; /* Implements MKeyGetters. */ contract KeyGetters is MainStorage, MKeyGetters { uint256 internal constant MASK_ADDRESS = (1 << 160) - 1; /* Returns the Ethereum public key (address) that owns the given ownerKey. If the ownerKey size is within the range of an Ethereum address (i.e. < 2**160) it returns the owner key itself. If the ownerKey is larger than a potential eth address, the eth address for which the starkKey was registered is returned, and 0 if the starkKey is not registered. Note - prior to version 4.0 this function reverted on an unregistered starkKey. For a variant of this function that reverts on an unregistered starkKey, use strictGetEthKey. */ function getEthKey(uint256 ownerKey) public view override returns (address) { address registeredEth = ethKeys[ownerKey]; if (registeredEth != address(0x0)) { return registeredEth; } return ownerKey == (ownerKey & MASK_ADDRESS) ? address(ownerKey) : address(0x0); } /* Same as getEthKey, but fails when a stark key is not registered. */ function strictGetEthKey(uint256 ownerKey) internal view override returns (address ethKey) { ethKey = getEthKey(ownerKey); require(ethKey != address(0x0), "USER_UNREGISTERED"); } function isMsgSenderKeyOwner(uint256 ownerKey) internal view override returns (bool) { return msg.sender == getEthKey(ownerKey); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; contract LibConstants { // Durations for time locked mechanisms (in seconds). // Note that it is known that miners can manipulate block timestamps // up to a deviation of a few seconds. // This mechanism should not be used for fine grained timing. // The time required to cancel a deposit, in the case the operator does not move the funds // to the off-chain storage. uint256 public constant DEPOSIT_CANCEL_DELAY = 2 days; // The time required to freeze the exchange, in the case the operator does not execute a // requested full withdrawal. uint256 public constant FREEZE_GRACE_PERIOD = 7 days; // The time after which the exchange may be unfrozen after it froze. This should be enough time // for users to perform escape hatches to get back their funds. uint256 public constant UNFREEZE_DELAY = 365 days; // Maximal number of verifiers which may co-exist. uint256 public constant MAX_VERIFIER_COUNT = uint256(64); // The time required to remove a verifier in case of a verifier upgrade. uint256 public constant VERIFIER_REMOVAL_DELAY = FREEZE_GRACE_PERIOD + (21 days); address constant ZERO_ADDRESS = address(0x0); uint256 constant K_MODULUS = 0x800000000000011000000000000000000000000000000000000000000000001; uint256 constant K_BETA = 0x6f21413efbe40de150e596d72f7a8c5609ad26c15c915c1f4cdfcb99cee9e89; uint256 internal constant MASK_250 = 0x03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; uint256 internal constant MASK_240 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; uint256 public constant MAX_FORCED_ACTIONS_REQS_PER_BLOCK = 10; uint256 constant QUANTUM_UPPER_BOUND = 2**128; uint256 internal constant MINTABLE_ASSET_ID_FLAG = 1 << 250; // The 64th bit (indexed 63, counting from 0) is a flag indicating a rollup vault id. uint256 constant ROLLUP_VAULTS_BIT = 63; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; /* Interface containing actions a verifier can invoke on the state. The contract containing the state should implement these and verify correctness. */ abstract contract MAcceptModifications { function acceptDeposit( uint256 ownerKey, uint256 vaultId, uint256 assetId, uint256 quantizedAmount ) internal virtual; function allowWithdrawal( uint256 ownerKey, uint256 assetId, uint256 quantizedAmount ) internal virtual; function acceptWithdrawal( uint256 ownerKey, uint256 assetId, uint256 quantizedAmount ) internal virtual; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract MBlocklist { event BlockPlaced(uint256 indexed ownerKey); event BlockReleased(uint256 indexed ownerKey); address internal constant BLOCK_ADMIN = 0x520Cf70a2D0B3dfB7386A2Bc9F800321F62a5c3a; // NOLINTNEXTLINE: external-function. function isBlockListed(uint256 ownerKey) public view virtual returns (bool); function addToBlockedList(uint256 ownerKey) external virtual; function removeFromBlockedList(uint256 ownerKey) external virtual; /** Reverts if called by a blocked account. */ modifier onlyNotBlocked(uint256 ownerKey) { require(!isBlockListed(ownerKey), "USER_BLOCK_LISTED"); _; } modifier onlyBlockAdmin() { require(msg.sender == BLOCK_ADMIN, "ONLY_BLOCK_ADMIN"); _; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract MDeposits { function depositERC20( // NOLINT external-function. uint256 starkKey, uint256 assetType, uint256 vaultId, uint256 quantizedAmount ) public virtual; function depositEth( // NOLINT external-function. uint256 starkKey, uint256 assetType, uint256 vaultId ) public payable virtual; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract MFreezable { /* Returns true if the exchange is frozen. */ function isFrozen() public view virtual returns (bool); // NOLINT: external-function. /* Forbids calling the function if the exchange is frozen. */ modifier notFrozen() { require(!isFrozen(), "STATE_IS_FROZEN"); _; } function validateFreezeRequest(uint256 requestTime) internal virtual; /* Allows calling the function only if the exchange is frozen. */ modifier onlyFrozen() { require(isFrozen(), "STATE_NOT_FROZEN"); _; } /* Freezes the exchange. */ function freeze() internal virtual; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; struct GovernanceInfoStruct { mapping(address => bool) effectiveGovernors; address candidateGovernor; bool initialized; } abstract contract MGovernance { function _isGovernor(address testGovernor) internal view virtual returns (bool); /* Allows calling the function only by a Governor. */ modifier onlyGovernance() { require(_isGovernor(msg.sender), "ONLY_GOVERNANCE"); _; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract MKeyGetters { // NOLINTNEXTLINE: external-function. function getEthKey(uint256 ownerKey) public view virtual returns (address); function strictGetEthKey(uint256 ownerKey) internal view virtual returns (address); function isMsgSenderKeyOwner(uint256 ownerKey) internal view virtual returns (bool); /* Allows calling the function only if ownerKey is registered to msg.sender. */ modifier onlyKeyOwner(uint256 ownerKey) { // Require the calling user to own the stark key. require(msg.sender == strictGetEthKey(ownerKey), "MISMATCHING_STARK_ETH_KEYS"); _; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract MStarkExForcedActionState { function fullWithdrawActionHash(uint256 ownerKey, uint256 vaultId) internal pure virtual returns (bytes32); function clearFullWithdrawalRequest(uint256 ownerKey, uint256 vaultId) internal virtual; // NOLINTNEXTLINE: external-function. function getFullWithdrawalRequest(uint256 ownerKey, uint256 vaultId) public view virtual returns (uint256); function setFullWithdrawalRequest(uint256 ownerKey, uint256 vaultId) internal virtual; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract MTokenAssetData { // NOLINTNEXTLINE: external-function. function getAssetInfo(uint256 assetType) public view virtual returns (bytes memory); function isEther(uint256 assetType) internal view virtual returns (bool); function isERC20(uint256 assetType) internal view virtual returns (bool); function isERC721(uint256 assetType) internal view virtual returns (bool); function isERC1155(uint256 assetType) internal view virtual returns (bool); function isFungibleAssetType(uint256 assetType) internal view virtual returns (bool); function isMintableAssetType(uint256 assetType) internal view virtual returns (bool); function isAssetTypeWithTokenId(uint256 assetType) internal view virtual returns (bool); function extractContractAddress(uint256 assetType) internal view virtual returns (address); function verifyAssetInfo(bytes memory assetInfo) internal view virtual; function isNonFungibleAssetInfo(bytes memory assetInfo) internal pure virtual returns (bool); function calculateAssetIdWithTokenId(uint256 assetType, uint256 tokenId) public view virtual returns (uint256); function calculateMintableAssetId(uint256 assetType, bytes memory mintingBlob) public pure virtual returns (uint256); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract MTokenQuantization { function fromQuantized(uint256 presumedAssetType, uint256 quantizedAmount) internal view virtual returns (uint256 amount); // NOLINTNEXTLINE: external-function. function getQuantum(uint256 presumedAssetType) public view virtual returns (uint256 quantum); function toQuantized(uint256 presumedAssetType, uint256 amount) internal view virtual returns (uint256 quantizedAmount); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; abstract contract MTokenTransfers { function transferIn(uint256 assetType, uint256 quantizedAmount) internal virtual; function transferInWithTokenId( uint256 assetType, uint256 tokenId, uint256 quantizedAmount ) internal virtual; function transferOut( address payable recipient, uint256 assetType, uint256 quantizedAmount ) internal virtual; function transferOutWithTokenId( address recipient, uint256 assetType, uint256 tokenId, uint256 quantizedAmount ) internal virtual; function transferOutMint( uint256 assetType, uint256 quantizedAmount, address recipient, bytes calldata mintingBlob ) internal virtual; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "./Governance.sol"; import "./GovernanceStorage.sol"; /** The StarkEx contract is governed by one or more Governors of which the initial one is the deployer of the contract. A governor has the sole authority to perform the following operations: 1. Nominate additional governors (:sol:func:`mainNominateNewGovernor`) 2. Remove other governors (:sol:func:`mainRemoveGovernor`) 3. Add new :sol:mod:`Verifiers` and :sol:mod:`AvailabilityVerifiers` 4. Remove :sol:mod:`Verifiers` and :sol:mod:`AvailabilityVerifiers` after a timelock allows it 5. Nominate Operators (see :sol:mod:`Operator`) and Token Administrators (see :sol:mod:`TokenRegister`) Adding governors is performed in a two step procedure: 1. First, an existing governor nominates a new governor (:sol:func:`mainNominateNewGovernor`) 2. Then, the new governor must accept governance to become a governor (:sol:func:`mainAcceptGovernance`) This two step procedure ensures that a governor public key cannot be nominated unless there is an entity that has the corresponding private key. This is intended to prevent errors in the addition process. The governor private key should typically be held in a secure cold wallet. */ /* Implements Governance for the StarkDex main contract. The wrapper methods (e.g. mainIsGovernor wrapping _isGovernor) are needed to give the method unique names. Both Proxy and StarkExchange inherit from Governance. Thus, the logical contract method names must have unique names in order for the proxy to successfully delegate to them. */ contract MainGovernance is GovernanceStorage, Governance { // The tag is the sting key that is used in the Governance storage mapping. string public constant MAIN_GOVERNANCE_INFO_TAG = "StarkEx.Main.2019.GovernorsInformation"; /* Returns the GovernanceInfoStruct associated with the governance tag. */ function getGovernanceInfo() internal view override returns (GovernanceInfoStruct storage) { return governanceInfo[MAIN_GOVERNANCE_INFO_TAG]; } function mainIsGovernor(address testGovernor) external view returns (bool) { return _isGovernor(testGovernor); } function mainNominateNewGovernor(address newGovernor) external { _nominateNewGovernor(newGovernor); } function mainRemoveGovernor(address governorForRemoval) external { _removeGovernor(governorForRemoval); } function mainAcceptGovernance() external { _acceptGovernance(); } function mainCancelNomination() external { _cancelNomination(); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../upgrade/ProxyStorage.sol"; import "../libraries/Common.sol"; /* Holds ALL the main contract state (storage) variables. */ contract MainStorage is ProxyStorage { uint256 internal constant LAYOUT_LENGTH = 2**64; address escapeVerifierAddress; // NOLINT: constable-states. // Global dex-frozen flag. bool stateFrozen; // NOLINT: constable-states. // Time when unFreeze can be successfully called (UNFREEZE_DELAY after freeze). uint256 unFreezeTime; // NOLINT: constable-states. // Pending deposits. // A map STARK key => asset id => vault id => quantized amount. mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256))) pendingDeposits; // Cancellation requests. // A map STARK key => asset id => vault id => request timestamp. mapping(uint256 => mapping(uint256 => mapping(uint256 => uint256))) cancellationRequests; // Pending withdrawals. // A map STARK key => asset id => quantized amount. mapping(uint256 => mapping(uint256 => uint256)) pendingWithdrawals; // vault_id => escape used boolean. mapping(uint256 => bool) escapesUsed; // Number of escapes that were performed when frozen. uint256 escapesUsedCount; // NOLINT: constable-states. // NOTE: fullWithdrawalRequests is deprecated, and replaced by forcedActionRequests. // NOLINTNEXTLINE naming-convention. mapping(uint256 => mapping(uint256 => uint256)) fullWithdrawalRequests_DEPRECATED; // State sequence number. uint256 sequenceNumber; // NOLINT: constable-states uninitialized-state. // Validium Vaults Tree Root & Height. uint256 validiumVaultRoot; // NOLINT: constable-states uninitialized-state. uint256 validiumTreeHeight; // NOLINT: constable-states uninitialized-state. // Order Tree Root & Height. uint256 orderRoot; // NOLINT: constable-states uninitialized-state. uint256 orderTreeHeight; // NOLINT: constable-states uninitialized-state. // True if and only if the address is allowed to add tokens. mapping(address => bool) tokenAdmins; // This mapping is no longer in use, remains for backwards compatibility. mapping(address => bool) userAdmins_DEPRECATED; // NOLINT: naming-convention. // True if and only if the address is an operator (allowed to update state). mapping(address => bool) operators; // NOLINT: uninitialized-state. // Mapping of contract ID to asset data. mapping(uint256 => bytes) assetTypeToAssetInfo; // NOLINT: uninitialized-state. // Mapping of registered contract IDs. mapping(uint256 => bool) registeredAssetType; // NOLINT: uninitialized-state. // Mapping from contract ID to quantum. mapping(uint256 => uint256) assetTypeToQuantum; // NOLINT: uninitialized-state. // This mapping is no longer in use, remains for backwards compatibility. mapping(address => uint256) starkKeys_DEPRECATED; // NOLINT: naming-convention. // Mapping from STARK public key to the Ethereum public key of its owner. mapping(uint256 => address) ethKeys; // NOLINT: uninitialized-state. // Timelocked state transition and availability verification chain. StarkExTypes.ApprovalChainData verifiersChain; StarkExTypes.ApprovalChainData availabilityVerifiersChain; // Batch id of last accepted proof. uint256 lastBatchId; // NOLINT: constable-states uninitialized-state. // Mapping between sub-contract index to sub-contract address. mapping(uint256 => address) subContracts; // NOLINT: uninitialized-state. mapping(uint256 => bool) permissiveAssetType_DEPRECATED; // NOLINT: naming-convention. // ---- END OF MAIN STORAGE AS DEPLOYED IN STARKEX2.0 ---- // Onchain-data version configured for the system. uint256 onchainDataVersion_DEPRECATED; // NOLINT: naming-convention constable-states. // Counter of forced action request in block. The key is the block number. mapping(uint256 => uint256) forcedRequestsInBlock; // ForcedAction requests: actionHash => requestTime. mapping(bytes32 => uint256) forcedActionRequests; // Mapping for timelocked actions. // A actionKey => activation time. mapping(bytes32 => uint256) actionsTimeLock; // Append only list of requested forced action hashes. bytes32[] actionHashList; // ---- END OF MAIN STORAGE AS DEPLOYED IN STARKEX3.0 ---- // ---- END OF MAIN STORAGE AS DEPLOYED IN STARKEX4.0 ---- // Rollup Vaults Tree Root & Height. uint256 rollupVaultRoot; // NOLINT: constable-states uninitialized-state. uint256 rollupTreeHeight; // NOLINT: constable-states uninitialized-state. uint256 globalConfigCode; // NOLINT: constable-states uninitialized-state. // Mapping of owner keys that are blocked from withdrawals. mapping(uint256 => bool) internal blockListed; // Reserved storage space for Extensibility. // Every added MUST be added above the end gap, and the __endGap size must be reduced // accordingly. // NOLINTNEXTLINE: naming-convention. uint256[LAYOUT_LENGTH - 41] private __endGap; // __endGap complements layout to LAYOUT_LENGTH. }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../components/GovernanceStorage.sol"; /* Holds the Proxy-specific state variables. This contract is inherited by the GovernanceStorage (and indirectly by MainStorage) to prevent collision hazard. */ contract ProxyStorage is GovernanceStorage { // NOLINTNEXTLINE: naming-convention uninitialized-state. mapping(address => bytes32) internal initializationHash_DEPRECATED; // The time after which we can switch to the implementation. // Hash(implementation, data, finalize) => time. mapping(bytes32 => uint256) internal enabledTime; // A central storage of the flags whether implementation has been initialized. // Note - it can be used flexibly enough to accommodate multiple levels of initialization // (i.e. using different key salting schemes for different initialization levels). mapping(bytes32 => bool) internal initialized; }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../components/StarkExStorage.sol"; import "../interfaces/MStarkExForcedActionState.sol"; import "../../components/ActionHash.sol"; /* StarkExchange specific action hashses. */ contract StarkExForcedActionState is StarkExStorage, ActionHash, MStarkExForcedActionState { function fullWithdrawActionHash(uint256 ownerKey, uint256 vaultId) internal pure override returns (bytes32) { return getActionHash("FULL_WITHDRAWAL", abi.encode(ownerKey, vaultId)); } /* Implemented in the FullWithdrawal contracts. */ function clearFullWithdrawalRequest(uint256 ownerKey, uint256 vaultId) internal virtual override { // Reset escape request. delete forcedActionRequests[fullWithdrawActionHash(ownerKey, vaultId)]; } function getFullWithdrawalRequest(uint256 ownerKey, uint256 vaultId) public view override returns (uint256) { // Return request value. Expect zero if the request doesn't exist or has been serviced, and // a non-zero value otherwise. return forcedActionRequests[fullWithdrawActionHash(ownerKey, vaultId)]; } function setFullWithdrawalRequest(uint256 ownerKey, uint256 vaultId) internal override { // FullWithdrawal is always at premium cost, hence the `true`. setActionHash(fullWithdrawActionHash(ownerKey, vaultId), true); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../../components/MainStorage.sol"; /* Extends MainStorage, holds StarkEx App specific state (storage) variables. ALL State variables that are common to all applications, reside in MainStorage, whereas ALL the StarkEx app specific ones reside here. */ contract StarkExStorage is MainStorage { // Onchain vaults balances. // A map eth_address => asset_id => vault_id => quantized amount. mapping(address => mapping(uint256 => mapping(uint256 => uint256))) vaultsBalances; // Onchain vaults withdrawal lock time. // A map eth_address => asset_id => vault_id => lock expiration timestamp. mapping(address => mapping(uint256 => mapping(uint256 => uint256))) vaultsWithdrawalLocks; // Enforces the minimal balance requirement (as output by Cairo) on onchain vault updates. // When disabled, flash loans are enabled. bool strictVaultBalancePolicy; // NOLINT: constable-states, uninitialized-state. // The default time, in seconds, that an onchain vault is locked for withdrawal after a deposit. uint256 public defaultVaultWithdrawalLock; // NOLINT: constable-states. // Address of the message registry contract that is used to sign and verify L1 orders. address public orderRegistryAddress; // NOLINT: constable-states. // Reserved storage space for Extensibility. // Every added MUST be added above the end gap, and the __endGap size must be reduced // accordingly. // NOLINTNEXTLINE: naming-convention shadowing-abstract. uint256[LAYOUT_LENGTH - 5] private __endGap; // __endGap complements layout to LAYOUT_LENGTH. }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "./Identity.sol"; interface SubContractor is Identity { function initialize(bytes calldata data) external; function initializerSize() external view returns (uint256); /* Returns an array with selectors for validation. These selectors are the critical ones for maintaining self custody and anti censorship. During the upgrade process, as part of the sub-contract validation, the MainDispatcher validates that the selectos are mapped to the correct sub-contract. */ function validatedSelectors() external pure returns (bytes4[] memory); }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../components/MainStorage.sol"; import "../interfaces/MTokenAssetData.sol"; import "../libraries/Common.sol"; import "../libraries/LibConstants.sol"; contract TokenAssetData is MainStorage, LibConstants, MTokenAssetData { bytes4 internal constant ERC20_SELECTOR = bytes4(keccak256("ERC20Token(address)")); bytes4 internal constant ETH_SELECTOR = bytes4(keccak256("ETH()")); bytes4 internal constant ERC721_SELECTOR = bytes4(keccak256("ERC721Token(address,uint256)")); bytes4 internal constant ERC1155_SELECTOR = bytes4(keccak256("ERC1155Token(address,uint256)")); bytes4 internal constant MINTABLE_ERC20_SELECTOR = bytes4(keccak256("MintableERC20Token(address)")); bytes4 internal constant MINTABLE_ERC721_SELECTOR = bytes4(keccak256("MintableERC721Token(address,uint256)")); // The selector follows the 0x20 bytes assetInfo.length field. uint256 internal constant SELECTOR_OFFSET = 0x20; uint256 internal constant SELECTOR_SIZE = 4; uint256 internal constant TOKEN_CONTRACT_ADDRESS_OFFSET = SELECTOR_OFFSET + SELECTOR_SIZE; string internal constant NFT_ASSET_ID_PREFIX = "NFT:"; string internal constant NON_MINTABLE_PREFIX = "NON_MINTABLE:"; string internal constant MINTABLE_PREFIX = "MINTABLE:"; using Addresses for address; /* Extract the tokenSelector from assetInfo. Works like bytes4 tokenSelector = abi.decode(assetInfo, (bytes4)) but does not revert when assetInfo.length < SELECTOR_OFFSET. */ function extractTokenSelectorFromAssetInfo(bytes memory assetInfo) private pure returns (bytes4 selector) { assembly { selector := and( 0xffffffff00000000000000000000000000000000000000000000000000000000, mload(add(assetInfo, SELECTOR_OFFSET)) ) } } function getAssetInfo(uint256 assetType) public view override returns (bytes memory assetInfo) { // Verify that the registration is set and valid. require(registeredAssetType[assetType], "ASSET_TYPE_NOT_REGISTERED"); // Retrieve registration. assetInfo = assetTypeToAssetInfo[assetType]; } function extractTokenSelectorFromAssetType(uint256 assetType) private view returns (bytes4) { return extractTokenSelectorFromAssetInfo(getAssetInfo(assetType)); } function isEther(uint256 assetType) internal view override returns (bool) { return extractTokenSelectorFromAssetType(assetType) == ETH_SELECTOR; } function isERC20(uint256 assetType) internal view override returns (bool) { return extractTokenSelectorFromAssetType(assetType) == ERC20_SELECTOR; } function isERC721(uint256 assetType) internal view override returns (bool) { return extractTokenSelectorFromAssetType(assetType) == ERC721_SELECTOR; } function isERC1155(uint256 assetType) internal view override returns (bool) { return extractTokenSelectorFromAssetType(assetType) == ERC1155_SELECTOR; } function isFungibleAssetType(uint256 assetType) internal view override returns (bool) { bytes4 tokenSelector = extractTokenSelectorFromAssetType(assetType); return tokenSelector == ETH_SELECTOR || tokenSelector == ERC20_SELECTOR || tokenSelector == MINTABLE_ERC20_SELECTOR; } function isMintableAssetType(uint256 assetType) internal view override returns (bool) { bytes4 tokenSelector = extractTokenSelectorFromAssetType(assetType); return tokenSelector == MINTABLE_ERC20_SELECTOR || tokenSelector == MINTABLE_ERC721_SELECTOR; } function isAssetTypeWithTokenId(uint256 assetType) internal view override returns (bool) { bytes4 tokenSelector = extractTokenSelectorFromAssetType(assetType); return tokenSelector == ERC721_SELECTOR || tokenSelector == ERC1155_SELECTOR; } function isTokenSupported(bytes4 tokenSelector) private pure returns (bool) { return tokenSelector == ETH_SELECTOR || tokenSelector == ERC20_SELECTOR || tokenSelector == ERC721_SELECTOR || tokenSelector == MINTABLE_ERC20_SELECTOR || tokenSelector == MINTABLE_ERC721_SELECTOR || tokenSelector == ERC1155_SELECTOR; } function extractContractAddressFromAssetInfo(bytes memory assetInfo) private pure returns (address) { uint256 offset = TOKEN_CONTRACT_ADDRESS_OFFSET; uint256 res; assembly { res := mload(add(assetInfo, offset)) } return address(res); } function extractContractAddress(uint256 assetType) internal view override returns (address) { return extractContractAddressFromAssetInfo(getAssetInfo(assetType)); } function verifyAssetInfo(bytes memory assetInfo) internal view override { bytes4 tokenSelector = extractTokenSelectorFromAssetInfo(assetInfo); // Ensure the selector is of an asset type we know. require(isTokenSupported(tokenSelector), "UNSUPPORTED_TOKEN_TYPE"); if (tokenSelector == ETH_SELECTOR) { // Assset info for ETH assetType is only a selector, i.e. 4 bytes length. require(assetInfo.length == 4, "INVALID_ASSET_STRING"); } else { // Assset info for other asset types are a selector + uint256 concatanation. // We pass the address as a uint256 (zero padded), // thus its length is 0x04 + 0x20 = 0x24. require(assetInfo.length == 0x24, "INVALID_ASSET_STRING"); address tokenAddress = extractContractAddressFromAssetInfo(assetInfo); require(tokenAddress.isContract(), "BAD_TOKEN_ADDRESS"); } } function isNonFungibleAssetInfo(bytes memory assetInfo) internal pure override returns (bool) { bytes4 tokenSelector = extractTokenSelectorFromAssetInfo(assetInfo); return tokenSelector == ERC721_SELECTOR || tokenSelector == MINTABLE_ERC721_SELECTOR; } function calculateAssetIdWithTokenId(uint256 assetType, uint256 tokenId) public view override returns (uint256) { require(isAssetTypeWithTokenId(assetType), "ASSET_TYPE_DOES_NOT_TAKE_TOKEN_ID"); string memory prefix = isERC721(assetType) ? NFT_ASSET_ID_PREFIX : NON_MINTABLE_PREFIX; return uint256(keccak256(abi.encodePacked(prefix, assetType, tokenId))) & MASK_250; } function calculateMintableAssetId(uint256 assetType, bytes memory mintingBlob) public pure override returns (uint256 assetId) { uint256 blobHash = uint256(keccak256(mintingBlob)); assetId = (uint256(keccak256(abi.encodePacked(MINTABLE_PREFIX, assetType, blobHash))) & MASK_240) | MINTABLE_ASSET_ID_FLAG; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../components/MainStorage.sol"; import "../interfaces/MTokenQuantization.sol"; contract TokenQuantization is MainStorage, MTokenQuantization { function fromQuantized(uint256 presumedAssetType, uint256 quantizedAmount) internal view override returns (uint256 amount) { uint256 quantum = getQuantum(presumedAssetType); amount = quantizedAmount * quantum; require(amount / quantum == quantizedAmount, "DEQUANTIZATION_OVERFLOW"); } function getQuantum(uint256 presumedAssetType) public view override returns (uint256 quantum) { if (!registeredAssetType[presumedAssetType]) { // Default quantization, for NFTs etc. quantum = 1; } else { // Retrieve registration. quantum = assetTypeToQuantum[presumedAssetType]; } } function toQuantized(uint256 presumedAssetType, uint256 amount) internal view override returns (uint256 quantizedAmount) { uint256 quantum = getQuantum(presumedAssetType); require(amount % quantum == 0, "INVALID_AMOUNT"); quantizedAmount = amount / quantum; } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../libraries/LibConstants.sol"; import "../interfaces/MGovernance.sol"; import "../interfaces/MTokenAssetData.sol"; import "../tokens/ERC20/IERC20.sol"; import "./MainStorage.sol"; /** Registration of a new token (:sol:func:`registerToken`) entails defining a new asset type within the system, and associating it with an `assetInfo` array of bytes and a quantization factor (`quantum`). The `assetInfo` is a byte array, with a size depending on the token. For ETH, assetInfo is 4 bytes long. For ERC20 tokens, it is 36 bytes long. For each token type, the following constant 4-byte hash is defined, called the `selector`: | `ETH_SELECTOR = bytes4(keccak256("ETH()"));` | `ERC20_SELECTOR = bytes4(keccak256("ERC20Token(address)"));` | `ERC721_SELECTOR = bytes4(keccak256("ERC721Token(address,uint256)"));` | `MINTABLE_ERC20_SELECTOR = bytes4(keccak256("MintableERC20Token(address)"));` | `MINTABLE_ERC721_SELECTOR = bytes4(keccak256("MintableERC721Token(address,uint256)"));` For each token type, `assetInfo` is defined as follows: The `quantum` quantization factor defines the multiplicative transformation from the native token denomination as a 256b unsigned integer to a 63b unsigned integer representation as used by the Stark exchange. Only amounts in the native representation that represent an integer number of quanta are allowed in the system. The asset type is restricted to be the result of a hash of the `assetInfo` and the `quantum` masked to 250 bits (to be less than the prime used) according to the following formula: | ``uint256 assetType = uint256(keccak256(abi.encodePacked(assetInfo, quantum))) &`` | ``0x03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;`` Once registered, tokens cannot be removed from the system, as their IDs may be used by off-chain accounts. New tokens may only be registered by a Token Administrator. A Token Administrator may be instantly appointed or removed by the contract Governor (see :sol:mod:`MainGovernance`). Typically, the Token Administrator's private key should be kept in a cold wallet. */ abstract contract TokenRegister is MainStorage, LibConstants, MGovernance, MTokenAssetData { event LogTokenRegistered(uint256 assetType, bytes assetInfo, uint256 quantum); event LogTokenAdminAdded(address tokenAdmin); event LogTokenAdminRemoved(address tokenAdmin); modifier onlyTokensAdmin() { require(isTokenAdmin(msg.sender), "ONLY_TOKENS_ADMIN"); _; } function isTokenAdmin(address testedAdmin) public view returns (bool) { return tokenAdmins[testedAdmin]; } function registerTokenAdmin(address newAdmin) external onlyGovernance { tokenAdmins[newAdmin] = true; emit LogTokenAdminAdded(newAdmin); } function unregisterTokenAdmin(address oldAdmin) external onlyGovernance { tokenAdmins[oldAdmin] = false; emit LogTokenAdminRemoved(oldAdmin); } function isAssetRegistered(uint256 assetType) public view returns (bool) { return registeredAssetType[assetType]; } /* Registers a new asset to the system. Once added, it can not be removed and there is a limited number of slots available. */ function registerToken( uint256 assetType, bytes calldata assetInfo, uint256 quantum ) public virtual onlyTokensAdmin { // Make sure it is not invalid or already registered. require(!isAssetRegistered(assetType), "ASSET_ALREADY_REGISTERED"); require(assetType < K_MODULUS, "INVALID_ASSET_TYPE"); require(quantum > 0, "INVALID_QUANTUM"); require(quantum < QUANTUM_UPPER_BOUND, "INVALID_QUANTUM"); // Require that the assetType is the hash of the assetInfo and quantum truncated to 250 bits. uint256 enforcedId = uint256(keccak256(abi.encodePacked(assetInfo, quantum))) & MASK_250; require(assetType == enforcedId, "INVALID_ASSET_TYPE"); verifyAssetInfo(assetInfo); // NFTs quantum must equal one. if (isNonFungibleAssetInfo(assetInfo)) { require(quantum == 1, "INVALID_NFT_QUANTUM"); } // Add token to the in-storage structures. registeredAssetType[assetType] = true; assetTypeToAssetInfo[assetType] = assetInfo; assetTypeToQuantum[assetType] = quantum; // Log the registration of a new token. emit LogTokenRegistered(assetType, assetInfo, quantum); } function registerToken(uint256 assetType, bytes calldata assetInfo) external virtual { registerToken(assetType, assetInfo, 1); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../libraries/Common.sol"; import "../interfaces/MTokenTransfers.sol"; import "../interfaces/MTokenAssetData.sol"; import "../interfaces/MTokenQuantization.sol"; import "../tokens/ERC1155/IERC1155.sol"; import "../tokens/ERC20/IERC20.sol"; /* Implements various transferIn and transferOut functionalities. */ abstract contract TokenTransfers is MTokenQuantization, MTokenAssetData, MTokenTransfers { using Addresses for address; using Addresses for address payable; /* Transfers funds from msg.sender to the exchange. */ function transferIn(uint256 assetType, uint256 quantizedAmount) internal override { uint256 amount = fromQuantized(assetType, quantizedAmount); if (isERC20(assetType)) { if (quantizedAmount == 0) return; address tokenAddress = extractContractAddress(assetType); IERC20 token = IERC20(tokenAddress); uint256 exchangeBalanceBefore = token.balanceOf(address(this)); bytes memory callData = abi.encodeWithSelector( token.transferFrom.selector, msg.sender, address(this), amount ); tokenAddress.safeTokenContractCall(callData); uint256 exchangeBalanceAfter = token.balanceOf(address(this)); require(exchangeBalanceAfter >= exchangeBalanceBefore, "OVERFLOW"); // NOLINTNEXTLINE(incorrect-equality): strict equality needed. require( exchangeBalanceAfter == exchangeBalanceBefore + amount, "INCORRECT_AMOUNT_TRANSFERRED" ); } else if (isEther(assetType)) { require(msg.value == amount, "INCORRECT_DEPOSIT_AMOUNT"); } else { revert("UNSUPPORTED_TOKEN_TYPE"); } } /* Transfers non fungible and semi fungible tokens from a user to the exchange. */ function transferInWithTokenId( uint256 assetType, uint256 tokenId, uint256 quantizedAmount ) internal override { require(isAssetTypeWithTokenId(assetType), "FUNGIBLE_ASSET_TYPE"); if (isERC721(assetType)) { require(quantizedAmount == 1, "ILLEGAL_NFT_BALANCE"); transferInNft(assetType, tokenId); } else if (quantizedAmount > 0) { transferInSft(assetType, tokenId, quantizedAmount); } } function transferInNft(uint256 assetType, uint256 tokenId) private { require(isERC721(assetType), "NOT_ERC721_TOKEN"); address tokenAddress = extractContractAddress(assetType); tokenAddress.safeTokenContractCall( abi.encodeWithSignature( "safeTransferFrom(address,address,uint256)", msg.sender, address(this), tokenId ) ); } function transferInSft( uint256 assetType, uint256 tokenId, uint256 quantizedAmount ) private { require(isERC1155(assetType), "NOT_ERC1155_TOKEN"); if (quantizedAmount == 0) return; uint256 amount = fromQuantized(assetType, quantizedAmount); address tokenAddress = extractContractAddress(assetType); IERC1155 token = IERC1155(tokenAddress); uint256 exchangeBalanceBefore = token.balanceOf(address(this), tokenId); // Call an ERC1155 token transfer. tokenAddress.safeTokenContractCall( abi.encodeWithSelector( token.safeTransferFrom.selector, msg.sender, address(this), tokenId, amount, bytes("") ) ); uint256 exchangeBalanceAfter = token.balanceOf(address(this), tokenId); require(exchangeBalanceAfter >= exchangeBalanceBefore, "OVERFLOW"); // NOLINTNEXTLINE(incorrect-equality): strict equality needed. require( exchangeBalanceAfter == exchangeBalanceBefore + amount, "INCORRECT_AMOUNT_TRANSFERRED" ); } /* Transfers funds from the exchange to recipient. */ function transferOut( address payable recipient, uint256 assetType, uint256 quantizedAmount ) internal override { // Make sure we don't accidentally burn funds. require(recipient != address(0x0), "INVALID_RECIPIENT"); uint256 amount = fromQuantized(assetType, quantizedAmount); if (isERC20(assetType)) { if (quantizedAmount == 0) return; address tokenAddress = extractContractAddress(assetType); IERC20 token = IERC20(tokenAddress); uint256 exchangeBalanceBefore = token.balanceOf(address(this)); bytes memory callData = abi.encodeWithSelector( token.transfer.selector, recipient, amount ); tokenAddress.safeTokenContractCall(callData); uint256 exchangeBalanceAfter = token.balanceOf(address(this)); require(exchangeBalanceAfter <= exchangeBalanceBefore, "UNDERFLOW"); // NOLINTNEXTLINE(incorrect-equality): strict equality needed. require( exchangeBalanceAfter == exchangeBalanceBefore - amount, "INCORRECT_AMOUNT_TRANSFERRED" ); } else if (isEther(assetType)) { if (quantizedAmount == 0) return; recipient.performEthTransfer(amount); } else { revert("UNSUPPORTED_TOKEN_TYPE"); } } /* Transfers non fungible and semi fungible tokens from the exchange to recipient. */ function transferOutWithTokenId( address recipient, uint256 assetType, uint256 tokenId, uint256 quantizedAmount ) internal override { require(isAssetTypeWithTokenId(assetType), "FUNGIBLE_ASSET_TYPE"); if (isERC721(assetType)) { require(quantizedAmount == 1, "ILLEGAL_NFT_BALANCE"); transferOutNft(recipient, assetType, tokenId); } else if (quantizedAmount > 0) { transferOutSft(recipient, assetType, tokenId, quantizedAmount); } } /* Transfers NFT from the exchange to recipient. */ function transferOutNft( address recipient, uint256 assetType, uint256 tokenId ) private { // Make sure we don't accidentally burn funds. require(recipient != address(0x0), "INVALID_RECIPIENT"); require(isERC721(assetType), "NOT_ERC721_TOKEN"); address tokenAddress = extractContractAddress(assetType); tokenAddress.safeTokenContractCall( abi.encodeWithSignature( "safeTransferFrom(address,address,uint256)", address(this), recipient, tokenId ) ); } /* Transfers Semi Fungible Tokens from the exchange to recipient. */ function transferOutSft( address recipient, uint256 assetType, uint256 tokenId, uint256 quantizedAmount ) private { // Make sure we don't accidentally burn funds. require(recipient != address(0x0), "INVALID_RECIPIENT"); require(isERC1155(assetType), "NOT_ERC1155_TOKEN"); if (quantizedAmount == 0) return; uint256 amount = fromQuantized(assetType, quantizedAmount); address tokenAddress = extractContractAddress(assetType); IERC1155 token = IERC1155(tokenAddress); uint256 exchangeBalanceBefore = token.balanceOf(address(this), tokenId); // Call an ERC1155 token transfer. tokenAddress.safeTokenContractCall( abi.encodeWithSelector( token.safeTransferFrom.selector, address(this), recipient, tokenId, amount, bytes("") ) ); uint256 exchangeBalanceAfter = token.balanceOf(address(this), tokenId); require(exchangeBalanceAfter <= exchangeBalanceBefore, "UNDERFLOW"); // NOLINTNEXTLINE(incorrect-equality): strict equality needed. require( exchangeBalanceAfter == exchangeBalanceBefore - amount, "INCORRECT_AMOUNT_TRANSFERRED" ); } function transferOutMint( uint256 assetType, uint256 quantizedAmount, address recipient, bytes calldata mintingBlob ) internal override { // Make sure we don't accidentally burn funds. require(recipient != address(0x0), "INVALID_RECIPIENT"); require(isMintableAssetType(assetType), "NON_MINTABLE_ASSET_TYPE"); require(quantizedAmount > 0, "INVALID_MINT_AMOUNT"); uint256 amount = fromQuantized(assetType, quantizedAmount); address tokenAddress = extractContractAddress(assetType); tokenAddress.safeTokenContractCall( abi.encodeWithSignature( "mintFor(address,uint256,bytes)", recipient, amount, mintingBlob ) ); } }
/* Copyright 2019-2024 StarkWare Industries Ltd. Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.starkware.co/open-source-license/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // SPDX-License-Identifier: Apache-2.0. pragma solidity ^0.6.12; import "../interfaces/MAcceptModifications.sol"; import "../interfaces/MBlocklist.sol"; import "../interfaces/MTokenQuantization.sol"; import "../interfaces/MTokenAssetData.sol"; import "../interfaces/MFreezable.sol"; import "../interfaces/MKeyGetters.sol"; import "../interfaces/MTokenTransfers.sol"; import "../components/MainStorage.sol"; /** For a user to perform a withdrawal operation from the Stark Exchange during normal operation two calls are required: 1. A call to an offchain exchange API, requesting a withdrawal from a user account (vault). 2. A call to the on-chain :sol:func:`withdraw` function to perform the actual withdrawal of funds transferring them to the users Eth or ERC20 account (depending on the token type). For simplicity, hereafter it is assumed that all tokens are ERC20 tokens but the text below applies to Eth in the same manner. In the first call mentioned above, anyone can call the API to request the withdrawal of an amount from a given vault. Following the request, the exchange may include the withdrawal in a STARK proof. The submission of a proof then results in the addition of the amount(s) withdrawn to an on-chain pending withdrawals account under the stark key of the vault owner and the appropriate asset ID. At the same time, this also implies that this amount is deducted from the off-chain vault. Once the amount to be withdrawn has been transfered to the on-chain pending withdrawals account, the user may perform the second call mentioned above to complete the transfer of funds from the Stark Exchange contract to the appropriate ERC20 account. Only a user holding the Eth key corresponding to the Stark Key of a pending withdrawals account may perform this operation. It is possible that for multiple withdrawal calls to the API, a single withdrawal call to the contract may retrieve all funds, as long as they are all for the same asset ID. The result of the operation, assuming all requirements are met, is that an amount of ERC20 tokens in the pending withdrawal account times the quantization factor is transferred to the ERC20 account of the user. A withdrawal request cannot be cancelled. Once funds reach the pending withdrawals account on-chain, they cannot be moved back into an off-chain vault before completion of the withdrawal to the ERC20 account of the user. In the event that the exchange reaches a frozen state the user may perform a withdrawal operation via an alternative flow, known as the "Escape" flow. In this flow, the API call above is replaced with an :sol:func:`escape` call to the on-chain contract (see :sol:mod:`Escapes`) proving the ownership of off-chain funds. If such proof is accepted, the user may proceed as above with the :sol:func:`withdraw` call to the contract to complete the operation. */ abstract contract Withdrawals is MainStorage, MAcceptModifications, MTokenQuantization, MTokenAssetData, MFreezable, MKeyGetters, MTokenTransfers, MBlocklist { event LogWithdrawalPerformed( uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount, address recipient ); event LogNftWithdrawalPerformed( uint256 ownerKey, uint256 assetType, uint256 tokenId, uint256 assetId, address recipient ); event LogWithdrawalWithTokenIdPerformed( uint256 ownerKey, uint256 assetType, uint256 tokenId, uint256 assetId, uint256 nonQuantizedAmount, uint256 quantizedAmount, address recipient ); event LogMintWithdrawalPerformed( uint256 ownerKey, uint256 assetType, uint256 nonQuantizedAmount, uint256 quantizedAmount, uint256 assetId ); function getWithdrawalBalance(uint256 ownerKey, uint256 assetId) external view returns (uint256) { uint256 presumedAssetType = assetId; return fromQuantized(presumedAssetType, pendingWithdrawals[ownerKey][assetId]); } /* Moves funds from the pending withdrawal account to the owner address. Note: this function can be called by anyone. Can be called normally while frozen. */ function withdraw(uint256 ownerKey, uint256 assetType) external onlyNotBlocked(ownerKey) { address payable recipient = payable(strictGetEthKey(ownerKey)); require(!isMintableAssetType(assetType), "MINTABLE_ASSET_TYPE"); require(isFungibleAssetType(assetType), "NON_FUNGIBLE_ASSET_TYPE"); uint256 assetId = assetType; // Fetch and clear quantized amount. uint256 quantizedAmount = pendingWithdrawals[ownerKey][assetId]; pendingWithdrawals[ownerKey][assetId] = 0; // Transfer funds. transferOut(recipient, assetType, quantizedAmount); emit LogWithdrawalPerformed( ownerKey, assetType, fromQuantized(assetType, quantizedAmount), quantizedAmount, recipient ); } /* Allows withdrawal of tokens to their owner's account. Note: this function can be called by anyone. This function can be called normally while frozen. */ function withdrawWithTokenId( uint256 ownerKey, uint256 assetType, uint256 tokenId // No notFrozen modifier: This function can always be used, even when frozen. ) public onlyNotBlocked(ownerKey) { require(isAssetTypeWithTokenId(assetType), "INVALID_ASSET_TYPE"); uint256 assetId = calculateAssetIdWithTokenId(assetType, tokenId); address recipient = strictGetEthKey(ownerKey); uint256 quantizedAmount = pendingWithdrawals[ownerKey][assetId]; pendingWithdrawals[ownerKey][assetId] = 0; // Transfer funds. transferOutWithTokenId(recipient, assetType, tokenId, quantizedAmount); if (isERC721(assetType)) { emit LogNftWithdrawalPerformed(ownerKey, assetType, tokenId, assetId, recipient); } emit LogWithdrawalWithTokenIdPerformed( ownerKey, assetType, tokenId, assetId, fromQuantized(assetType, quantizedAmount), quantizedAmount, recipient ); } /* Allows withdrawal of an NFT to its owner's account. Note: this function can be called by anyone. This function can be called normally while frozen. */ function withdrawNft( uint256 ownerKey, uint256 assetType, uint256 tokenId // No notFrozen modifier: This function can always be used, even when frozen. ) external { withdrawWithTokenId(ownerKey, assetType, tokenId); } function withdrawAndMint( uint256 ownerKey, uint256 assetType, bytes calldata mintingBlob ) external onlyNotBlocked(ownerKey) { address recipient = strictGetEthKey(ownerKey); require(registeredAssetType[assetType], "INVALID_ASSET_TYPE"); require(isMintableAssetType(assetType), "NON_MINTABLE_ASSET_TYPE"); uint256 assetId = calculateMintableAssetId(assetType, mintingBlob); require(pendingWithdrawals[ownerKey][assetId] > 0, "NO_PENDING_WITHDRAWAL_BALANCE"); uint256 quantizedAmount = pendingWithdrawals[ownerKey][assetId]; pendingWithdrawals[ownerKey][assetId] = 0; // Transfer funds. transferOutMint(assetType, quantizedAmount, recipient, mintingBlob); emit LogMintWithdrawalPerformed( ownerKey, assetType, fromQuantized(assetType, quantizedAmount), quantizedAmount, assetId ); } }
{ "metadata": { "useLiteralContent": true }, "libraries": {}, "remappings": [], "optimizer": { "enabled": true, "runs": 100 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ownerKey","type":"uint256"}],"name":"BlockPlaced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"ownerKey","type":"uint256"}],"name":"BlockReleased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ownerKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"LogAssetWithdrawalAllowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"depositorEthKey","type":"address"},{"indexed":false,"internalType":"uint256","name":"starkKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonQuantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"LogDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"starkKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"}],"name":"LogDepositCancel","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"starkKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonQuantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"LogDepositCancelReclaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"starkKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"}],"name":"LogDepositNftCancelReclaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"depositorEthKey","type":"address"},{"indexed":false,"internalType":"uint256","name":"starkKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonQuantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"LogDepositWithTokenId","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"starkKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonQuantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"LogDepositWithTokenIdCancelReclaimed","type":"event"},{"anonymous":false,"inputs":[],"name":"LogFrozen","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ownerKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonQuantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"}],"name":"LogMintWithdrawalPerformed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ownerKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"LogMintableWithdrawalAllowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"acceptedGovernor","type":"address"}],"name":"LogNewGovernorAccepted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"depositorEthKey","type":"address"},{"indexed":false,"internalType":"uint256","name":"starkKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"vaultId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"}],"name":"LogNftDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ownerKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"}],"name":"LogNftWithdrawalAllowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ownerKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"LogNftWithdrawalPerformed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"nominatedGovernor","type":"address"}],"name":"LogNominatedGovernor","type":"event"},{"anonymous":false,"inputs":[],"name":"LogNominationCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"removedGovernor","type":"address"}],"name":"LogRemovedGovernor","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenAdmin","type":"address"}],"name":"LogTokenAdminAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenAdmin","type":"address"}],"name":"LogTokenAdminRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"assetInfo","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"quantum","type":"uint256"}],"name":"LogTokenRegistered","type":"event"},{"anonymous":false,"inputs":[],"name":"LogUnFrozen","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ownerKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonQuantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"LogWithdrawalAllowed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ownerKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonQuantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"LogWithdrawalPerformed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"ownerKey","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"assetId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nonQuantizedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantizedAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"LogWithdrawalWithTokenIdPerformed","type":"event"},{"inputs":[],"name":"DEPOSIT_CANCEL_DELAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FREEZE_GRACE_PERIOD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAIN_GOVERNANCE_INFO_TAG","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FORCED_ACTIONS_REQS_PER_BLOCK","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_VERIFIER_COUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNFREEZE_DELAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERIFIER_REMOVAL_DELAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"}],"name":"addToBlockedList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"calculateAssetIdWithTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"bytes","name":"mintingBlob","type":"bytes"}],"name":"calculateMintableAssetId","outputs":[{"internalType":"uint256","name":"assetId","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"defaultVaultWithdrawalLock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"},{"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"depositCancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"},{"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"depositERC1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"},{"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"depositERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"depositEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"depositNft","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"depositNftReclaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"depositReclaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"},{"internalType":"uint256","name":"quantizedAmount","type":"uint256"}],"name":"depositWithTokenId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"depositWithTokenIdReclaim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getActionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"actionIndex","type":"uint256"}],"name":"getActionHashByIndex","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetType","type":"uint256"}],"name":"getAssetInfo","outputs":[{"internalType":"bytes","name":"assetInfo","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"getCancellationRequest","outputs":[{"internalType":"uint256","name":"request","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"getDepositBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"}],"name":"getEthKey","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"getFullWithdrawalRequest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"starkKey","type":"uint256"},{"internalType":"uint256","name":"assetId","type":"uint256"},{"internalType":"uint256","name":"vaultId","type":"uint256"}],"name":"getQuantizedDepositBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"presumedAssetType","type":"uint256"}],"name":"getQuantum","outputs":[{"internalType":"uint256","name":"quantum","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"},{"internalType":"uint256","name":"assetId","type":"uint256"}],"name":"getWithdrawalBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"identify","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initializerSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetType","type":"uint256"}],"name":"isAssetRegistered","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"}],"name":"isBlockListed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isFrozen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"testedAdmin","type":"address"}],"name":"isTokenAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mainAcceptGovernance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mainCancelNomination","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"testGovernor","type":"address"}],"name":"mainIsGovernor","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newGovernor","type":"address"}],"name":"mainNominateNewGovernor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"governorForRemoval","type":"address"}],"name":"mainRemoveGovernor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"orderRegistryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"bytes","name":"assetInfo","type":"bytes"}],"name":"registerToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"bytes","name":"assetInfo","type":"bytes"},{"internalType":"uint256","name":"quantum","type":"uint256"}],"name":"registerToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"registerTokenAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"}],"name":"removeFromBlockedList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unFreeze","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"oldAdmin","type":"address"}],"name":"unregisterTokenAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"validatedSelectors","outputs":[{"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"bytes","name":"mintingBlob","type":"bytes"}],"name":"withdrawAndMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdrawNft","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ownerKey","type":"uint256"},{"internalType":"uint256","name":"assetType","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"withdrawWithTokenId","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506151d4806100206000396000f3fe60806040526004361061030a5760003560e01c80637cf12b901161019c578063b7663112116100e2578063dd7202d811610090578063dd7202d814610fbd578063e30a5cff14610fe7578063e6de628214610ffc578063ec3161b014611011578063eeb7286614611041578063f23a6e6114611056578063f637d950146110f6578063fcb05822146111205761030a565b8063b766311214610c23578063bc197c8114610c38578063be2b110514610d6c578063c23b60ef14610da8578063c8b1031a14610e32578063d88d8b3814610eb4578063d91443b714610f365761030a565b8063a1cc921e1161014a578063a1cc921e14610a15578063a2bdde3d14610a48578063a45d784114610a7b578063a6fa6e9014610a90578063abf98fe114610ac3578063ae1cdde614610af9578063ae87381614610b35578063b12773fb14610b6b5761030a565b80637cf12b90146109015780637df7dc04146109165780638c4bce1c1461094c578063993f36391461097f5780639c6a2837146109945780639ed17084146109a9578063a1cc5e13146109e55761030a565b8063345385ac116102615780634e8912da1161020f5780634e8912da146108025780635e586cd1146108385780635eecd2181461086257806364d848421461087757806369de5046146108ad5780636ce5d9571461033657806372eb3688146108d757806377e84e0d146108ec5761030a565b8063345385ac14610679578063381baf6f146106a35780633cc660ad146106cd578063439fab91146106e2578063441a3e701461075d57806345f5cd971461078d57806349325bac146107c05761030a565b80631dbd1da7116102be5780631dbd1da7146105255780632505c3d91461056b57806328700a15146105a7578063296e2f37146105bc57806329e411ac146105ec578063333ac20b1461062e57806333eeb147146106645761030a565b80627175421461030f578062aeef8a14610336578063019b417a14610361578063049f5ade146103975780630b3a2d21146103d55780630ebdac0314610408578063150b7a021461046d575b600080fd5b34801561031b57600080fd5b5061032461115c565b60408051918252519081900360200190f35b61035f6004803603606081101561034c57600080fd5b5080359060208101359060400135611163565b005b34801561036d57600080fd5b5061035f6004803603606081101561038457600080fd5b50803590602081013590604001356111cc565b3480156103a357600080fd5b506103c1600480360360208110156103ba57600080fd5b50356111d7565b604080519115158252519081900360200190f35b3480156103e157600080fd5b5061035f600480360360208110156103f857600080fd5b50356001600160a01b03166111ef565b34801561041457600080fd5b5061041d611296565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610459578181015183820152602001610441565b505050509050019250505060405180910390f35b34801561047957600080fd5b506105086004803603608081101561049057600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b8111156104ca57600080fd5b8201836020820111156104dc57600080fd5b803590602001918460018302840111600160201b831117156104fd57600080fd5b509092509050611484565b604080516001600160e01b03199092168252519081900360200190f35b34801561053157600080fd5b5061054f6004803603602081101561054857600080fd5b50356114b0565b604080516001600160a01b039092168252519081900360200190f35b34801561057757600080fd5b5061035f6004803603608081101561058e57600080fd5b50803590602081013590604081013590606001356114f5565b3480156105b357600080fd5b5061035f61166f565b3480156105c857600080fd5b50610324600480360360408110156105df57600080fd5b5080359060200135611679565b3480156105f857600080fd5b5061035f600480360360a081101561060f57600080fd5b50803590602081013590604081013590606081013590608001356116a0565b34801561063a57600080fd5b506103246004803603606081101561065157600080fd5b5080359060208101359060400135611899565b34801561067057600080fd5b506103c16118bd565b34801561068557600080fd5b5061035f6004803603602081101561069c57600080fd5b50356118cd565b3480156106af57600080fd5b5061035f600480360360208110156106c657600080fd5b503561197a565b3480156106d957600080fd5b50610324611a29565b3480156106ee57600080fd5b5061035f6004803603602081101561070557600080fd5b810190602081018135600160201b81111561071f57600080fd5b82018360208201111561073157600080fd5b803590602001918460018302840111600160201b8311171561075257600080fd5b509092509050611a2e565b34801561076957600080fd5b5061035f6004803603604081101561078057600080fd5b5080359060200135611a6d565b34801561079957600080fd5b506103c1600480360360208110156107b057600080fd5b50356001600160a01b0316611c02565b3480156107cc57600080fd5b5061035f600480360360a08110156107e357600080fd5b5080359060208101359060408101359060608101359060800135611c13565b34801561080e57600080fd5b506103246004803603606081101561082557600080fd5b5080359060208101359060400135611cc1565b34801561084457600080fd5b506103246004803603602081101561085b57600080fd5b5035611ce5565b34801561086e57600080fd5b50610324611d55565b34801561088357600080fd5b5061035f6004803603606081101561089a57600080fd5b5080359060208101359060400135611d5b565b3480156108b957600080fd5b506103c1600480360360208110156108d057600080fd5b5035611f1d565b3480156108e357600080fd5b5061035f611f32565b3480156108f857600080fd5b50610324611f3a565b34801561090d57600080fd5b5061035f611f41565b34801561092257600080fd5b5061035f6004803603606081101561093957600080fd5b5080359060208101359060400135612080565b34801561095857600080fd5b5061035f6004803603602081101561096f57600080fd5b50356001600160a01b0316612145565b34801561098b57600080fd5b50610324612151565b3480156109a057600080fd5b5061054f612159565b3480156109b557600080fd5b5061035f600480360360808110156109cc57600080fd5b5080359060208101359060408101359060600135612170565b3480156109f157600080fd5b5061032460048036036040811015610a0857600080fd5b5080359060200135612182565b348015610a2157600080fd5b5061035f60048036036020811015610a3857600080fd5b50356001600160a01b03166122a9565b348015610a5457600080fd5b506103c160048036036020811015610a6b57600080fd5b50356001600160a01b03166122b2565b348015610a8757600080fd5b506103246122d0565b348015610a9c57600080fd5b5061035f60048036036020811015610ab357600080fd5b50356001600160a01b03166122de565b348015610acf57600080fd5b5061032460048036036060811015610ae657600080fd5b5080359060208101359060400135612382565b348015610b0557600080fd5b5061035f60048036036080811015610b1c57600080fd5b50803590602081013590604081013590606001356123ba565b348015610b4157600080fd5b5061035f60048036036060811015610b5857600080fd5b5080359060208101359060400135612461565b348015610b7757600080fd5b5061032460048036036040811015610b8e57600080fd5b81359190810190604081016020820135600160201b811115610baf57600080fd5b820183602082011115610bc157600080fd5b803590602001918460018302840111600160201b83111715610be257600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061258f945050505050565b348015610c2f57600080fd5b50610324612650565b348015610c4457600080fd5b50610508600480360360a0811015610c5b57600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b811115610c8e57600080fd5b820183602082011115610ca057600080fd5b803590602001918460208302840111600160201b83111715610cc157600080fd5b919390929091602081019035600160201b811115610cde57600080fd5b820183602082011115610cf057600080fd5b803590602001918460208302840111600160201b83111715610d1157600080fd5b919390929091602081019035600160201b811115610d2e57600080fd5b820183602082011115610d4057600080fd5b803590602001918460018302840111600160201b83111715610d6157600080fd5b509092509050612657565b348015610d7857600080fd5b5061035f60048036036080811015610d8f57600080fd5b5080359060208101359060408101359060600135612686565b348015610db457600080fd5b50610dbd612830565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610df7578181015183820152602001610ddf565b50505050905090810190601f168015610e245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610e3e57600080fd5b5061035f60048036036040811015610e5557600080fd5b81359190810190604081016020820135600160201b811115610e7657600080fd5b820183602082011115610e8857600080fd5b803590602001918460018302840111600160201b83111715610ea957600080fd5b50909250905061284c565b348015610ec057600080fd5b5061035f60048036036060811015610ed757600080fd5b81359190810190604081016020820135600160201b811115610ef857600080fd5b820183602082011115610f0a57600080fd5b803590602001918460018302840111600160201b83111715610f2b57600080fd5b919350915035612855565b348015610f4257600080fd5b5061035f60048036036060811015610f5957600080fd5b813591602081013591810190606081016040820135600160201b811115610f7f57600080fd5b820183602082011115610f9157600080fd5b803590602001918460018302840111600160201b83111715610fb257600080fd5b509092509050612bf7565b348015610fc957600080fd5b5061032460048036036020811015610fe057600080fd5b5035612e3e565b348015610ff357600080fd5b50610324612e6f565b34801561100857600080fd5b50610324612e74565b34801561101d57600080fd5b506103246004803603604081101561103457600080fd5b5080359060200135612e79565b34801561104d57600080fd5b50610dbd612ea8565b34801561106257600080fd5b50610508600480360360a081101561107957600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b8111156110b857600080fd5b8201836020820111156110ca57600080fd5b803590602001918460018302840111600160201b831117156110eb57600080fd5b509092509050612ec8565b34801561110257600080fd5b50610dbd6004803603602081101561111957600080fd5b5035612ef5565b34801561112c57600080fd5b5061035f6004803603608081101561114357600080fd5b5080359060208101359060408101359060600135612ff6565b62093a8081565b61116c8261305f565b6111b2576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b6111c78383836111c28634613083565b6114f5565b505050565b6111c7838383611d5b565b60008181526015602052604090205460ff165b919050565b6111f8336130f0565b61123b576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6001600160a01b038116600081815260116020908152604091829020805460ff19166001179055815192835290517f9085a9044aeb6daeeb5b4bf84af42b1a1613d4056f503c4e992b6396c16bd52f9281900390910190a150565b604080516007808252610100820190925260609190600090826020820160e08036833750508151919450506001820191631f7df70160e21b9185919081106112da57fe5b6001600160e01b0319909216602092830291909101909101528251600182019163be2b110560e01b91859190811061130e57fe5b6001600160e01b031990921660209283029190910190910152825160018201916357439c0b60e11b91859190811061134257fe5b6001600160e01b03199092166020928302919091019091015282516001820191630441a3e760e41b91859190811061137657fe5b6001600160e01b0319909216602092830291909101909101528251600182019163d91443b760e01b9185919081106113aa57fe5b6001600160e01b0319909216602092830291909101909101528251600182019163326c242160e11b9185919081106113de57fe5b6001600160e01b0319909216602092830291909101909101528251600182019163381baf6f60e01b91859190811061141257fe5b6001600160e01b03199092166020928302919091019091015280821461147f576040805162461bcd60e51b815260206004820181905260248201527f494e434f52524543545f53454c4543544f52535f41525241595f4c454e475448604482015290519081900360640190fd5b505090565b60006001600160a01b038616301461149d5760006114a6565b630a85bd0160e11b5b9695505050505050565b6000818152601860205260408120546001600160a01b031680156114d55790506111ea565b6001600160a01b03831683146114ec5760006114ee565b825b9392505050565b6114fd6118bd565b15611541576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b61154a8361311f565b15611592576040805162461bcd60e51b81526020600482015260136024820152724d494e5441424c455f41535345545f5459504560681b604482015290519081900360640190fd5b61159b83613163565b6115e6576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f46554e4749424c455f41535345545f5459504560481b604482015290519081900360640190fd5b826115f3858285856131c2565b506115fe84836132b7565b7f06724742ccc8c330a39a641ef02a0b419bd09248360680bb38159b0a8c2635d63386858761162d898861357c565b604080516001600160a01b0390961686526020860194909452848401929092526060840152608083015260a08201859052519081900360c00190a15050505050565b6116776135ed565b565b60006022600061168985856136b4565b815260200190815260200160002054905092915050565b6116a86118bd565b156116ec576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b6116f58461370e565b61173b576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b60006117478585612182565b90506000611757878386866131c2565b905061176286613752565b1561180b5760018111156117b5576040805162461bcd60e51b81526020600482015260156024820152741253131151d05317d15490cdcc8c57d05353d55395605a1b604482015290519081900360640190fd5b6040805133815260208101899052808201869052606081018890526080810187905260a0810184905290517f0fcf2162832b2d6033d4d34d2f45a28d9cfee523f1899945bbdd32529cfda67b9181900360c00190a15b611816868685613765565b7fed94dc026fa9364c53bc0af51cde7f54f3109b3f31fceb26d01396d80e20453b3388868989876118478d8b61357c565b604080516001600160a01b0390981688526020880196909652868601949094526060860192909252608085015260a084015260c083015260e0820186905251908190036101000190a150505050505050565b60009283526007602090815260408085209385529281528284209184525290205490565b600454600160a01b900460ff1690565b3373520cf70a2d0b3dfb7386a2bc9f800321f62a5c3a14611928576040805162461bcd60e51b815260206004820152601060248201526f27a7262cafa12627a1a5afa0a226a4a760811b604482015290519081900360640190fd5b61193181611f1d565b156119625760405181907fc5c4ee30d6cb77d673bd39088a871847fe5d6939fc472c5e0a70e0cca6dd10dc90600090a25b6000908152602860205260409020805460ff19169055565b3373520cf70a2d0b3dfb7386a2bc9f800321f62a5c3a146119d5576040805162461bcd60e51b815260206004820152601060248201526f27a7262cafa12627a1a5afa0a226a4a760811b604482015290519081900360640190fd5b6119de81611f1d565b611a0e5760405181907f9ff85bce88647ea2dd40dc32cdf6d3207cb8bdf6e7d1b3d3ac50222d3d1d582490600090a25b6000908152602860205260409020805460ff19166001179055565b600090565b6040805162461bcd60e51b815260206004820152600f60248201526e1393d517d253541311535153951151608a1b604482015290519081900360640190fd5b81611a7781611f1d565b15611abd576040805162461bcd60e51b81526020600482015260116024820152701554d15497d09313d0d2d7d31254d51151607a1b604482015290519081900360640190fd5b6000611ac884613829565b9050611ad38361311f565b15611b1b576040805162461bcd60e51b81526020600482015260136024820152724d494e5441424c455f41535345545f5459504560681b604482015290519081900360640190fd5b611b2483613163565b611b6f576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f46554e4749424c455f41535345545f5459504560481b604482015290519081900360640190fd5b6000848152600860209081526040808320868452909152812080549190558390611b9a838383613885565b7fb7477a7b93b2addc5272bbd7ad0986ef1c0d0bd265f26c3dc4bbe42727c2ac0c8686611bc7888561357c565b60408051938452602084019290925282820152606082018490526001600160a01b0386166080830152519081900360a00190a1505050505050565b6000611c0d826130f0565b92915050565b611c1b6118bd565b15611c5f576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b611c6884613b1c565b611cad576040805162461bcd60e51b81526020600482015260116024820152702727aa2fa2a92198989a9aafaa27a5a2a760791b604482015290519081900360640190fd5b611cba85858585856116a0565b5050505050565b60009283526006602090815260408085209385529281528284209184525290205490565b6024546000908210611d36576040805162461bcd60e51b815260206004820152601560248201527408286a8929e9cbe929c888ab0bea89e9ebe90928e9605b1b604482015290519081900360640190fd5b60248281548110611d4357fe5b90600052602060002001549050919050565b60245490565b82611d6581611f1d565b15611dab576040805162461bcd60e51b81526020600482015260116024820152701554d15497d09313d0d2d7d31254d51151607a1b604482015290519081900360640190fd5b611db48361370e565b611dfa576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b6000611e068484612182565b90506000611e1386613829565b600087815260086020908152604080832086845290915281208054919055909150611e4082878784613b2f565b611e4986613752565b15611ea5576040805188815260208101889052808201879052606081018590526001600160a01b038416608082015290517fa5cfa8e2199ec5b8ca319288bcab72734207d30569756ee594a74b4df7abbf419181900360a00190a15b7fc6ba68235f3229e53f3a95cda25543ad54c0f6df2493a06c05fb930bea7966fe87878786611ed48b8761357c565b604080519586526020860194909452848401929092526060840152608083015260a082018490526001600160a01b03851660c0830152519081900360e00190a150505050505050565b60009081526028602052604090205460ff1690565b611677613bf5565b6202a30081565b611f496118bd565b611f8d576040805162461bcd60e51b815260206004820152601060248201526f29aa20aa22afa727aa2fa32927ad22a760811b604482015290519081900360640190fd5b611f96336130f0565b611fd9576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b60055442101561202b576040805162461bcd60e51b8152602060048201526018602482015277155391949151569157d393d517d0531313d5d15117d6515560421b604482015290519081900360640190fd5b6004805460ff60a01b19169055600d805460019081019091556025805482019055600f805490910190556040517f07017fe9180629cfffba412f65a9affcf9a121de02294179f5c058f881dcc9f890600090a1565b8261208a81613829565b6001600160a01b0316336001600160a01b0316146120dd576040805162461bcd60e51b815260206004820152601a6024820152600080516020615117833981519152604482015290519081900360640190fd5b60008481526007602090815260408083208684528252808320858452825291829020429055815186815290810184905280820185905290517f0bc1df35228095c37da66a6ffcc755ea79dfc437345685f618e05fafad6b445e9181900360600190a150505050565b61214e81613c8c565b50565b6301e1338081565b68010000000000000004546001600160a01b031681565b61217c848484846114f5565b50505050565b600061218d8361370e565b6121c85760405162461bcd60e51b81526004018080602001828103825260218152602001806151376021913960400191505060405180910390fd5b60606121d384613752565b612202576040518060400160405280600d81526020016c2727a72fa6a4a72a20a126229d60991b815250612220565b6040518060400160405280600481526020016327232a1d60e11b8152505b90506001600160fa1b038185856040516020018084805190602001908083835b6020831061225f5780518252601f199092019160209182019101612240565b51815160209384036101000a600019018019909216911617905292019485525083810192909252506040805180840383018152928101905281519101209190911695945050505050565b61214e81613d89565b6001600160a01b031660009081526011602052604090205460ff1690565b680100000000000000035481565b6122e7336130f0565b61232a576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6001600160a01b038116600081815260116020908152604091829020805460ff19169055815192835290517ffa49aecb996ea8d99950bb051552dfcc0b5460a0bb209867a1ed8067c32c21779281900390910190a150565b6000838152600660209081526040808320858452825280832084845290915281205483906123b190829061357c565b95945050505050565b6123c26118bd565b15612406576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b61240f83613752565b612453576040805162461bcd60e51b815260206004820152601060248201526f2727aa2fa2a9219b9918afaa27a5a2a760811b604482015290519081900360640190fd5b61217c8484838560016116a0565b8261246b81613829565b6001600160a01b0316336001600160a01b0316146124be576040805162461bcd60e51b815260206004820152601a6024820152600080516020615117833981519152604482015290519081900360640190fd5b6124c783613163565b612512576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f46554e4749424c455f41535345545f5459504560481b604482015290519081900360640190fd5b826000612520868386613ed6565b905061252d338683613885565b7fe3e46ecf1138180bf93cba62a0b7e661d976a8ab3d40243f7b082667d8f500af86858761255b898661357c565b60408051948552602085019390935283830191909152606083015260808201849052519081900360a00190a1505050505050565b600080828051906020012060001c9050600160fa1b6001600160f01b036040518060400160405280600981526020016826a4a72a20a126229d60b91b81525086846040516020018084805190602001908083835b602083106126025780518252601f1990920191602091820191016125e3565b51815160209384036101000a60001901801990921691161790529201948552508381019290925250604080518084038301815292810190528151910120919091169190911795945050505050565b6224ea0081565b60006001600160a01b0389163014612670576000612679565b63bc197c8160e01b5b9998505050505050505050565b8361269081613829565b6001600160a01b0316336001600160a01b0316146126e3576040805162461bcd60e51b815260206004820152601a6024820152600080516020615117833981519152604482015290519081900360640190fd5b6126ec8461370e565b612732576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b600061273e8585612182565b9050600061274d878386613ed6565b905080156127615761276133878784613b2f565b61276a86613752565b156127be576040805188815260208101869052808201889052606081018790526080810184905290517ff00c0c1a754f6df7545d96a7e12aad552728b94ca6aa94f81e297bdbcf1dab9c9181900360a00190a15b7fcc00f2179d127845242252f3c3b6b238c5ed33c2e933179f09653cfb1cdee7ca87858888866127ee8c8861357c565b604080519687526020870195909552858501939093526060850191909152608084015260a083015260c08201849052519081900360e00190a150505050505050565b6040518060600160405280602681526020016151586026913981565b6111c783838360015b61285e336122b2565b6128a3576040805162461bcd60e51b815260206004820152601160248201527027a7262cafaa27a5a2a729afa0a226a4a760791b604482015290519081900360640190fd5b6128ac846111d7565b156128f9576040805162461bcd60e51b81526020600482015260186024820152771054d4d15517d053149150511657d49151d254d51154915160421b604482015290519081900360640190fd5b600167080000000000001160c01b018410612950576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b60008111612997576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f5155414e54554d60881b604482015290519081900360640190fd5b600160801b81106129e1576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f5155414e54554d60881b604482015290519081900360640190fd5b60006001600160fa1b0384848460405160200180848480828437919091019283525050604080518083038152602092830190915280519101209290921692505050848114612a6b576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b612aaa84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613fe392505050565b612ae984848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061415f92505050565b15612b395781600114612b39576040805162461bcd60e51b8152602060048201526013602482015272494e56414c49445f4e46545f5155414e54554d60681b604482015290519081900360640190fd5b6000858152601560209081526040808320805460ff1916600117905560149091529020612b67908585615063565b508160166000878152602001908152602001600020819055507f7a0efbc885500f3b4a895231945be4520e4c0ba5ef7274a225a0272c81ccbcb78585858560405180858152602001806020018381526020018281038252858582818152602001925080828437600083820152604051601f909101601f191690920182900397509095505050505050a15050505050565b83612c0181611f1d565b15612c47576040805162461bcd60e51b81526020600482015260116024820152701554d15497d09313d0d2d7d31254d51151607a1b604482015290519081900360640190fd5b6000612c5286613829565b60008681526015602052604090205490915060ff16612cad576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b612cb68561311f565b612d01576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f4d494e5441424c455f41535345545f5459504560481b604482015290519081900360640190fd5b6000612d438686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061258f92505050565b6000888152600860209081526040808320848452909152902054909150612db1576040805162461bcd60e51b815260206004820152601d60248201527f4e4f5f50454e44494e475f5749544844524157414c5f42414c414e4345000000604482015290519081900360640190fd5b600087815260086020908152604080832084845290915281208054919055612ddc87828589896141a3565b7f7e6e15df814c1a309a57686de672b2bedd128eacde35c5370c36d6840d4e9a928888612e098a8561357c565b604080519384526020840192909252828201526060820184905260808201859052519081900360a00190a15050505050505050565b60008181526015602052604081205460ff16612e5c575060016111ea565b5060009081526016602052604090205490565b600a81565b604081565b60008281526008602090815260408083208484529091528120548290612ea090829061357c565b949350505050565b606060405180606001604052806021815260200161517e60219139905090565b60006001600160a01b0387163014612ee1576000612eea565b63f23a6e6160e01b5b979650505050505050565b60008181526015602052604090205460609060ff16612f57576040805162461bcd60e51b81526020600482015260196024820152781054d4d15517d516541157d393d517d49151d254d511549151603a1b604482015290519081900360640190fd5b60008281526014602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015612fea5780601f10612fbf57610100808354040283529160200191612fea565b820191906000526020600020905b815481529060010190602001808311612fcd57829003601f168201915b50505050509050919050565b8361300081613829565b6001600160a01b0316336001600160a01b031614613053576040805162461bcd60e51b815260206004820152601a6024820152600080516020615117833981519152604482015290519081900360640190fd5b611cba85858486612686565b60006341917ff960e11b61307283614345565b6001600160e01b0319161492915050565b60008061308f84612e3e565b905080838161309a57fe5b06156130de576040805162461bcd60e51b815260206004820152600e60248201526d1253959053125117d05353d5539560921b604482015290519081900360640190fd5b8083816130e757fe5b04949350505050565b6000806130fb614358565b6001600160a01b039390931660009081526020939093525050604090205460ff1690565b60008061312b83614345565b90506001600160e01b031981166368646e2d60e01b14806114ee57506001600160e01b03198116635c5c333960e11b14915050919050565b60008061316f83614345565b90506001600160e01b031981166341917ff960e11b14806131a057506001600160e01b03198116630f47261b60e41b145b806114ee57506001600160e01b031981166368646e2d60e01b14915050919050565b6000848152600660209081526040808320868452825280832085845290915281205482018281101561322e576040805162461bcd60e51b815260206004820152601060248201526f4445504f5349545f4f564552464c4f5760801b604482015290519081900360640190fd5b60008681526006602090815260408083208884528252808320878452909152902081905561325b866143d5565b801561328757506000868152600760209081526040808320888452825280832087845290915290205415155b156123b1576000868152600760209081526040808320888452825280832087845290915281205595945050505050565b60006132c3838361357c565b90506132ce836143fb565b156134d057816132de5750613578565b60006132e98461440e565b905060008190506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561333f57600080fd5b505afa158015613353573d6000803e3d6000fd5b505050506040513d602081101561336957600080fd5b50516040805133602482015230604482015260648082018890528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790529091506133c56001600160a01b03851682614421565b6000836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561341457600080fd5b505afa158015613428573d6000803e3d6000fd5b505050506040513d602081101561343e57600080fd5b5051905082811015613482576040805162461bcd60e51b81526020600482015260086024820152674f564552464c4f5760c01b604482015290519081900360640190fd5b85830181146134c6576040805162461bcd60e51b815260206004820152601c60248201526000805160206150f7833981519152604482015290519081900360640190fd5b50505050506111c7565b6134d98361305f565b156135325780341461352d576040805162461bcd60e51b8152602060048201526018602482015277125390d3d4949150d517d1115413d4d25517d05353d5539560421b604482015290519081900360640190fd5b6111c7565b6040805162461bcd60e51b8152602060048201526016602482015275554e535550504f525445445f544f4b454e5f5459504560501b604482015290519081900360640190fd5b5050565b60008061358884612e3e565b905080830291508281838161359957fe5b04146135e6576040805162461bcd60e51b815260206004820152601760248201527644455155414e54495a4154494f4e5f4f564552464c4f5760481b604482015290519081900360640190fd5b5092915050565b60006135f7614358565b60018101549091506001600160a01b03163314613655576040805162461bcd60e51b815260206004820152601760248201527627a7262cafa1a0a72224a220aa22afa3a7ab22a92727a960491b604482015290519081900360640190fd5b600181015461366c906001600160a01b031661460d565b6001810180546001600160a01b03191690556040805133815290517fcfb473e6c03f9a29ddaf990e736fa3de5188a0bd85d684f5b6e164ebfbfff5d29181900360200190a150565b60006114ee6040518060400160405280600f81526020016e1195531317d5d2551211149055d053608a1b8152508484604051602001808381526020018281526020019250505060405160208183030381529060405261468d565b60008061371a83614345565b90506001600160e01b0319811663012b8bc960e11b14806114ee57506001600160e01b03198116633348691d60e01b14915050919050565b600063012b8bc960e11b61307283614345565b61376e8361370e565b6137b5576040805162461bcd60e51b815260206004820152601360248201527246554e4749424c455f41535345545f5459504560681b604482015290519081900360640190fd5b6137be83613752565b15613818578060011461380e576040805162461bcd60e51b8152602060048201526013602482015272494c4c4547414c5f4e46545f42414c414e434560681b604482015290519081900360640190fd5b61352d838361474f565b80156111c7576111c7838383614802565b6000613834826114b0565b90506001600160a01b0381166111ea576040805162461bcd60e51b81526020600482015260116024820152701554d15497d553949151d254d511549151607a1b604482015290519081900360640190fd5b6001600160a01b0383166138d4576040805162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015290519081900360640190fd5b60006138e0838361357c565b90506138eb836143fb565b15613aeb57816138fb57506111c7565b60006139068461440e565b905060008190506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561395c57600080fd5b505afa158015613970573d6000803e3d6000fd5b505050506040513d602081101561398657600080fd5b5051604080516001600160a01b03808b16602483015260448083018990528351808403909101815260649092019092526020810180516001600160e01b031663a9059cbb60e01b1790529192506139df90851682614421565b6000836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613a2e57600080fd5b505afa158015613a42573d6000803e3d6000fd5b505050506040513d6020811015613a5857600080fd5b5051905082811115613a9d576040805162461bcd60e51b8152602060048201526009602482015268554e444552464c4f5760b81b604482015290519081900360640190fd5b8583038114613ae1576040805162461bcd60e51b815260206004820152601c60248201526000805160206150f7833981519152604482015290519081900360640190fd5b505050505061217c565b613af48361305f565b156135325781613b0457506111c7565b613b176001600160a01b03851682614b18565b61217c565b6000633348691d60e01b61307283614345565b613b388361370e565b613b7f576040805162461bcd60e51b815260206004820152601360248201527246554e4749424c455f41535345545f5459504560681b604482015290519081900360640190fd5b613b8883613752565b15613be35780600114613bd8576040805162461bcd60e51b8152602060048201526013602482015272494c4c4547414c5f4e46545f42414c414e434560681b604482015290519081900360640190fd5b613b17848484614bb4565b801561217c5761217c84848484614cb9565b613bfe336130f0565b613c41576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6000613c4b614358565b6001810180546001600160a01b03191690556040519091507f7a8dc7dd7fffb43c4807438fa62729225156941e641fd877938f4edade3429f590600090a150565b613c95336130f0565b613cd8576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6000613ce2614358565b9050613ced826130f0565b15613d32576040805162461bcd60e51b815260206004820152601060248201526f20a62922a0a22cafa3a7ab22a92727a960811b604482015290519081900360640190fd5b6001810180546001600160a01b0384166001600160a01b0319909116811790915560408051918252517f6166272c8d3f5f579082f2827532732f97195007983bb5b83ac12c56700b01a69181900360200190a15050565b613d92336130f0565b613dd5576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b336001600160a01b0382161415613e2a576040805162461bcd60e51b8152602060048201526014602482015273474f5645524e4f525f53454c465f52454d4f564560601b604482015290519081900360640190fd5b6000613e34614358565b9050613e3f826130f0565b613e7f576040805162461bcd60e51b815260206004820152600c60248201526b2727aa2fa3a7ab22a92727a960a11b604482015290519081900360640190fd5b6001600160a01b03821660008181526020838152604091829020805460ff19169055815192835290517fd75f94825e770b8b512be8e74759e252ad00e102e38f50cce2f7c6f868a295999281900390910190a15050565b6000838152600760209081526040808320858452825280832084845290915281205480613f41576040805162461bcd60e51b815260206004820152601460248201527311115413d4d25517d393d517d0d05390d153115160621b604482015290519081900360640190fd5b6202a30081810190811015613f5257fe5b80421015613f98576040805162461bcd60e51b815260206004820152600e60248201526d11115413d4d25517d313d0d2d15160921b604482015290519081900360640190fd5b50505060008381526006602090815260408083208584528252808320848452825280832080549084905595835260078252808320948352938152838220928252919091529081205590565b6000613fee82614fa6565b9050613ff981614fb7565b614043576040805162461bcd60e51b8152602060048201526016602482015275554e535550504f525445445f544f4b454e5f5459504560501b604482015290519081900360640190fd5b6001600160e01b031981166341917ff960e11b14156140ae5781516004146140a9576040805162461bcd60e51b8152602060048201526014602482015273494e56414c49445f41535345545f535452494e4760601b604482015290519081900360640190fd5b613578565b81516024146140fb576040805162461bcd60e51b8152602060048201526014602482015273494e56414c49445f41535345545f535452494e4760601b604482015290519081900360640190fd5b600061410683615056565b905061411a816001600160a01b031661505d565b6111c7576040805162461bcd60e51b81526020600482015260116024820152704241445f544f4b454e5f4144445245535360781b604482015290519081900360640190fd5b60008061416b83614fa6565b90506001600160e01b0319811663012b8bc960e11b14806114ee57506001600160e01b03198116635c5c333960e11b14915050919050565b6001600160a01b0383166141f2576040805162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015290519081900360640190fd5b6141fb8561311f565b614246576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f4d494e5441424c455f41535345545f5459504560481b604482015290519081900360640190fd5b60008411614291576040805162461bcd60e51b81526020600482015260136024820152721253959053125117d352539517d05353d55395606a1b604482015290519081900360640190fd5b600061429d868661357c565b905060006142aa8761440e565b905061433c8583868660405160240180856001600160a01b0316815260200184815260200180602001828103825284848281815260200192508082843760008184015260408051601f19601f9093018316909401848103909201845252506020810180516319ee6e3f60e01b6001600160e01b039091161790526001600160a01b038916965094506144219350505050565b50505050505050565b6000611c0d61435383612ef5565b614fa6565b600080604051806060016040528060268152602001615158602691396040518082805190602001908083835b602083106143a35780518252601f199092019160209182019101614384565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092209392505050565b60006143e0826114b0565b6001600160a01b0316336001600160a01b0316149050919050565b6000630f47261b60e41b61307283614345565b6000611c0d61441c83612ef5565b615056565b61442a8261505d565b61446f576040805162461bcd60e51b81526020600482015260116024820152704241445f544f4b454e5f4144445245535360781b604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106144ad5780518252601f19909201916020918201910161448e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461450f576040519150601f19603f3d011682016040523d82523d6000602084013e614514565b606091505b50915091508181906145a45760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614569578181015183820152602001614551565b50505050905090810190601f1680156145965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080511561217c578080602001905160208110156145c157600080fd5b505161217c576040805162461bcd60e51b81526020600482015260166024820152751513d2d15397d3d4115490551253d397d1905253115160521b604482015290519081900360640190fd5b614616816130f0565b1561465b576040805162461bcd60e51b815260206004820152601060248201526f20a62922a0a22cafa3a7ab22a92727a960811b604482015290519081900360640190fd5b6000614665614358565b6001600160a01b0390921660009081526020929092525060409020805460ff19166001179055565b600082826040516020018083805190602001908083835b602083106146c35780518252601f1990920191602091820191016146a4565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b6020831061470b5780518252601f1990920191602091820191016146ec565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405280519060200120905092915050565b61475882613752565b61479c576040805162461bcd60e51b815260206004820152601060248201526f2727aa2fa2a9219b9918afaa27a5a2a760811b604482015290519081900360640190fd5b60006147a78361440e565b6040805133602482015230604482015260648082018690528251808303909101815260849091019091526020810180516001600160e01b0316632142170760e11b1790529091506111c7906001600160a01b03831690614421565b61480b83613b1c565b614850576040805162461bcd60e51b81526020600482015260116024820152702727aa2fa2a92198989a9aafaa27a5a2a760791b604482015290519081900360640190fd5b8061485a576111c7565b6000614866848361357c565b905060006148738561440e565b60408051627eeac760e11b815230600482015260248101879052905191925082916000916001600160a01b0384169162fdd58e91604480820192602092909190829003018186803b1580156148c757600080fd5b505afa1580156148db573d6000803e3d6000fd5b505050506040513d60208110156148f157600080fd5b81019080805190602001909291905050509050614a0663f242432a60e01b333089886040518060200160405280600081525060405160240180866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561498d578181015183820152602001614975565b50505050905090810190601f1680156149ba5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909a169990991790985250506001600160a01b038a169594505061442192505050565b6000826001600160a01b031662fdd58e30896040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b158015614a5c57600080fd5b505afa158015614a70573d6000803e3d6000fd5b505050506040513d6020811015614a8657600080fd5b5051905081811015614aca576040805162461bcd60e51b81526020600482015260086024820152674f564552464c4f5760c01b604482015290519081900360640190fd5b8482018114614b0e576040805162461bcd60e51b815260206004820152601c60248201526000805160206150f7833981519152604482015290519081900360640190fd5b5050505050505050565b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114614b63576040519150601f19603f3d011682016040523d82523d6000602084013e614b68565b606091505b50509050806111c7576040805162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b604482015290519081900360640190fd5b6001600160a01b038316614c03576040805162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015290519081900360640190fd5b614c0c82613752565b614c50576040805162461bcd60e51b815260206004820152601060248201526f2727aa2fa2a9219b9918afaa27a5a2a760811b604482015290519081900360640190fd5b6000614c5b8361440e565b604080513060248201526001600160a01b03808816604483015260648083018790528351808403909101815260849092019092526020810180516001600160e01b0316632142170760e11b17905291925061217c9190831690614421565b6001600160a01b038416614d08576040805162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015290519081900360640190fd5b614d1183613b1c565b614d56576040805162461bcd60e51b81526020600482015260116024820152702727aa2fa2a92198989a9aafaa27a5a2a760791b604482015290519081900360640190fd5b80614d605761217c565b6000614d6c848361357c565b90506000614d798561440e565b60408051627eeac760e11b815230600482015260248101879052905191925082916000916001600160a01b0384169162fdd58e91604480820192602092909190829003018186803b158015614dcd57600080fd5b505afa158015614de1573d6000803e3d6000fd5b505050506040513d6020811015614df757600080fd5b81019080805190602001909291905050509050614e9263f242432a60e01b308a89886040518060200160405280600081525060405160240180866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360008381101561498d578181015183820152602001614975565b6000826001600160a01b031662fdd58e30896040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b158015614ee857600080fd5b505afa158015614efc573d6000803e3d6000fd5b505050506040513d6020811015614f1257600080fd5b5051905081811115614f57576040805162461bcd60e51b8152602060048201526009602482015268554e444552464c4f5760b81b604482015290519081900360640190fd5b8482038114614f9b576040805162461bcd60e51b815260206004820152601c60248201526000805160206150f7833981519152604482015290519081900360640190fd5b505050505050505050565b602001516001600160e01b03191690565b60006001600160e01b031982166341917ff960e11b1480614fe857506001600160e01b03198216630f47261b60e41b145b8061500357506001600160e01b0319821663012b8bc960e11b145b8061501e57506001600160e01b031982166368646e2d60e01b145b8061503957506001600160e01b03198216635c5c333960e11b145b80611c0d5750506001600160e01b031916633348691d60e01b1490565b6024015190565b3b151590565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106150a45782800160ff198235161785556150d1565b828001600101855582156150d1579182015b828111156150d15782358255916020019190600101906150b6565b506150dd9291506150e1565b5090565b5b808211156150dd57600081556001016150e256fe494e434f52524543545f414d4f554e545f5452414e53464552524544000000004d49534d41544348494e475f535441524b5f4554485f4b45595300000000000041535345545f545950455f444f45535f4e4f545f54414b455f544f4b454e5f4944537461726b45782e4d61696e2e323031392e476f7665726e6f7273496e666f726d6174696f6e537461726b576172655f546f6b656e73416e6452616d70696e675f323032345f33a26469706673582212204c484f57d7b3e2b3dee1366510d21c7857a127eb537570bf3f7efed09c10d7e164736f6c634300060c0033
Deployed Bytecode
0x60806040526004361061030a5760003560e01c80637cf12b901161019c578063b7663112116100e2578063dd7202d811610090578063dd7202d814610fbd578063e30a5cff14610fe7578063e6de628214610ffc578063ec3161b014611011578063eeb7286614611041578063f23a6e6114611056578063f637d950146110f6578063fcb05822146111205761030a565b8063b766311214610c23578063bc197c8114610c38578063be2b110514610d6c578063c23b60ef14610da8578063c8b1031a14610e32578063d88d8b3814610eb4578063d91443b714610f365761030a565b8063a1cc921e1161014a578063a1cc921e14610a15578063a2bdde3d14610a48578063a45d784114610a7b578063a6fa6e9014610a90578063abf98fe114610ac3578063ae1cdde614610af9578063ae87381614610b35578063b12773fb14610b6b5761030a565b80637cf12b90146109015780637df7dc04146109165780638c4bce1c1461094c578063993f36391461097f5780639c6a2837146109945780639ed17084146109a9578063a1cc5e13146109e55761030a565b8063345385ac116102615780634e8912da1161020f5780634e8912da146108025780635e586cd1146108385780635eecd2181461086257806364d848421461087757806369de5046146108ad5780636ce5d9571461033657806372eb3688146108d757806377e84e0d146108ec5761030a565b8063345385ac14610679578063381baf6f146106a35780633cc660ad146106cd578063439fab91146106e2578063441a3e701461075d57806345f5cd971461078d57806349325bac146107c05761030a565b80631dbd1da7116102be5780631dbd1da7146105255780632505c3d91461056b57806328700a15146105a7578063296e2f37146105bc57806329e411ac146105ec578063333ac20b1461062e57806333eeb147146106645761030a565b80627175421461030f578062aeef8a14610336578063019b417a14610361578063049f5ade146103975780630b3a2d21146103d55780630ebdac0314610408578063150b7a021461046d575b600080fd5b34801561031b57600080fd5b5061032461115c565b60408051918252519081900360200190f35b61035f6004803603606081101561034c57600080fd5b5080359060208101359060400135611163565b005b34801561036d57600080fd5b5061035f6004803603606081101561038457600080fd5b50803590602081013590604001356111cc565b3480156103a357600080fd5b506103c1600480360360208110156103ba57600080fd5b50356111d7565b604080519115158252519081900360200190f35b3480156103e157600080fd5b5061035f600480360360208110156103f857600080fd5b50356001600160a01b03166111ef565b34801561041457600080fd5b5061041d611296565b60408051602080825283518183015283519192839290830191858101910280838360005b83811015610459578181015183820152602001610441565b505050509050019250505060405180910390f35b34801561047957600080fd5b506105086004803603608081101561049057600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b8111156104ca57600080fd5b8201836020820111156104dc57600080fd5b803590602001918460018302840111600160201b831117156104fd57600080fd5b509092509050611484565b604080516001600160e01b03199092168252519081900360200190f35b34801561053157600080fd5b5061054f6004803603602081101561054857600080fd5b50356114b0565b604080516001600160a01b039092168252519081900360200190f35b34801561057757600080fd5b5061035f6004803603608081101561058e57600080fd5b50803590602081013590604081013590606001356114f5565b3480156105b357600080fd5b5061035f61166f565b3480156105c857600080fd5b50610324600480360360408110156105df57600080fd5b5080359060200135611679565b3480156105f857600080fd5b5061035f600480360360a081101561060f57600080fd5b50803590602081013590604081013590606081013590608001356116a0565b34801561063a57600080fd5b506103246004803603606081101561065157600080fd5b5080359060208101359060400135611899565b34801561067057600080fd5b506103c16118bd565b34801561068557600080fd5b5061035f6004803603602081101561069c57600080fd5b50356118cd565b3480156106af57600080fd5b5061035f600480360360208110156106c657600080fd5b503561197a565b3480156106d957600080fd5b50610324611a29565b3480156106ee57600080fd5b5061035f6004803603602081101561070557600080fd5b810190602081018135600160201b81111561071f57600080fd5b82018360208201111561073157600080fd5b803590602001918460018302840111600160201b8311171561075257600080fd5b509092509050611a2e565b34801561076957600080fd5b5061035f6004803603604081101561078057600080fd5b5080359060200135611a6d565b34801561079957600080fd5b506103c1600480360360208110156107b057600080fd5b50356001600160a01b0316611c02565b3480156107cc57600080fd5b5061035f600480360360a08110156107e357600080fd5b5080359060208101359060408101359060608101359060800135611c13565b34801561080e57600080fd5b506103246004803603606081101561082557600080fd5b5080359060208101359060400135611cc1565b34801561084457600080fd5b506103246004803603602081101561085b57600080fd5b5035611ce5565b34801561086e57600080fd5b50610324611d55565b34801561088357600080fd5b5061035f6004803603606081101561089a57600080fd5b5080359060208101359060400135611d5b565b3480156108b957600080fd5b506103c1600480360360208110156108d057600080fd5b5035611f1d565b3480156108e357600080fd5b5061035f611f32565b3480156108f857600080fd5b50610324611f3a565b34801561090d57600080fd5b5061035f611f41565b34801561092257600080fd5b5061035f6004803603606081101561093957600080fd5b5080359060208101359060400135612080565b34801561095857600080fd5b5061035f6004803603602081101561096f57600080fd5b50356001600160a01b0316612145565b34801561098b57600080fd5b50610324612151565b3480156109a057600080fd5b5061054f612159565b3480156109b557600080fd5b5061035f600480360360808110156109cc57600080fd5b5080359060208101359060408101359060600135612170565b3480156109f157600080fd5b5061032460048036036040811015610a0857600080fd5b5080359060200135612182565b348015610a2157600080fd5b5061035f60048036036020811015610a3857600080fd5b50356001600160a01b03166122a9565b348015610a5457600080fd5b506103c160048036036020811015610a6b57600080fd5b50356001600160a01b03166122b2565b348015610a8757600080fd5b506103246122d0565b348015610a9c57600080fd5b5061035f60048036036020811015610ab357600080fd5b50356001600160a01b03166122de565b348015610acf57600080fd5b5061032460048036036060811015610ae657600080fd5b5080359060208101359060400135612382565b348015610b0557600080fd5b5061035f60048036036080811015610b1c57600080fd5b50803590602081013590604081013590606001356123ba565b348015610b4157600080fd5b5061035f60048036036060811015610b5857600080fd5b5080359060208101359060400135612461565b348015610b7757600080fd5b5061032460048036036040811015610b8e57600080fd5b81359190810190604081016020820135600160201b811115610baf57600080fd5b820183602082011115610bc157600080fd5b803590602001918460018302840111600160201b83111715610be257600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061258f945050505050565b348015610c2f57600080fd5b50610324612650565b348015610c4457600080fd5b50610508600480360360a0811015610c5b57600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b811115610c8e57600080fd5b820183602082011115610ca057600080fd5b803590602001918460208302840111600160201b83111715610cc157600080fd5b919390929091602081019035600160201b811115610cde57600080fd5b820183602082011115610cf057600080fd5b803590602001918460208302840111600160201b83111715610d1157600080fd5b919390929091602081019035600160201b811115610d2e57600080fd5b820183602082011115610d4057600080fd5b803590602001918460018302840111600160201b83111715610d6157600080fd5b509092509050612657565b348015610d7857600080fd5b5061035f60048036036080811015610d8f57600080fd5b5080359060208101359060408101359060600135612686565b348015610db457600080fd5b50610dbd612830565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610df7578181015183820152602001610ddf565b50505050905090810190601f168015610e245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b348015610e3e57600080fd5b5061035f60048036036040811015610e5557600080fd5b81359190810190604081016020820135600160201b811115610e7657600080fd5b820183602082011115610e8857600080fd5b803590602001918460018302840111600160201b83111715610ea957600080fd5b50909250905061284c565b348015610ec057600080fd5b5061035f60048036036060811015610ed757600080fd5b81359190810190604081016020820135600160201b811115610ef857600080fd5b820183602082011115610f0a57600080fd5b803590602001918460018302840111600160201b83111715610f2b57600080fd5b919350915035612855565b348015610f4257600080fd5b5061035f60048036036060811015610f5957600080fd5b813591602081013591810190606081016040820135600160201b811115610f7f57600080fd5b820183602082011115610f9157600080fd5b803590602001918460018302840111600160201b83111715610fb257600080fd5b509092509050612bf7565b348015610fc957600080fd5b5061032460048036036020811015610fe057600080fd5b5035612e3e565b348015610ff357600080fd5b50610324612e6f565b34801561100857600080fd5b50610324612e74565b34801561101d57600080fd5b506103246004803603604081101561103457600080fd5b5080359060200135612e79565b34801561104d57600080fd5b50610dbd612ea8565b34801561106257600080fd5b50610508600480360360a081101561107957600080fd5b6001600160a01b03823581169260208101359091169160408201359160608101359181019060a081016080820135600160201b8111156110b857600080fd5b8201836020820111156110ca57600080fd5b803590602001918460018302840111600160201b831117156110eb57600080fd5b509092509050612ec8565b34801561110257600080fd5b50610dbd6004803603602081101561111957600080fd5b5035612ef5565b34801561112c57600080fd5b5061035f6004803603608081101561114357600080fd5b5080359060208101359060408101359060600135612ff6565b62093a8081565b61116c8261305f565b6111b2576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b6111c78383836111c28634613083565b6114f5565b505050565b6111c7838383611d5b565b60008181526015602052604090205460ff165b919050565b6111f8336130f0565b61123b576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6001600160a01b038116600081815260116020908152604091829020805460ff19166001179055815192835290517f9085a9044aeb6daeeb5b4bf84af42b1a1613d4056f503c4e992b6396c16bd52f9281900390910190a150565b604080516007808252610100820190925260609190600090826020820160e08036833750508151919450506001820191631f7df70160e21b9185919081106112da57fe5b6001600160e01b0319909216602092830291909101909101528251600182019163be2b110560e01b91859190811061130e57fe5b6001600160e01b031990921660209283029190910190910152825160018201916357439c0b60e11b91859190811061134257fe5b6001600160e01b03199092166020928302919091019091015282516001820191630441a3e760e41b91859190811061137657fe5b6001600160e01b0319909216602092830291909101909101528251600182019163d91443b760e01b9185919081106113aa57fe5b6001600160e01b0319909216602092830291909101909101528251600182019163326c242160e11b9185919081106113de57fe5b6001600160e01b0319909216602092830291909101909101528251600182019163381baf6f60e01b91859190811061141257fe5b6001600160e01b03199092166020928302919091019091015280821461147f576040805162461bcd60e51b815260206004820181905260248201527f494e434f52524543545f53454c4543544f52535f41525241595f4c454e475448604482015290519081900360640190fd5b505090565b60006001600160a01b038616301461149d5760006114a6565b630a85bd0160e11b5b9695505050505050565b6000818152601860205260408120546001600160a01b031680156114d55790506111ea565b6001600160a01b03831683146114ec5760006114ee565b825b9392505050565b6114fd6118bd565b15611541576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b61154a8361311f565b15611592576040805162461bcd60e51b81526020600482015260136024820152724d494e5441424c455f41535345545f5459504560681b604482015290519081900360640190fd5b61159b83613163565b6115e6576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f46554e4749424c455f41535345545f5459504560481b604482015290519081900360640190fd5b826115f3858285856131c2565b506115fe84836132b7565b7f06724742ccc8c330a39a641ef02a0b419bd09248360680bb38159b0a8c2635d63386858761162d898861357c565b604080516001600160a01b0390961686526020860194909452848401929092526060840152608083015260a08201859052519081900360c00190a15050505050565b6116776135ed565b565b60006022600061168985856136b4565b815260200190815260200160002054905092915050565b6116a86118bd565b156116ec576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b6116f58461370e565b61173b576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b60006117478585612182565b90506000611757878386866131c2565b905061176286613752565b1561180b5760018111156117b5576040805162461bcd60e51b81526020600482015260156024820152741253131151d05317d15490cdcc8c57d05353d55395605a1b604482015290519081900360640190fd5b6040805133815260208101899052808201869052606081018890526080810187905260a0810184905290517f0fcf2162832b2d6033d4d34d2f45a28d9cfee523f1899945bbdd32529cfda67b9181900360c00190a15b611816868685613765565b7fed94dc026fa9364c53bc0af51cde7f54f3109b3f31fceb26d01396d80e20453b3388868989876118478d8b61357c565b604080516001600160a01b0390981688526020880196909652868601949094526060860192909252608085015260a084015260c083015260e0820186905251908190036101000190a150505050505050565b60009283526007602090815260408085209385529281528284209184525290205490565b600454600160a01b900460ff1690565b3373520cf70a2d0b3dfb7386a2bc9f800321f62a5c3a14611928576040805162461bcd60e51b815260206004820152601060248201526f27a7262cafa12627a1a5afa0a226a4a760811b604482015290519081900360640190fd5b61193181611f1d565b156119625760405181907fc5c4ee30d6cb77d673bd39088a871847fe5d6939fc472c5e0a70e0cca6dd10dc90600090a25b6000908152602860205260409020805460ff19169055565b3373520cf70a2d0b3dfb7386a2bc9f800321f62a5c3a146119d5576040805162461bcd60e51b815260206004820152601060248201526f27a7262cafa12627a1a5afa0a226a4a760811b604482015290519081900360640190fd5b6119de81611f1d565b611a0e5760405181907f9ff85bce88647ea2dd40dc32cdf6d3207cb8bdf6e7d1b3d3ac50222d3d1d582490600090a25b6000908152602860205260409020805460ff19166001179055565b600090565b6040805162461bcd60e51b815260206004820152600f60248201526e1393d517d253541311535153951151608a1b604482015290519081900360640190fd5b81611a7781611f1d565b15611abd576040805162461bcd60e51b81526020600482015260116024820152701554d15497d09313d0d2d7d31254d51151607a1b604482015290519081900360640190fd5b6000611ac884613829565b9050611ad38361311f565b15611b1b576040805162461bcd60e51b81526020600482015260136024820152724d494e5441424c455f41535345545f5459504560681b604482015290519081900360640190fd5b611b2483613163565b611b6f576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f46554e4749424c455f41535345545f5459504560481b604482015290519081900360640190fd5b6000848152600860209081526040808320868452909152812080549190558390611b9a838383613885565b7fb7477a7b93b2addc5272bbd7ad0986ef1c0d0bd265f26c3dc4bbe42727c2ac0c8686611bc7888561357c565b60408051938452602084019290925282820152606082018490526001600160a01b0386166080830152519081900360a00190a1505050505050565b6000611c0d826130f0565b92915050565b611c1b6118bd565b15611c5f576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b611c6884613b1c565b611cad576040805162461bcd60e51b81526020600482015260116024820152702727aa2fa2a92198989a9aafaa27a5a2a760791b604482015290519081900360640190fd5b611cba85858585856116a0565b5050505050565b60009283526006602090815260408085209385529281528284209184525290205490565b6024546000908210611d36576040805162461bcd60e51b815260206004820152601560248201527408286a8929e9cbe929c888ab0bea89e9ebe90928e9605b1b604482015290519081900360640190fd5b60248281548110611d4357fe5b90600052602060002001549050919050565b60245490565b82611d6581611f1d565b15611dab576040805162461bcd60e51b81526020600482015260116024820152701554d15497d09313d0d2d7d31254d51151607a1b604482015290519081900360640190fd5b611db48361370e565b611dfa576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b6000611e068484612182565b90506000611e1386613829565b600087815260086020908152604080832086845290915281208054919055909150611e4082878784613b2f565b611e4986613752565b15611ea5576040805188815260208101889052808201879052606081018590526001600160a01b038416608082015290517fa5cfa8e2199ec5b8ca319288bcab72734207d30569756ee594a74b4df7abbf419181900360a00190a15b7fc6ba68235f3229e53f3a95cda25543ad54c0f6df2493a06c05fb930bea7966fe87878786611ed48b8761357c565b604080519586526020860194909452848401929092526060840152608083015260a082018490526001600160a01b03851660c0830152519081900360e00190a150505050505050565b60009081526028602052604090205460ff1690565b611677613bf5565b6202a30081565b611f496118bd565b611f8d576040805162461bcd60e51b815260206004820152601060248201526f29aa20aa22afa727aa2fa32927ad22a760811b604482015290519081900360640190fd5b611f96336130f0565b611fd9576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b60055442101561202b576040805162461bcd60e51b8152602060048201526018602482015277155391949151569157d393d517d0531313d5d15117d6515560421b604482015290519081900360640190fd5b6004805460ff60a01b19169055600d805460019081019091556025805482019055600f805490910190556040517f07017fe9180629cfffba412f65a9affcf9a121de02294179f5c058f881dcc9f890600090a1565b8261208a81613829565b6001600160a01b0316336001600160a01b0316146120dd576040805162461bcd60e51b815260206004820152601a6024820152600080516020615117833981519152604482015290519081900360640190fd5b60008481526007602090815260408083208684528252808320858452825291829020429055815186815290810184905280820185905290517f0bc1df35228095c37da66a6ffcc755ea79dfc437345685f618e05fafad6b445e9181900360600190a150505050565b61214e81613c8c565b50565b6301e1338081565b68010000000000000004546001600160a01b031681565b61217c848484846114f5565b50505050565b600061218d8361370e565b6121c85760405162461bcd60e51b81526004018080602001828103825260218152602001806151376021913960400191505060405180910390fd5b60606121d384613752565b612202576040518060400160405280600d81526020016c2727a72fa6a4a72a20a126229d60991b815250612220565b6040518060400160405280600481526020016327232a1d60e11b8152505b90506001600160fa1b038185856040516020018084805190602001908083835b6020831061225f5780518252601f199092019160209182019101612240565b51815160209384036101000a600019018019909216911617905292019485525083810192909252506040805180840383018152928101905281519101209190911695945050505050565b61214e81613d89565b6001600160a01b031660009081526011602052604090205460ff1690565b680100000000000000035481565b6122e7336130f0565b61232a576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6001600160a01b038116600081815260116020908152604091829020805460ff19169055815192835290517ffa49aecb996ea8d99950bb051552dfcc0b5460a0bb209867a1ed8067c32c21779281900390910190a150565b6000838152600660209081526040808320858452825280832084845290915281205483906123b190829061357c565b95945050505050565b6123c26118bd565b15612406576040805162461bcd60e51b815260206004820152600f60248201526e29aa20aa22afa4a9afa32927ad22a760891b604482015290519081900360640190fd5b61240f83613752565b612453576040805162461bcd60e51b815260206004820152601060248201526f2727aa2fa2a9219b9918afaa27a5a2a760811b604482015290519081900360640190fd5b61217c8484838560016116a0565b8261246b81613829565b6001600160a01b0316336001600160a01b0316146124be576040805162461bcd60e51b815260206004820152601a6024820152600080516020615117833981519152604482015290519081900360640190fd5b6124c783613163565b612512576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f46554e4749424c455f41535345545f5459504560481b604482015290519081900360640190fd5b826000612520868386613ed6565b905061252d338683613885565b7fe3e46ecf1138180bf93cba62a0b7e661d976a8ab3d40243f7b082667d8f500af86858761255b898661357c565b60408051948552602085019390935283830191909152606083015260808201849052519081900360a00190a1505050505050565b600080828051906020012060001c9050600160fa1b6001600160f01b036040518060400160405280600981526020016826a4a72a20a126229d60b91b81525086846040516020018084805190602001908083835b602083106126025780518252601f1990920191602091820191016125e3565b51815160209384036101000a60001901801990921691161790529201948552508381019290925250604080518084038301815292810190528151910120919091169190911795945050505050565b6224ea0081565b60006001600160a01b0389163014612670576000612679565b63bc197c8160e01b5b9998505050505050505050565b8361269081613829565b6001600160a01b0316336001600160a01b0316146126e3576040805162461bcd60e51b815260206004820152601a6024820152600080516020615117833981519152604482015290519081900360640190fd5b6126ec8461370e565b612732576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b600061273e8585612182565b9050600061274d878386613ed6565b905080156127615761276133878784613b2f565b61276a86613752565b156127be576040805188815260208101869052808201889052606081018790526080810184905290517ff00c0c1a754f6df7545d96a7e12aad552728b94ca6aa94f81e297bdbcf1dab9c9181900360a00190a15b7fcc00f2179d127845242252f3c3b6b238c5ed33c2e933179f09653cfb1cdee7ca87858888866127ee8c8861357c565b604080519687526020870195909552858501939093526060850191909152608084015260a083015260c08201849052519081900360e00190a150505050505050565b6040518060600160405280602681526020016151586026913981565b6111c783838360015b61285e336122b2565b6128a3576040805162461bcd60e51b815260206004820152601160248201527027a7262cafaa27a5a2a729afa0a226a4a760791b604482015290519081900360640190fd5b6128ac846111d7565b156128f9576040805162461bcd60e51b81526020600482015260186024820152771054d4d15517d053149150511657d49151d254d51154915160421b604482015290519081900360640190fd5b600167080000000000001160c01b018410612950576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b60008111612997576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f5155414e54554d60881b604482015290519081900360640190fd5b600160801b81106129e1576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f5155414e54554d60881b604482015290519081900360640190fd5b60006001600160fa1b0384848460405160200180848480828437919091019283525050604080518083038152602092830190915280519101209290921692505050848114612a6b576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b612aaa84848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250613fe392505050565b612ae984848080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061415f92505050565b15612b395781600114612b39576040805162461bcd60e51b8152602060048201526013602482015272494e56414c49445f4e46545f5155414e54554d60681b604482015290519081900360640190fd5b6000858152601560209081526040808320805460ff1916600117905560149091529020612b67908585615063565b508160166000878152602001908152602001600020819055507f7a0efbc885500f3b4a895231945be4520e4c0ba5ef7274a225a0272c81ccbcb78585858560405180858152602001806020018381526020018281038252858582818152602001925080828437600083820152604051601f909101601f191690920182900397509095505050505050a15050505050565b83612c0181611f1d565b15612c47576040805162461bcd60e51b81526020600482015260116024820152701554d15497d09313d0d2d7d31254d51151607a1b604482015290519081900360640190fd5b6000612c5286613829565b60008681526015602052604090205490915060ff16612cad576040805162461bcd60e51b8152602060048201526012602482015271494e56414c49445f41535345545f5459504560701b604482015290519081900360640190fd5b612cb68561311f565b612d01576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f4d494e5441424c455f41535345545f5459504560481b604482015290519081900360640190fd5b6000612d438686868080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061258f92505050565b6000888152600860209081526040808320848452909152902054909150612db1576040805162461bcd60e51b815260206004820152601d60248201527f4e4f5f50454e44494e475f5749544844524157414c5f42414c414e4345000000604482015290519081900360640190fd5b600087815260086020908152604080832084845290915281208054919055612ddc87828589896141a3565b7f7e6e15df814c1a309a57686de672b2bedd128eacde35c5370c36d6840d4e9a928888612e098a8561357c565b604080519384526020840192909252828201526060820184905260808201859052519081900360a00190a15050505050505050565b60008181526015602052604081205460ff16612e5c575060016111ea565b5060009081526016602052604090205490565b600a81565b604081565b60008281526008602090815260408083208484529091528120548290612ea090829061357c565b949350505050565b606060405180606001604052806021815260200161517e60219139905090565b60006001600160a01b0387163014612ee1576000612eea565b63f23a6e6160e01b5b979650505050505050565b60008181526015602052604090205460609060ff16612f57576040805162461bcd60e51b81526020600482015260196024820152781054d4d15517d516541157d393d517d49151d254d511549151603a1b604482015290519081900360640190fd5b60008281526014602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015612fea5780601f10612fbf57610100808354040283529160200191612fea565b820191906000526020600020905b815481529060010190602001808311612fcd57829003601f168201915b50505050509050919050565b8361300081613829565b6001600160a01b0316336001600160a01b031614613053576040805162461bcd60e51b815260206004820152601a6024820152600080516020615117833981519152604482015290519081900360640190fd5b611cba85858486612686565b60006341917ff960e11b61307283614345565b6001600160e01b0319161492915050565b60008061308f84612e3e565b905080838161309a57fe5b06156130de576040805162461bcd60e51b815260206004820152600e60248201526d1253959053125117d05353d5539560921b604482015290519081900360640190fd5b8083816130e757fe5b04949350505050565b6000806130fb614358565b6001600160a01b039390931660009081526020939093525050604090205460ff1690565b60008061312b83614345565b90506001600160e01b031981166368646e2d60e01b14806114ee57506001600160e01b03198116635c5c333960e11b14915050919050565b60008061316f83614345565b90506001600160e01b031981166341917ff960e11b14806131a057506001600160e01b03198116630f47261b60e41b145b806114ee57506001600160e01b031981166368646e2d60e01b14915050919050565b6000848152600660209081526040808320868452825280832085845290915281205482018281101561322e576040805162461bcd60e51b815260206004820152601060248201526f4445504f5349545f4f564552464c4f5760801b604482015290519081900360640190fd5b60008681526006602090815260408083208884528252808320878452909152902081905561325b866143d5565b801561328757506000868152600760209081526040808320888452825280832087845290915290205415155b156123b1576000868152600760209081526040808320888452825280832087845290915281205595945050505050565b60006132c3838361357c565b90506132ce836143fb565b156134d057816132de5750613578565b60006132e98461440e565b905060008190506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561333f57600080fd5b505afa158015613353573d6000803e3d6000fd5b505050506040513d602081101561336957600080fd5b50516040805133602482015230604482015260648082018890528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b1790529091506133c56001600160a01b03851682614421565b6000836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561341457600080fd5b505afa158015613428573d6000803e3d6000fd5b505050506040513d602081101561343e57600080fd5b5051905082811015613482576040805162461bcd60e51b81526020600482015260086024820152674f564552464c4f5760c01b604482015290519081900360640190fd5b85830181146134c6576040805162461bcd60e51b815260206004820152601c60248201526000805160206150f7833981519152604482015290519081900360640190fd5b50505050506111c7565b6134d98361305f565b156135325780341461352d576040805162461bcd60e51b8152602060048201526018602482015277125390d3d4949150d517d1115413d4d25517d05353d5539560421b604482015290519081900360640190fd5b6111c7565b6040805162461bcd60e51b8152602060048201526016602482015275554e535550504f525445445f544f4b454e5f5459504560501b604482015290519081900360640190fd5b5050565b60008061358884612e3e565b905080830291508281838161359957fe5b04146135e6576040805162461bcd60e51b815260206004820152601760248201527644455155414e54495a4154494f4e5f4f564552464c4f5760481b604482015290519081900360640190fd5b5092915050565b60006135f7614358565b60018101549091506001600160a01b03163314613655576040805162461bcd60e51b815260206004820152601760248201527627a7262cafa1a0a72224a220aa22afa3a7ab22a92727a960491b604482015290519081900360640190fd5b600181015461366c906001600160a01b031661460d565b6001810180546001600160a01b03191690556040805133815290517fcfb473e6c03f9a29ddaf990e736fa3de5188a0bd85d684f5b6e164ebfbfff5d29181900360200190a150565b60006114ee6040518060400160405280600f81526020016e1195531317d5d2551211149055d053608a1b8152508484604051602001808381526020018281526020019250505060405160208183030381529060405261468d565b60008061371a83614345565b90506001600160e01b0319811663012b8bc960e11b14806114ee57506001600160e01b03198116633348691d60e01b14915050919050565b600063012b8bc960e11b61307283614345565b61376e8361370e565b6137b5576040805162461bcd60e51b815260206004820152601360248201527246554e4749424c455f41535345545f5459504560681b604482015290519081900360640190fd5b6137be83613752565b15613818578060011461380e576040805162461bcd60e51b8152602060048201526013602482015272494c4c4547414c5f4e46545f42414c414e434560681b604482015290519081900360640190fd5b61352d838361474f565b80156111c7576111c7838383614802565b6000613834826114b0565b90506001600160a01b0381166111ea576040805162461bcd60e51b81526020600482015260116024820152701554d15497d553949151d254d511549151607a1b604482015290519081900360640190fd5b6001600160a01b0383166138d4576040805162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015290519081900360640190fd5b60006138e0838361357c565b90506138eb836143fb565b15613aeb57816138fb57506111c7565b60006139068461440e565b905060008190506000816001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b15801561395c57600080fd5b505afa158015613970573d6000803e3d6000fd5b505050506040513d602081101561398657600080fd5b5051604080516001600160a01b03808b16602483015260448083018990528351808403909101815260649092019092526020810180516001600160e01b031663a9059cbb60e01b1790529192506139df90851682614421565b6000836001600160a01b03166370a08231306040518263ffffffff1660e01b815260040180826001600160a01b0316815260200191505060206040518083038186803b158015613a2e57600080fd5b505afa158015613a42573d6000803e3d6000fd5b505050506040513d6020811015613a5857600080fd5b5051905082811115613a9d576040805162461bcd60e51b8152602060048201526009602482015268554e444552464c4f5760b81b604482015290519081900360640190fd5b8583038114613ae1576040805162461bcd60e51b815260206004820152601c60248201526000805160206150f7833981519152604482015290519081900360640190fd5b505050505061217c565b613af48361305f565b156135325781613b0457506111c7565b613b176001600160a01b03851682614b18565b61217c565b6000633348691d60e01b61307283614345565b613b388361370e565b613b7f576040805162461bcd60e51b815260206004820152601360248201527246554e4749424c455f41535345545f5459504560681b604482015290519081900360640190fd5b613b8883613752565b15613be35780600114613bd8576040805162461bcd60e51b8152602060048201526013602482015272494c4c4547414c5f4e46545f42414c414e434560681b604482015290519081900360640190fd5b613b17848484614bb4565b801561217c5761217c84848484614cb9565b613bfe336130f0565b613c41576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6000613c4b614358565b6001810180546001600160a01b03191690556040519091507f7a8dc7dd7fffb43c4807438fa62729225156941e641fd877938f4edade3429f590600090a150565b613c95336130f0565b613cd8576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b6000613ce2614358565b9050613ced826130f0565b15613d32576040805162461bcd60e51b815260206004820152601060248201526f20a62922a0a22cafa3a7ab22a92727a960811b604482015290519081900360640190fd5b6001810180546001600160a01b0384166001600160a01b0319909116811790915560408051918252517f6166272c8d3f5f579082f2827532732f97195007983bb5b83ac12c56700b01a69181900360200190a15050565b613d92336130f0565b613dd5576040805162461bcd60e51b815260206004820152600f60248201526e4f4e4c595f474f5645524e414e434560881b604482015290519081900360640190fd5b336001600160a01b0382161415613e2a576040805162461bcd60e51b8152602060048201526014602482015273474f5645524e4f525f53454c465f52454d4f564560601b604482015290519081900360640190fd5b6000613e34614358565b9050613e3f826130f0565b613e7f576040805162461bcd60e51b815260206004820152600c60248201526b2727aa2fa3a7ab22a92727a960a11b604482015290519081900360640190fd5b6001600160a01b03821660008181526020838152604091829020805460ff19169055815192835290517fd75f94825e770b8b512be8e74759e252ad00e102e38f50cce2f7c6f868a295999281900390910190a15050565b6000838152600760209081526040808320858452825280832084845290915281205480613f41576040805162461bcd60e51b815260206004820152601460248201527311115413d4d25517d393d517d0d05390d153115160621b604482015290519081900360640190fd5b6202a30081810190811015613f5257fe5b80421015613f98576040805162461bcd60e51b815260206004820152600e60248201526d11115413d4d25517d313d0d2d15160921b604482015290519081900360640190fd5b50505060008381526006602090815260408083208584528252808320848452825280832080549084905595835260078252808320948352938152838220928252919091529081205590565b6000613fee82614fa6565b9050613ff981614fb7565b614043576040805162461bcd60e51b8152602060048201526016602482015275554e535550504f525445445f544f4b454e5f5459504560501b604482015290519081900360640190fd5b6001600160e01b031981166341917ff960e11b14156140ae5781516004146140a9576040805162461bcd60e51b8152602060048201526014602482015273494e56414c49445f41535345545f535452494e4760601b604482015290519081900360640190fd5b613578565b81516024146140fb576040805162461bcd60e51b8152602060048201526014602482015273494e56414c49445f41535345545f535452494e4760601b604482015290519081900360640190fd5b600061410683615056565b905061411a816001600160a01b031661505d565b6111c7576040805162461bcd60e51b81526020600482015260116024820152704241445f544f4b454e5f4144445245535360781b604482015290519081900360640190fd5b60008061416b83614fa6565b90506001600160e01b0319811663012b8bc960e11b14806114ee57506001600160e01b03198116635c5c333960e11b14915050919050565b6001600160a01b0383166141f2576040805162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015290519081900360640190fd5b6141fb8561311f565b614246576040805162461bcd60e51b81526020600482015260176024820152764e4f4e5f4d494e5441424c455f41535345545f5459504560481b604482015290519081900360640190fd5b60008411614291576040805162461bcd60e51b81526020600482015260136024820152721253959053125117d352539517d05353d55395606a1b604482015290519081900360640190fd5b600061429d868661357c565b905060006142aa8761440e565b905061433c8583868660405160240180856001600160a01b0316815260200184815260200180602001828103825284848281815260200192508082843760008184015260408051601f19601f9093018316909401848103909201845252506020810180516319ee6e3f60e01b6001600160e01b039091161790526001600160a01b038916965094506144219350505050565b50505050505050565b6000611c0d61435383612ef5565b614fa6565b600080604051806060016040528060268152602001615158602691396040518082805190602001908083835b602083106143a35780518252601f199092019160209182019101614384565b51815160209384036101000a600019018019909216911617905292019485525060405193849003019092209392505050565b60006143e0826114b0565b6001600160a01b0316336001600160a01b0316149050919050565b6000630f47261b60e41b61307283614345565b6000611c0d61441c83612ef5565b615056565b61442a8261505d565b61446f576040805162461bcd60e51b81526020600482015260116024820152704241445f544f4b454e5f4144445245535360781b604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106144ad5780518252601f19909201916020918201910161448e565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461450f576040519150601f19603f3d011682016040523d82523d6000602084013e614514565b606091505b50915091508181906145a45760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015614569578181015183820152602001614551565b50505050905090810190601f1680156145965780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080511561217c578080602001905160208110156145c157600080fd5b505161217c576040805162461bcd60e51b81526020600482015260166024820152751513d2d15397d3d4115490551253d397d1905253115160521b604482015290519081900360640190fd5b614616816130f0565b1561465b576040805162461bcd60e51b815260206004820152601060248201526f20a62922a0a22cafa3a7ab22a92727a960811b604482015290519081900360640190fd5b6000614665614358565b6001600160a01b0390921660009081526020929092525060409020805460ff19166001179055565b600082826040516020018083805190602001908083835b602083106146c35780518252601f1990920191602091820191016146a4565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b6020831061470b5780518252601f1990920191602091820191016146ec565b6001836020036101000a0380198251168184511680821785525050505050509050019250505060405160208183030381529060405280519060200120905092915050565b61475882613752565b61479c576040805162461bcd60e51b815260206004820152601060248201526f2727aa2fa2a9219b9918afaa27a5a2a760811b604482015290519081900360640190fd5b60006147a78361440e565b6040805133602482015230604482015260648082018690528251808303909101815260849091019091526020810180516001600160e01b0316632142170760e11b1790529091506111c7906001600160a01b03831690614421565b61480b83613b1c565b614850576040805162461bcd60e51b81526020600482015260116024820152702727aa2fa2a92198989a9aafaa27a5a2a760791b604482015290519081900360640190fd5b8061485a576111c7565b6000614866848361357c565b905060006148738561440e565b60408051627eeac760e11b815230600482015260248101879052905191925082916000916001600160a01b0384169162fdd58e91604480820192602092909190829003018186803b1580156148c757600080fd5b505afa1580156148db573d6000803e3d6000fd5b505050506040513d60208110156148f157600080fd5b81019080805190602001909291905050509050614a0663f242432a60e01b333089886040518060200160405280600081525060405160240180866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561498d578181015183820152602001614975565b50505050905090810190601f1680156149ba5780820380516001836020036101000a031916815260200191505b5060408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909a169990991790985250506001600160a01b038a169594505061442192505050565b6000826001600160a01b031662fdd58e30896040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b158015614a5c57600080fd5b505afa158015614a70573d6000803e3d6000fd5b505050506040513d6020811015614a8657600080fd5b5051905081811015614aca576040805162461bcd60e51b81526020600482015260086024820152674f564552464c4f5760c01b604482015290519081900360640190fd5b8482018114614b0e576040805162461bcd60e51b815260206004820152601c60248201526000805160206150f7833981519152604482015290519081900360640190fd5b5050505050505050565b6040516000906001600160a01b0384169083908381818185875af1925050503d8060008114614b63576040519150601f19603f3d011682016040523d82523d6000602084013e614b68565b606091505b50509050806111c7576040805162461bcd60e51b815260206004820152601360248201527211551217d514905394d1915497d19052531151606a1b604482015290519081900360640190fd5b6001600160a01b038316614c03576040805162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015290519081900360640190fd5b614c0c82613752565b614c50576040805162461bcd60e51b815260206004820152601060248201526f2727aa2fa2a9219b9918afaa27a5a2a760811b604482015290519081900360640190fd5b6000614c5b8361440e565b604080513060248201526001600160a01b03808816604483015260648083018790528351808403909101815260849092019092526020810180516001600160e01b0316632142170760e11b17905291925061217c9190831690614421565b6001600160a01b038416614d08576040805162461bcd60e51b81526020600482015260116024820152701253959053125117d49150d25412515395607a1b604482015290519081900360640190fd5b614d1183613b1c565b614d56576040805162461bcd60e51b81526020600482015260116024820152702727aa2fa2a92198989a9aafaa27a5a2a760791b604482015290519081900360640190fd5b80614d605761217c565b6000614d6c848361357c565b90506000614d798561440e565b60408051627eeac760e11b815230600482015260248101879052905191925082916000916001600160a01b0384169162fdd58e91604480820192602092909190829003018186803b158015614dcd57600080fd5b505afa158015614de1573d6000803e3d6000fd5b505050506040513d6020811015614df757600080fd5b81019080805190602001909291905050509050614e9263f242432a60e01b308a89886040518060200160405280600081525060405160240180866001600160a01b03168152602001856001600160a01b0316815260200184815260200183815260200180602001828103825283818151815260200191508051906020019080838360008381101561498d578181015183820152602001614975565b6000826001600160a01b031662fdd58e30896040518363ffffffff1660e01b815260040180836001600160a01b031681526020018281526020019250505060206040518083038186803b158015614ee857600080fd5b505afa158015614efc573d6000803e3d6000fd5b505050506040513d6020811015614f1257600080fd5b5051905081811115614f57576040805162461bcd60e51b8152602060048201526009602482015268554e444552464c4f5760b81b604482015290519081900360640190fd5b8482038114614f9b576040805162461bcd60e51b815260206004820152601c60248201526000805160206150f7833981519152604482015290519081900360640190fd5b505050505050505050565b602001516001600160e01b03191690565b60006001600160e01b031982166341917ff960e11b1480614fe857506001600160e01b03198216630f47261b60e41b145b8061500357506001600160e01b0319821663012b8bc960e11b145b8061501e57506001600160e01b031982166368646e2d60e01b145b8061503957506001600160e01b03198216635c5c333960e11b145b80611c0d5750506001600160e01b031916633348691d60e01b1490565b6024015190565b3b151590565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106150a45782800160ff198235161785556150d1565b828001600101855582156150d1579182015b828111156150d15782358255916020019190600101906150b6565b506150dd9291506150e1565b5090565b5b808211156150dd57600081556001016150e256fe494e434f52524543545f414d4f554e545f5452414e53464552524544000000004d49534d41544348494e475f535441524b5f4554485f4b45595300000000000041535345545f545950455f444f45535f4e4f545f54414b455f544f4b454e5f4944537461726b45782e4d61696e2e323031392e476f7665726e6f7273496e666f726d6174696f6e537461726b576172655f546f6b656e73416e6452616d70696e675f323032345f33a26469706673582212204c484f57d7b3e2b3dee1366510d21c7857a127eb537570bf3f7efed09c10d7e164736f6c634300060c0033
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.