Search is not available for this dataset
chain_id
uint64 1
1
| block_number
uint64 19.5M
20M
| block_hash
stringlengths 64
64
| transaction_hash
stringlengths 64
64
| deployer_address
stringlengths 40
40
| factory_address
stringlengths 40
40
| contract_address
stringlengths 40
40
| creation_bytecode
stringlengths 0
98.3k
| runtime_bytecode
stringlengths 0
49.2k
| creation_sourcecode
stringlengths 0
976k
|
---|---|---|---|---|---|---|---|---|---|
1 | 19,498,525 |
a5316b249f4d247d8450de743dee0adc3e6abd1c62bef5e810d4bd27a911610e
|
88433c5c14b91ed06f50ed7bf74dff3cd42e452c8702c81865ddf59871092830
|
9b8521d493260b9b63a0ef95854b6e2ae99165e1
|
9b8521d493260b9b63a0ef95854b6e2ae99165e1
|
e4382744d3ed7a300a43137081a25818103b6147
|
608060405234801561000f575f80fd5b5061018f8061001d5f395ff3fe608060405234801561000f575f80fd5b5060043610610034575f3560e01c806342db104614610038578063fd28521914610054575b5f80fd5b610052600480360381019061004d919061011b565b610070565b005b61006e6004803603810190610069919061011b565b610074565b005b5050565b5050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a58261007c565b9050919050565b6100b58161009b565b81146100bf575f80fd5b50565b5f813590506100d0816100ac565b92915050565b5f6fffffffffffffffffffffffffffffffff82169050919050565b6100fa816100d6565b8114610104575f80fd5b50565b5f81359050610115816100f1565b92915050565b5f806040838503121561013157610130610078565b5b5f61013e858286016100c2565b925050602061014f85828601610107565b915050925092905056fea26469706673582212200245b7202755cedf48f06ede79e32852bdab41ba85bbee897bb2026786bee80d64736f6c63430008140033
|
608060405234801561000f575f80fd5b5060043610610034575f3560e01c806342db104614610038578063fd28521914610054575b5f80fd5b610052600480360381019061004d919061011b565b610070565b005b61006e6004803603810190610069919061011b565b610074565b005b5050565b5050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100a58261007c565b9050919050565b6100b58161009b565b81146100bf575f80fd5b50565b5f813590506100d0816100ac565b92915050565b5f6fffffffffffffffffffffffffffffffff82169050919050565b6100fa816100d6565b8114610104575f80fd5b50565b5f81359050610115816100f1565b92915050565b5f806040838503121561013157610130610078565b5b5f61013e858286016100c2565b925050602061014f85828601610107565b915050925092905056fea26469706673582212200245b7202755cedf48f06ede79e32852bdab41ba85bbee897bb2026786bee80d64736f6c63430008140033
| |
1 | 19,498,525 |
a5316b249f4d247d8450de743dee0adc3e6abd1c62bef5e810d4bd27a911610e
|
9aff4d45ecedb6817753377941b4f4fe27388788c22f677c5f45a267aec5efb2
|
578f533873dc8ea60ab1417180cc531f172ee292
|
29ef46035e9fa3d570c598d3266424ca11413b0c
|
248a02b6b693f7543ed760353a9e610a2a5c25f8
|
3d602d80600a3d3981f3363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"contracts/Forwarder.sol": {
"content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.10;\nimport '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';\nimport '@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol';\nimport './ERC20Interface.sol';\nimport './TransferHelper.sol';\nimport './IForwarder.sol';\n\n/**\n * Contract that will forward any incoming Ether to the creator of the contract\n *\n */\ncontract Forwarder is IERC721Receiver, ERC1155Receiver, IForwarder {\n // Address to which any funds sent to this contract will be forwarded\n address public parentAddress;\n bool public autoFlush721 = true;\n bool public autoFlush1155 = true;\n\n event ForwarderDeposited(address from, uint256 value, bytes data);\n\n /**\n * Initialize the contract, and sets the destination address to that of the creator\n */\n function init(\n address _parentAddress,\n bool _autoFlush721,\n bool _autoFlush1155\n ) external onlyUninitialized {\n parentAddress = _parentAddress;\n uint256 value = address(this).balance;\n\n // set whether we want to automatically flush erc721/erc1155 tokens or not\n autoFlush721 = _autoFlush721;\n autoFlush1155 = _autoFlush1155;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n\n // NOTE: since we are forwarding on initialization,\n // we don't have the context of the original sender.\n // We still emit an event about the forwarding but set\n // the sender to the forwarder itself\n emit ForwarderDeposited(address(this), value, msg.data);\n }\n\n /**\n * Modifier that will execute internal code block only if the sender is the parent address\n */\n modifier onlyParent {\n require(msg.sender == parentAddress, 'Only Parent');\n _;\n }\n\n /**\n * Modifier that will execute internal code block only if the contract has not been initialized yet\n */\n modifier onlyUninitialized {\n require(parentAddress == address(0x0), 'Already initialized');\n _;\n }\n\n /**\n * Default function; Gets called when data is sent but does not match any other function\n */\n fallback() external payable {\n flush();\n }\n\n /**\n * Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address\n */\n receive() external payable {\n flush();\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush721(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush721 = autoFlush;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush1155(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush1155 = autoFlush;\n }\n\n /**\n * ERC721 standard callback function for when a ERC721 is transfered. The forwarder will send the nft\n * to the base wallet once the nft contract invokes this method after transfering the nft.\n *\n * @param _operator The address which called `safeTransferFrom` function\n * @param _from The address of the sender\n * @param _tokenId The token id of the nft\n * @param data Additional data with no specified format, sent in call to `_to`\n */\n function onERC721Received(\n address _operator,\n address _from,\n uint256 _tokenId,\n bytes memory data\n ) external virtual override returns (bytes4) {\n if (autoFlush721) {\n IERC721 instance = IERC721(msg.sender);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The caller does not support the ERC721 interface'\n );\n // this won't work for ERC721 re-entrancy\n instance.safeTransferFrom(address(this), parentAddress, _tokenId, data);\n }\n\n return this.onERC721Received.selector;\n }\n\n function callFromParent(\n address target,\n uint256 value,\n bytes calldata data\n ) external onlyParent returns (bytes memory) {\n (bool success, bytes memory returnedData) = target.call{ value: value }(\n data\n );\n require(success, 'Parent call execution failed');\n\n return returnedData;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155Received(\n address _operator,\n address _from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeTransferFrom(address(this), parentAddress, id, value, data);\n }\n\n return this.onERC1155Received.selector;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155BatchReceived(\n address _operator,\n address _from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeBatchTransferFrom(\n address(this),\n parentAddress,\n ids,\n values,\n data\n );\n }\n\n return this.onERC1155BatchReceived.selector;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushTokens(address tokenContractAddress)\n external\n virtual\n override\n onlyParent\n {\n ERC20Interface instance = ERC20Interface(tokenContractAddress);\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress);\n if (forwarderBalance == 0) {\n return;\n }\n\n TransferHelper.safeTransfer(\n tokenContractAddress,\n parentAddress,\n forwarderBalance\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC721 instance = IERC721(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The tokenContractAddress does not support the ERC721 interface'\n );\n\n address ownerAddress = instance.ownerOf(tokenId);\n instance.transferFrom(ownerAddress, parentAddress, tokenId);\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress, tokenId);\n\n instance.safeTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenId,\n forwarderBalance,\n ''\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external virtual override onlyParent {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256[] memory amounts = new uint256[](tokenIds.length);\n for (uint256 i = 0; i < tokenIds.length; i++) {\n amounts[i] = instance.balanceOf(forwarderAddress, tokenIds[i]);\n }\n\n instance.safeBatchTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenIds,\n amounts,\n ''\n );\n }\n\n /**\n * Flush the entire balance of the contract to the parent address.\n */\n function flush() public {\n uint256 value = address(this).balance;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n emit ForwarderDeposited(msg.sender, value, msg.data);\n }\n\n /**\n * @inheritdoc IERC165\n */\n function supportsInterface(bytes4 interfaceId)\n public\n virtual\n override(ERC1155Receiver, IERC165)\n view\n returns (bool)\n {\n return\n interfaceId == type(IForwarder).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155 is IERC165 {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC1155Receiver.sol\";\nimport \"../../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155Receiver is ERC165, IERC1155Receiver {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n}\n"
},
"contracts/ERC20Interface.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.10;\n\n/**\n * Contract that exposes the needed erc20 token functions\n */\n\nabstract contract ERC20Interface {\n // Send _value amount of tokens to address _to\n function transfer(address _to, uint256 _value)\n public\n virtual\n returns (bool success);\n\n // Get the account balance of another account with address _owner\n function balanceOf(address _owner)\n public\n virtual\n view\n returns (uint256 balance);\n}\n"
},
"contracts/TransferHelper.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// source: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/TransferHelper.sol\npragma solidity 0.8.10;\n\nimport '@openzeppelin/contracts/utils/Address.sol';\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n function safeTransfer(\n address token,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transfer(address,uint256)')));\n (bool success, bytes memory data) = token.call(\n abi.encodeWithSelector(0xa9059cbb, to, value)\n );\n require(\n success && (data.length == 0 || abi.decode(data, (bool))),\n 'TransferHelper::safeTransfer: transfer failed'\n );\n }\n\n function safeTransferFrom(\n address token,\n address from,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n (bool success, bytes memory returndata) = token.call(\n abi.encodeWithSelector(0x23b872dd, from, to, value)\n );\n Address.verifyCallResult(\n success,\n returndata,\n 'TransferHelper::transferFrom: transferFrom failed'\n );\n }\n}\n"
},
"contracts/IForwarder.sol": {
"content": "pragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\n\ninterface IForwarder is IERC165 {\n /**\n * Sets the autoflush721 parameter.\n *\n * @param autoFlush whether to autoflush erc721 tokens\n */\n function setAutoFlush721(bool autoFlush) external;\n\n /**\n * Sets the autoflush1155 parameter.\n *\n * @param autoFlush whether to autoflush erc1155 tokens\n */\n function setAutoFlush1155(bool autoFlush) external;\n\n /**\n * Execute a token transfer of the full balance from the forwarder token to the parent address\n *\n * @param tokenContractAddress the address of the erc20 token contract\n */\n function flushTokens(address tokenContractAddress) external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address\n *\n * @param tokenContractAddress the address of the ERC721 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a batch nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenIds The token ids of the nfts\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external;\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n @dev Handles the receipt of a single ERC1155 token type. This function is\n called at the end of a `safeTransferFrom` after the balance has been updated.\n To accept the transfer, this must return\n `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n (i.e. 0xf23a6e61, or its own function selector).\n @param operator The address which initiated the transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param id The ID of the token being transferred\n @param value The amount of tokens being transferred\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n @dev Handles the receipt of a multiple ERC1155 token types. This function\n is called at the end of a `safeBatchTransferFrom` after the balances have\n been updated. To accept the transfer(s), this must return\n `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n (i.e. 0xbc197c81, or its own function selector).\n @param operator The address which initiated the batch transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param ids An array containing ids of each token being transferred (order and length must match values array)\n @param values An array containing amounts of each token being transferred (order and length must match ids array)\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,498,525 |
a5316b249f4d247d8450de743dee0adc3e6abd1c62bef5e810d4bd27a911610e
|
699dee0ba4e197d24da8e2f61220eddbefee844978517c6b9d84439bc3bd3c66
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
0c248fe9c02176adee5668b292fbfd5e3e8a3fa4
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,528 |
4835e33ed19f7a9e1fbe5ed63c119c55a316ffd41977b426d5a3c9ebaf52fe01
|
4c84ac5373a279589f7d37184f99c48dc69cf8e49a12dd47f27e4cd7e5c508e0
|
072c318c919e797790a753828a4467b8ec21a60e
|
000000f20032b9e171844b00ea507e11960bd94a
|
cb5223e70a71e4803f63a677edcc2fe0e9694bd9
|
3d602d80600a3d3981f3363d3d373d3d3d363d730d223d05e1cc4ac20de7fce86bc9bb8efb56f4d45af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730d223d05e1cc4ac20de7fce86bc9bb8efb56f4d45af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/clones/ERC1155SeaDropCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ERC1155SeaDropContractOffererCloneable\n} from \"./ERC1155SeaDropContractOffererCloneable.sol\";\n\n/**\n * @title ERC1155SeaDropCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable ERC1155 token contract that can mint as a\n * Seaport contract offerer.\n */\ncontract ERC1155SeaDropCloneable is ERC1155SeaDropContractOffererCloneable {\n /**\n * @notice Initialize the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * implementation code. Also contains SeaDrop\n * implementation code.\n * @param allowedSeaport The address of the Seaport contract allowed to\n * interact.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function initialize(\n address allowedConfigurer,\n address allowedSeaport,\n string memory name_,\n string memory symbol_,\n address initialOwner\n ) public initializer {\n // Initialize ownership.\n _initializeOwner(initialOwner);\n\n // Initialize ERC1155SeaDropContractOffererCloneable.\n __ERC1155SeaDropContractOffererCloneable_init(\n allowedConfigurer,\n allowedSeaport,\n name_,\n symbol_\n );\n }\n\n /**\n * @dev Auto-approve the conduit after mint or transfer.\n *\n * @custom:param from The address to transfer from.\n * @param to The address to transfer to.\n * @custom:param ids The token ids to transfer.\n * @custom:param amounts The quantities to transfer.\n * @custom:param data The data to pass if receiver is a contract.\n */\n function _afterTokenTransfer(\n address /* from */,\n address to,\n uint256[] memory /* ids */,\n uint256[] memory /* amounts */,\n bytes memory /* data */\n ) internal virtual override {\n // Auto-approve the conduit.\n if (to != address(0) && !isApprovedForAll(to, _CONDUIT)) {\n _setApprovalForAll(to, _CONDUIT, true);\n }\n }\n\n /**\n * @dev Override this function to return true if `_afterTokenTransfer` is\n * used. The is to help the compiler avoid producing dead bytecode.\n */\n function _useAfterTokenTransfer()\n internal\n view\n virtual\n override\n returns (bool)\n {\n return true;\n }\n\n /**\n * @notice Burns a token, restricted to the owner or approved operator,\n * and must have sufficient balance.\n *\n * @param from The address to burn from.\n * @param id The token id to burn.\n * @param amount The amount to burn.\n */\n function burn(address from, uint256 id, uint256 amount) external {\n // Burn the token.\n _burn(msg.sender, from, id, amount);\n }\n\n /**\n * @notice Burns a batch of tokens, restricted to the owner or\n * approved operator, and must have sufficient balance.\n *\n * @param from The address to burn from.\n * @param ids The token ids to burn.\n * @param amounts The amounts to burn per token id.\n */\n function batchBurn(\n address from,\n uint256[] calldata ids,\n uint256[] calldata amounts\n ) external {\n // Burn the tokens.\n _batchBurn(msg.sender, from, ids, amounts);\n }\n}\n"
},
"src/clones/ERC1155SeaDropContractOffererCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { IERC1155SeaDrop } from \"../interfaces/IERC1155SeaDrop.sol\";\n\nimport { ISeaDropToken } from \"../interfaces/ISeaDropToken.sol\";\n\nimport {\n ERC1155ContractMetadataCloneable\n} from \"./ERC1155ContractMetadataCloneable.sol\";\n\nimport {\n ERC1155SeaDropContractOffererStorage\n} from \"../lib/ERC1155SeaDropContractOffererStorage.sol\";\n\nimport {\n ERC1155SeaDropErrorsAndEvents\n} from \"../lib/ERC1155SeaDropErrorsAndEvents.sol\";\n\nimport { PublicDrop } from \"../lib//ERC1155SeaDropStructs.sol\";\n\nimport { AllowListData } from \"../lib/SeaDropStructs.sol\";\n\nimport {\n ERC1155ConduitPreapproved\n} from \"../lib/ERC1155ConduitPreapproved.sol\";\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\nimport { SpentItem } from \"seaport-types/src/lib/ConsiderationStructs.sol\";\n\nimport {\n ContractOffererInterface\n} from \"seaport-types/src/interfaces/ContractOffererInterface.sol\";\n\nimport {\n IERC165\n} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title ERC1155SeaDropContractOffererCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable ERC1155 token contract that can mint as a\n * Seaport contract offerer.\n */\ncontract ERC1155SeaDropContractOffererCloneable is\n ERC1155ContractMetadataCloneable,\n ERC1155SeaDropErrorsAndEvents\n{\n using ERC1155SeaDropContractOffererStorage for ERC1155SeaDropContractOffererStorage.Layout;\n\n /**\n * @notice Initialize the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * configure parameters. Also contains SeaDrop\n * implementation code.\n * @param allowedSeaport The address of the Seaport contract allowed to\n * interact.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function __ERC1155SeaDropContractOffererCloneable_init(\n address allowedConfigurer,\n address allowedSeaport,\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n // Set the allowed Seaport to interact with this contract.\n if (allowedSeaport == address(0)) {\n revert AllowedSeaportCannotBeZeroAddress();\n }\n ERC1155SeaDropContractOffererStorage.layout()._allowedSeaport[\n allowedSeaport\n ] = true;\n\n // Set the allowed Seaport enumeration.\n address[] memory enumeratedAllowedSeaport = new address[](1);\n enumeratedAllowedSeaport[0] = allowedSeaport;\n ERC1155SeaDropContractOffererStorage\n .layout()\n ._enumeratedAllowedSeaport = enumeratedAllowedSeaport;\n\n // Emit an event noting the contract deployment.\n emit SeaDropTokenDeployed(SEADROP_TOKEN_TYPE.ERC1155_CLONE);\n\n // Initialize ERC1155ContractMetadataCloneable.\n __ERC1155ContractMetadataCloneable_init(\n allowedConfigurer,\n name_,\n symbol_\n );\n }\n\n /**\n * @notice The fallback function is used as a dispatcher for SeaDrop\n * methods.\n */\n fallback(bytes calldata) external returns (bytes memory output) {\n // Get the function selector.\n bytes4 selector = msg.sig;\n\n // Get the rest of the msg data after the selector.\n bytes calldata data = msg.data[4:];\n\n // Determine if we should forward the call to the implementation\n // contract with SeaDrop logic.\n bool callSeaDropImplementation = selector ==\n ISeaDropToken.updateAllowedSeaport.selector ||\n selector == ISeaDropToken.updateDropURI.selector ||\n selector == ISeaDropToken.updateAllowList.selector ||\n selector == ISeaDropToken.updateCreatorPayouts.selector ||\n selector == ISeaDropToken.updatePayer.selector ||\n selector == ISeaDropToken.updateAllowedFeeRecipient.selector ||\n selector == ISeaDropToken.updateSigner.selector ||\n selector == IERC1155SeaDrop.updatePublicDrop.selector ||\n selector == ContractOffererInterface.previewOrder.selector ||\n selector == ContractOffererInterface.generateOrder.selector ||\n selector == ContractOffererInterface.getSeaportMetadata.selector ||\n selector == IERC1155SeaDrop.getPublicDrop.selector ||\n selector == IERC1155SeaDrop.getPublicDropIndexes.selector ||\n selector == ISeaDropToken.getAllowedSeaport.selector ||\n selector == ISeaDropToken.getCreatorPayouts.selector ||\n selector == ISeaDropToken.getAllowListMerkleRoot.selector ||\n selector == ISeaDropToken.getAllowedFeeRecipients.selector ||\n selector == ISeaDropToken.getSigners.selector ||\n selector == ISeaDropToken.getDigestIsUsed.selector ||\n selector == ISeaDropToken.getPayers.selector;\n\n // Determine if we should require only the owner or configurer calling.\n bool requireOnlyOwnerOrConfigurer = selector ==\n ISeaDropToken.updateAllowedSeaport.selector ||\n selector == ISeaDropToken.updateDropURI.selector ||\n selector == ISeaDropToken.updateAllowList.selector ||\n selector == ISeaDropToken.updateCreatorPayouts.selector ||\n selector == ISeaDropToken.updatePayer.selector ||\n selector == ISeaDropToken.updateAllowedFeeRecipient.selector ||\n selector == IERC1155SeaDrop.updatePublicDrop.selector;\n\n if (callSeaDropImplementation) {\n // For update calls, ensure the sender is only the owner\n // or configurer contract.\n if (requireOnlyOwnerOrConfigurer) {\n _onlyOwnerOrConfigurer();\n } else if (selector == ISeaDropToken.updateSigner.selector) {\n // For updateSigner, a signer can disallow themselves.\n // Get the signer parameter.\n address signer = address(bytes20(data[12:32]));\n // If the signer is not allowed, ensure sender is only owner\n // or configurer.\n if (\n msg.sender != signer ||\n (msg.sender == signer &&\n !ERC1155SeaDropContractOffererStorage\n .layout()\n ._allowedSigners[signer])\n ) {\n _onlyOwnerOrConfigurer();\n }\n }\n\n // Forward the call to the implementation contract.\n (bool success, bytes memory returnedData) = _CONFIGURER\n .delegatecall(msg.data);\n\n // Require that the call was successful.\n if (!success) {\n // Bubble up the revert reason.\n assembly {\n revert(add(32, returnedData), mload(returnedData))\n }\n }\n\n // If the call was to generateOrder, mint the tokens.\n if (selector == ContractOffererInterface.generateOrder.selector) {\n _mintOrder(data);\n }\n\n // Return the data from the delegate call.\n return returnedData;\n } else if (selector == IERC1155SeaDrop.getMintStats.selector) {\n // Get the minter and token id.\n (address minter, uint256 tokenId) = abi.decode(\n data,\n (address, uint256)\n );\n\n // Get the mint stats.\n (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n ) = _getMintStats(minter, tokenId);\n\n // Encode the return data.\n return\n abi.encode(\n minterNumMinted,\n minterNumMintedForTokenId,\n totalMintedForTokenId,\n maxSupply\n );\n } else if (selector == ContractOffererInterface.ratifyOrder.selector) {\n // This function is a no-op, nothing additional needs to happen here.\n // Utilize assembly to efficiently return the ratifyOrder magic value.\n assembly {\n mstore(0, 0xf4dd92ce)\n return(0x1c, 32)\n }\n } else if (selector == ISeaDropToken.configurer.selector) {\n // Return the configurer contract.\n return abi.encode(_CONFIGURER);\n } else if (selector == IERC1155SeaDrop.multiConfigureMint.selector) {\n // Ensure only the owner or configurer can call this function.\n _onlyOwnerOrConfigurer();\n\n // Mint the tokens.\n _multiConfigureMint(data);\n } else {\n // Revert if the function selector is not supported.\n revert UnsupportedFunctionSelector(selector);\n }\n }\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists in enforcing maxSupply, maxTotalMintableByWallet,\n * and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC1155Received() hooks.\n *\n * @param minter The minter address.\n * @param tokenId The token id to return the stats for.\n */\n function _getMintStats(\n address minter,\n uint256 tokenId\n )\n internal\n view\n returns (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n )\n {\n // Put the token supply on the stack.\n TokenSupply storage tokenSupply = _tokenSupply[tokenId];\n\n // Assign the return values.\n totalMintedForTokenId = tokenSupply.totalMinted;\n maxSupply = tokenSupply.maxSupply;\n minterNumMinted = _totalMintedByUser[minter];\n minterNumMintedForTokenId = _totalMintedByUserPerToken[minter][tokenId];\n }\n\n /**\n * @dev Handle ERC-1155 safeTransferFrom. If \"from\" is this contract,\n * the sender can only be Seaport or the conduit.\n *\n * @param from The address to transfer from.\n * @param to The address to transfer to.\n * @param id The token id to transfer.\n * @param amount The amount of tokens to transfer.\n * @param data The data to pass to the onERC1155Received hook.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual override {\n if (from == address(this)) {\n // Only Seaport or the conduit can use this function\n // when \"from\" is this contract.\n if (\n msg.sender != _CONDUIT &&\n !ERC1155SeaDropContractOffererStorage.layout()._allowedSeaport[\n msg.sender\n ]\n ) {\n revert InvalidCallerOnlyAllowedSeaport(msg.sender);\n }\n return;\n }\n\n ERC1155._safeTransfer(_by(), from, to, id, amount, data);\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n virtual\n override(ERC1155ContractMetadataCloneable)\n returns (bool)\n {\n return\n interfaceId == type(IERC1155SeaDrop).interfaceId ||\n interfaceId == type(ContractOffererInterface).interfaceId ||\n interfaceId == 0x2e778efc || // SIP-5 (getSeaportMetadata)\n // ERC1155ContractMetadata returns supportsInterface true for\n // IERC1155ContractMetadata, ERC-4906, ERC-2981\n // ERC1155A returns supportsInterface true for\n // ERC165, ERC1155, ERC1155MetadataURI\n ERC1155ContractMetadataCloneable.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Internal function to mint tokens during a generateOrder call\n * from Seaport.\n *\n * @param data The original transaction calldata, without the selector.\n */\n function _mintOrder(bytes calldata data) internal {\n // Decode fulfiller, minimumReceived, and context from calldata.\n (\n address fulfiller,\n SpentItem[] memory minimumReceived,\n ,\n bytes memory context\n ) = abi.decode(data, (address, SpentItem[], SpentItem[], bytes));\n\n // Assign the minter from context[22:42]. We validate context has the\n // correct minimum length in the implementation's `_decodeOrder`.\n address minter;\n assembly {\n minter := shr(96, mload(add(add(context, 0x20), 22)))\n }\n\n // If the minter is the zero address, set it to the fulfiller.\n if (minter == address(0)) {\n minter = fulfiller;\n }\n\n // Set the token ids and quantities.\n uint256 minimumReceivedLength = minimumReceived.length;\n uint256[] memory tokenIds = new uint256[](minimumReceivedLength);\n uint256[] memory quantities = new uint256[](minimumReceivedLength);\n for (uint256 i = 0; i < minimumReceivedLength; ) {\n tokenIds[i] = minimumReceived[i].identifier;\n quantities[i] = minimumReceived[i].amount;\n unchecked {\n ++i;\n }\n }\n\n // Mint the tokens.\n _batchMint(minter, tokenIds, quantities, \"\");\n }\n\n /**\n * @dev Internal function to mint tokens during a multiConfigureMint call\n * from the configurer contract.\n *\n * @param data The original transaction calldata, without the selector.\n */\n function _multiConfigureMint(bytes calldata data) internal {\n // Decode the calldata.\n (\n address recipient,\n uint256[] memory tokenIds,\n uint256[] memory amounts\n ) = abi.decode(data, (address, uint256[], uint256[]));\n\n _batchMint(recipient, tokenIds, amounts, \"\");\n }\n}\n"
},
"src/interfaces/IERC1155SeaDrop.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { ISeaDropToken } from \"./ISeaDropToken.sol\";\n\nimport { PublicDrop } from \"../lib/ERC1155SeaDropStructs.sol\";\n\n/**\n * @dev A helper interface to get and set parameters for ERC1155SeaDrop.\n * The token does not expose these methods as part of its external\n * interface to optimize contract size, but does implement them.\n */\ninterface IERC1155SeaDrop is ISeaDropToken {\n /**\n * @notice Update the SeaDrop public drop parameters at a given index.\n *\n * @param publicDrop The new public drop parameters.\n * @param index The public drop index.\n */\n function updatePublicDrop(\n PublicDrop calldata publicDrop,\n uint256 index\n ) external;\n\n /**\n * @notice Returns the public drop stage parameters at a given index.\n *\n * @param index The index of the public drop stage.\n */\n function getPublicDrop(\n uint256 index\n ) external view returns (PublicDrop memory);\n\n /**\n * @notice Returns the public drop indexes.\n */\n function getPublicDropIndexes() external view returns (uint256[] memory);\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, maxTotalMintableByWalletPerToken,\n * and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC1155Received() hooks.\n *\n * @param minter The minter address.\n * @param tokenId The token id to return stats for.\n */\n function getMintStats(\n address minter,\n uint256 tokenId\n )\n external\n view\n returns (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n );\n\n /**\n * @notice This function is only allowed to be called by the configurer\n * contract as a way to batch mints and configuration in one tx.\n *\n * @param recipient The address to receive the mints.\n * @param tokenIds The tokenIds to mint.\n * @param amounts The amounts to mint.\n */\n function multiConfigureMint(\n address recipient,\n uint256[] calldata tokenIds,\n uint256[] calldata amounts\n ) external;\n}\n"
},
"src/interfaces/ISeaDropToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\nimport { AllowListData, CreatorPayout } from \"../lib/SeaDropStructs.sol\";\n\n/**\n * @dev A helper base interface for IERC721SeaDrop and IERC1155SeaDrop.\n * The token does not expose these methods as part of its external\n * interface to optimize contract size, but does implement them.\n */\ninterface ISeaDropToken is ISeaDropTokenContractMetadata {\n /**\n * @notice Update the SeaDrop allowed Seaport contracts privileged to mint.\n * Only the owner can use this function.\n *\n * @param allowedSeaport The allowed Seaport addresses.\n */\n function updateAllowedSeaport(address[] calldata allowedSeaport) external;\n\n /**\n * @notice Update the SeaDrop allowed fee recipient.\n * Only the owner can use this function.\n *\n * @param feeRecipient The new fee recipient.\n * @param allowed Whether the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(\n address feeRecipient,\n bool allowed\n ) external;\n\n /**\n * @notice Update the SeaDrop creator payout addresses.\n * The total basis points must add up to exactly 10_000.\n * Only the owner can use this function.\n *\n * @param creatorPayouts The new creator payouts.\n */\n function updateCreatorPayouts(\n CreatorPayout[] calldata creatorPayouts\n ) external;\n\n /**\n * @notice Update the SeaDrop drop URI.\n * Only the owner can use this function.\n *\n * @param dropURI The new drop URI.\n */\n function updateDropURI(string calldata dropURI) external;\n\n /**\n * @notice Update the SeaDrop allow list data.\n * Only the owner can use this function.\n *\n * @param allowListData The new allow list data.\n */\n function updateAllowList(AllowListData calldata allowListData) external;\n\n /**\n * @notice Update the SeaDrop allowed payers.\n * Only the owner can use this function.\n *\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(address payer, bool allowed) external;\n\n /**\n * @notice Update the SeaDrop allowed signer.\n * Only the owner can use this function.\n * An allowed signer can also disallow themselves.\n *\n * @param signer The signer to update.\n * @param allowed Whether the signer is allowed.\n */\n function updateSigner(address signer, bool allowed) external;\n\n /**\n * @notice Get the SeaDrop allowed Seaport contracts privileged to mint.\n */\n function getAllowedSeaport() external view returns (address[] memory);\n\n /**\n * @notice Returns the SeaDrop creator payouts.\n */\n function getCreatorPayouts() external view returns (CreatorPayout[] memory);\n\n /**\n * @notice Returns the SeaDrop allow list merkle root.\n */\n function getAllowListMerkleRoot() external view returns (bytes32);\n\n /**\n * @notice Returns the SeaDrop allowed fee recipients.\n */\n function getAllowedFeeRecipients() external view returns (address[] memory);\n\n /**\n * @notice Returns the SeaDrop allowed signers.\n */\n function getSigners() external view returns (address[] memory);\n\n /**\n * @notice Returns if the signed digest has been used.\n *\n * @param digest The digest hash.\n */\n function getDigestIsUsed(bytes32 digest) external view returns (bool);\n\n /**\n * @notice Returns the SeaDrop allowed payers.\n */\n function getPayers() external view returns (address[] memory);\n\n /**\n * @notice Returns the configurer contract.\n */\n function configurer() external view returns (address);\n}\n"
},
"src/clones/ERC1155ContractMetadataCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n IERC1155ContractMetadata\n} from \"../interfaces/IERC1155ContractMetadata.sol\";\n\nimport {\n ERC1155ConduitPreapproved\n} from \"../lib/ERC1155ConduitPreapproved.sol\";\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\nimport { ERC2981 } from \"solady/src/tokens/ERC2981.sol\";\n\nimport { Ownable } from \"solady/src/auth/Ownable.sol\";\n\nimport {\n Initializable\n} from \"@openzeppelin-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\n/**\n * @title ERC1155ContractMetadataCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable token contract that extends ERC-1155\n * with additional metadata and ownership capabilities.\n */\ncontract ERC1155ContractMetadataCloneable is\n ERC1155ConduitPreapproved,\n ERC2981,\n Ownable,\n IERC1155ContractMetadata,\n Initializable\n{\n /// @notice A struct containing the token supply info per token id.\n mapping(uint256 => TokenSupply) _tokenSupply;\n\n /// @notice The total number of tokens minted by address.\n mapping(address => uint256) _totalMintedByUser;\n\n /// @notice The total number of tokens minted per token id by address.\n mapping(address => mapping(uint256 => uint256)) _totalMintedByUserPerToken;\n\n /// @notice The name of the token.\n string internal _name;\n\n /// @notice The symbol of the token.\n string internal _symbol;\n\n /// @notice The base URI for token metadata.\n string internal _baseURI;\n\n /// @notice The contract URI for contract metadata.\n string internal _contractURI;\n\n /// @notice The provenance hash for guaranteeing metadata order\n /// for random reveals.\n bytes32 internal _provenanceHash;\n\n /// @notice The allowed contract that can configure SeaDrop parameters.\n address internal _CONFIGURER;\n\n /**\n * @dev Reverts if the sender is not the owner or the allowed\n * configurer contract.\n *\n * This is used as a function instead of a modifier\n * to save contract space when used multiple times.\n */\n function _onlyOwnerOrConfigurer() internal view {\n if (msg.sender != _CONFIGURER && msg.sender != owner()) {\n revert Unauthorized();\n }\n }\n\n /**\n * @notice Deploy the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * configure parameters. Also contains SeaDrop\n * implementation code.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function __ERC1155ContractMetadataCloneable_init(\n address allowedConfigurer,\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n // Set the name of the token.\n _name = name_;\n\n // Set the symbol of the token.\n _symbol = symbol_;\n\n // Set the allowed configurer contract to interact with this contract.\n _CONFIGURER = allowedConfigurer;\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param newBaseURI The new base URI to set.\n */\n function setBaseURI(string calldata newBaseURI) external override {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the new base URI.\n _baseURI = newBaseURI;\n\n // Emit an event with the update.\n emit BatchMetadataUpdate(0, type(uint256).max);\n }\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external override {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the new contract URI.\n _contractURI = newContractURI;\n\n // Emit an event with the update.\n emit ContractURIUpdated(newContractURI);\n }\n\n /**\n * @notice Emit an event notifying metadata updates for\n * a range of token ids, according to EIP-4906.\n *\n * @param fromTokenId The start token id.\n * @param toTokenId The end token id.\n */\n function emitBatchMetadataUpdate(\n uint256 fromTokenId,\n uint256 toTokenId\n ) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Emit an event with the update.\n if (fromTokenId == toTokenId) {\n // If only one token is being updated, use the event\n // in the 1155 spec.\n emit URI(uri(fromTokenId), fromTokenId);\n } else {\n emit BatchMetadataUpdate(fromTokenId, toTokenId);\n }\n }\n\n /**\n * @notice Sets the max token supply and emits an event.\n *\n * @param tokenId The token id to set the max supply for.\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 tokenId, uint256 newMaxSupply) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Ensure the max supply does not exceed the maximum value of uint64,\n // a limit due to the storage of bit-packed variables in TokenSupply,\n if (newMaxSupply > 2 ** 64 - 1) {\n revert CannotExceedMaxSupplyOfUint64(newMaxSupply);\n }\n\n // Set the new max supply.\n _tokenSupply[tokenId].maxSupply = uint64(newMaxSupply);\n\n // Emit an event with the update.\n emit MaxSupplyUpdated(tokenId, newMaxSupply);\n }\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert if the provenance hash has already\n * been set, so be sure to carefully set it only once.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Keep track of the old provenance hash for emitting with the event.\n bytes32 oldProvenanceHash = _provenanceHash;\n\n // Revert if the provenance hash has already been set.\n if (oldProvenanceHash != bytes32(0)) {\n revert ProvenanceHashCannotBeSetAfterAlreadyBeingSet();\n }\n\n // Set the new provenance hash.\n _provenanceHash = newProvenanceHash;\n\n // Emit an event with the update.\n emit ProvenanceHashUpdated(oldProvenanceHash, newProvenanceHash);\n }\n\n /**\n * @notice Sets the default royalty information.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator of 10_000 basis points.\n */\n function setDefaultRoyalty(address receiver, uint96 feeNumerator) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the default royalty.\n // ERC2981 implementation ensures feeNumerator <= feeDenominator\n // and receiver != address(0).\n _setDefaultRoyalty(receiver, feeNumerator);\n\n // Emit an event with the updated params.\n emit RoyaltyInfoUpdated(receiver, feeNumerator);\n }\n\n /**\n * @notice Returns the name of the token.\n */\n function name() external view returns (string memory) {\n return _name;\n }\n\n /**\n * @notice Returns the symbol of the token.\n */\n function symbol() external view returns (string memory) {\n return _symbol;\n }\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view override returns (string memory) {\n return _baseURI;\n }\n\n /**\n * @notice Returns the contract URI for contract metadata.\n */\n function contractURI() external view override returns (string memory) {\n return _contractURI;\n }\n\n /**\n * @notice Returns the max token supply for a token id.\n */\n function maxSupply(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].maxSupply;\n }\n\n /**\n * @notice Returns the total supply for a token id.\n */\n function totalSupply(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].totalSupply;\n }\n\n /**\n * @notice Returns the total minted for a token id.\n */\n function totalMinted(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].totalMinted;\n }\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view override returns (bytes32) {\n return _provenanceHash;\n }\n\n /**\n * @notice Returns the URI for token metadata.\n *\n * This implementation returns the same URI for *all* token types.\n * It relies on the token type ID substitution mechanism defined\n * in the EIP to replace {id} with the token id.\n *\n * @custom:param tokenId The token id to get the URI for.\n */\n function uri(\n uint256 /* tokenId */\n ) public view virtual override returns (string memory) {\n // Return the base URI.\n return _baseURI;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC1155, ERC2981) returns (bool) {\n return\n interfaceId == type(IERC1155ContractMetadata).interfaceId ||\n interfaceId == 0x49064906 || // ERC-4906 (MetadataUpdate)\n ERC2981.supportsInterface(interfaceId) ||\n // ERC1155 returns supportsInterface true for\n // ERC165, ERC1155, ERC1155MetadataURI\n ERC1155.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Adds to the internal counters for a mint.\n *\n * @param to The address to mint to.\n * @param id The token id to mint.\n * @param amount The quantity to mint.\n * @param data The data to pass if receiver is a contract.\n */\n function _mint(\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual override {\n // Increment mint counts.\n _incrementMintCounts(to, id, amount);\n\n ERC1155._mint(to, id, amount, data);\n }\n\n /**\n * @dev Adds to the internal counters for a batch mint.\n *\n * @param to The address to mint to.\n * @param ids The token ids to mint.\n * @param amounts The quantities to mint.\n * @param data The data to pass if receiver is a contract.\n */\n function _batchMint(\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual override {\n // Put ids length on the stack to save MLOADs.\n uint256 idsLength = ids.length;\n\n for (uint256 i = 0; i < idsLength; ) {\n // Increment mint counts.\n _incrementMintCounts(to, ids[i], amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n\n ERC1155._batchMint(to, ids, amounts, data);\n }\n\n /**\n * @dev Subtracts from the internal counters for a burn.\n *\n * @param by The address calling the burn.\n * @param from The address to burn from.\n * @param id The token id to burn.\n * @param amount The amount to burn.\n */\n function _burn(\n address by,\n address from,\n uint256 id,\n uint256 amount\n ) internal virtual override {\n // Reduce the supply.\n _reduceSupplyOnBurn(id, amount);\n\n ERC1155._burn(by, from, id, amount);\n }\n\n /**\n * @dev Subtracts from the internal counters for a batch burn.\n *\n * @param by The address calling the burn.\n * @param from The address to burn from.\n * @param ids The token ids to burn.\n * @param amounts The amounts to burn.\n */\n function _batchBurn(\n address by,\n address from,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal virtual override {\n // Put ids length on the stack to save MLOADs.\n uint256 idsLength = ids.length;\n\n for (uint256 i = 0; i < idsLength; ) {\n // Reduce the supply.\n _reduceSupplyOnBurn(ids[i], amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n\n ERC1155._batchBurn(by, from, ids, amounts);\n }\n\n function _reduceSupplyOnBurn(uint256 id, uint256 amount) internal {\n // Get the current token supply.\n TokenSupply storage tokenSupply = _tokenSupply[id];\n\n // Reduce the totalSupply.\n unchecked {\n tokenSupply.totalSupply -= uint64(amount);\n }\n }\n\n /**\n * @dev Internal function to increment mint counts.\n *\n * Note that this function does not check if the mint exceeds\n * maxSupply, which should be validated before this function is called.\n *\n * @param to The address to mint to.\n * @param id The token id to mint.\n * @param amount The quantity to mint.\n */\n function _incrementMintCounts(\n address to,\n uint256 id,\n uint256 amount\n ) internal {\n // Get the current token supply.\n TokenSupply storage tokenSupply = _tokenSupply[id];\n\n if (tokenSupply.totalMinted + amount > tokenSupply.maxSupply) {\n revert MintExceedsMaxSupply(\n tokenSupply.totalMinted + amount,\n tokenSupply.maxSupply\n );\n }\n\n // Increment supply and number minted.\n // Can be unchecked because maxSupply cannot be set to exceed uint64.\n unchecked {\n tokenSupply.totalSupply += uint64(amount);\n tokenSupply.totalMinted += uint64(amount);\n\n // Increment total minted by user.\n _totalMintedByUser[to] += amount;\n\n // Increment total minted by user per token.\n _totalMintedByUserPerToken[to][id] += amount;\n }\n }\n}\n"
},
"src/lib/ERC1155SeaDropContractOffererStorage.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { PublicDrop } from \"./ERC1155SeaDropStructs.sol\";\n\nimport { CreatorPayout } from \"./SeaDropStructs.sol\";\n\nlibrary ERC1155SeaDropContractOffererStorage {\n struct Layout {\n /// @notice The allowed Seaport addresses that can mint.\n mapping(address => bool) _allowedSeaport;\n /// @notice The enumerated allowed Seaport addresses.\n address[] _enumeratedAllowedSeaport;\n /// @notice The public drop data.\n mapping(uint256 => PublicDrop) _publicDrops;\n /// @notice The enumerated public drop indexes.\n uint256[] _enumeratedPublicDropIndexes;\n /// @notice The creator payout addresses and basis points.\n CreatorPayout[] _creatorPayouts;\n /// @notice The allow list merkle root.\n bytes32 _allowListMerkleRoot;\n /// @notice The allowed fee recipients.\n mapping(address => bool) _allowedFeeRecipients;\n /// @notice The enumerated allowed fee recipients.\n address[] _enumeratedFeeRecipients;\n /// @notice The allowed server-side signers.\n mapping(address => bool) _allowedSigners;\n /// @notice The enumerated allowed signers.\n address[] _enumeratedSigners;\n /// @notice The used signature digests.\n mapping(bytes32 => bool) _usedDigests;\n /// @notice The allowed payers.\n mapping(address => bool) _allowedPayers;\n /// @notice The enumerated allowed payers.\n address[] _enumeratedPayers;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n bytes32(\n uint256(\n keccak256(\"contracts.storage.ERC1155SeaDropContractOfferer\")\n ) - 1\n );\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n"
},
"src/lib/ERC1155SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { PublicDrop } from \"./ERC1155SeaDropStructs.sol\";\n\nimport { SeaDropErrorsAndEvents } from \"./SeaDropErrorsAndEvents.sol\";\n\ninterface ERC1155SeaDropErrorsAndEvents is SeaDropErrorsAndEvents {\n /**\n * @dev Revert with an error if an empty PublicDrop is provided\n * for an already-empty public drop.\n */\n error PublicDropStageNotPresent();\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the\n * max minted per wallet for a certain token id.\n */\n error MintQuantityExceedsMaxMintedPerWalletForTokenId(\n uint256 tokenId,\n uint256 total,\n uint256 allowed\n );\n\n /**\n * @dev Revert with an error if the target token id to mint is not within\n * the drop stage range.\n */\n error TokenIdNotWithinDropStageRange(\n uint256 tokenId,\n uint256 startTokenId,\n uint256 endTokenId\n );\n\n /**\n * @notice Revert with an error if the number of maxSupplyAmounts doesn't\n * match the number of maxSupplyTokenIds.\n */\n error MaxSupplyMismatch();\n\n /**\n * @notice Revert with an error if the number of mint tokenIds doesn't\n * match the number of mint amounts.\n */\n error MintAmountsMismatch();\n\n /**\n * @notice Revert with an error if the mint order offer contains\n * a duplicate tokenId.\n */\n error OfferContainsDuplicateTokenId(uint256 tokenId);\n\n /**\n * @dev Revert if the fromTokenId is greater than the toTokenId.\n */\n error InvalidFromAndToTokenId(uint256 fromTokenId, uint256 toTokenId);\n\n /**\n * @notice Revert with an error if the number of publicDropIndexes doesn't\n * match the number of publicDrops.\n */\n error PublicDropsMismatch();\n\n /**\n * @dev An event with updated public drop data.\n */\n event PublicDropUpdated(PublicDrop publicDrop, uint256 index);\n}\n"
},
"src/lib/ERC1155SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { AllowListData, CreatorPayout } from \"./SeaDropStructs.sol\";\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in two storage slots.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n * @param paymentToken The payment token address. Null for\n * native token.\n * @param fromTokenId The start token id for the stage.\n * @param toTokenId The end token id for the stage.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param maxTotalMintableByWalletPerToken Maximum total number of mints a user\n * is allowed for the token id. (The limit for\n * this field is 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n */\nstruct PublicDrop {\n // slot 1\n uint80 startPrice; // 80/512 bits\n uint80 endPrice; // 160/512 bits\n uint40 startTime; // 200/512 bits\n uint40 endTime; // 240/512 bits\n bool restrictFeeRecipients; // 248/512 bits\n // uint8 unused;\n\n // slot 2\n address paymentToken; // 408/512 bits\n uint24 fromTokenId; // 432/512 bits\n uint24 toTokenId; // 456/512 bits\n uint16 maxTotalMintableByWallet; // 472/512 bits\n uint16 maxTotalMintableByWalletPerToken; // 488/512 bits\n uint16 feeBps; // 504/512 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n *\n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token for the mint. Null for\n * native token.\n * @param fromTokenId The start token id for the stage.\n * @param toTokenId The end token id for the stage.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param maxTotalMintableByWalletPerToken Maximum total number of mints a user\n * is allowed for the token id.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 startPrice;\n uint256 endPrice;\n uint256 startTime;\n uint256 endTime;\n address paymentToken;\n uint256 fromTokenId;\n uint256 toTokenId;\n uint256 maxTotalMintableByWallet;\n uint256 maxTotalMintableByWalletPerToken;\n uint256 maxTokenSupplyForStage;\n uint256 dropStageIndex; // non-zero\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @dev Struct containing internal SeaDrop implementation logic\n * mint details to avoid stack too deep.\n *\n * @param feeRecipient The fee recipient.\n * @param payer The payer of the mint.\n * @param minter The mint recipient.\n * @param tokenIds The tokenIds to mint.\n * @param quantities The number of tokens to mint per tokenId.\n * @param withEffects Whether to apply state changes of the mint.\n */\nstruct MintDetails {\n address feeRecipient;\n address payer;\n address minter;\n uint256[] tokenIds;\n uint256[] quantities;\n bool withEffects;\n}\n\n/**\n * @notice A struct to configure multiple contract options in one transaction.\n */\nstruct MultiConfigureStruct {\n uint256[] maxSupplyTokenIds;\n uint256[] maxSupplyAmounts;\n string baseURI;\n string contractURI;\n PublicDrop[] publicDrops;\n uint256[] publicDropsIndexes;\n string dropURI;\n AllowListData allowListData;\n CreatorPayout[] creatorPayouts;\n bytes32 provenanceHash;\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n address[] allowedPayers;\n address[] disallowedPayers;\n // Server-signed\n address[] allowedSigners;\n address[] disallowedSigners;\n // ERC-2981\n address royaltyReceiver;\n uint96 royaltyBps;\n // Mint\n address mintRecipient;\n uint256[] mintTokenIds;\n uint256[] mintAmounts;\n}\n"
},
"src/lib/SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\n/**\n * @notice A struct defining a creator payout address and basis points.\n *\n * @param payoutAddress The payout address.\n * @param basisPoints The basis points to pay out to the creator.\n * The total creator payouts must equal 10_000 bps.\n */\nstruct CreatorPayout {\n address payoutAddress;\n uint16 basisPoints;\n}\n\n/**\n * @notice A struct defining allow list data (for minting an allow list).\n *\n * @param merkleRoot The merkle root for the allow list.\n * @param publicKeyURIs If the allowListURI is encrypted, a list of URIs\n * pointing to the public keys. Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\nstruct AllowListData {\n bytes32 merkleRoot;\n string[] publicKeyURIs;\n string allowListURI;\n}\n"
},
"src/lib/ERC1155ConduitPreapproved.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\n/**\n * @title ERC1155ConduitPreapproved\n * @notice Solady's ERC1155 with the OpenSea conduit preapproved.\n */\nabstract contract ERC1155ConduitPreapproved is ERC1155 {\n /// @dev The canonical OpenSea conduit.\n address internal constant _CONDUIT =\n 0x1E0049783F008A0085193E00003D00cd54003c71;\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual override {\n _safeTransfer(_by(), from, to, id, amount, data);\n }\n\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) public virtual override {\n _safeBatchTransfer(_by(), from, to, ids, amounts, data);\n }\n\n function isApprovedForAll(\n address owner,\n address operator\n ) public view virtual override returns (bool) {\n if (operator == _CONDUIT) return true;\n return ERC1155.isApprovedForAll(owner, operator);\n }\n\n function _by() internal view returns (address result) {\n assembly {\n // `msg.sender == _CONDUIT ? address(0) : msg.sender`.\n result := mul(iszero(eq(caller(), _CONDUIT)), caller())\n }\n }\n}\n"
},
"lib/solady/src/tokens/ERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple ERC1155 implementation.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC1155.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC1155/ERC1155.sol)\n///\n/// @dev Note:\n/// The ERC1155 standard allows for self-approvals.\n/// For performance, this implementation WILL NOT revert for such actions.\n/// Please add any checks with overrides if desired.\nabstract contract ERC1155 {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The lengths of the input arrays are not the same.\n error ArrayLengthsMismatch();\n\n /// @dev Cannot mint or transfer to the zero address.\n error TransferToZeroAddress();\n\n /// @dev The recipient's balance has overflowed.\n error AccountBalanceOverflow();\n\n /// @dev Insufficient balance.\n error InsufficientBalance();\n\n /// @dev Only the token owner or an approved account can manage the tokens.\n error NotOwnerNorApproved();\n\n /// @dev Cannot safely transfer to a contract that does not implement\n /// the ERC1155Receiver interface.\n error TransferToNonERC1155ReceiverImplementer();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EVENTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Emitted when `amount` of token `id` is transferred\n /// from `from` to `to` by `operator`.\n event TransferSingle(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256 id,\n uint256 amount\n );\n\n /// @dev Emitted when `amounts` of token `ids` are transferred\n /// from `from` to `to` by `operator`.\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] amounts\n );\n\n /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.\n event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);\n\n /// @dev Emitted when the Uniform Resource Identifier (URI) for token `id`\n /// is updated to `value`. This event is not used in the base contract.\n /// You may need to emit this event depending on your URI logic.\n ///\n /// See: https://eips.ethereum.org/EIPS/eip-1155#metadata\n event URI(string value, uint256 indexed id);\n\n /// @dev `keccak256(bytes(\"TransferSingle(address,address,address,uint256,uint256)\"))`.\n uint256 private constant _TRANSFER_SINGLE_EVENT_SIGNATURE =\n 0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62;\n\n /// @dev `keccak256(bytes(\"TransferBatch(address,address,address,uint256[],uint256[])\"))`.\n uint256 private constant _TRANSFER_BATCH_EVENT_SIGNATURE =\n 0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb;\n\n /// @dev `keccak256(bytes(\"ApprovalForAll(address,address,bool)\"))`.\n uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =\n 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The `ownerSlotSeed` of a given owner is given by.\n /// ```\n /// let ownerSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner))\n /// ```\n ///\n /// The balance slot of `owner` is given by.\n /// ```\n /// mstore(0x20, ownerSlotSeed)\n /// mstore(0x00, id)\n /// let balanceSlot := keccak256(0x00, 0x40)\n /// ```\n ///\n /// The operator approval slot of `owner` is given by.\n /// ```\n /// mstore(0x20, ownerSlotSeed)\n /// mstore(0x00, operator)\n /// let operatorApprovalSlot := keccak256(0x0c, 0x34)\n /// ```\n uint256 private constant _ERC1155_MASTER_SLOT_SEED = 0x9a31110384e0b0c9;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC1155 METADATA */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the URI for token `id`.\n ///\n /// You can either return the same templated URI for all token IDs,\n /// (e.g. \"https://example.com/api/{id}.json\"),\n /// or return a unique URI for each `id`.\n ///\n /// See: https://eips.ethereum.org/EIPS/eip-1155#metadata\n function uri(uint256 id) public view virtual returns (string memory);\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC1155 */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the amount of `id` owned by `owner`.\n function balanceOf(address owner, uint256 id) public view virtual returns (uint256 result) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, owner)\n mstore(0x00, id)\n result := sload(keccak256(0x00, 0x40))\n }\n }\n\n /// @dev Returns whether `operator` is approved to manage the tokens of `owner`.\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n returns (bool result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, owner)\n mstore(0x00, operator)\n result := sload(keccak256(0x0c, 0x34))\n }\n }\n\n /// @dev Sets whether `operator` is approved to manage the tokens of the caller.\n ///\n /// Emits a {ApprovalForAll} event.\n function setApprovalForAll(address operator, bool isApproved) public virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Convert to 0 or 1.\n isApproved := iszero(iszero(isApproved))\n // Update the `isApproved` for (`msg.sender`, `operator`).\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, caller())\n mstore(0x00, operator)\n sstore(keccak256(0x0c, 0x34), isApproved)\n // Emit the {ApprovalForAll} event.\n mstore(0x00, isApproved)\n // forgefmt: disable-next-line\n log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), shr(96, shl(96, operator)))\n }\n }\n\n /// @dev Transfers `amount` of `id` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - If the caller is not `from`,\n /// it must be approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from))\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to))\n mstore(0x20, fromSlotSeed)\n // Clear the upper 96 bits.\n from := shr(96, fromSlotSeed)\n to := shr(96, toSlotSeed)\n // Revert if `to` is the zero address.\n if iszero(to) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // If the caller is not `from`, do the authorization check.\n if iszero(eq(caller(), from)) {\n mstore(0x00, caller())\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), from, to)\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Do the {onERC1155Received} check if `to` is a smart contract.\n if extcodesize(to) {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155Received(address,address,uint256,uint256,bytes)`.\n mstore(m, 0xf23a6e61)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), from)\n mstore(add(m, 0x60), id)\n mstore(add(m, 0x80), amount)\n mstore(add(m, 0xa0), 0xa0)\n calldatacopy(add(m, 0xc0), sub(data.offset, 0x20), add(0x20, data.length))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, data.length), m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xf23a6e61))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n }\n\n /// @dev Transfers `amounts` of `ids` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - `ids` and `amounts` must have the same length.\n /// - If the caller is not `from`,\n /// it must be approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) public virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(ids.length, amounts.length)) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from))\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to))\n mstore(0x20, fromSlotSeed)\n // Clear the upper 96 bits.\n from := shr(96, fromSlotSeed)\n to := shr(96, toSlotSeed)\n // Revert if `to` is the zero address.\n if iszero(to) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // If the caller is not `from`, do the authorization check.\n if iszero(eq(caller(), from)) {\n mstore(0x00, caller())\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, ids.length)\n for { let i := 0 } iszero(eq(i, end)) { i := add(i, 0x20) } {\n let amount := calldataload(add(amounts.offset, i))\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x20, fromSlotSeed)\n mstore(0x00, calldataload(add(ids.offset, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, ids.length))\n let o := add(m, 0x40)\n calldatacopy(o, sub(ids.offset, 0x20), n)\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, n))\n o := add(o, n)\n n := add(0x20, shl(5, amounts.length))\n calldatacopy(o, sub(amounts.offset, 0x20), n)\n n := sub(add(o, n), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), from, to)\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransferCalldata(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Do the {onERC1155BatchReceived} check if `to` is a smart contract.\n if extcodesize(to) {\n let m := mload(0x40)\n // Prepare the calldata.\n // `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`.\n mstore(m, 0xbc197c81)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), from)\n // Copy the `ids`.\n mstore(add(m, 0x60), 0xa0)\n let n := add(0x20, shl(5, ids.length))\n let o := add(m, 0xc0)\n calldatacopy(o, sub(ids.offset, 0x20), n)\n // Copy the `amounts`.\n let s := add(0xa0, n)\n mstore(add(m, 0x80), s)\n o := add(o, n)\n n := add(0x20, shl(5, amounts.length))\n calldatacopy(o, sub(amounts.offset, 0x20), n)\n // Copy the `data`.\n mstore(add(m, 0xa0), add(s, n))\n o := add(o, n)\n n := add(0x20, data.length)\n calldatacopy(o, sub(data.offset, 0x20), n)\n n := sub(add(o, n), add(m, 0x1c))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), n, m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xbc197c81))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n }\n\n /// @dev Returns the amounts of `ids` for `owners.\n ///\n /// Requirements:\n /// - `owners` and `ids` must have the same length.\n function balanceOfBatch(address[] calldata owners, uint256[] calldata ids)\n public\n view\n virtual\n returns (uint256[] memory balances)\n {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(ids.length, owners.length)) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n balances := mload(0x40)\n mstore(balances, ids.length)\n let o := add(balances, 0x20)\n let end := shl(5, ids.length)\n mstore(0x40, add(end, o))\n // Loop through all the `ids` and load the balances.\n for { let i := 0 } iszero(eq(i, end)) { i := add(i, 0x20) } {\n let owner := calldataload(add(owners.offset, i))\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner)))\n mstore(0x00, calldataload(add(ids.offset, i)))\n mstore(add(o, i), sload(keccak256(0x00, 0x40)))\n }\n }\n }\n\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\n /// See: https://eips.ethereum.org/EIPS/eip-165\n /// This function call must use less than 30000 gas.\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := shr(224, interfaceId)\n // ERC165: 0x01ffc9a7, ERC1155: 0xd9b67a26, ERC1155MetadataURI: 0x0e89341c.\n result := or(or(eq(s, 0x01ffc9a7), eq(s, 0xd9b67a26)), eq(s, 0x0e89341c))\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL MINT FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Mints `amount` of `id` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(address(0), to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, to)\n mstore(0x00, id)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x00, id)\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), 0, shr(96, to_))\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(address(0), to, _single(id), _single(amount), data);\n }\n if (_hasCode(to)) _checkOnERC1155Received(address(0), to, id, amount, data);\n }\n\n /// @dev Mints `amounts` of `ids` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `ids` and `amounts` must have the same length.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function _batchMint(\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(address(0), to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // Loop through all the `ids` and update the balances.\n {\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_))\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Increase and store the updated balance of `to`.\n {\n mstore(0x00, mload(add(ids, i)))\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), 0, shr(96, to_))\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(address(0), to, ids, amounts, data);\n }\n if (_hasCode(to)) _checkOnERC1155BatchReceived(address(0), to, ids, amounts, data);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL BURN FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Equivalent to `_burn(address(0), from, id, amount)`.\n function _burn(address from, uint256 id, uint256 amount) internal virtual {\n _burn(address(0), from, id, amount);\n }\n\n /// @dev Destroys `amount` of `id` from `from`.\n ///\n /// Requirements:\n /// - `from` must have at least `amount` of `id`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n ///\n /// Emits a {Transfer} event.\n function _burn(address by, address from, uint256 id, uint256 amount) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, address(0), _single(id), _single(amount), \"\");\n }\n /// @solidity memory-safe-assembly\n assembly {\n let from_ := shl(96, from)\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n if iszero(or(iszero(shl(96, by)), eq(shl(96, by), from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Decrease and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Emit a {TransferSingle} event.\n mstore(0x00, id)\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), 0)\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, address(0), _single(id), _single(amount), \"\");\n }\n }\n\n /// @dev Equivalent to `_batchBurn(address(0), from, ids, amounts)`.\n function _batchBurn(address from, uint256[] memory ids, uint256[] memory amounts)\n internal\n virtual\n {\n _batchBurn(address(0), from, ids, amounts);\n }\n\n /// @dev Destroys `amounts` of `ids` from `from`.\n ///\n /// Requirements:\n /// - `ids` and `amounts` must have the same length.\n /// - `from` must have at least `amounts` of `ids`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n ///\n /// Emits a {TransferBatch} event.\n function _batchBurn(address by, address from, uint256[] memory ids, uint256[] memory amounts)\n internal\n virtual\n {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, address(0), ids, amounts, \"\");\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let from_ := shl(96, from)\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Decrease and store the updated balance of `to`.\n {\n mstore(0x00, mload(add(ids, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), 0)\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, address(0), ids, amounts, \"\");\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL APPROVAL FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Approve or remove the `operator` as an operator for `by`,\n /// without authorization checks.\n ///\n /// Emits a {ApprovalForAll} event.\n function _setApprovalForAll(address by, address operator, bool isApproved) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Convert to 0 or 1.\n isApproved := iszero(iszero(isApproved))\n // Update the `isApproved` for (`by`, `operator`).\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, by)\n mstore(0x00, operator)\n sstore(keccak256(0x0c, 0x34), isApproved)\n // Emit the {ApprovalForAll} event.\n mstore(0x00, isApproved)\n let m := shr(96, not(0))\n log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, and(m, by), and(m, operator))\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL TRANSFER FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Equivalent to `_safeTransfer(address(0), from, to, id, amount, data)`.\n function _safeTransfer(address from, address to, uint256 id, uint256 amount, bytes memory data)\n internal\n virtual\n {\n _safeTransfer(address(0), from, to, id, amount, data);\n }\n\n /// @dev Transfers `amount` of `id` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function _safeTransfer(\n address by,\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let from_ := shl(96, from)\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_))\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x20, amount)\n // forgefmt: disable-next-line\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_))\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n if (_hasCode(to)) _checkOnERC1155Received(from, to, id, amount, data);\n }\n\n /// @dev Equivalent to `_safeBatchTransfer(address(0), from, to, ids, amounts, data)`.\n function _safeBatchTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _safeBatchTransfer(address(0), from, to, ids, amounts, data);\n }\n\n /// @dev Transfers `amounts` of `ids` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `ids` and `amounts` must have the same length.\n /// - `from` must have at least `amounts` of `ids`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function _safeBatchTransfer(\n address by,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let from_ := shl(96, from)\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, from_)\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, to_)\n mstore(0x20, fromSlotSeed)\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x20, fromSlotSeed)\n mstore(0x00, mload(add(ids, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_))\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, ids, amounts, data);\n }\n if (_hasCode(to)) _checkOnERC1155BatchReceived(from, to, ids, amounts, data);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* HOOKS FOR OVERRIDING */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Override this function to return true if `_beforeTokenTransfer` is used.\n /// The is to help the compiler avoid producing dead bytecode.\n function _useBeforeTokenTransfer() internal view virtual returns (bool) {\n return false;\n }\n\n /// @dev Hook that is called before any token transfer.\n /// This includes minting and burning, as well as batched variants.\n ///\n /// The same hook is called on both single and batched variants.\n /// For single transfers, the length of the `id` and `amount` arrays are 1.\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n\n /// @dev Override this function to return true if `_afterTokenTransfer` is used.\n /// The is to help the compiler avoid producing dead bytecode.\n function _useAfterTokenTransfer() internal view virtual returns (bool) {\n return false;\n }\n\n /// @dev Hook that is called after any token transfer.\n /// This includes minting and burning, as well as batched variants.\n ///\n /// The same hook is called on both single and batched variants.\n /// For single transfers, the length of the `id` and `amount` arrays are 1.\n function _afterTokenTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PRIVATE HELPERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Helper for calling the `_afterTokenTransfer` hook.\n /// The is to help the compiler avoid producing dead bytecode.\n function _afterTokenTransferCalldata(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) private {\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, ids, amounts, data);\n }\n }\n\n /// @dev Returns if `a` has bytecode of non-zero length.\n function _hasCode(address a) private view returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := extcodesize(a) // Can handle dirty upper bits.\n }\n }\n\n /// @dev Perform a call to invoke {IERC1155Receiver-onERC1155Received} on `to`.\n /// Reverts if the target does not support the function correctly.\n function _checkOnERC1155Received(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) private {\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155Received(address,address,uint256,uint256,bytes)`.\n mstore(m, 0xf23a6e61)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), shr(96, shl(96, from)))\n mstore(add(m, 0x60), id)\n mstore(add(m, 0x80), amount)\n mstore(add(m, 0xa0), 0xa0)\n let n := mload(data)\n mstore(add(m, 0xc0), n)\n if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xe0), n)) }\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, n), m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xf23a6e61))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Perform a call to invoke {IERC1155Receiver-onERC1155BatchReceived} on `to`.\n /// Reverts if the target does not support the function correctly.\n function _checkOnERC1155BatchReceived(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) private {\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`.\n mstore(m, 0xbc197c81)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), shr(96, shl(96, from)))\n // Copy the `ids`.\n mstore(add(m, 0x60), 0xa0)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0xc0)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n let s := add(0xa0, returndatasize())\n mstore(add(m, 0x80), s)\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n // Copy the `data`.\n mstore(add(m, 0xa0), add(s, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, mload(data))\n pop(staticcall(gas(), 4, data, n, o, n))\n n := sub(add(o, returndatasize()), add(m, 0x1c))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), n, m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xbc197c81))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Returns `x` in an array with a single element.\n function _single(uint256 x) private pure returns (uint256[] memory result) {\n assembly {\n result := mload(0x40)\n mstore(0x40, add(result, 0x40))\n mstore(result, 1)\n mstore(add(result, 0x20), x)\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/lib/ConsiderationStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {\n BasicOrderType,\n ItemType,\n OrderType,\n Side\n} from \"./ConsiderationEnums.sol\";\n\nimport {\n CalldataPointer,\n MemoryPointer\n} from \"../helpers/PointerLibraries.sol\";\n\n/**\n * @dev An order contains eleven components: an offerer, a zone (or account that\n * can cancel the order or restrict who can fulfill the order depending on\n * the type), the order type (specifying partial fill support as well as\n * restricted order status), the start and end time, a hash that will be\n * provided to the zone when validating restricted orders, a salt, a key\n * corresponding to a given conduit, a counter, and an arbitrary number of\n * offer items that can be spent along with consideration items that must\n * be received by their respective recipient.\n */\nstruct OrderComponents {\n address offerer;\n address zone;\n OfferItem[] offer;\n ConsiderationItem[] consideration;\n OrderType orderType;\n uint256 startTime;\n uint256 endTime;\n bytes32 zoneHash;\n uint256 salt;\n bytes32 conduitKey;\n uint256 counter;\n}\n\n/**\n * @dev An offer item has five components: an item type (ETH or other native\n * tokens, ERC20, ERC721, and ERC1155, as well as criteria-based ERC721 and\n * ERC1155), a token address, a dual-purpose \"identifierOrCriteria\"\n * component that will either represent a tokenId or a merkle root\n * depending on the item type, and a start and end amount that support\n * increasing or decreasing amounts over the duration of the respective\n * order.\n */\nstruct OfferItem {\n ItemType itemType;\n address token;\n uint256 identifierOrCriteria;\n uint256 startAmount;\n uint256 endAmount;\n}\n\n/**\n * @dev A consideration item has the same five components as an offer item and\n * an additional sixth component designating the required recipient of the\n * item.\n */\nstruct ConsiderationItem {\n ItemType itemType;\n address token;\n uint256 identifierOrCriteria;\n uint256 startAmount;\n uint256 endAmount;\n address payable recipient;\n}\n\n/**\n * @dev A spent item is translated from a utilized offer item and has four\n * components: an item type (ETH or other native tokens, ERC20, ERC721, and\n * ERC1155), a token address, a tokenId, and an amount.\n */\nstruct SpentItem {\n ItemType itemType;\n address token;\n uint256 identifier;\n uint256 amount;\n}\n\n/**\n * @dev A received item is translated from a utilized consideration item and has\n * the same four components as a spent item, as well as an additional fifth\n * component designating the required recipient of the item.\n */\nstruct ReceivedItem {\n ItemType itemType;\n address token;\n uint256 identifier;\n uint256 amount;\n address payable recipient;\n}\n\n/**\n * @dev For basic orders involving ETH / native / ERC20 <=> ERC721 / ERC1155\n * matching, a group of six functions may be called that only requires a\n * subset of the usual order arguments. Note the use of a \"basicOrderType\"\n * enum; this represents both the usual order type as well as the \"route\"\n * of the basic order (a simple derivation function for the basic order\n * type is `basicOrderType = orderType + (4 * basicOrderRoute)`.)\n */\nstruct BasicOrderParameters {\n // calldata offset\n address considerationToken; // 0x24\n uint256 considerationIdentifier; // 0x44\n uint256 considerationAmount; // 0x64\n address payable offerer; // 0x84\n address zone; // 0xa4\n address offerToken; // 0xc4\n uint256 offerIdentifier; // 0xe4\n uint256 offerAmount; // 0x104\n BasicOrderType basicOrderType; // 0x124\n uint256 startTime; // 0x144\n uint256 endTime; // 0x164\n bytes32 zoneHash; // 0x184\n uint256 salt; // 0x1a4\n bytes32 offererConduitKey; // 0x1c4\n bytes32 fulfillerConduitKey; // 0x1e4\n uint256 totalOriginalAdditionalRecipients; // 0x204\n AdditionalRecipient[] additionalRecipients; // 0x224\n bytes signature; // 0x244\n // Total length, excluding dynamic array data: 0x264 (580)\n}\n\n/**\n * @dev Basic orders can supply any number of additional recipients, with the\n * implied assumption that they are supplied from the offered ETH (or other\n * native token) or ERC20 token for the order.\n */\nstruct AdditionalRecipient {\n uint256 amount;\n address payable recipient;\n}\n\n/**\n * @dev The full set of order components, with the exception of the counter,\n * must be supplied when fulfilling more sophisticated orders or groups of\n * orders. The total number of original consideration items must also be\n * supplied, as the caller may specify additional consideration items.\n */\nstruct OrderParameters {\n address offerer; // 0x00\n address zone; // 0x20\n OfferItem[] offer; // 0x40\n ConsiderationItem[] consideration; // 0x60\n OrderType orderType; // 0x80\n uint256 startTime; // 0xa0\n uint256 endTime; // 0xc0\n bytes32 zoneHash; // 0xe0\n uint256 salt; // 0x100\n bytes32 conduitKey; // 0x120\n uint256 totalOriginalConsiderationItems; // 0x140\n // offer.length // 0x160\n}\n\n/**\n * @dev Orders require a signature in addition to the other order parameters.\n */\nstruct Order {\n OrderParameters parameters;\n bytes signature;\n}\n\n/**\n * @dev Advanced orders include a numerator (i.e. a fraction to attempt to fill)\n * and a denominator (the total size of the order) in addition to the\n * signature and other order parameters. It also supports an optional field\n * for supplying extra data; this data will be provided to the zone if the\n * order type is restricted and the zone is not the caller, or will be\n * provided to the offerer as context for contract order types.\n */\nstruct AdvancedOrder {\n OrderParameters parameters;\n uint120 numerator;\n uint120 denominator;\n bytes signature;\n bytes extraData;\n}\n\n/**\n * @dev Orders can be validated (either explicitly via `validate`, or as a\n * consequence of a full or partial fill), specifically cancelled (they can\n * also be cancelled in bulk via incrementing a per-zone counter), and\n * partially or fully filled (with the fraction filled represented by a\n * numerator and denominator).\n */\nstruct OrderStatus {\n bool isValidated;\n bool isCancelled;\n uint120 numerator;\n uint120 denominator;\n}\n\n/**\n * @dev A criteria resolver specifies an order, side (offer vs. consideration),\n * and item index. It then provides a chosen identifier (i.e. tokenId)\n * alongside a merkle proof demonstrating the identifier meets the required\n * criteria.\n */\nstruct CriteriaResolver {\n uint256 orderIndex;\n Side side;\n uint256 index;\n uint256 identifier;\n bytes32[] criteriaProof;\n}\n\n/**\n * @dev A fulfillment is applied to a group of orders. It decrements a series of\n * offer and consideration items, then generates a single execution\n * element. A given fulfillment can be applied to as many offer and\n * consideration items as desired, but must contain at least one offer and\n * at least one consideration that match. The fulfillment must also remain\n * consistent on all key parameters across all offer items (same offerer,\n * token, type, tokenId, and conduit preference) as well as across all\n * consideration items (token, type, tokenId, and recipient).\n */\nstruct Fulfillment {\n FulfillmentComponent[] offerComponents;\n FulfillmentComponent[] considerationComponents;\n}\n\n/**\n * @dev Each fulfillment component contains one index referencing a specific\n * order and another referencing a specific offer or consideration item.\n */\nstruct FulfillmentComponent {\n uint256 orderIndex;\n uint256 itemIndex;\n}\n\n/**\n * @dev An execution is triggered once all consideration items have been zeroed\n * out. It sends the item in question from the offerer to the item's\n * recipient, optionally sourcing approvals from either this contract\n * directly or from the offerer's chosen conduit if one is specified. An\n * execution is not provided as an argument, but rather is derived via\n * orders, criteria resolvers, and fulfillments (where the total number of\n * executions will be less than or equal to the total number of indicated\n * fulfillments) and returned as part of `matchOrders`.\n */\nstruct Execution {\n ReceivedItem item;\n address offerer;\n bytes32 conduitKey;\n}\n\n/**\n * @dev Restricted orders are validated post-execution by calling validateOrder\n * on the zone. This struct provides context about the order fulfillment\n * and any supplied extraData, as well as all order hashes fulfilled in a\n * call to a match or fulfillAvailable method.\n */\nstruct ZoneParameters {\n bytes32 orderHash;\n address fulfiller;\n address offerer;\n SpentItem[] offer;\n ReceivedItem[] consideration;\n bytes extraData;\n bytes32[] orderHashes;\n uint256 startTime;\n uint256 endTime;\n bytes32 zoneHash;\n}\n\n/**\n * @dev Zones and contract offerers can communicate which schemas they implement\n * along with any associated metadata related to each schema.\n */\nstruct Schema {\n uint256 id;\n bytes metadata;\n}\n\nusing StructPointers for OrderComponents global;\nusing StructPointers for OfferItem global;\nusing StructPointers for ConsiderationItem global;\nusing StructPointers for SpentItem global;\nusing StructPointers for ReceivedItem global;\nusing StructPointers for BasicOrderParameters global;\nusing StructPointers for AdditionalRecipient global;\nusing StructPointers for OrderParameters global;\nusing StructPointers for Order global;\nusing StructPointers for AdvancedOrder global;\nusing StructPointers for OrderStatus global;\nusing StructPointers for CriteriaResolver global;\nusing StructPointers for Fulfillment global;\nusing StructPointers for FulfillmentComponent global;\nusing StructPointers for Execution global;\nusing StructPointers for ZoneParameters global;\n\n/**\n * @dev This library provides a set of functions for converting structs to\n * pointers.\n */\nlibrary StructPointers {\n /**\n * @dev Get a MemoryPointer from OrderComponents.\n *\n * @param obj The OrderComponents object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderComponents memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderComponents.\n *\n * @param obj The OrderComponents object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderComponents calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OfferItem.\n *\n * @param obj The OfferItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OfferItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OfferItem.\n *\n * @param obj The OfferItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OfferItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ConsiderationItem.\n *\n * @param obj The ConsiderationItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ConsiderationItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ConsiderationItem.\n *\n * @param obj The ConsiderationItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ConsiderationItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from SpentItem.\n *\n * @param obj The SpentItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n SpentItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from SpentItem.\n *\n * @param obj The SpentItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n SpentItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ReceivedItem.\n *\n * @param obj The ReceivedItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ReceivedItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ReceivedItem.\n *\n * @param obj The ReceivedItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ReceivedItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from BasicOrderParameters.\n *\n * @param obj The BasicOrderParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n BasicOrderParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from BasicOrderParameters.\n *\n * @param obj The BasicOrderParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n BasicOrderParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from AdditionalRecipient.\n *\n * @param obj The AdditionalRecipient object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n AdditionalRecipient memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from AdditionalRecipient.\n *\n * @param obj The AdditionalRecipient object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n AdditionalRecipient calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OrderParameters.\n *\n * @param obj The OrderParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderParameters.\n *\n * @param obj The OrderParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Order.\n *\n * @param obj The Order object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Order memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Order.\n *\n * @param obj The Order object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Order calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from AdvancedOrder.\n *\n * @param obj The AdvancedOrder object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n AdvancedOrder memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from AdvancedOrder.\n *\n * @param obj The AdvancedOrder object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n AdvancedOrder calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OrderStatus.\n *\n * @param obj The OrderStatus object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderStatus memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderStatus.\n *\n * @param obj The OrderStatus object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderStatus calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from CriteriaResolver.\n *\n * @param obj The CriteriaResolver object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n CriteriaResolver memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from CriteriaResolver.\n *\n * @param obj The CriteriaResolver object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n CriteriaResolver calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Fulfillment.\n *\n * @param obj The Fulfillment object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Fulfillment memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Fulfillment.\n *\n * @param obj The Fulfillment object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Fulfillment calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from FulfillmentComponent.\n *\n * @param obj The FulfillmentComponent object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n FulfillmentComponent memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from FulfillmentComponent.\n *\n * @param obj The FulfillmentComponent object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n FulfillmentComponent calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Execution.\n *\n * @param obj The Execution object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Execution memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Execution.\n *\n * @param obj The Execution object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Execution calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ZoneParameters.\n *\n * @param obj The ZoneParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ZoneParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ZoneParameters.\n *\n * @param obj The ZoneParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ZoneParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/interfaces/ContractOffererInterface.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {ReceivedItem, Schema, SpentItem} from \"../lib/ConsiderationStructs.sol\";\nimport {IERC165} from \"../interfaces/IERC165.sol\";\n\n/**\n * @title ContractOffererInterface\n * @notice Contains the minimum interfaces needed to interact with a contract\n * offerer.\n */\ninterface ContractOffererInterface is IERC165 {\n /**\n * @dev Generates an order with the specified minimum and maximum spent\n * items, and optional context (supplied as extraData).\n *\n * @param fulfiller The address of the fulfiller.\n * @param minimumReceived The minimum items that the caller is willing to\n * receive.\n * @param maximumSpent The maximum items the caller is willing to spend.\n * @param context Additional context of the order.\n *\n * @return offer A tuple containing the offer items.\n * @return consideration A tuple containing the consideration items.\n */\n function generateOrder(\n address fulfiller,\n SpentItem[] calldata minimumReceived,\n SpentItem[] calldata maximumSpent,\n bytes calldata context // encoded based on the schemaID\n ) external returns (SpentItem[] memory offer, ReceivedItem[] memory consideration);\n\n /**\n * @dev Ratifies an order with the specified offer, consideration, and\n * optional context (supplied as extraData).\n *\n * @param offer The offer items.\n * @param consideration The consideration items.\n * @param context Additional context of the order.\n * @param orderHashes The hashes to ratify.\n * @param contractNonce The nonce of the contract.\n *\n * @return ratifyOrderMagicValue The magic value returned by the contract\n * offerer.\n */\n function ratifyOrder(\n SpentItem[] calldata offer,\n ReceivedItem[] calldata consideration,\n bytes calldata context, // encoded based on the schemaID\n bytes32[] calldata orderHashes,\n uint256 contractNonce\n ) external returns (bytes4 ratifyOrderMagicValue);\n\n /**\n * @dev View function to preview an order generated in response to a minimum\n * set of received items, maximum set of spent items, and context\n * (supplied as extraData).\n *\n * @param caller The address of the caller (e.g. Seaport).\n * @param fulfiller The address of the fulfiller (e.g. the account\n * calling Seaport).\n * @param minimumReceived The minimum items that the caller is willing to\n * receive.\n * @param maximumSpent The maximum items the caller is willing to spend.\n * @param context Additional context of the order.\n *\n * @return offer A tuple containing the offer items.\n * @return consideration A tuple containing the consideration items.\n */\n function previewOrder(\n address caller,\n address fulfiller,\n SpentItem[] calldata minimumReceived,\n SpentItem[] calldata maximumSpent,\n bytes calldata context // encoded based on the schemaID\n ) external view returns (SpentItem[] memory offer, ReceivedItem[] memory consideration);\n\n /**\n * @dev Gets the metadata for this contract offerer.\n *\n * @return name The name of the contract offerer.\n * @return schemas The schemas supported by the contract offerer.\n */\n function getSeaportMetadata() external view returns (string memory name, Schema[] memory schemas); // map to Seaport Improvement Proposal IDs\n\n function supportsInterface(bytes4 interfaceId) external view override returns (bool);\n\n // Additional functions and/or events based on implemented schemaIDs\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.19;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"src/interfaces/ISeaDropTokenContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\ninterface ISeaDropTokenContractMetadata {\n /**\n * @dev Emit an event for token metadata reveals/updates,\n * according to EIP-4906.\n *\n * @param _fromTokenId The start token id.\n * @param _toTokenId The end token id.\n */\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n\n /**\n * @dev Emit an event when the URI for the collection-level metadata\n * is updated.\n */\n event ContractURIUpdated(string newContractURI);\n\n /**\n * @dev Emit an event with the previous and new provenance hash after\n * being updated.\n */\n event ProvenanceHashUpdated(bytes32 previousHash, bytes32 newHash);\n\n /**\n * @dev Emit an event when the EIP-2981 royalty info is updated.\n */\n event RoyaltyInfoUpdated(address receiver, uint256 basisPoints);\n\n /**\n * @notice Throw if the max supply exceeds uint64, a limit\n * due to the storage of bit-packed variables.\n */\n error CannotExceedMaxSupplyOfUint64(uint256 got);\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after the mint has started.\n */\n error ProvenanceHashCannotBeSetAfterMintStarted();\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after it has already been set.\n */\n error ProvenanceHashCannotBeSetAfterAlreadyBeingSet();\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param tokenURI The new base URI to set.\n */\n function setBaseURI(string calldata tokenURI) external;\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external;\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external;\n\n /**\n * @notice Sets the default royalty information.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator of\n * 10_000 basis points.\n */\n function setDefaultRoyalty(address receiver, uint96 feeNumerator) external;\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view returns (string memory);\n\n /**\n * @notice Returns the contract URI.\n */\n function contractURI() external view returns (string memory);\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view returns (bytes32);\n}\n"
},
"src/interfaces/IERC1155ContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\ninterface IERC1155ContractMetadata is ISeaDropTokenContractMetadata {\n /**\n * @dev A struct representing the supply info for a token id,\n * packed into one storage slot.\n *\n * @param maxSupply The max supply for the token id.\n * @param totalSupply The total token supply for the token id.\n * Subtracted when an item is burned.\n * @param totalMinted The total number of tokens minted for the token id.\n */\n struct TokenSupply {\n uint64 maxSupply; // 64/256 bits\n uint64 totalSupply; // 128/256 bits\n uint64 totalMinted; // 192/256 bits\n }\n\n /**\n * @dev Emit an event when the max token supply for a token id is updated.\n */\n event MaxSupplyUpdated(uint256 tokenId, uint256 newMaxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @notice Sets the max supply for a token id and emits an event.\n *\n * @param tokenId The token id to set the max supply for.\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 tokenId, uint256 newMaxSupply) external;\n\n /**\n * @notice Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @notice Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @notice Returns the max token supply for a token id.\n */\n function maxSupply(uint256 tokenId) external view returns (uint256);\n\n /**\n * @notice Returns the total supply for a token id.\n */\n function totalSupply(uint256 tokenId) external view returns (uint256);\n\n /**\n * @notice Returns the total minted for a token id.\n */\n function totalMinted(uint256 tokenId) external view returns (uint256);\n}\n"
},
"lib/solady/src/tokens/ERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple ERC2981 NFT Royalty Standard implementation.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC2981.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/common/ERC2981.sol)\nabstract contract ERC2981 {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The royalty fee numerator exceeds the fee denominator.\n error RoyaltyOverflow();\n\n /// @dev The royalty receiver cannot be the zero address.\n error RoyaltyReceiverIsZeroAddress();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The default royalty info is given by:\n /// ```\n /// let packed := sload(_ERC2981_MASTER_SLOT_SEED)\n /// let receiver := shr(96, packed)\n /// let royaltyFraction := xor(packed, shl(96, receiver))\n /// ```\n ///\n /// The per token royalty info is given by.\n /// ```\n /// mstore(0x00, tokenId)\n /// mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n /// let packed := sload(keccak256(0x00, 0x40))\n /// let receiver := shr(96, packed)\n /// let royaltyFraction := xor(packed, shl(96, receiver))\n /// ```\n uint256 private constant _ERC2981_MASTER_SLOT_SEED = 0xaa4ec00224afccfdb7;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC2981 */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Checks that `_feeDenominator` is non-zero.\n constructor() {\n require(_feeDenominator() != 0, \"Fee denominator cannot be zero.\");\n }\n\n /// @dev Returns the denominator for the royalty amount.\n /// Defaults to 10000, which represents fees in basis points.\n /// Override this function to return a custom amount if needed.\n function _feeDenominator() internal pure virtual returns (uint96) {\n return 10000;\n }\n\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\n /// See: https://eips.ethereum.org/EIPS/eip-165\n /// This function call must use less than 30000 gas.\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := shr(224, interfaceId)\n // ERC165: 0x01ffc9a7, ERC2981: 0x2a55205a.\n result := or(eq(s, 0x01ffc9a7), eq(s, 0x2a55205a))\n }\n }\n\n /// @dev Returns the `receiver` and `royaltyAmount` for `tokenId` sold at `salePrice`.\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n public\n view\n virtual\n returns (address receiver, uint256 royaltyAmount)\n {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n let packed := sload(keccak256(0x00, 0x40))\n receiver := shr(96, packed)\n if iszero(receiver) {\n packed := sload(mload(0x20))\n receiver := shr(96, packed)\n }\n let x := salePrice\n let y := xor(packed, shl(96, receiver)) // `feeNumerator`.\n // Overflow check, equivalent to `require(y == 0 || x <= type(uint256).max / y)`.\n // Out-of-gas revert. Should not be triggered in practice, but included for safety.\n returndatacopy(returndatasize(), returndatasize(), mul(y, gt(x, div(not(0), y))))\n royaltyAmount := div(mul(x, y), feeDenominator)\n }\n }\n\n /// @dev Sets the default royalty `receiver` and `feeNumerator`.\n ///\n /// Requirements:\n /// - `receiver` must not be the zero address.\n /// - `feeNumerator` must not be greater than the fee denominator.\n function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n feeNumerator := shr(160, shl(160, feeNumerator))\n if gt(feeNumerator, feeDenominator) {\n mstore(0x00, 0x350a88b3) // `RoyaltyOverflow()`.\n revert(0x1c, 0x04)\n }\n let packed := shl(96, receiver)\n if iszero(packed) {\n mstore(0x00, 0xb4457eaa) // `RoyaltyReceiverIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n sstore(_ERC2981_MASTER_SLOT_SEED, or(packed, feeNumerator))\n }\n }\n\n /// @dev Sets the default royalty `receiver` and `feeNumerator` to zero.\n function _deleteDefaultRoyalty() internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n sstore(_ERC2981_MASTER_SLOT_SEED, 0)\n }\n }\n\n /// @dev Sets the royalty `receiver` and `feeNumerator` for `tokenId`.\n ///\n /// Requirements:\n /// - `receiver` must not be the zero address.\n /// - `feeNumerator` must not be greater than the fee denominator.\n function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator)\n internal\n virtual\n {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n feeNumerator := shr(160, shl(160, feeNumerator))\n if gt(feeNumerator, feeDenominator) {\n mstore(0x00, 0x350a88b3) // `RoyaltyOverflow()`.\n revert(0x1c, 0x04)\n }\n let packed := shl(96, receiver)\n if iszero(packed) {\n mstore(0x00, 0xb4457eaa) // `RoyaltyReceiverIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n sstore(keccak256(0x00, 0x40), or(packed, feeNumerator))\n }\n }\n\n /// @dev Sets the royalty `receiver` and `feeNumerator` for `tokenId` to zero.\n function _resetTokenRoyalty(uint256 tokenId) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n sstore(keccak256(0x00, 0x40), 0)\n }\n }\n}\n"
},
"lib/solady/src/auth/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple single owner authorization mixin.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)\n/// @dev While the ownable portion follows\n/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,\n/// the nomenclature for the 2-step ownership handover may be unique to this codebase.\nabstract contract Ownable {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The caller is not authorized to call the function.\n error Unauthorized();\n\n /// @dev The `newOwner` cannot be the zero address.\n error NewOwnerIsZeroAddress();\n\n /// @dev The `pendingOwner` does not have a valid handover request.\n error NoHandoverRequest();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EVENTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\n /// This event is intentionally kept the same as OpenZeppelin's Ownable to be\n /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),\n /// despite it not being as lightweight as a single argument event.\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\n\n /// @dev An ownership handover to `pendingOwner` has been requested.\n event OwnershipHandoverRequested(address indexed pendingOwner);\n\n /// @dev The ownership handover to `pendingOwner` has been canceled.\n event OwnershipHandoverCanceled(address indexed pendingOwner);\n\n /// @dev `keccak256(bytes(\"OwnershipTransferred(address,address)\"))`.\n uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =\n 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverRequested(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =\n 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverCanceled(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =\n 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The owner slot is given by: `not(_OWNER_SLOT_NOT)`.\n /// It is intentionally chosen to be a high value\n /// to avoid collision with lower slots.\n /// The choice of manual storage layout is to enable compatibility\n /// with both regular and upgradeable contracts.\n uint256 private constant _OWNER_SLOT_NOT = 0x8b78c6d8;\n\n /// The ownership handover slot of `newOwner` is given by:\n /// ```\n /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))\n /// let handoverSlot := keccak256(0x00, 0x20)\n /// ```\n /// It stores the expiry timestamp of the two-step ownership handover.\n uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Initializes the owner directly without authorization guard.\n /// This function must be called upon initialization,\n /// regardless of whether the contract is upgradeable or not.\n /// This is to enable generalization to both regular and upgradeable contracts,\n /// and to save gas in case the initial owner is not the caller.\n /// For performance reasons, this function will not check if there\n /// is an existing owner.\n function _initializeOwner(address newOwner) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Store the new value.\n sstore(not(_OWNER_SLOT_NOT), newOwner)\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\n }\n }\n\n /// @dev Sets the owner directly without authorization guard.\n function _setOwner(address newOwner) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := not(_OWNER_SLOT_NOT)\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\n // Store the new value.\n sstore(ownerSlot, newOwner)\n }\n }\n\n /// @dev Throws if the sender is not the owner.\n function _checkOwner() internal view virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // If the caller is not the stored owner, revert.\n if iszero(eq(caller(), sload(not(_OWNER_SLOT_NOT)))) {\n mstore(0x00, 0x82b42900) // `Unauthorized()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC UPDATE FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Allows the owner to transfer the ownership to `newOwner`.\n function transferOwnership(address newOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(shl(96, newOwner)) {\n mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n }\n _setOwner(newOwner);\n }\n\n /// @dev Allows the owner to renounce their ownership.\n function renounceOwnership() public payable virtual onlyOwner {\n _setOwner(address(0));\n }\n\n /// @dev Request a two-step ownership handover to the caller.\n /// The request will automatically expire in 48 hours (172800 seconds) by default.\n function requestOwnershipHandover() public payable virtual {\n unchecked {\n uint256 expires = block.timestamp + ownershipHandoverValidFor();\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to `expires`.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), expires)\n // Emit the {OwnershipHandoverRequested} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())\n }\n }\n }\n\n /// @dev Cancels the two-step ownership handover to the caller, if any.\n function cancelOwnershipHandover() public payable virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), 0)\n // Emit the {OwnershipHandoverCanceled} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())\n }\n }\n\n /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.\n /// Reverts if there is no existing ownership handover requested by `pendingOwner`.\n function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n let handoverSlot := keccak256(0x0c, 0x20)\n // If the handover does not exist, or has expired.\n if gt(timestamp(), sload(handoverSlot)) {\n mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.\n revert(0x1c, 0x04)\n }\n // Set the handover slot to 0.\n sstore(handoverSlot, 0)\n }\n _setOwner(pendingOwner);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC READ FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the owner of the contract.\n function owner() public view virtual returns (address result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := sload(not(_OWNER_SLOT_NOT))\n }\n }\n\n /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\n function ownershipHandoverExpiresAt(address pendingOwner)\n public\n view\n virtual\n returns (uint256 result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute the handover slot.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n // Load the handover slot.\n result := sload(keccak256(0x0c, 0x20))\n }\n }\n\n /// @dev Returns how long a two-step ownership handover is valid for in seconds.\n function ownershipHandoverValidFor() public view virtual returns (uint64) {\n return 48 * 3600;\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* MODIFIERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Marks a function as only callable by the owner.\n modifier onlyOwner() virtual {\n _checkOwner();\n _;\n }\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.19;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (address(this).code.length == 0 && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
},
"src/lib/SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { CreatorPayout, PublicDrop } from \"./ERC721SeaDropStructs.sol\";\n\ninterface SeaDropErrorsAndEvents {\n /**\n * @notice The SeaDrop token types, emitted as part of\n * `event SeaDropTokenDeployed`.\n */\n enum SEADROP_TOKEN_TYPE {\n ERC721_STANDARD,\n ERC721_CLONE,\n ERC721_UPGRADEABLE,\n ERC1155_STANDARD,\n ERC1155_CLONE,\n ERC1155_UPGRADEABLE\n }\n\n /**\n * @notice An event to signify that a SeaDrop token contract was deployed.\n */\n event SeaDropTokenDeployed(SEADROP_TOKEN_TYPE tokenType);\n\n /**\n * @notice Revert with an error if the function selector is not supported.\n */\n error UnsupportedFunctionSelector(bytes4 selector);\n\n /**\n * @dev Revert with an error if the drop stage is not active.\n */\n error NotActive(\n uint256 currentTimestamp,\n uint256 startTimestamp,\n uint256 endTimestamp\n );\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max allowed\n * to be minted per wallet.\n */\n error MintQuantityExceedsMaxMintedPerWallet(uint256 total, uint256 allowed);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply for the stage.\n * Note: The `maxTokenSupplyForStage` for public mint is\n * always `type(uint).max`.\n */\n error MintQuantityExceedsMaxTokenSupplyForStage(\n uint256 total,\n uint256 maxTokenSupplyForStage\n );\n\n /**\n * @dev Revert if the fee recipient is the zero address.\n */\n error FeeRecipientCannotBeZeroAddress();\n\n /**\n * @dev Revert if the fee recipient is not already included.\n */\n error FeeRecipientNotPresent();\n\n /**\n * @dev Revert if the fee basis points is greater than 10_000.\n */\n error InvalidFeeBps(uint256 feeBps);\n\n /**\n * @dev Revert if the fee recipient is already included.\n */\n error DuplicateFeeRecipient();\n\n /**\n * @dev Revert if the fee recipient is restricted and not allowed.\n */\n error FeeRecipientNotAllowed(address got);\n\n /**\n * @dev Revert if the creator payout address is the zero address.\n */\n error CreatorPayoutAddressCannotBeZeroAddress();\n\n /**\n * @dev Revert if the creator payouts are not set.\n */\n error CreatorPayoutsNotSet();\n\n /**\n * @dev Revert if the creator payout basis points are zero.\n */\n error CreatorPayoutBasisPointsCannotBeZero();\n\n /**\n * @dev Revert if the total basis points for the creator payouts\n * don't equal exactly 10_000.\n */\n error InvalidCreatorPayoutTotalBasisPoints(\n uint256 totalReceivedBasisPoints\n );\n\n /**\n * @dev Revert if the creator payout basis points don't add up to 10_000.\n */\n error InvalidCreatorPayoutBasisPoints(uint256 totalReceivedBasisPoints);\n\n /**\n * @dev Revert with an error if the allow list proof is invalid.\n */\n error InvalidProof();\n\n /**\n * @dev Revert if a supplied signer address is the zero address.\n */\n error SignerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if a signer is not included in\n * the enumeration when removing.\n */\n error SignerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is not included in\n * the enumeration when removing.\n */\n error PayerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is already included in mapping\n * when adding.\n */\n error DuplicatePayer();\n\n /**\n * @dev Revert with an error if a signer is already included in mapping\n * when adding.\n */\n error DuplicateSigner();\n\n /**\n * @dev Revert with an error if the payer is not allowed. The minter must\n * pay for their own mint.\n */\n error PayerNotAllowed(address got);\n\n /**\n * @dev Revert if a supplied payer address is the zero address.\n */\n error PayerCannotBeZeroAddress();\n\n /**\n * @dev Revert if the start time is greater than the end time.\n */\n error InvalidStartAndEndTime(uint256 startTime, uint256 endTime);\n\n /**\n * @dev Revert with an error if the signer payment token is not the same.\n */\n error InvalidSignedPaymentToken(address got, address want);\n\n /**\n * @dev Revert with an error if supplied signed mint price is less than\n * the minimum specified.\n */\n error InvalidSignedMintPrice(\n address paymentToken,\n uint256 got,\n uint256 minimum\n );\n\n /**\n * @dev Revert with an error if supplied signed maxTotalMintableByWallet\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTotalMintableByWallet(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed\n * maxTotalMintableByWalletPerToken is greater than the maximum\n * specified.\n */\n error InvalidSignedMaxTotalMintableByWalletPerToken(\n uint256 got,\n uint256 maximum\n );\n\n /**\n * @dev Revert with an error if the fromTokenId is not within range.\n */\n error InvalidSignedFromTokenId(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if the toTokenId is not within range.\n */\n error InvalidSignedToTokenId(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed start time is less than\n * the minimum specified.\n */\n error InvalidSignedStartTime(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if supplied signed end time is greater than\n * the maximum specified.\n */\n error InvalidSignedEndTime(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed maxTokenSupplyForStage\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTokenSupplyForStage(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed feeBps is greater than\n * the maximum specified, or less than the minimum.\n */\n error InvalidSignedFeeBps(uint256 got, uint256 minimumOrMaximum);\n\n /**\n * @dev Revert with an error if signed mint did not specify to restrict\n * fee recipients.\n */\n error SignedMintsMustRestrictFeeRecipients();\n\n /**\n * @dev Revert with an error if a signature for a signed mint has already\n * been used.\n */\n error SignatureAlreadyUsed();\n\n /**\n * @dev Revert with an error if the contract has no balance to withdraw.\n */\n error NoBalanceToWithdraw();\n\n /**\n * @dev Revert with an error if the caller is not an allowed Seaport.\n */\n error InvalidCallerOnlyAllowedSeaport(address caller);\n\n /**\n * @dev Revert with an error if the order does not have the ERC1155 magic\n * consideration item to signify a consecutive mint.\n */\n error MustSpecifyERC1155ConsiderationItemForSeaDropMint();\n\n /**\n * @dev Revert with an error if the extra data version is not supported.\n */\n error UnsupportedExtraDataVersion(uint8 version);\n\n /**\n * @dev Revert with an error if the extra data encoding is not supported.\n */\n error InvalidExtraDataEncoding(uint8 version);\n\n /**\n * @dev Revert with an error if the provided substandard is not supported.\n */\n error InvalidSubstandard(uint8 substandard);\n\n /**\n * @dev Revert with an error if the implementation contract is called without\n * delegatecall.\n */\n error OnlyDelegateCalled();\n\n /**\n * @dev Revert with an error if the provided allowed Seaport is the\n * zero address.\n */\n error AllowedSeaportCannotBeZeroAddress();\n\n /**\n * @dev Emit an event when allowed Seaport contracts are updated.\n */\n event AllowedSeaportUpdated(address[] allowedSeaport);\n\n /**\n * @dev An event with details of a SeaDrop mint, for analytical purposes.\n *\n * @param payer The address who payed for the tx.\n * @param dropStageIndex The drop stage index. Items minted through\n * public mint have dropStageIndex of 0\n */\n event SeaDropMint(address payer, uint256 dropStageIndex);\n\n /**\n * @dev An event with updated allow list data.\n *\n * @param previousMerkleRoot The previous allow list merkle root.\n * @param newMerkleRoot The new allow list merkle root.\n * @param publicKeyURI If the allow list is encrypted, the public key\n * URIs that can decrypt the list.\n * Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\n event AllowListUpdated(\n bytes32 indexed previousMerkleRoot,\n bytes32 indexed newMerkleRoot,\n string[] publicKeyURI,\n string allowListURI\n );\n\n /**\n * @dev An event with updated drop URI.\n */\n event DropURIUpdated(string newDropURI);\n\n /**\n * @dev An event with the updated creator payout address.\n */\n event CreatorPayoutsUpdated(CreatorPayout[] creatorPayouts);\n\n /**\n * @dev An event with the updated allowed fee recipient.\n */\n event AllowedFeeRecipientUpdated(\n address indexed feeRecipient,\n bool indexed allowed\n );\n\n /**\n * @dev An event with the updated signer.\n */\n event SignerUpdated(address indexed signer, bool indexed allowed);\n\n /**\n * @dev An event with the updated payer.\n */\n event PayerUpdated(address indexed payer, bool indexed allowed);\n}\n"
},
"lib/seaport/lib/seaport-types/src/lib/ConsiderationEnums.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nenum OrderType {\n // 0: no partial fills, anyone can execute\n FULL_OPEN,\n\n // 1: partial fills supported, anyone can execute\n PARTIAL_OPEN,\n\n // 2: no partial fills, only offerer or zone can execute\n FULL_RESTRICTED,\n\n // 3: partial fills supported, only offerer or zone can execute\n PARTIAL_RESTRICTED,\n\n // 4: contract order type\n CONTRACT\n}\n\nenum BasicOrderType {\n // 0: no partial fills, anyone can execute\n ETH_TO_ERC721_FULL_OPEN,\n\n // 1: partial fills supported, anyone can execute\n ETH_TO_ERC721_PARTIAL_OPEN,\n\n // 2: no partial fills, only offerer or zone can execute\n ETH_TO_ERC721_FULL_RESTRICTED,\n\n // 3: partial fills supported, only offerer or zone can execute\n ETH_TO_ERC721_PARTIAL_RESTRICTED,\n\n // 4: no partial fills, anyone can execute\n ETH_TO_ERC1155_FULL_OPEN,\n\n // 5: partial fills supported, anyone can execute\n ETH_TO_ERC1155_PARTIAL_OPEN,\n\n // 6: no partial fills, only offerer or zone can execute\n ETH_TO_ERC1155_FULL_RESTRICTED,\n\n // 7: partial fills supported, only offerer or zone can execute\n ETH_TO_ERC1155_PARTIAL_RESTRICTED,\n\n // 8: no partial fills, anyone can execute\n ERC20_TO_ERC721_FULL_OPEN,\n\n // 9: partial fills supported, anyone can execute\n ERC20_TO_ERC721_PARTIAL_OPEN,\n\n // 10: no partial fills, only offerer or zone can execute\n ERC20_TO_ERC721_FULL_RESTRICTED,\n\n // 11: partial fills supported, only offerer or zone can execute\n ERC20_TO_ERC721_PARTIAL_RESTRICTED,\n\n // 12: no partial fills, anyone can execute\n ERC20_TO_ERC1155_FULL_OPEN,\n\n // 13: partial fills supported, anyone can execute\n ERC20_TO_ERC1155_PARTIAL_OPEN,\n\n // 14: no partial fills, only offerer or zone can execute\n ERC20_TO_ERC1155_FULL_RESTRICTED,\n\n // 15: partial fills supported, only offerer or zone can execute\n ERC20_TO_ERC1155_PARTIAL_RESTRICTED,\n\n // 16: no partial fills, anyone can execute\n ERC721_TO_ERC20_FULL_OPEN,\n\n // 17: partial fills supported, anyone can execute\n ERC721_TO_ERC20_PARTIAL_OPEN,\n\n // 18: no partial fills, only offerer or zone can execute\n ERC721_TO_ERC20_FULL_RESTRICTED,\n\n // 19: partial fills supported, only offerer or zone can execute\n ERC721_TO_ERC20_PARTIAL_RESTRICTED,\n\n // 20: no partial fills, anyone can execute\n ERC1155_TO_ERC20_FULL_OPEN,\n\n // 21: partial fills supported, anyone can execute\n ERC1155_TO_ERC20_PARTIAL_OPEN,\n\n // 22: no partial fills, only offerer or zone can execute\n ERC1155_TO_ERC20_FULL_RESTRICTED,\n\n // 23: partial fills supported, only offerer or zone can execute\n ERC1155_TO_ERC20_PARTIAL_RESTRICTED\n}\n\nenum BasicOrderRouteType {\n // 0: provide Ether (or other native token) to receive offered ERC721 item.\n ETH_TO_ERC721,\n\n // 1: provide Ether (or other native token) to receive offered ERC1155 item.\n ETH_TO_ERC1155,\n\n // 2: provide ERC20 item to receive offered ERC721 item.\n ERC20_TO_ERC721,\n\n // 3: provide ERC20 item to receive offered ERC1155 item.\n ERC20_TO_ERC1155,\n\n // 4: provide ERC721 item to receive offered ERC20 item.\n ERC721_TO_ERC20,\n\n // 5: provide ERC1155 item to receive offered ERC20 item.\n ERC1155_TO_ERC20\n}\n\nenum ItemType {\n // 0: ETH on mainnet, MATIC on polygon, etc.\n NATIVE,\n\n // 1: ERC20 items (ERC777 and ERC20 analogues could also technically work)\n ERC20,\n\n // 2: ERC721 items\n ERC721,\n\n // 3: ERC1155 items\n ERC1155,\n\n // 4: ERC721 items where a number of tokenIds are supported\n ERC721_WITH_CRITERIA,\n\n // 5: ERC1155 items where a number of ids are supported\n ERC1155_WITH_CRITERIA\n}\n\nenum Side {\n // 0: Items that can be spent\n OFFER,\n\n // 1: Items that must be received\n CONSIDERATION\n}\n"
},
"lib/seaport/lib/seaport-types/src/helpers/PointerLibraries.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ntype CalldataPointer is uint256;\n\ntype ReturndataPointer is uint256;\n\ntype MemoryPointer is uint256;\n\nusing CalldataPointerLib for CalldataPointer global;\nusing MemoryPointerLib for MemoryPointer global;\nusing ReturndataPointerLib for ReturndataPointer global;\n\nusing CalldataReaders for CalldataPointer global;\nusing ReturndataReaders for ReturndataPointer global;\nusing MemoryReaders for MemoryPointer global;\nusing MemoryWriters for MemoryPointer global;\n\nCalldataPointer constant CalldataStart = CalldataPointer.wrap(0x04);\nMemoryPointer constant FreeMemoryPPtr = MemoryPointer.wrap(0x40);\nuint256 constant IdentityPrecompileAddress = 0x4;\nuint256 constant OffsetOrLengthMask = 0xffffffff;\nuint256 constant _OneWord = 0x20;\nuint256 constant _FreeMemoryPointerSlot = 0x40;\n\n/// @dev Allocates `size` bytes in memory by increasing the free memory pointer\n/// and returns the memory pointer to the first byte of the allocated region.\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction malloc(uint256 size) pure returns (MemoryPointer mPtr) {\n assembly {\n mPtr := mload(_FreeMemoryPointerSlot)\n mstore(_FreeMemoryPointerSlot, add(mPtr, size))\n }\n}\n\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction getFreeMemoryPointer() pure returns (MemoryPointer mPtr) {\n mPtr = FreeMemoryPPtr.readMemoryPointer();\n}\n\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction setFreeMemoryPointer(MemoryPointer mPtr) pure {\n FreeMemoryPPtr.write(mPtr);\n}\n\nlibrary CalldataPointerLib {\n function lt(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(CalldataPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n /// @dev Resolves an offset stored at `cdPtr + headOffset` to a calldata.\n /// pointer `cdPtr` must point to some parent object with a dynamic\n /// type's head stored at `cdPtr + headOffset`.\n function pptr(\n CalldataPointer cdPtr,\n uint256 headOffset\n ) internal pure returns (CalldataPointer cdPtrChild) {\n cdPtrChild = cdPtr.offset(\n cdPtr.offset(headOffset).readUint256() & OffsetOrLengthMask\n );\n }\n\n /// @dev Resolves an offset stored at `cdPtr` to a calldata pointer.\n /// `cdPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n CalldataPointer cdPtr\n ) internal pure returns (CalldataPointer cdPtrChild) {\n cdPtrChild = cdPtr.offset(cdPtr.readUint256() & OffsetOrLengthMask);\n }\n\n /// @dev Returns the calldata pointer one word after `cdPtr`.\n function next(\n CalldataPointer cdPtr\n ) internal pure returns (CalldataPointer cdPtrNext) {\n assembly {\n cdPtrNext := add(cdPtr, _OneWord)\n }\n }\n\n /// @dev Returns the calldata pointer `_offset` bytes after `cdPtr`.\n function offset(\n CalldataPointer cdPtr,\n uint256 _offset\n ) internal pure returns (CalldataPointer cdPtrNext) {\n assembly {\n cdPtrNext := add(cdPtr, _offset)\n }\n }\n\n /// @dev Copies `size` bytes from calldata starting at `src` to memory at\n /// `dst`.\n function copy(\n CalldataPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal pure {\n assembly {\n calldatacopy(dst, src, size)\n }\n }\n}\n\nlibrary ReturndataPointerLib {\n function lt(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(ReturndataPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n /// @dev Resolves an offset stored at `rdPtr + headOffset` to a returndata\n /// pointer. `rdPtr` must point to some parent object with a dynamic\n /// type's head stored at `rdPtr + headOffset`.\n function pptr(\n ReturndataPointer rdPtr,\n uint256 headOffset\n ) internal pure returns (ReturndataPointer rdPtrChild) {\n rdPtrChild = rdPtr.offset(\n rdPtr.offset(headOffset).readUint256() & OffsetOrLengthMask\n );\n }\n\n /// @dev Resolves an offset stored at `rdPtr` to a returndata pointer.\n /// `rdPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n ReturndataPointer rdPtr\n ) internal pure returns (ReturndataPointer rdPtrChild) {\n rdPtrChild = rdPtr.offset(rdPtr.readUint256() & OffsetOrLengthMask);\n }\n\n /// @dev Returns the returndata pointer one word after `cdPtr`.\n function next(\n ReturndataPointer rdPtr\n ) internal pure returns (ReturndataPointer rdPtrNext) {\n assembly {\n rdPtrNext := add(rdPtr, _OneWord)\n }\n }\n\n /// @dev Returns the returndata pointer `_offset` bytes after `cdPtr`.\n function offset(\n ReturndataPointer rdPtr,\n uint256 _offset\n ) internal pure returns (ReturndataPointer rdPtrNext) {\n assembly {\n rdPtrNext := add(rdPtr, _offset)\n }\n }\n\n /// @dev Copies `size` bytes from returndata starting at `src` to memory at\n /// `dst`.\n function copy(\n ReturndataPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal pure {\n assembly {\n returndatacopy(dst, src, size)\n }\n }\n}\n\nlibrary MemoryPointerLib {\n function copy(\n MemoryPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal view {\n assembly {\n let success := staticcall(\n gas(),\n IdentityPrecompileAddress,\n src,\n size,\n dst,\n size\n )\n if or(iszero(returndatasize()), iszero(success)) {\n revert(0, 0)\n }\n }\n }\n\n function lt(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(MemoryPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n function hash(\n MemoryPointer ptr,\n uint256 length\n ) internal pure returns (bytes32 _hash) {\n assembly {\n _hash := keccak256(ptr, length)\n }\n }\n\n /// @dev Returns the memory pointer one word after `mPtr`.\n function next(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer mPtrNext) {\n assembly {\n mPtrNext := add(mPtr, _OneWord)\n }\n }\n\n /// @dev Returns the memory pointer `_offset` bytes after `mPtr`.\n function offset(\n MemoryPointer mPtr,\n uint256 _offset\n ) internal pure returns (MemoryPointer mPtrNext) {\n assembly {\n mPtrNext := add(mPtr, _offset)\n }\n }\n\n /// @dev Resolves a pointer at `mPtr + headOffset` to a memory\n /// pointer. `mPtr` must point to some parent object with a dynamic\n /// type's pointer stored at `mPtr + headOffset`.\n function pptr(\n MemoryPointer mPtr,\n uint256 headOffset\n ) internal pure returns (MemoryPointer mPtrChild) {\n mPtrChild = mPtr.offset(headOffset).readMemoryPointer();\n }\n\n /// @dev Resolves a pointer stored at `mPtr` to a memory pointer.\n /// `mPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer mPtrChild) {\n mPtrChild = mPtr.readMemoryPointer();\n }\n}\n\nlibrary CalldataReaders {\n /// @dev Reads the value at `cdPtr` and applies a mask to return only the\n /// last 4 bytes.\n function readMaskedUint256(\n CalldataPointer cdPtr\n ) internal pure returns (uint256 value) {\n value = cdPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `cdPtr` in calldata.\n function readBool(\n CalldataPointer cdPtr\n ) internal pure returns (bool value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the address at `cdPtr` in calldata.\n function readAddress(\n CalldataPointer cdPtr\n ) internal pure returns (address value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes1 at `cdPtr` in calldata.\n function readBytes1(\n CalldataPointer cdPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes2 at `cdPtr` in calldata.\n function readBytes2(\n CalldataPointer cdPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes3 at `cdPtr` in calldata.\n function readBytes3(\n CalldataPointer cdPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes4 at `cdPtr` in calldata.\n function readBytes4(\n CalldataPointer cdPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes5 at `cdPtr` in calldata.\n function readBytes5(\n CalldataPointer cdPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes6 at `cdPtr` in calldata.\n function readBytes6(\n CalldataPointer cdPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes7 at `cdPtr` in calldata.\n function readBytes7(\n CalldataPointer cdPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes8 at `cdPtr` in calldata.\n function readBytes8(\n CalldataPointer cdPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes9 at `cdPtr` in calldata.\n function readBytes9(\n CalldataPointer cdPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes10 at `cdPtr` in calldata.\n function readBytes10(\n CalldataPointer cdPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes11 at `cdPtr` in calldata.\n function readBytes11(\n CalldataPointer cdPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes12 at `cdPtr` in calldata.\n function readBytes12(\n CalldataPointer cdPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes13 at `cdPtr` in calldata.\n function readBytes13(\n CalldataPointer cdPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes14 at `cdPtr` in calldata.\n function readBytes14(\n CalldataPointer cdPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes15 at `cdPtr` in calldata.\n function readBytes15(\n CalldataPointer cdPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes16 at `cdPtr` in calldata.\n function readBytes16(\n CalldataPointer cdPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes17 at `cdPtr` in calldata.\n function readBytes17(\n CalldataPointer cdPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes18 at `cdPtr` in calldata.\n function readBytes18(\n CalldataPointer cdPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes19 at `cdPtr` in calldata.\n function readBytes19(\n CalldataPointer cdPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes20 at `cdPtr` in calldata.\n function readBytes20(\n CalldataPointer cdPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes21 at `cdPtr` in calldata.\n function readBytes21(\n CalldataPointer cdPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes22 at `cdPtr` in calldata.\n function readBytes22(\n CalldataPointer cdPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes23 at `cdPtr` in calldata.\n function readBytes23(\n CalldataPointer cdPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes24 at `cdPtr` in calldata.\n function readBytes24(\n CalldataPointer cdPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes25 at `cdPtr` in calldata.\n function readBytes25(\n CalldataPointer cdPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes26 at `cdPtr` in calldata.\n function readBytes26(\n CalldataPointer cdPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes27 at `cdPtr` in calldata.\n function readBytes27(\n CalldataPointer cdPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes28 at `cdPtr` in calldata.\n function readBytes28(\n CalldataPointer cdPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes29 at `cdPtr` in calldata.\n function readBytes29(\n CalldataPointer cdPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes30 at `cdPtr` in calldata.\n function readBytes30(\n CalldataPointer cdPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes31 at `cdPtr` in calldata.\n function readBytes31(\n CalldataPointer cdPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes32 at `cdPtr` in calldata.\n function readBytes32(\n CalldataPointer cdPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint8 at `cdPtr` in calldata.\n function readUint8(\n CalldataPointer cdPtr\n ) internal pure returns (uint8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint16 at `cdPtr` in calldata.\n function readUint16(\n CalldataPointer cdPtr\n ) internal pure returns (uint16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint24 at `cdPtr` in calldata.\n function readUint24(\n CalldataPointer cdPtr\n ) internal pure returns (uint24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint32 at `cdPtr` in calldata.\n function readUint32(\n CalldataPointer cdPtr\n ) internal pure returns (uint32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint40 at `cdPtr` in calldata.\n function readUint40(\n CalldataPointer cdPtr\n ) internal pure returns (uint40 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint48 at `cdPtr` in calldata.\n function readUint48(\n CalldataPointer cdPtr\n ) internal pure returns (uint48 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint56 at `cdPtr` in calldata.\n function readUint56(\n CalldataPointer cdPtr\n ) internal pure returns (uint56 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint64 at `cdPtr` in calldata.\n function readUint64(\n CalldataPointer cdPtr\n ) internal pure returns (uint64 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint72 at `cdPtr` in calldata.\n function readUint72(\n CalldataPointer cdPtr\n ) internal pure returns (uint72 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint80 at `cdPtr` in calldata.\n function readUint80(\n CalldataPointer cdPtr\n ) internal pure returns (uint80 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint88 at `cdPtr` in calldata.\n function readUint88(\n CalldataPointer cdPtr\n ) internal pure returns (uint88 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint96 at `cdPtr` in calldata.\n function readUint96(\n CalldataPointer cdPtr\n ) internal pure returns (uint96 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint104 at `cdPtr` in calldata.\n function readUint104(\n CalldataPointer cdPtr\n ) internal pure returns (uint104 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint112 at `cdPtr` in calldata.\n function readUint112(\n CalldataPointer cdPtr\n ) internal pure returns (uint112 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint120 at `cdPtr` in calldata.\n function readUint120(\n CalldataPointer cdPtr\n ) internal pure returns (uint120 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint128 at `cdPtr` in calldata.\n function readUint128(\n CalldataPointer cdPtr\n ) internal pure returns (uint128 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint136 at `cdPtr` in calldata.\n function readUint136(\n CalldataPointer cdPtr\n ) internal pure returns (uint136 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint144 at `cdPtr` in calldata.\n function readUint144(\n CalldataPointer cdPtr\n ) internal pure returns (uint144 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint152 at `cdPtr` in calldata.\n function readUint152(\n CalldataPointer cdPtr\n ) internal pure returns (uint152 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint160 at `cdPtr` in calldata.\n function readUint160(\n CalldataPointer cdPtr\n ) internal pure returns (uint160 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint168 at `cdPtr` in calldata.\n function readUint168(\n CalldataPointer cdPtr\n ) internal pure returns (uint168 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint176 at `cdPtr` in calldata.\n function readUint176(\n CalldataPointer cdPtr\n ) internal pure returns (uint176 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint184 at `cdPtr` in calldata.\n function readUint184(\n CalldataPointer cdPtr\n ) internal pure returns (uint184 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint192 at `cdPtr` in calldata.\n function readUint192(\n CalldataPointer cdPtr\n ) internal pure returns (uint192 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint200 at `cdPtr` in calldata.\n function readUint200(\n CalldataPointer cdPtr\n ) internal pure returns (uint200 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint208 at `cdPtr` in calldata.\n function readUint208(\n CalldataPointer cdPtr\n ) internal pure returns (uint208 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint216 at `cdPtr` in calldata.\n function readUint216(\n CalldataPointer cdPtr\n ) internal pure returns (uint216 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint224 at `cdPtr` in calldata.\n function readUint224(\n CalldataPointer cdPtr\n ) internal pure returns (uint224 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint232 at `cdPtr` in calldata.\n function readUint232(\n CalldataPointer cdPtr\n ) internal pure returns (uint232 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint240 at `cdPtr` in calldata.\n function readUint240(\n CalldataPointer cdPtr\n ) internal pure returns (uint240 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint248 at `cdPtr` in calldata.\n function readUint248(\n CalldataPointer cdPtr\n ) internal pure returns (uint248 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint256 at `cdPtr` in calldata.\n function readUint256(\n CalldataPointer cdPtr\n ) internal pure returns (uint256 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int8 at `cdPtr` in calldata.\n function readInt8(\n CalldataPointer cdPtr\n ) internal pure returns (int8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int16 at `cdPtr` in calldata.\n function readInt16(\n CalldataPointer cdPtr\n ) internal pure returns (int16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int24 at `cdPtr` in calldata.\n function readInt24(\n CalldataPointer cdPtr\n ) internal pure returns (int24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int32 at `cdPtr` in calldata.\n function readInt32(\n CalldataPointer cdPtr\n ) internal pure returns (int32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int40 at `cdPtr` in calldata.\n function readInt40(\n CalldataPointer cdPtr\n ) internal pure returns (int40 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int48 at `cdPtr` in calldata.\n function readInt48(\n CalldataPointer cdPtr\n ) internal pure returns (int48 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int56 at `cdPtr` in calldata.\n function readInt56(\n CalldataPointer cdPtr\n ) internal pure returns (int56 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int64 at `cdPtr` in calldata.\n function readInt64(\n CalldataPointer cdPtr\n ) internal pure returns (int64 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int72 at `cdPtr` in calldata.\n function readInt72(\n CalldataPointer cdPtr\n ) internal pure returns (int72 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int80 at `cdPtr` in calldata.\n function readInt80(\n CalldataPointer cdPtr\n ) internal pure returns (int80 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int88 at `cdPtr` in calldata.\n function readInt88(\n CalldataPointer cdPtr\n ) internal pure returns (int88 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int96 at `cdPtr` in calldata.\n function readInt96(\n CalldataPointer cdPtr\n ) internal pure returns (int96 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int104 at `cdPtr` in calldata.\n function readInt104(\n CalldataPointer cdPtr\n ) internal pure returns (int104 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int112 at `cdPtr` in calldata.\n function readInt112(\n CalldataPointer cdPtr\n ) internal pure returns (int112 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int120 at `cdPtr` in calldata.\n function readInt120(\n CalldataPointer cdPtr\n ) internal pure returns (int120 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int128 at `cdPtr` in calldata.\n function readInt128(\n CalldataPointer cdPtr\n ) internal pure returns (int128 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int136 at `cdPtr` in calldata.\n function readInt136(\n CalldataPointer cdPtr\n ) internal pure returns (int136 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int144 at `cdPtr` in calldata.\n function readInt144(\n CalldataPointer cdPtr\n ) internal pure returns (int144 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int152 at `cdPtr` in calldata.\n function readInt152(\n CalldataPointer cdPtr\n ) internal pure returns (int152 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int160 at `cdPtr` in calldata.\n function readInt160(\n CalldataPointer cdPtr\n ) internal pure returns (int160 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int168 at `cdPtr` in calldata.\n function readInt168(\n CalldataPointer cdPtr\n ) internal pure returns (int168 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int176 at `cdPtr` in calldata.\n function readInt176(\n CalldataPointer cdPtr\n ) internal pure returns (int176 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int184 at `cdPtr` in calldata.\n function readInt184(\n CalldataPointer cdPtr\n ) internal pure returns (int184 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int192 at `cdPtr` in calldata.\n function readInt192(\n CalldataPointer cdPtr\n ) internal pure returns (int192 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int200 at `cdPtr` in calldata.\n function readInt200(\n CalldataPointer cdPtr\n ) internal pure returns (int200 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int208 at `cdPtr` in calldata.\n function readInt208(\n CalldataPointer cdPtr\n ) internal pure returns (int208 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int216 at `cdPtr` in calldata.\n function readInt216(\n CalldataPointer cdPtr\n ) internal pure returns (int216 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int224 at `cdPtr` in calldata.\n function readInt224(\n CalldataPointer cdPtr\n ) internal pure returns (int224 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int232 at `cdPtr` in calldata.\n function readInt232(\n CalldataPointer cdPtr\n ) internal pure returns (int232 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int240 at `cdPtr` in calldata.\n function readInt240(\n CalldataPointer cdPtr\n ) internal pure returns (int240 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int248 at `cdPtr` in calldata.\n function readInt248(\n CalldataPointer cdPtr\n ) internal pure returns (int248 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int256 at `cdPtr` in calldata.\n function readInt256(\n CalldataPointer cdPtr\n ) internal pure returns (int256 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n}\n\nlibrary ReturndataReaders {\n /// @dev Reads value at `rdPtr` & applies a mask to return only last 4 bytes\n function readMaskedUint256(\n ReturndataPointer rdPtr\n ) internal pure returns (uint256 value) {\n value = rdPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `rdPtr` in returndata.\n function readBool(\n ReturndataPointer rdPtr\n ) internal pure returns (bool value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the address at `rdPtr` in returndata.\n function readAddress(\n ReturndataPointer rdPtr\n ) internal pure returns (address value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes1 at `rdPtr` in returndata.\n function readBytes1(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes2 at `rdPtr` in returndata.\n function readBytes2(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes3 at `rdPtr` in returndata.\n function readBytes3(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes4 at `rdPtr` in returndata.\n function readBytes4(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes5 at `rdPtr` in returndata.\n function readBytes5(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes6 at `rdPtr` in returndata.\n function readBytes6(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes7 at `rdPtr` in returndata.\n function readBytes7(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes8 at `rdPtr` in returndata.\n function readBytes8(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes9 at `rdPtr` in returndata.\n function readBytes9(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes10 at `rdPtr` in returndata.\n function readBytes10(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes11 at `rdPtr` in returndata.\n function readBytes11(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes12 at `rdPtr` in returndata.\n function readBytes12(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes13 at `rdPtr` in returndata.\n function readBytes13(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes14 at `rdPtr` in returndata.\n function readBytes14(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes15 at `rdPtr` in returndata.\n function readBytes15(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes16 at `rdPtr` in returndata.\n function readBytes16(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes17 at `rdPtr` in returndata.\n function readBytes17(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes18 at `rdPtr` in returndata.\n function readBytes18(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes19 at `rdPtr` in returndata.\n function readBytes19(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes20 at `rdPtr` in returndata.\n function readBytes20(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes21 at `rdPtr` in returndata.\n function readBytes21(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes22 at `rdPtr` in returndata.\n function readBytes22(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes23 at `rdPtr` in returndata.\n function readBytes23(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes24 at `rdPtr` in returndata.\n function readBytes24(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes25 at `rdPtr` in returndata.\n function readBytes25(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes26 at `rdPtr` in returndata.\n function readBytes26(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes27 at `rdPtr` in returndata.\n function readBytes27(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes28 at `rdPtr` in returndata.\n function readBytes28(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes29 at `rdPtr` in returndata.\n function readBytes29(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes30 at `rdPtr` in returndata.\n function readBytes30(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes31 at `rdPtr` in returndata.\n function readBytes31(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes32 at `rdPtr` in returndata.\n function readBytes32(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint8 at `rdPtr` in returndata.\n function readUint8(\n ReturndataPointer rdPtr\n ) internal pure returns (uint8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint16 at `rdPtr` in returndata.\n function readUint16(\n ReturndataPointer rdPtr\n ) internal pure returns (uint16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint24 at `rdPtr` in returndata.\n function readUint24(\n ReturndataPointer rdPtr\n ) internal pure returns (uint24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint32 at `rdPtr` in returndata.\n function readUint32(\n ReturndataPointer rdPtr\n ) internal pure returns (uint32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint40 at `rdPtr` in returndata.\n function readUint40(\n ReturndataPointer rdPtr\n ) internal pure returns (uint40 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint48 at `rdPtr` in returndata.\n function readUint48(\n ReturndataPointer rdPtr\n ) internal pure returns (uint48 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint56 at `rdPtr` in returndata.\n function readUint56(\n ReturndataPointer rdPtr\n ) internal pure returns (uint56 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint64 at `rdPtr` in returndata.\n function readUint64(\n ReturndataPointer rdPtr\n ) internal pure returns (uint64 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint72 at `rdPtr` in returndata.\n function readUint72(\n ReturndataPointer rdPtr\n ) internal pure returns (uint72 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint80 at `rdPtr` in returndata.\n function readUint80(\n ReturndataPointer rdPtr\n ) internal pure returns (uint80 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint88 at `rdPtr` in returndata.\n function readUint88(\n ReturndataPointer rdPtr\n ) internal pure returns (uint88 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint96 at `rdPtr` in returndata.\n function readUint96(\n ReturndataPointer rdPtr\n ) internal pure returns (uint96 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint104 at `rdPtr` in returndata.\n function readUint104(\n ReturndataPointer rdPtr\n ) internal pure returns (uint104 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint112 at `rdPtr` in returndata.\n function readUint112(\n ReturndataPointer rdPtr\n ) internal pure returns (uint112 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint120 at `rdPtr` in returndata.\n function readUint120(\n ReturndataPointer rdPtr\n ) internal pure returns (uint120 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint128 at `rdPtr` in returndata.\n function readUint128(\n ReturndataPointer rdPtr\n ) internal pure returns (uint128 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint136 at `rdPtr` in returndata.\n function readUint136(\n ReturndataPointer rdPtr\n ) internal pure returns (uint136 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint144 at `rdPtr` in returndata.\n function readUint144(\n ReturndataPointer rdPtr\n ) internal pure returns (uint144 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint152 at `rdPtr` in returndata.\n function readUint152(\n ReturndataPointer rdPtr\n ) internal pure returns (uint152 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint160 at `rdPtr` in returndata.\n function readUint160(\n ReturndataPointer rdPtr\n ) internal pure returns (uint160 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint168 at `rdPtr` in returndata.\n function readUint168(\n ReturndataPointer rdPtr\n ) internal pure returns (uint168 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint176 at `rdPtr` in returndata.\n function readUint176(\n ReturndataPointer rdPtr\n ) internal pure returns (uint176 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint184 at `rdPtr` in returndata.\n function readUint184(\n ReturndataPointer rdPtr\n ) internal pure returns (uint184 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint192 at `rdPtr` in returndata.\n function readUint192(\n ReturndataPointer rdPtr\n ) internal pure returns (uint192 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint200 at `rdPtr` in returndata.\n function readUint200(\n ReturndataPointer rdPtr\n ) internal pure returns (uint200 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint208 at `rdPtr` in returndata.\n function readUint208(\n ReturndataPointer rdPtr\n ) internal pure returns (uint208 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint216 at `rdPtr` in returndata.\n function readUint216(\n ReturndataPointer rdPtr\n ) internal pure returns (uint216 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint224 at `rdPtr` in returndata.\n function readUint224(\n ReturndataPointer rdPtr\n ) internal pure returns (uint224 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint232 at `rdPtr` in returndata.\n function readUint232(\n ReturndataPointer rdPtr\n ) internal pure returns (uint232 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint240 at `rdPtr` in returndata.\n function readUint240(\n ReturndataPointer rdPtr\n ) internal pure returns (uint240 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint248 at `rdPtr` in returndata.\n function readUint248(\n ReturndataPointer rdPtr\n ) internal pure returns (uint248 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint256 at `rdPtr` in returndata.\n function readUint256(\n ReturndataPointer rdPtr\n ) internal pure returns (uint256 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int8 at `rdPtr` in returndata.\n function readInt8(\n ReturndataPointer rdPtr\n ) internal pure returns (int8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int16 at `rdPtr` in returndata.\n function readInt16(\n ReturndataPointer rdPtr\n ) internal pure returns (int16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int24 at `rdPtr` in returndata.\n function readInt24(\n ReturndataPointer rdPtr\n ) internal pure returns (int24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int32 at `rdPtr` in returndata.\n function readInt32(\n ReturndataPointer rdPtr\n ) internal pure returns (int32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int40 at `rdPtr` in returndata.\n function readInt40(\n ReturndataPointer rdPtr\n ) internal pure returns (int40 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int48 at `rdPtr` in returndata.\n function readInt48(\n ReturndataPointer rdPtr\n ) internal pure returns (int48 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int56 at `rdPtr` in returndata.\n function readInt56(\n ReturndataPointer rdPtr\n ) internal pure returns (int56 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int64 at `rdPtr` in returndata.\n function readInt64(\n ReturndataPointer rdPtr\n ) internal pure returns (int64 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int72 at `rdPtr` in returndata.\n function readInt72(\n ReturndataPointer rdPtr\n ) internal pure returns (int72 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int80 at `rdPtr` in returndata.\n function readInt80(\n ReturndataPointer rdPtr\n ) internal pure returns (int80 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int88 at `rdPtr` in returndata.\n function readInt88(\n ReturndataPointer rdPtr\n ) internal pure returns (int88 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int96 at `rdPtr` in returndata.\n function readInt96(\n ReturndataPointer rdPtr\n ) internal pure returns (int96 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int104 at `rdPtr` in returndata.\n function readInt104(\n ReturndataPointer rdPtr\n ) internal pure returns (int104 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int112 at `rdPtr` in returndata.\n function readInt112(\n ReturndataPointer rdPtr\n ) internal pure returns (int112 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int120 at `rdPtr` in returndata.\n function readInt120(\n ReturndataPointer rdPtr\n ) internal pure returns (int120 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int128 at `rdPtr` in returndata.\n function readInt128(\n ReturndataPointer rdPtr\n ) internal pure returns (int128 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int136 at `rdPtr` in returndata.\n function readInt136(\n ReturndataPointer rdPtr\n ) internal pure returns (int136 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int144 at `rdPtr` in returndata.\n function readInt144(\n ReturndataPointer rdPtr\n ) internal pure returns (int144 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int152 at `rdPtr` in returndata.\n function readInt152(\n ReturndataPointer rdPtr\n ) internal pure returns (int152 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int160 at `rdPtr` in returndata.\n function readInt160(\n ReturndataPointer rdPtr\n ) internal pure returns (int160 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int168 at `rdPtr` in returndata.\n function readInt168(\n ReturndataPointer rdPtr\n ) internal pure returns (int168 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int176 at `rdPtr` in returndata.\n function readInt176(\n ReturndataPointer rdPtr\n ) internal pure returns (int176 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int184 at `rdPtr` in returndata.\n function readInt184(\n ReturndataPointer rdPtr\n ) internal pure returns (int184 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int192 at `rdPtr` in returndata.\n function readInt192(\n ReturndataPointer rdPtr\n ) internal pure returns (int192 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int200 at `rdPtr` in returndata.\n function readInt200(\n ReturndataPointer rdPtr\n ) internal pure returns (int200 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int208 at `rdPtr` in returndata.\n function readInt208(\n ReturndataPointer rdPtr\n ) internal pure returns (int208 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int216 at `rdPtr` in returndata.\n function readInt216(\n ReturndataPointer rdPtr\n ) internal pure returns (int216 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int224 at `rdPtr` in returndata.\n function readInt224(\n ReturndataPointer rdPtr\n ) internal pure returns (int224 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int232 at `rdPtr` in returndata.\n function readInt232(\n ReturndataPointer rdPtr\n ) internal pure returns (int232 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int240 at `rdPtr` in returndata.\n function readInt240(\n ReturndataPointer rdPtr\n ) internal pure returns (int240 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int248 at `rdPtr` in returndata.\n function readInt248(\n ReturndataPointer rdPtr\n ) internal pure returns (int248 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int256 at `rdPtr` in returndata.\n function readInt256(\n ReturndataPointer rdPtr\n ) internal pure returns (int256 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n}\n\nlibrary MemoryReaders {\n /// @dev Reads the memory pointer at `mPtr` in memory.\n function readMemoryPointer(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads value at `mPtr` & applies a mask to return only last 4 bytes\n function readMaskedUint256(\n MemoryPointer mPtr\n ) internal pure returns (uint256 value) {\n value = mPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `mPtr` in memory.\n function readBool(MemoryPointer mPtr) internal pure returns (bool value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the address at `mPtr` in memory.\n function readAddress(\n MemoryPointer mPtr\n ) internal pure returns (address value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes1 at `mPtr` in memory.\n function readBytes1(\n MemoryPointer mPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes2 at `mPtr` in memory.\n function readBytes2(\n MemoryPointer mPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes3 at `mPtr` in memory.\n function readBytes3(\n MemoryPointer mPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes4 at `mPtr` in memory.\n function readBytes4(\n MemoryPointer mPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes5 at `mPtr` in memory.\n function readBytes5(\n MemoryPointer mPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes6 at `mPtr` in memory.\n function readBytes6(\n MemoryPointer mPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes7 at `mPtr` in memory.\n function readBytes7(\n MemoryPointer mPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes8 at `mPtr` in memory.\n function readBytes8(\n MemoryPointer mPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes9 at `mPtr` in memory.\n function readBytes9(\n MemoryPointer mPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes10 at `mPtr` in memory.\n function readBytes10(\n MemoryPointer mPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes11 at `mPtr` in memory.\n function readBytes11(\n MemoryPointer mPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes12 at `mPtr` in memory.\n function readBytes12(\n MemoryPointer mPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes13 at `mPtr` in memory.\n function readBytes13(\n MemoryPointer mPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes14 at `mPtr` in memory.\n function readBytes14(\n MemoryPointer mPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes15 at `mPtr` in memory.\n function readBytes15(\n MemoryPointer mPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes16 at `mPtr` in memory.\n function readBytes16(\n MemoryPointer mPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes17 at `mPtr` in memory.\n function readBytes17(\n MemoryPointer mPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes18 at `mPtr` in memory.\n function readBytes18(\n MemoryPointer mPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes19 at `mPtr` in memory.\n function readBytes19(\n MemoryPointer mPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes20 at `mPtr` in memory.\n function readBytes20(\n MemoryPointer mPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes21 at `mPtr` in memory.\n function readBytes21(\n MemoryPointer mPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes22 at `mPtr` in memory.\n function readBytes22(\n MemoryPointer mPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes23 at `mPtr` in memory.\n function readBytes23(\n MemoryPointer mPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes24 at `mPtr` in memory.\n function readBytes24(\n MemoryPointer mPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes25 at `mPtr` in memory.\n function readBytes25(\n MemoryPointer mPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes26 at `mPtr` in memory.\n function readBytes26(\n MemoryPointer mPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes27 at `mPtr` in memory.\n function readBytes27(\n MemoryPointer mPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes28 at `mPtr` in memory.\n function readBytes28(\n MemoryPointer mPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes29 at `mPtr` in memory.\n function readBytes29(\n MemoryPointer mPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes30 at `mPtr` in memory.\n function readBytes30(\n MemoryPointer mPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes31 at `mPtr` in memory.\n function readBytes31(\n MemoryPointer mPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes32 at `mPtr` in memory.\n function readBytes32(\n MemoryPointer mPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint8 at `mPtr` in memory.\n function readUint8(MemoryPointer mPtr) internal pure returns (uint8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint16 at `mPtr` in memory.\n function readUint16(\n MemoryPointer mPtr\n ) internal pure returns (uint16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint24 at `mPtr` in memory.\n function readUint24(\n MemoryPointer mPtr\n ) internal pure returns (uint24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint32 at `mPtr` in memory.\n function readUint32(\n MemoryPointer mPtr\n ) internal pure returns (uint32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint40 at `mPtr` in memory.\n function readUint40(\n MemoryPointer mPtr\n ) internal pure returns (uint40 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint48 at `mPtr` in memory.\n function readUint48(\n MemoryPointer mPtr\n ) internal pure returns (uint48 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint56 at `mPtr` in memory.\n function readUint56(\n MemoryPointer mPtr\n ) internal pure returns (uint56 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint64 at `mPtr` in memory.\n function readUint64(\n MemoryPointer mPtr\n ) internal pure returns (uint64 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint72 at `mPtr` in memory.\n function readUint72(\n MemoryPointer mPtr\n ) internal pure returns (uint72 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint80 at `mPtr` in memory.\n function readUint80(\n MemoryPointer mPtr\n ) internal pure returns (uint80 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint88 at `mPtr` in memory.\n function readUint88(\n MemoryPointer mPtr\n ) internal pure returns (uint88 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint96 at `mPtr` in memory.\n function readUint96(\n MemoryPointer mPtr\n ) internal pure returns (uint96 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint104 at `mPtr` in memory.\n function readUint104(\n MemoryPointer mPtr\n ) internal pure returns (uint104 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint112 at `mPtr` in memory.\n function readUint112(\n MemoryPointer mPtr\n ) internal pure returns (uint112 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint120 at `mPtr` in memory.\n function readUint120(\n MemoryPointer mPtr\n ) internal pure returns (uint120 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint128 at `mPtr` in memory.\n function readUint128(\n MemoryPointer mPtr\n ) internal pure returns (uint128 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint136 at `mPtr` in memory.\n function readUint136(\n MemoryPointer mPtr\n ) internal pure returns (uint136 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint144 at `mPtr` in memory.\n function readUint144(\n MemoryPointer mPtr\n ) internal pure returns (uint144 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint152 at `mPtr` in memory.\n function readUint152(\n MemoryPointer mPtr\n ) internal pure returns (uint152 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint160 at `mPtr` in memory.\n function readUint160(\n MemoryPointer mPtr\n ) internal pure returns (uint160 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint168 at `mPtr` in memory.\n function readUint168(\n MemoryPointer mPtr\n ) internal pure returns (uint168 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint176 at `mPtr` in memory.\n function readUint176(\n MemoryPointer mPtr\n ) internal pure returns (uint176 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint184 at `mPtr` in memory.\n function readUint184(\n MemoryPointer mPtr\n ) internal pure returns (uint184 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint192 at `mPtr` in memory.\n function readUint192(\n MemoryPointer mPtr\n ) internal pure returns (uint192 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint200 at `mPtr` in memory.\n function readUint200(\n MemoryPointer mPtr\n ) internal pure returns (uint200 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint208 at `mPtr` in memory.\n function readUint208(\n MemoryPointer mPtr\n ) internal pure returns (uint208 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint216 at `mPtr` in memory.\n function readUint216(\n MemoryPointer mPtr\n ) internal pure returns (uint216 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint224 at `mPtr` in memory.\n function readUint224(\n MemoryPointer mPtr\n ) internal pure returns (uint224 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint232 at `mPtr` in memory.\n function readUint232(\n MemoryPointer mPtr\n ) internal pure returns (uint232 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint240 at `mPtr` in memory.\n function readUint240(\n MemoryPointer mPtr\n ) internal pure returns (uint240 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint248 at `mPtr` in memory.\n function readUint248(\n MemoryPointer mPtr\n ) internal pure returns (uint248 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint256 at `mPtr` in memory.\n function readUint256(\n MemoryPointer mPtr\n ) internal pure returns (uint256 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int8 at `mPtr` in memory.\n function readInt8(MemoryPointer mPtr) internal pure returns (int8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int16 at `mPtr` in memory.\n function readInt16(MemoryPointer mPtr) internal pure returns (int16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int24 at `mPtr` in memory.\n function readInt24(MemoryPointer mPtr) internal pure returns (int24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int32 at `mPtr` in memory.\n function readInt32(MemoryPointer mPtr) internal pure returns (int32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int40 at `mPtr` in memory.\n function readInt40(MemoryPointer mPtr) internal pure returns (int40 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int48 at `mPtr` in memory.\n function readInt48(MemoryPointer mPtr) internal pure returns (int48 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int56 at `mPtr` in memory.\n function readInt56(MemoryPointer mPtr) internal pure returns (int56 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int64 at `mPtr` in memory.\n function readInt64(MemoryPointer mPtr) internal pure returns (int64 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int72 at `mPtr` in memory.\n function readInt72(MemoryPointer mPtr) internal pure returns (int72 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int80 at `mPtr` in memory.\n function readInt80(MemoryPointer mPtr) internal pure returns (int80 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int88 at `mPtr` in memory.\n function readInt88(MemoryPointer mPtr) internal pure returns (int88 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int96 at `mPtr` in memory.\n function readInt96(MemoryPointer mPtr) internal pure returns (int96 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int104 at `mPtr` in memory.\n function readInt104(\n MemoryPointer mPtr\n ) internal pure returns (int104 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int112 at `mPtr` in memory.\n function readInt112(\n MemoryPointer mPtr\n ) internal pure returns (int112 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int120 at `mPtr` in memory.\n function readInt120(\n MemoryPointer mPtr\n ) internal pure returns (int120 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int128 at `mPtr` in memory.\n function readInt128(\n MemoryPointer mPtr\n ) internal pure returns (int128 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int136 at `mPtr` in memory.\n function readInt136(\n MemoryPointer mPtr\n ) internal pure returns (int136 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int144 at `mPtr` in memory.\n function readInt144(\n MemoryPointer mPtr\n ) internal pure returns (int144 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int152 at `mPtr` in memory.\n function readInt152(\n MemoryPointer mPtr\n ) internal pure returns (int152 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int160 at `mPtr` in memory.\n function readInt160(\n MemoryPointer mPtr\n ) internal pure returns (int160 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int168 at `mPtr` in memory.\n function readInt168(\n MemoryPointer mPtr\n ) internal pure returns (int168 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int176 at `mPtr` in memory.\n function readInt176(\n MemoryPointer mPtr\n ) internal pure returns (int176 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int184 at `mPtr` in memory.\n function readInt184(\n MemoryPointer mPtr\n ) internal pure returns (int184 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int192 at `mPtr` in memory.\n function readInt192(\n MemoryPointer mPtr\n ) internal pure returns (int192 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int200 at `mPtr` in memory.\n function readInt200(\n MemoryPointer mPtr\n ) internal pure returns (int200 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int208 at `mPtr` in memory.\n function readInt208(\n MemoryPointer mPtr\n ) internal pure returns (int208 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int216 at `mPtr` in memory.\n function readInt216(\n MemoryPointer mPtr\n ) internal pure returns (int216 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int224 at `mPtr` in memory.\n function readInt224(\n MemoryPointer mPtr\n ) internal pure returns (int224 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int232 at `mPtr` in memory.\n function readInt232(\n MemoryPointer mPtr\n ) internal pure returns (int232 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int240 at `mPtr` in memory.\n function readInt240(\n MemoryPointer mPtr\n ) internal pure returns (int240 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int248 at `mPtr` in memory.\n function readInt248(\n MemoryPointer mPtr\n ) internal pure returns (int248 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int256 at `mPtr` in memory.\n function readInt256(\n MemoryPointer mPtr\n ) internal pure returns (int256 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n}\n\nlibrary MemoryWriters {\n /// @dev Writes `valuePtr` to memory at `mPtr`.\n function write(MemoryPointer mPtr, MemoryPointer valuePtr) internal pure {\n assembly {\n mstore(mPtr, valuePtr)\n }\n }\n\n /// @dev Writes a boolean `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, bool value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes an address `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, address value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes a bytes32 `value` to `mPtr` in memory.\n /// Separate name to disambiguate literal write parameters.\n function writeBytes32(MemoryPointer mPtr, bytes32 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes a uint256 `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, uint256 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes an int256 `value` to `mPtr` in memory.\n /// Separate name to disambiguate literal write parameters.\n function writeInt(MemoryPointer mPtr, int256 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.7;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.19;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(target.code.length > 0, \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
},
"src/lib/ERC721SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { AllowListData, CreatorPayout } from \"./SeaDropStructs.sol\";\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in two storage slots.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token address. Null for\n * native token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct PublicDrop {\n uint80 startPrice; // 80/512 bits\n uint80 endPrice; // 160/512 bits\n uint40 startTime; // 200/512 bits\n uint40 endTime; // 240/512 bits\n address paymentToken; // 400/512 bits\n uint16 maxTotalMintableByWallet; // 416/512 bits\n uint16 feeBps; // 432/512 bits\n bool restrictFeeRecipients; // 440/512 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n *\n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token for the mint. Null for\n * native token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 startPrice;\n uint256 endPrice;\n uint256 startTime;\n uint256 endTime;\n address paymentToken;\n uint256 maxTotalMintableByWallet;\n uint256 maxTokenSupplyForStage;\n uint256 dropStageIndex; // non-zero\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @dev Struct containing internal SeaDrop implementation logic\n * mint details to avoid stack too deep.\n *\n * @param feeRecipient The fee recipient.\n * @param payer The payer of the mint.\n * @param minter The mint recipient.\n * @param quantity The number of tokens to mint.\n * @param withEffects Whether to apply state changes of the mint.\n */\nstruct MintDetails {\n address feeRecipient;\n address payer;\n address minter;\n uint256 quantity;\n bool withEffects;\n}\n\n/**\n * @notice A struct to configure multiple contract options in one transaction.\n */\nstruct MultiConfigureStruct {\n uint256 maxSupply;\n string baseURI;\n string contractURI;\n PublicDrop publicDrop;\n string dropURI;\n AllowListData allowListData;\n CreatorPayout[] creatorPayouts;\n bytes32 provenanceHash;\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n address[] allowedPayers;\n address[] disallowedPayers;\n // Server-signed\n address[] allowedSigners;\n address[] disallowedSigners;\n // ERC-2981\n address royaltyReceiver;\n uint96 royaltyBps;\n // Mint\n address mintRecipient;\n uint256 mintQuantity;\n}\n"
}
},
"settings": {
"remappings": [
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"ERC721A/=lib/ERC721A/contracts/",
"ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin-upgradeable/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@rari-capital/solmate/=lib/seaport/lib/solmate/",
"murky/=lib/murky/src/",
"create2-scripts/=lib/create2-helpers/script/",
"seadrop/=src/",
"seaport-sol/=lib/seaport/lib/seaport-sol/",
"seaport-types/=lib/seaport/lib/seaport-types/",
"seaport-core/=lib/seaport/lib/seaport-core/",
"seaport-test-utils/=lib/seaport/test/foundry/utils/",
"solady/=lib/solady/"
],
"optimizer": {
"enabled": true,
"runs": 99999999
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"libraries": {}
}
}}
|
1 | 19,498,532 |
95695be05a8ff33da4f941ed0935876584200097bc1b0a8cdcf6b80ff0c8f0bd
|
9b601ba059c7a05d24ab9e0962be2c6bd349617ed998859ed5ef3284a93985cf
|
0722ae7fa5ce7335d9a5751341ef67c3c78f9c8d
|
0722ae7fa5ce7335d9a5751341ef67c3c78f9c8d
|
f541afabdc8608bb2d970beae19b62ffe83b3a75
|
608060405234801562000010575f80fd5b5060405162000fe738038062000fe78339810160408190526200003391620002e3565b80604051806040016040528060098152602001682124a39026a2a6a2a960b91b81525060405180604001604052806005815260200164424d454d4560d81b8152508160039081620000859190620003b0565b506004620000948282620003b0565b5050506001600160a01b038116620000c657604051631e4fbdf760e01b81525f60048201526024015b60405180910390fd5b620000d18162000127565b505f620000e16012600a6200058b565b620000f1906305f5e10062000598565b9050620000ff828262000178565b506001600160a01b03165f908152600660205260409020805460ff19166001179055620005c8565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6001600160a01b038216620001a35760405163ec442f0560e01b81525f6004820152602401620000bd565b620001b05f8383620001b4565b5050565b6001600160a01b038316620001e2578060025f828254620001d69190620005b2565b90915550620002549050565b6001600160a01b0383165f9081526020819052604090205481811015620002365760405163391434e360e21b81526001600160a01b03851660048201526024810182905260448101839052606401620000bd565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b038216620002725760028054829003905562000290565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051620002d691815260200190565b60405180910390a3505050565b5f60208284031215620002f4575f80fd5b81516001600160a01b03811681146200030b575f80fd5b9392505050565b634e487b7160e01b5f52604160045260245ffd5b600181811c908216806200033b57607f821691505b6020821081036200035a57634e487b7160e01b5f52602260045260245ffd5b50919050565b601f821115620003ab57805f5260205f20601f840160051c81016020851015620003875750805b601f840160051c820191505b81811015620003a8575f815560010162000393565b50505b505050565b81516001600160401b03811115620003cc57620003cc62000312565b620003e481620003dd845462000326565b8462000360565b602080601f8311600181146200041a575f8415620004025750858301515b5f19600386901b1c1916600185901b17855562000474565b5f85815260208120601f198616915b828110156200044a5788860151825594840194600190910190840162000429565b50858210156200046857878501515f19600388901b60f8161c191681555b505060018460011b0185555b505050505050565b634e487b7160e01b5f52601160045260245ffd5b600181815b80851115620004d057815f1904821115620004b457620004b46200047c565b80851615620004c257918102915b93841c939080029062000495565b509250929050565b5f82620004e85750600162000585565b81620004f657505f62000585565b81600181146200050f57600281146200051a576200053a565b600191505062000585565b60ff8411156200052e576200052e6200047c565b50506001821b62000585565b5060208310610133831016604e8410600b84101617156200055f575081810a62000585565b6200056b838362000490565b805f19048211156200058157620005816200047c565b0290505b92915050565b5f6200030b8383620004d8565b80820281158282048414176200058557620005856200047c565b808201808211156200058557620005856200047c565b610a1180620005d65f395ff3fe608060405234801561000f575f80fd5b50600436106100f0575f3560e01c806370a0823111610093578063a9059cbb11610063578063a9059cbb146101fc578063ab2042821461020f578063dd62ed3e14610222578063f2fde38b1461025a575f80fd5b806370a08231146101a9578063715018a6146101d15780638da5cb5b146101d957806395d89b41146101f4575f80fd5b806318160ddd116100ce57806318160ddd1461014a57806323b872dd1461015c578063313ce5671461016f5780633805e84e1461017e575f80fd5b806306fdde03146100f4578063095ea7b31461011257806311d39b6e14610135575b5f80fd5b6100fc61026d565b6040516101099190610830565b60405180910390f35b610125610120366004610897565b6102fd565b6040519015158152602001610109565b6101486101433660046108bf565b610316565b005b6002545b604051908152602001610109565b61012561016a3660046108d8565b610369565b60405160128152602001610109565b61012561018c3660046108bf565b6001600160a01b03165f9081526006602052604090205460ff1690565b61014e6101b73660046108bf565b6001600160a01b03165f9081526020819052604090205490565b6101486103bc565b6005546040516001600160a01b039091168152602001610109565b6100fc6103cf565b61012561020a366004610897565b6103de565b61014861021d3660046108bf565b61041d565b61014e610230366004610911565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6101486102683660046108bf565b61046d565b60606003805461027c90610942565b80601f01602080910402602001604051908101604052809291908181526020018280546102a890610942565b80156102f35780601f106102ca576101008083540402835291602001916102f3565b820191905f5260205f20905b8154815290600101906020018083116102d657829003601f168201915b5050505050905090565b5f3361030a8185856104aa565b60019150505b92915050565b61031e6104bc565b6001600160a01b0381165f81815260066020526040808220805460ff19166001179055517fa829544c54c3f830039b99959d8f585db9860cd66c217978e5294a0f5656434d9190a250565b6001600160a01b0383165f9081526006602052604081205460ff166103a95760405162461bcd60e51b81526004016103a09061097a565b60405180910390fd5b6103b48484846104e9565b949350505050565b6103c46104bc565b6103cd5f61050c565b565b60606004805461027c90610942565b335f9081526006602052604081205460ff1661040c5760405162461bcd60e51b81526004016103a09061097a565b610416838361055d565b9392505050565b6104256104bc565b6001600160a01b0381165f81815260066020526040808220805460ff19169055517fbedd44ef8b3f33e9f984e7cbf8619bf14a5d7f2751057fe502757fc2d7f69ba79190a250565b6104756104bc565b6001600160a01b03811661049e57604051631e4fbdf760e01b81525f60048201526024016103a0565b6104a78161050c565b50565b6104b7838383600161056a565b505050565b6005546001600160a01b031633146103cd5760405163118cdaa760e01b81523360048201526024016103a0565b5f336104f685828561063d565b6105018585856106b2565b506001949350505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b5f3361030a8185856106b2565b6001600160a01b0384166105935760405163e602df0560e01b81525f60048201526024016103a0565b6001600160a01b0383166105bc57604051634a1406b160e11b81525f60048201526024016103a0565b6001600160a01b038085165f908152600160209081526040808320938716835292905220829055801561063757826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161062e91815260200190565b60405180910390a35b50505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f19811461063757818110156106a457604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064016103a0565b61063784848484035f61056a565b6001600160a01b0383166106db57604051634b637e8f60e11b81525f60048201526024016103a0565b6001600160a01b0382166107045760405163ec442f0560e01b81525f60048201526024016103a0565b6104b78383836001600160a01b038316610734578060025f82825461072991906109bc565b909155506107a49050565b6001600160a01b0383165f90815260208190526040902054818110156107865760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103a0565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b0382166107c0576002805482900390556107de565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161082391815260200190565b60405180910390a3505050565b5f602080835283518060208501525f5b8181101561085c57858101830151858201604001528201610840565b505f604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610892575f80fd5b919050565b5f80604083850312156108a8575f80fd5b6108b18361087c565b946020939093013593505050565b5f602082840312156108cf575f80fd5b6104168261087c565b5f805f606084860312156108ea575f80fd5b6108f38461087c565b92506109016020850161087c565b9150604084013590509250925092565b5f8060408385031215610922575f80fd5b61092b8361087c565b91506109396020840161087c565b90509250929050565b600181811c9082168061095657607f821691505b60208210810361097457634e487b7160e01b5f52602260045260245ffd5b50919050565b60208082526022908201527f53656e646572206973206e6f7420617070726f76656420746f207472616e736660408201526132b960f11b606082015260800190565b8082018082111561031057634e487b7160e01b5f52601160045260245ffdfea2646970667358221220bbc2587d2f45de5533f05914bef48bbb61f7b336a3c6651c51bf30b2374834cb64736f6c634300081800330000000000000000000000000722ae7fa5ce7335d9a5751341ef67c3c78f9c8d
|
608060405234801561000f575f80fd5b50600436106100f0575f3560e01c806370a0823111610093578063a9059cbb11610063578063a9059cbb146101fc578063ab2042821461020f578063dd62ed3e14610222578063f2fde38b1461025a575f80fd5b806370a08231146101a9578063715018a6146101d15780638da5cb5b146101d957806395d89b41146101f4575f80fd5b806318160ddd116100ce57806318160ddd1461014a57806323b872dd1461015c578063313ce5671461016f5780633805e84e1461017e575f80fd5b806306fdde03146100f4578063095ea7b31461011257806311d39b6e14610135575b5f80fd5b6100fc61026d565b6040516101099190610830565b60405180910390f35b610125610120366004610897565b6102fd565b6040519015158152602001610109565b6101486101433660046108bf565b610316565b005b6002545b604051908152602001610109565b61012561016a3660046108d8565b610369565b60405160128152602001610109565b61012561018c3660046108bf565b6001600160a01b03165f9081526006602052604090205460ff1690565b61014e6101b73660046108bf565b6001600160a01b03165f9081526020819052604090205490565b6101486103bc565b6005546040516001600160a01b039091168152602001610109565b6100fc6103cf565b61012561020a366004610897565b6103de565b61014861021d3660046108bf565b61041d565b61014e610230366004610911565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b6101486102683660046108bf565b61046d565b60606003805461027c90610942565b80601f01602080910402602001604051908101604052809291908181526020018280546102a890610942565b80156102f35780601f106102ca576101008083540402835291602001916102f3565b820191905f5260205f20905b8154815290600101906020018083116102d657829003601f168201915b5050505050905090565b5f3361030a8185856104aa565b60019150505b92915050565b61031e6104bc565b6001600160a01b0381165f81815260066020526040808220805460ff19166001179055517fa829544c54c3f830039b99959d8f585db9860cd66c217978e5294a0f5656434d9190a250565b6001600160a01b0383165f9081526006602052604081205460ff166103a95760405162461bcd60e51b81526004016103a09061097a565b60405180910390fd5b6103b48484846104e9565b949350505050565b6103c46104bc565b6103cd5f61050c565b565b60606004805461027c90610942565b335f9081526006602052604081205460ff1661040c5760405162461bcd60e51b81526004016103a09061097a565b610416838361055d565b9392505050565b6104256104bc565b6001600160a01b0381165f81815260066020526040808220805460ff19169055517fbedd44ef8b3f33e9f984e7cbf8619bf14a5d7f2751057fe502757fc2d7f69ba79190a250565b6104756104bc565b6001600160a01b03811661049e57604051631e4fbdf760e01b81525f60048201526024016103a0565b6104a78161050c565b50565b6104b7838383600161056a565b505050565b6005546001600160a01b031633146103cd5760405163118cdaa760e01b81523360048201526024016103a0565b5f336104f685828561063d565b6105018585856106b2565b506001949350505050565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b5f3361030a8185856106b2565b6001600160a01b0384166105935760405163e602df0560e01b81525f60048201526024016103a0565b6001600160a01b0383166105bc57604051634a1406b160e11b81525f60048201526024016103a0565b6001600160a01b038085165f908152600160209081526040808320938716835292905220829055801561063757826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258460405161062e91815260200190565b60405180910390a35b50505050565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f19811461063757818110156106a457604051637dc7a0d960e11b81526001600160a01b038416600482015260248101829052604481018390526064016103a0565b61063784848484035f61056a565b6001600160a01b0383166106db57604051634b637e8f60e11b81525f60048201526024016103a0565b6001600160a01b0382166107045760405163ec442f0560e01b81525f60048201526024016103a0565b6104b78383836001600160a01b038316610734578060025f82825461072991906109bc565b909155506107a49050565b6001600160a01b0383165f90815260208190526040902054818110156107865760405163391434e360e21b81526001600160a01b038516600482015260248101829052604481018390526064016103a0565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b0382166107c0576002805482900390556107de565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161082391815260200190565b60405180910390a3505050565b5f602080835283518060208501525f5b8181101561085c57858101830151858201604001528201610840565b505f604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610892575f80fd5b919050565b5f80604083850312156108a8575f80fd5b6108b18361087c565b946020939093013593505050565b5f602082840312156108cf575f80fd5b6104168261087c565b5f805f606084860312156108ea575f80fd5b6108f38461087c565b92506109016020850161087c565b9150604084013590509250925092565b5f8060408385031215610922575f80fd5b61092b8361087c565b91506109396020840161087c565b90509250929050565b600181811c9082168061095657607f821691505b60208210810361097457634e487b7160e01b5f52602260045260245ffd5b50919050565b60208082526022908201527f53656e646572206973206e6f7420617070726f76656420746f207472616e736660408201526132b960f11b606082015260800190565b8082018082111561031057634e487b7160e01b5f52601160045260245ffdfea2646970667358221220bbc2587d2f45de5533f05914bef48bbb61f7b336a3c6651c51bf30b2374834cb64736f6c63430008180033
| |
1 | 19,498,536 |
630e98b9fd20f92209cad630df6f01585d673f77d191059bdaa88fe8f67784b0
|
e180788ee0f3f551bed9a4ecf8e753366c1e2cc88c6a763bba9c804e820c12dd
|
f4862233955b4f41b616da5f5eca67f784bde726
|
f4862233955b4f41b616da5f5eca67f784bde726
|
c8f6b2238950851c9acf48ba631e8307abc42aae
|
608060405234801561000f575f80fd5b50604051611ac7380380611ac7833981810160405281019061003191906102a7565b336040518060400160405280600681526020017f5368656b656c00000000000000000000000000000000000000000000000000008152506040518060400160405280600681526020017f5348454b454c000000000000000000000000000000000000000000000000000081525081600390816100ad919061050c565b5080600490816100bd919061050c565b5050505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610130575f6040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161012791906105ea565b60405180910390fd5b61013f8161018660201b60201c565b508060065f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610603565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102768261024d565b9050919050565b6102868161026c565b8114610290575f80fd5b50565b5f815190506102a18161027d565b92915050565b5f602082840312156102bc576102bb610249565b5b5f6102c984828501610293565b91505092915050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061034d57607f821691505b6020821081036103605761035f610309565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026103c27fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610387565b6103cc8683610387565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61041061040b610406846103e4565b6103ed565b6103e4565b9050919050565b5f819050919050565b610429836103f6565b61043d61043582610417565b848454610393565b825550505050565b5f90565b610451610445565b61045c818484610420565b505050565b5b8181101561047f576104745f82610449565b600181019050610462565b5050565b601f8211156104c45761049581610366565b61049e84610378565b810160208510156104ad578190505b6104c16104b985610378565b830182610461565b50505b505050565b5f82821c905092915050565b5f6104e45f19846008026104c9565b1980831691505092915050565b5f6104fc83836104d5565b9150826002028217905092915050565b610515826102d2565b67ffffffffffffffff81111561052e5761052d6102dc565b5b6105388254610336565b610543828285610483565b5f60209050601f831160018114610574575f8415610562578287015190505b61056c85826104f1565b8655506105d3565b601f19841661058286610366565b5f5b828110156105a957848901518255600182019150602085019450602081019050610584565b868310156105c657848901516105c2601f8916826104d5565b8355505b6001600288020188555050505b505050505050565b6105e48161026c565b82525050565b5f6020820190506105fd5f8301846105db565b92915050565b6114b7806106105f395ff3fe608060405234801561000f575f80fd5b50600436106100fe575f3560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb14610288578063dd62ed3e146102b8578063f2fde38b146102e8578063fca3b5aa14610304576100fe565b806370a0823114610212578063715018a6146102425780638da5cb5b1461024c57806395d89b411461026a576100fe565b806323b872dd116100d157806323b872dd1461018c578063313ce567146101bc57806340c10f19146101da57806342966c68146101f6576100fe565b806306fdde03146101025780630754617214610120578063095ea7b31461013e57806318160ddd1461016e575b5f80fd5b61010a610320565b6040516101179190610fe9565b60405180910390f35b6101286103b0565b6040516101359190611048565b60405180910390f35b610158600480360381019061015391906110c2565b6103d5565b604051610165919061111a565b60405180910390f35b6101766103f7565b6040516101839190611142565b60405180910390f35b6101a660048036038101906101a1919061115b565b610400565b6040516101b3919061111a565b60405180910390f35b6101c461042e565b6040516101d191906111c6565b60405180910390f35b6101f460048036038101906101ef91906110c2565b610436565b005b610210600480360381019061020b91906111df565b6104d3565b005b61022c6004803603810190610227919061120a565b61052b565b6040516102399190611142565b60405180910390f35b61024a610570565b005b610254610583565b6040516102619190611048565b60405180910390f35b6102726105ab565b60405161027f9190610fe9565b60405180910390f35b6102a2600480360381019061029d91906110c2565b61063b565b6040516102af919061111a565b60405180910390f35b6102d260048036038101906102cd9190611235565b61065d565b6040516102df9190611142565b60405180910390f35b61030260048036038101906102fd919061120a565b6106df565b005b61031e6004803603810190610319919061120a565b610763565b005b60606003805461032f906112a0565b80601f016020809104026020016040519081016040528092919081815260200182805461035b906112a0565b80156103a65780601f1061037d576101008083540402835291602001916103a6565b820191905f5260205f20905b81548152906001019060200180831161038957829003601f168201915b5050505050905090565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f806103df6107ae565b90506103ec8185856107b5565b600191505092915050565b5f600254905090565b5f8061040a6107ae565b90506104178582856107c7565b610422858585610859565b60019150509392505050565b5f6012905090565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104bc90611340565b60405180910390fd5b6104cf8282610949565b5050565b806104dd3361052b565b101561051e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610515906113ce565b60405180910390fd5b61052833826109c8565b50565b5f805f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b610578610a47565b6105815f610ace565b565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546105ba906112a0565b80601f01602080910402602001604051908101604052809291908181526020018280546105e6906112a0565b80156106315780601f1061060857610100808354040283529160200191610631565b820191905f5260205f20905b81548152906001019060200180831161061457829003601f168201915b5050505050905090565b5f806106456107ae565b9050610652818585610859565b600191505092915050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b6106e7610a47565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610757575f6040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161074e9190611048565b60405180910390fd5b61076081610ace565b50565b61076b610a47565b8060065f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f33905090565b6107c28383836001610b91565b505050565b5f6107d2848461065d565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146108535781811015610844578281836040517ffb8f41b200000000000000000000000000000000000000000000000000000000815260040161083b939291906113ec565b60405180910390fd5b61085284848484035f610b91565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036108c9575f6040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016108c09190611048565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610939575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016109309190611048565b60405180910390fd5b610944838383610d60565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036109b9575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016109b09190611048565b60405180910390fd5b6109c45f8383610d60565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a38575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401610a2f9190611048565b60405180910390fd5b610a43825f83610d60565b5050565b610a4f6107ae565b73ffffffffffffffffffffffffffffffffffffffff16610a6d610583565b73ffffffffffffffffffffffffffffffffffffffff1614610acc57610a906107ae565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610ac39190611048565b60405180910390fd5b565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610c01575f6040517fe602df05000000000000000000000000000000000000000000000000000000008152600401610bf89190611048565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610c71575f6040517f94280d62000000000000000000000000000000000000000000000000000000008152600401610c689190611048565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508015610d5a578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610d519190611142565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610db0578060025f828254610da4919061144e565b92505081905550610e7e565b5f805f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015610e39578381836040517fe450d38c000000000000000000000000000000000000000000000000000000008152600401610e30939291906113ec565b60405180910390fd5b8181035f808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610ec5578060025f8282540392505081905550610f0f565b805f808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610f6c9190611142565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f610fbb82610f79565b610fc58185610f83565b9350610fd5818560208601610f93565b610fde81610fa1565b840191505092915050565b5f6020820190508181035f8301526110018184610fb1565b905092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61103282611009565b9050919050565b61104281611028565b82525050565b5f60208201905061105b5f830184611039565b92915050565b5f80fd5b61106e81611028565b8114611078575f80fd5b50565b5f8135905061108981611065565b92915050565b5f819050919050565b6110a18161108f565b81146110ab575f80fd5b50565b5f813590506110bc81611098565b92915050565b5f80604083850312156110d8576110d7611061565b5b5f6110e58582860161107b565b92505060206110f6858286016110ae565b9150509250929050565b5f8115159050919050565b61111481611100565b82525050565b5f60208201905061112d5f83018461110b565b92915050565b61113c8161108f565b82525050565b5f6020820190506111555f830184611133565b92915050565b5f805f6060848603121561117257611171611061565b5b5f61117f8682870161107b565b93505060206111908682870161107b565b92505060406111a1868287016110ae565b9150509250925092565b5f60ff82169050919050565b6111c0816111ab565b82525050565b5f6020820190506111d95f8301846111b7565b92915050565b5f602082840312156111f4576111f3611061565b5b5f611201848285016110ae565b91505092915050565b5f6020828403121561121f5761121e611061565b5b5f61122c8482850161107b565b91505092915050565b5f806040838503121561124b5761124a611061565b5b5f6112588582860161107b565b92505060206112698582860161107b565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806112b757607f821691505b6020821081036112ca576112c9611273565b5b50919050565b7f4f6e6c7920616c6c6f776564206d696e7465722063616e2063616c6c207468695f8201527f732066756e6374696f6e00000000000000000000000000000000000000000000602082015250565b5f61132a602a83610f83565b9150611335826112d0565b604082019050919050565b5f6020820190508181035f8301526113578161131e565b9050919050565b7f596f7520646f206e6f74206861766520656e6f7567682062616c616e636520745f8201527f6f206275726e0000000000000000000000000000000000000000000000000000602082015250565b5f6113b8602683610f83565b91506113c38261135e565b604082019050919050565b5f6020820190508181035f8301526113e5816113ac565b9050919050565b5f6060820190506113ff5f830186611039565b61140c6020830185611133565b6114196040830184611133565b949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6114588261108f565b91506114638361108f565b925082820190508082111561147b5761147a611421565b5b9291505056fea26469706673582212204b8d15f798e430cbaa9cf4b8ba5f69a28898c6b7d36974c2d13215c126e3d46264736f6c63430008190033000000000000000000000000e9959c7a1cf7891cac0be4b2c835e723db68a474
|
608060405234801561000f575f80fd5b50600436106100fe575f3560e01c806370a0823111610095578063a9059cbb11610064578063a9059cbb14610288578063dd62ed3e146102b8578063f2fde38b146102e8578063fca3b5aa14610304576100fe565b806370a0823114610212578063715018a6146102425780638da5cb5b1461024c57806395d89b411461026a576100fe565b806323b872dd116100d157806323b872dd1461018c578063313ce567146101bc57806340c10f19146101da57806342966c68146101f6576100fe565b806306fdde03146101025780630754617214610120578063095ea7b31461013e57806318160ddd1461016e575b5f80fd5b61010a610320565b6040516101179190610fe9565b60405180910390f35b6101286103b0565b6040516101359190611048565b60405180910390f35b610158600480360381019061015391906110c2565b6103d5565b604051610165919061111a565b60405180910390f35b6101766103f7565b6040516101839190611142565b60405180910390f35b6101a660048036038101906101a1919061115b565b610400565b6040516101b3919061111a565b60405180910390f35b6101c461042e565b6040516101d191906111c6565b60405180910390f35b6101f460048036038101906101ef91906110c2565b610436565b005b610210600480360381019061020b91906111df565b6104d3565b005b61022c6004803603810190610227919061120a565b61052b565b6040516102399190611142565b60405180910390f35b61024a610570565b005b610254610583565b6040516102619190611048565b60405180910390f35b6102726105ab565b60405161027f9190610fe9565b60405180910390f35b6102a2600480360381019061029d91906110c2565b61063b565b6040516102af919061111a565b60405180910390f35b6102d260048036038101906102cd9190611235565b61065d565b6040516102df9190611142565b60405180910390f35b61030260048036038101906102fd919061120a565b6106df565b005b61031e6004803603810190610319919061120a565b610763565b005b60606003805461032f906112a0565b80601f016020809104026020016040519081016040528092919081815260200182805461035b906112a0565b80156103a65780601f1061037d576101008083540402835291602001916103a6565b820191905f5260205f20905b81548152906001019060200180831161038957829003601f168201915b5050505050905090565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f806103df6107ae565b90506103ec8185856107b5565b600191505092915050565b5f600254905090565b5f8061040a6107ae565b90506104178582856107c7565b610422858585610859565b60019150509392505050565b5f6012905090565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104bc90611340565b60405180910390fd5b6104cf8282610949565b5050565b806104dd3361052b565b101561051e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610515906113ce565b60405180910390fd5b61052833826109c8565b50565b5f805f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b610578610a47565b6105815f610ace565b565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546105ba906112a0565b80601f01602080910402602001604051908101604052809291908181526020018280546105e6906112a0565b80156106315780601f1061060857610100808354040283529160200191610631565b820191905f5260205f20905b81548152906001019060200180831161061457829003601f168201915b5050505050905090565b5f806106456107ae565b9050610652818585610859565b600191505092915050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b6106e7610a47565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610757575f6040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161074e9190611048565b60405180910390fd5b61076081610ace565b50565b61076b610a47565b8060065f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f33905090565b6107c28383836001610b91565b505050565b5f6107d2848461065d565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146108535781811015610844578281836040517ffb8f41b200000000000000000000000000000000000000000000000000000000815260040161083b939291906113ec565b60405180910390fd5b61085284848484035f610b91565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036108c9575f6040517f96c6fd1e0000000000000000000000000000000000000000000000000000000081526004016108c09190611048565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610939575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016109309190611048565b60405180910390fd5b610944838383610d60565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036109b9575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016109b09190611048565b60405180910390fd5b6109c45f8383610d60565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a38575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401610a2f9190611048565b60405180910390fd5b610a43825f83610d60565b5050565b610a4f6107ae565b73ffffffffffffffffffffffffffffffffffffffff16610a6d610583565b73ffffffffffffffffffffffffffffffffffffffff1614610acc57610a906107ae565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610ac39190611048565b60405180910390fd5b565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610c01575f6040517fe602df05000000000000000000000000000000000000000000000000000000008152600401610bf89190611048565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610c71575f6040517f94280d62000000000000000000000000000000000000000000000000000000008152600401610c689190611048565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508015610d5a578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610d519190611142565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610db0578060025f828254610da4919061144e565b92505081905550610e7e565b5f805f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015610e39578381836040517fe450d38c000000000000000000000000000000000000000000000000000000008152600401610e30939291906113ec565b60405180910390fd5b8181035f808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610ec5578060025f8282540392505081905550610f0f565b805f808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610f6c9190611142565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f610fbb82610f79565b610fc58185610f83565b9350610fd5818560208601610f93565b610fde81610fa1565b840191505092915050565b5f6020820190508181035f8301526110018184610fb1565b905092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61103282611009565b9050919050565b61104281611028565b82525050565b5f60208201905061105b5f830184611039565b92915050565b5f80fd5b61106e81611028565b8114611078575f80fd5b50565b5f8135905061108981611065565b92915050565b5f819050919050565b6110a18161108f565b81146110ab575f80fd5b50565b5f813590506110bc81611098565b92915050565b5f80604083850312156110d8576110d7611061565b5b5f6110e58582860161107b565b92505060206110f6858286016110ae565b9150509250929050565b5f8115159050919050565b61111481611100565b82525050565b5f60208201905061112d5f83018461110b565b92915050565b61113c8161108f565b82525050565b5f6020820190506111555f830184611133565b92915050565b5f805f6060848603121561117257611171611061565b5b5f61117f8682870161107b565b93505060206111908682870161107b565b92505060406111a1868287016110ae565b9150509250925092565b5f60ff82169050919050565b6111c0816111ab565b82525050565b5f6020820190506111d95f8301846111b7565b92915050565b5f602082840312156111f4576111f3611061565b5b5f611201848285016110ae565b91505092915050565b5f6020828403121561121f5761121e611061565b5b5f61122c8482850161107b565b91505092915050565b5f806040838503121561124b5761124a611061565b5b5f6112588582860161107b565b92505060206112698582860161107b565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806112b757607f821691505b6020821081036112ca576112c9611273565b5b50919050565b7f4f6e6c7920616c6c6f776564206d696e7465722063616e2063616c6c207468695f8201527f732066756e6374696f6e00000000000000000000000000000000000000000000602082015250565b5f61132a602a83610f83565b9150611335826112d0565b604082019050919050565b5f6020820190508181035f8301526113578161131e565b9050919050565b7f596f7520646f206e6f74206861766520656e6f7567682062616c616e636520745f8201527f6f206275726e0000000000000000000000000000000000000000000000000000602082015250565b5f6113b8602683610f83565b91506113c38261135e565b604082019050919050565b5f6020820190508181035f8301526113e5816113ac565b9050919050565b5f6060820190506113ff5f830186611039565b61140c6020830185611133565b6114196040830184611133565b949350505050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6114588261108f565b91506114638361108f565b925082820190508082111561147b5761147a611421565b5b9291505056fea26469706673582212204b8d15f798e430cbaa9cf4b8ba5f69a28898c6b7d36974c2d13215c126e3d46264736f6c63430008190033
|
{{
"language": "Solidity",
"sources": {
"contracts/SHEKEL.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract Shekel is ERC20, Ownable {\n address public minter;\n modifier onlyMinter() {\n require(msg.sender == minter, \"Only allowed minter can call this function\");\n _;\n }\n\n constructor(address _minter) ERC20(\"Shekel\", \"SHEKEL\") Ownable(msg.sender) {\n minter = _minter;\n }\n\n function setMinter(address _minter) external onlyOwner {\n minter = _minter;\n }\n\n function burn(uint256 _amount) external {\n require(\n balanceOf(msg.sender) >= _amount,\n \"You do not have enough balance to burn\"\n );\n _burn(msg.sender, _amount);\n }\n\n function mint(address to, uint256 _amount) external onlyMinter{\n _mint(to, _amount);\n }\n}\n"
},
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/interfaces/draft-IERC6093.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,498,537 |
59371e387b9fc8511864cb88c157fb078aa96231e405615f0c279494fa4ac2b1
|
2805d477b2c06bd9c5b0d1aced7b28a8cd5113e816c903f9d37cc7bfad9123a5
|
a7fb5ca286fc3fd67525629048a4de3ba24cba2e
|
c77ad0a71008d7094a62cfbd250a2eb2afdf2776
|
9dbf556778fc93c6ff5d4e3a3bfd8e55b260752b
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,498,541 |
f660b51fb9560ad4ce3170f627eed6675646fe4c4545b40fc09828737fb6c7f0
|
089644e3441b0b02dd312ecf2296a8a307ff9478d0b73bfae427cfa1610a47fd
|
948461a52cd1c604e19e2b8308109b1355720bff
|
948461a52cd1c604e19e2b8308109b1355720bff
|
2db342ad15ebeb414d935243bce78c32ca6edb91
|
60806040526006805460ff19166001179055600a6007819055601960088190555f6009818155818455600b839055600c929092556017600d55600e55620000469162000345565b62000056906305f5e1006200035c565b600f55620000676009600a62000345565b6200007590619c406200035c565b601055620000866009600a62000345565b62000096906305f5e1006200035c565b601155620000a76009600a62000345565b620000b7906305f5e1006200035c565b6012556014805461ffff60a81b19169055348015620000d4575f80fd5b505f80546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060068054610100600160a81b03191661010033021790556200013a6009600a62000345565b6200014a906305f5e1006200035c565b335f908152600160208190526040822092909255600390620001735f546001600160a01b031690565b6001600160a01b03908116825260208083019390935260409182015f908120805495151560ff1996871617905530815260039093528183208054851660019081179091556006546101009004909116835291208054909216179055620001d63390565b6001600160a01b03165f7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6200020f6009600a62000345565b6200021f906305f5e1006200035c565b60405190815260200160405180910390a362000376565b634e487b7160e01b5f52601160045260245ffd5b600181815b808511156200028a57815f19048211156200026e576200026e62000236565b808516156200027c57918102915b93841c93908002906200024f565b509250929050565b5f82620002a2575060016200033f565b81620002b057505f6200033f565b8160018114620002c95760028114620002d457620002f4565b60019150506200033f565b60ff841115620002e857620002e862000236565b50506001821b6200033f565b5060208310610133831016604e8410600b841016171562000319575081810a6200033f565b6200032583836200024a565b805f19048211156200033b576200033b62000236565b0290505b92915050565b5f6200035560ff84168362000292565b9392505050565b80820281158282048414176200033f576200033f62000236565b61189980620003845f395ff3fe608060405260043610610129575f3560e01c806370a08231116100a857806395d89b411161006d57806395d89b4114610306578063a9059cbb14610334578063bf474bed14610353578063c876d0b914610368578063dd62ed3e14610381578063f4293890146103c5575f80fd5b806370a082311461026e578063715018a6146102a25780637d1db4a5146102b65780638da5cb5b146102cb5780638f9a55c0146102f1575f80fd5b806318acd4cb116100ee57806318acd4cb146101f857806323b872dd1461020c578063313ce5671461022b578063359c8d841461024657806356cc11a51461025a575f80fd5b806306fdde0314610134578063095ea7b31461017c5780630f8540e4146101ab5780630faee56f146101c157806318160ddd146101e4575f80fd5b3661013057005b5f80fd5b34801561013f575f80fd5b5060408051808201909152600e81526d4d65726b6c652046696e616e636560901b60208201525b604051610173919061148f565b60405180910390f35b348015610187575f80fd5b5061019b6101963660046114ee565b6103d9565b6040519015158152602001610173565b3480156101b6575f80fd5b506101bf6103ef565b005b3480156101cc575f80fd5b506101d660125481565b604051908152602001610173565b3480156101ef575f80fd5b506101d66107a6565b348015610203575f80fd5b506101bf6107c6565b348015610217575f80fd5b5061019b610226366004611518565b610881565b348015610236575f80fd5b5060405160098152602001610173565b348015610251575f80fd5b506101bf6108e3565b348015610265575f80fd5b506101bf610939565b348015610279575f80fd5b506101d6610288366004611556565b6001600160a01b03165f9081526001602052604090205490565b3480156102ad575f80fd5b506101bf610989565b3480156102c1575f80fd5b506101d6600f5481565b3480156102d6575f80fd5b505f546040516001600160a01b039091168152602001610173565b3480156102fc575f80fd5b506101d660105481565b348015610311575f80fd5b506040805180820190915260068152654d45524b4c4560d01b6020820152610166565b34801561033f575f80fd5b5061019b61034e3660046114ee565b6109fa565b34801561035e575f80fd5b506101d660115481565b348015610373575f80fd5b5060065461019b9060ff1681565b34801561038c575f80fd5b506101d661039b366004611571565b6001600160a01b039182165f90815260026020908152604080832093909416825291909152205490565b3480156103d0575f80fd5b506101bf610a06565b5f6103e5338484610a10565b5060015b92915050565b5f546001600160a01b031633146104215760405162461bcd60e51b8152600401610418906115a8565b60405180910390fd5b601454600160a01b900460ff161561047b5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610418565b601380546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556104c99030906104b66009600a6116d1565b6104c4906305f5e1006116df565b610a10565b60135f9054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610519573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061053d91906116f6565b6001600160a01b031663c9c653963060135f9054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561059c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105c091906116f6565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af115801561060a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061062e91906116f6565b601480546001600160a01b039283166001600160a01b03199091161790556013541663f305d7194730610675816001600160a01b03165f9081526001602052604090205490565b5f806106885f546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af11580156106ee573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906107139190611711565b505060145460135460405163095ea7b360e01b81526001600160a01b0391821660048201525f1960248201529116915063095ea7b3906044016020604051808303815f875af1158015610768573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061078c919061173c565b506014805462ff00ff60a01b19166201000160a01b179055565b5f6107b36009600a6116d1565b6107c1906305f5e1006116df565b905090565b5f546001600160a01b031633146107ef5760405162461bcd60e51b8152600401610418906115a8565b6107fb6009600a6116d1565b610809906305f5e1006116df565b600f556108186009600a6116d1565b610826906305f5e1006116df565b6010556006805460ff191690557f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf6108606009600a6116d1565b61086e906305f5e1006116df565b60405190815260200160405180910390a1565b5f61088d848484610b33565b6108d984336104c48560405180606001604052806028815260200161183c602891396001600160a01b038a165f9081526002602090815260408083203384529091529020549190611107565b5060019392505050565b60065461010090046001600160a01b0316336001600160a01b031614610907575f80fd5b305f908152600160205260409020548015610925576109258161113f565b47801561093557610935816112af565b5050565b60065461010090046001600160a01b0316336001600160a01b03161461095d575f80fd5b60405133904780156108fc02915f818181858888f19350505050158015610986573d5f803e3d5ffd5b50565b5f546001600160a01b031633146109b25760405162461bcd60e51b8152600401610418906115a8565b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f6103e5338484610b33565b47610986816112af565b6001600160a01b038316610a725760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610418565b6001600160a01b038216610ad35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610418565b6001600160a01b038381165f8181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b975760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610418565b6001600160a01b038216610bf95760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610418565b5f8111610c5a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610418565b5f80546001600160a01b03858116911614801590610c8557505f546001600160a01b03848116911614155b15610fca57610cb66064610cb0600b54600e5411610ca557600754610ca9565b6009545b85906112ea565b9061136f565b60065490915060ff1615610d9c576013546001600160a01b03848116911614801590610cf057506014546001600160a01b03848116911614155b15610d9c57325f908152600560205260409020544311610d8a5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610418565b325f9081526005602052604090204390555b6014546001600160a01b038581169116148015610dc757506013546001600160a01b03848116911614155b8015610deb57506001600160a01b0383165f9081526003602052604090205460ff16155b15610ed157600f54821115610e425760405162461bcd60e51b815260206004820152601960248201527f4578636565647320746865205f6d61785478416d6f756e742e000000000000006044820152606401610418565b60105482610e64856001600160a01b03165f9081526001602052604090205490565b610e6e919061175b565b1115610ebc5760405162461bcd60e51b815260206004820152601a60248201527f4578636565647320746865206d617857616c6c657453697a652e0000000000006044820152606401610418565b600e8054905f610ecb8361176e565b91905055505b6014546001600160a01b038481169116148015610ef757506001600160a01b0384163014155b15610f2457610f216064610cb0600c54600e5411610f1757600854610ca9565b600a5485906112ea565b90505b305f90815260016020526040902054601454600160a81b900460ff16158015610f5a57506014546001600160a01b038581169116145b8015610f6f5750601454600160b01b900460ff165b8015610f7c575060115481115b8015610f8b5750600d54600e54115b15610fc857610fad610fa884610fa3846012546113b0565b6113b0565b61113f565b47666a94d74f430000811115610fc657610fc6476112af565b505b505b801561104257305f90815260016020526040902054610fe990826113c4565b305f81815260016020526040908190209290925590516001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906110399085815260200190565b60405180910390a35b6001600160a01b0384165f908152600160205260409020546110649083611422565b6001600160a01b0385165f908152600160205260409020556110a76110898383611422565b6001600160a01b0385165f90815260016020526040902054906113c4565b6001600160a01b038085165f8181526001602052604090209290925585167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6110f08585611422565b60405190815260200160405180910390a350505050565b5f818484111561112a5760405162461bcd60e51b8152600401610418919061148f565b505f6111368486611786565b95945050505050565b6014805460ff60a81b1916600160a81b1790556040805160028082526060820183525f9260208301908036833701905050905030815f8151811061118557611185611799565b6001600160a01b03928316602091820292909201810191909152601354604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa1580156111dc573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061120091906116f6565b8160018151811061121357611213611799565b6001600160a01b0392831660209182029290920101526013546112399130911684610a10565b60135460405163791ac94760e01b81526001600160a01b039091169063791ac947906112719085905f908690309042906004016117ad565b5f604051808303815f87803b158015611288575f80fd5b505af115801561129a573d5f803e3d5ffd5b50506014805460ff60a81b1916905550505050565b6006546040516101009091046001600160a01b0316906108fc8315029083905f818181858888f19350505050158015610935573d5f803e3d5ffd5b5f825f036112f957505f6103e9565b5f61130483856116df565b905082611311858361181c565b146113685760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610418565b9392505050565b5f61136883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611463565b5f8183116113be5782611368565b50919050565b5f806113d0838561175b565b9050838110156113685760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610418565b5f61136883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611107565b5f81836114835760405162461bcd60e51b8152600401610418919061148f565b505f611136848661181c565b5f6020808352835180828501525f5b818110156114ba5785810183015185820160400152820161149e565b505f604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b0381168114610986575f80fd5b5f80604083850312156114ff575f80fd5b823561150a816114da565b946020939093013593505050565b5f805f6060848603121561152a575f80fd5b8335611535816114da565b92506020840135611545816114da565b929592945050506040919091013590565b5f60208284031215611566575f80fd5b8135611368816114da565b5f8060408385031215611582575f80fd5b823561158d816114da565b9150602083013561159d816114da565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561162b57815f1904821115611611576116116115dd565b8085161561161e57918102915b93841c93908002906115f6565b509250929050565b5f82611641575060016103e9565b8161164d57505f6103e9565b8160018114611663576002811461166d57611689565b60019150506103e9565b60ff84111561167e5761167e6115dd565b50506001821b6103e9565b5060208310610133831016604e8410600b84101617156116ac575081810a6103e9565b6116b683836115f1565b805f19048211156116c9576116c96115dd565b029392505050565b5f61136860ff841683611633565b80820281158282048414176103e9576103e96115dd565b5f60208284031215611706575f80fd5b8151611368816114da565b5f805f60608486031215611723575f80fd5b8351925060208401519150604084015190509250925092565b5f6020828403121561174c575f80fd5b81518015158114611368575f80fd5b808201808211156103e9576103e96115dd565b5f6001820161177f5761177f6115dd565b5060010190565b818103818111156103e9576103e96115dd565b634e487b7160e01b5f52603260045260245ffd5b5f60a082018783526020878185015260a0604085015281875180845260c08601915082890193505f5b818110156117fb5784516001600160a01b0316835293830193918301916001016117d6565b50506001600160a01b03969096166060850152505050608001529392505050565b5f8261183657634e487b7160e01b5f52601260045260245ffd5b50049056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220c80458a1db85ed72c2f9f1e80f2e6d9643ccb4ad99f0ccefaf9b1fad9662f85764736f6c63430008140033
|
608060405260043610610129575f3560e01c806370a08231116100a857806395d89b411161006d57806395d89b4114610306578063a9059cbb14610334578063bf474bed14610353578063c876d0b914610368578063dd62ed3e14610381578063f4293890146103c5575f80fd5b806370a082311461026e578063715018a6146102a25780637d1db4a5146102b65780638da5cb5b146102cb5780638f9a55c0146102f1575f80fd5b806318acd4cb116100ee57806318acd4cb146101f857806323b872dd1461020c578063313ce5671461022b578063359c8d841461024657806356cc11a51461025a575f80fd5b806306fdde0314610134578063095ea7b31461017c5780630f8540e4146101ab5780630faee56f146101c157806318160ddd146101e4575f80fd5b3661013057005b5f80fd5b34801561013f575f80fd5b5060408051808201909152600e81526d4d65726b6c652046696e616e636560901b60208201525b604051610173919061148f565b60405180910390f35b348015610187575f80fd5b5061019b6101963660046114ee565b6103d9565b6040519015158152602001610173565b3480156101b6575f80fd5b506101bf6103ef565b005b3480156101cc575f80fd5b506101d660125481565b604051908152602001610173565b3480156101ef575f80fd5b506101d66107a6565b348015610203575f80fd5b506101bf6107c6565b348015610217575f80fd5b5061019b610226366004611518565b610881565b348015610236575f80fd5b5060405160098152602001610173565b348015610251575f80fd5b506101bf6108e3565b348015610265575f80fd5b506101bf610939565b348015610279575f80fd5b506101d6610288366004611556565b6001600160a01b03165f9081526001602052604090205490565b3480156102ad575f80fd5b506101bf610989565b3480156102c1575f80fd5b506101d6600f5481565b3480156102d6575f80fd5b505f546040516001600160a01b039091168152602001610173565b3480156102fc575f80fd5b506101d660105481565b348015610311575f80fd5b506040805180820190915260068152654d45524b4c4560d01b6020820152610166565b34801561033f575f80fd5b5061019b61034e3660046114ee565b6109fa565b34801561035e575f80fd5b506101d660115481565b348015610373575f80fd5b5060065461019b9060ff1681565b34801561038c575f80fd5b506101d661039b366004611571565b6001600160a01b039182165f90815260026020908152604080832093909416825291909152205490565b3480156103d0575f80fd5b506101bf610a06565b5f6103e5338484610a10565b5060015b92915050565b5f546001600160a01b031633146104215760405162461bcd60e51b8152600401610418906115a8565b60405180910390fd5b601454600160a01b900460ff161561047b5760405162461bcd60e51b815260206004820152601760248201527f74726164696e6720697320616c7265616479206f70656e0000000000000000006044820152606401610418565b601380546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556104c99030906104b66009600a6116d1565b6104c4906305f5e1006116df565b610a10565b60135f9054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610519573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061053d91906116f6565b6001600160a01b031663c9c653963060135f9054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561059c573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906105c091906116f6565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af115801561060a573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061062e91906116f6565b601480546001600160a01b039283166001600160a01b03199091161790556013541663f305d7194730610675816001600160a01b03165f9081526001602052604090205490565b5f806106885f546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af11580156106ee573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906107139190611711565b505060145460135460405163095ea7b360e01b81526001600160a01b0391821660048201525f1960248201529116915063095ea7b3906044016020604051808303815f875af1158015610768573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061078c919061173c565b506014805462ff00ff60a01b19166201000160a01b179055565b5f6107b36009600a6116d1565b6107c1906305f5e1006116df565b905090565b5f546001600160a01b031633146107ef5760405162461bcd60e51b8152600401610418906115a8565b6107fb6009600a6116d1565b610809906305f5e1006116df565b600f556108186009600a6116d1565b610826906305f5e1006116df565b6010556006805460ff191690557f947f344d56e1e8c70dc492fb94c4ddddd490c016aab685f5e7e47b2e85cb44cf6108606009600a6116d1565b61086e906305f5e1006116df565b60405190815260200160405180910390a1565b5f61088d848484610b33565b6108d984336104c48560405180606001604052806028815260200161183c602891396001600160a01b038a165f9081526002602090815260408083203384529091529020549190611107565b5060019392505050565b60065461010090046001600160a01b0316336001600160a01b031614610907575f80fd5b305f908152600160205260409020548015610925576109258161113f565b47801561093557610935816112af565b5050565b60065461010090046001600160a01b0316336001600160a01b03161461095d575f80fd5b60405133904780156108fc02915f818181858888f19350505050158015610986573d5f803e3d5ffd5b50565b5f546001600160a01b031633146109b25760405162461bcd60e51b8152600401610418906115a8565b5f80546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a35f80546001600160a01b0319169055565b5f6103e5338484610b33565b47610986816112af565b6001600160a01b038316610a725760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610418565b6001600160a01b038216610ad35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610418565b6001600160a01b038381165f8181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610b975760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610418565b6001600160a01b038216610bf95760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610418565b5f8111610c5a5760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b6064820152608401610418565b5f80546001600160a01b03858116911614801590610c8557505f546001600160a01b03848116911614155b15610fca57610cb66064610cb0600b54600e5411610ca557600754610ca9565b6009545b85906112ea565b9061136f565b60065490915060ff1615610d9c576013546001600160a01b03848116911614801590610cf057506014546001600160a01b03848116911614155b15610d9c57325f908152600560205260409020544311610d8a5760405162461bcd60e51b815260206004820152604960248201527f5f7472616e736665723a3a205472616e736665722044656c617920656e61626c60448201527f65642e20204f6e6c79206f6e652070757263686173652070657220626c6f636b6064820152681030b63637bbb2b21760b91b608482015260a401610418565b325f9081526005602052604090204390555b6014546001600160a01b038581169116148015610dc757506013546001600160a01b03848116911614155b8015610deb57506001600160a01b0383165f9081526003602052604090205460ff16155b15610ed157600f54821115610e425760405162461bcd60e51b815260206004820152601960248201527f4578636565647320746865205f6d61785478416d6f756e742e000000000000006044820152606401610418565b60105482610e64856001600160a01b03165f9081526001602052604090205490565b610e6e919061175b565b1115610ebc5760405162461bcd60e51b815260206004820152601a60248201527f4578636565647320746865206d617857616c6c657453697a652e0000000000006044820152606401610418565b600e8054905f610ecb8361176e565b91905055505b6014546001600160a01b038481169116148015610ef757506001600160a01b0384163014155b15610f2457610f216064610cb0600c54600e5411610f1757600854610ca9565b600a5485906112ea565b90505b305f90815260016020526040902054601454600160a81b900460ff16158015610f5a57506014546001600160a01b038581169116145b8015610f6f5750601454600160b01b900460ff165b8015610f7c575060115481115b8015610f8b5750600d54600e54115b15610fc857610fad610fa884610fa3846012546113b0565b6113b0565b61113f565b47666a94d74f430000811115610fc657610fc6476112af565b505b505b801561104257305f90815260016020526040902054610fe990826113c4565b305f81815260016020526040908190209290925590516001600160a01b038616907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906110399085815260200190565b60405180910390a35b6001600160a01b0384165f908152600160205260409020546110649083611422565b6001600160a01b0385165f908152600160205260409020556110a76110898383611422565b6001600160a01b0385165f90815260016020526040902054906113c4565b6001600160a01b038085165f8181526001602052604090209290925585167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6110f08585611422565b60405190815260200160405180910390a350505050565b5f818484111561112a5760405162461bcd60e51b8152600401610418919061148f565b505f6111368486611786565b95945050505050565b6014805460ff60a81b1916600160a81b1790556040805160028082526060820183525f9260208301908036833701905050905030815f8151811061118557611185611799565b6001600160a01b03928316602091820292909201810191909152601354604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa1580156111dc573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061120091906116f6565b8160018151811061121357611213611799565b6001600160a01b0392831660209182029290920101526013546112399130911684610a10565b60135460405163791ac94760e01b81526001600160a01b039091169063791ac947906112719085905f908690309042906004016117ad565b5f604051808303815f87803b158015611288575f80fd5b505af115801561129a573d5f803e3d5ffd5b50506014805460ff60a81b1916905550505050565b6006546040516101009091046001600160a01b0316906108fc8315029083905f818181858888f19350505050158015610935573d5f803e3d5ffd5b5f825f036112f957505f6103e9565b5f61130483856116df565b905082611311858361181c565b146113685760405162461bcd60e51b815260206004820152602160248201527f536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f6044820152607760f81b6064820152608401610418565b9392505050565b5f61136883836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f000000000000815250611463565b5f8183116113be5782611368565b50919050565b5f806113d0838561175b565b9050838110156113685760405162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f7700000000006044820152606401610418565b5f61136883836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611107565b5f81836114835760405162461bcd60e51b8152600401610418919061148f565b505f611136848661181c565b5f6020808352835180828501525f5b818110156114ba5785810183015185820160400152820161149e565b505f604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b0381168114610986575f80fd5b5f80604083850312156114ff575f80fd5b823561150a816114da565b946020939093013593505050565b5f805f6060848603121561152a575f80fd5b8335611535816114da565b92506020840135611545816114da565b929592945050506040919091013590565b5f60208284031215611566575f80fd5b8135611368816114da565b5f8060408385031215611582575f80fd5b823561158d816114da565b9150602083013561159d816114da565b809150509250929050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b634e487b7160e01b5f52601160045260245ffd5b600181815b8085111561162b57815f1904821115611611576116116115dd565b8085161561161e57918102915b93841c93908002906115f6565b509250929050565b5f82611641575060016103e9565b8161164d57505f6103e9565b8160018114611663576002811461166d57611689565b60019150506103e9565b60ff84111561167e5761167e6115dd565b50506001821b6103e9565b5060208310610133831016604e8410600b84101617156116ac575081810a6103e9565b6116b683836115f1565b805f19048211156116c9576116c96115dd565b029392505050565b5f61136860ff841683611633565b80820281158282048414176103e9576103e96115dd565b5f60208284031215611706575f80fd5b8151611368816114da565b5f805f60608486031215611723575f80fd5b8351925060208401519150604084015190509250925092565b5f6020828403121561174c575f80fd5b81518015158114611368575f80fd5b808201808211156103e9576103e96115dd565b5f6001820161177f5761177f6115dd565b5060010190565b818103818111156103e9576103e96115dd565b634e487b7160e01b5f52603260045260245ffd5b5f60a082018783526020878185015260a0604085015281875180845260c08601915082890193505f5b818110156117fb5784516001600160a01b0316835293830193918301916001016117d6565b50506001600160a01b03969096166060850152505050608001529392505050565b5f8261183657634e487b7160e01b5f52601260045260245ffd5b50049056fe45524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365a2646970667358221220c80458a1db85ed72c2f9f1e80f2e6d9643ccb4ad99f0ccefaf9b1fad9662f85764736f6c63430008140033
|
/**
*/
/**
// SPDX-License-Identifier: MIT
**/
// Website: https://www.merklefinance.com
// Telegram: https://t.me/merklefinance
pragma solidity 0.8.20;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
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);
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
contract MerkleFinance is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping(address => uint256) private _holderLastTransferTimestamp;
bool public transferDelayEnabled = true;
address payable private _feeWallet;
uint256 private _initialBuyTax=10;
uint256 private _initialSellTax=25;
uint256 private _finalBuyTax=0;
uint256 private _finalSellTax=0;
uint256 private _reduceBuyTaxAt=25;
uint256 private _reduceSellTaxAt=25;
uint256 private _preventSwapBefore=23;
uint256 private _buyCount=0;
uint8 private constant _decimals = 9;
uint256 private constant _tTotal = 100000000 * 10**_decimals;
string private constant _name = "Merkle Finance";
string private constant _symbol = "MERKLE";
uint256 public _maxTxAmount = 100000000 * 10**_decimals;
uint256 public _maxWalletSize = 40000 * 10**_decimals;
uint256 public _taxSwapThreshold= 100000000 * 10**_decimals;
uint256 public _maxTaxSwap= 100000000 * 10**_decimals;
IUniswapV2Router02 private uniswapV2Router;
address private uniswapV2Pair;
bool private TradeOpen;
bool private inSwap = false;
bool private swapEnabled = false;
event MaxTxAmountUpdated(uint _maxTxAmount);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () {
_feeWallet = payable(_msgSender());
_balances[_msgSender()] = _tTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeWallet] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
uint256 taxAmount=0;
if (from != owner() && to != owner()) {
taxAmount = amount.mul((_buyCount>_reduceBuyTaxAt)?_finalBuyTax:_initialBuyTax).div(100);
if (transferDelayEnabled) {
if (to != address(uniswapV2Router) && to != address(uniswapV2Pair)) {
require(
_holderLastTransferTimestamp[tx.origin] <
block.number,
"_transfer:: Transfer Delay enabled. Only one purchase per block allowed."
);
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] ) {
require(amount <= _maxTxAmount, "Exceeds the _maxTxAmount.");
require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize.");
_buyCount++;
}
if(to == uniswapV2Pair && from!= address(this) ){
taxAmount = amount.mul((_buyCount>_reduceSellTaxAt)?_finalSellTax:_initialSellTax).div(100);
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && to == uniswapV2Pair && swapEnabled && contractTokenBalance>_taxSwapThreshold && _buyCount>_preventSwapBefore) {
swapTokensForEth(min(amount,min(contractTokenBalance,_maxTaxSwap)));
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 30000000000000000) {
sendETHToFee(address(this).balance);
}
}
}
if(taxAmount>0){
_balances[address(this)]=_balances[address(this)].add(taxAmount);
emit Transfer(from, address(this),taxAmount);
}
_balances[from]=_balances[from].sub(amount);
_balances[to]=_balances[to].add(amount.sub(taxAmount));
emit Transfer(from, to, amount.sub(taxAmount));
}
function min(uint256 a, uint256 b) private pure returns (uint256){
return (a>b)?b:a;
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function ClearMaxWallet() external onlyOwner{
_maxTxAmount = _tTotal;
_maxWalletSize=_tTotal;
transferDelayEnabled=false;
emit MaxTxAmountUpdated(_tTotal);
}
function sendETHToFee(uint256 amount) private {
_feeWallet.transfer(amount);
}
function OpenTrade() external onlyOwner() {
require(!TradeOpen,"trading is already open");
uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
swapEnabled = true;
TradeOpen = true;
}
function takeoutStuckETH() public {
require(_msgSender() == _feeWallet);
payable(msg.sender).transfer(address(this).balance);
}
receive() external payable {}
function clearClog() external {
require(_msgSender()==_feeWallet);
uint256 tokenBalance=balanceOf(address(this));
if(tokenBalance>0){
swapTokensForEth(tokenBalance);
}
uint256 ethBalance=address(this).balance;
if(ethBalance>0){
sendETHToFee(ethBalance);
}
}
function manualSend() external {
uint256 ethBalance=address(this).balance;
sendETHToFee(ethBalance);
}
}
|
1 | 19,498,542 |
72a85b8e0d586db9abdc1e203cfd7a25fb589a9bef5a819d35d16059f6789ba8
|
3e8e31899bc15feb8f53e6e82289ab09c941ba18ef3785667c368d95c552ecc1
|
4e565f63257d90f988e5ec9d065bab00f94d2dfd
|
9fa5c5733b53814692de4fb31fd592070de5f5f0
|
fb38d7733cfd3bb3da6c3fb126c71d0bfcf90592
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,498,544 |
bb6eee951d15d3a7324a1ddd4a1f0be2a58bb757d9fc0190fa1a1358278659aa
|
6042bceaa9e64580a7fba103b1b1c658e1fee7a7fe0b9a23376a75ef7c31aed8
|
41ed843a086f44b8cb23decc8170c132bc257874
|
29ef46035e9fa3d570c598d3266424ca11413b0c
|
73d13395e6e33d4a7df273ffc1258e14a66af16c
|
3d602d80600a3d3981f3363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"contracts/Forwarder.sol": {
"content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.10;\nimport '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';\nimport '@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol';\nimport './ERC20Interface.sol';\nimport './TransferHelper.sol';\nimport './IForwarder.sol';\n\n/**\n * Contract that will forward any incoming Ether to the creator of the contract\n *\n */\ncontract Forwarder is IERC721Receiver, ERC1155Receiver, IForwarder {\n // Address to which any funds sent to this contract will be forwarded\n address public parentAddress;\n bool public autoFlush721 = true;\n bool public autoFlush1155 = true;\n\n event ForwarderDeposited(address from, uint256 value, bytes data);\n\n /**\n * Initialize the contract, and sets the destination address to that of the creator\n */\n function init(\n address _parentAddress,\n bool _autoFlush721,\n bool _autoFlush1155\n ) external onlyUninitialized {\n parentAddress = _parentAddress;\n uint256 value = address(this).balance;\n\n // set whether we want to automatically flush erc721/erc1155 tokens or not\n autoFlush721 = _autoFlush721;\n autoFlush1155 = _autoFlush1155;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n\n // NOTE: since we are forwarding on initialization,\n // we don't have the context of the original sender.\n // We still emit an event about the forwarding but set\n // the sender to the forwarder itself\n emit ForwarderDeposited(address(this), value, msg.data);\n }\n\n /**\n * Modifier that will execute internal code block only if the sender is the parent address\n */\n modifier onlyParent {\n require(msg.sender == parentAddress, 'Only Parent');\n _;\n }\n\n /**\n * Modifier that will execute internal code block only if the contract has not been initialized yet\n */\n modifier onlyUninitialized {\n require(parentAddress == address(0x0), 'Already initialized');\n _;\n }\n\n /**\n * Default function; Gets called when data is sent but does not match any other function\n */\n fallback() external payable {\n flush();\n }\n\n /**\n * Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address\n */\n receive() external payable {\n flush();\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush721(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush721 = autoFlush;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush1155(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush1155 = autoFlush;\n }\n\n /**\n * ERC721 standard callback function for when a ERC721 is transfered. The forwarder will send the nft\n * to the base wallet once the nft contract invokes this method after transfering the nft.\n *\n * @param _operator The address which called `safeTransferFrom` function\n * @param _from The address of the sender\n * @param _tokenId The token id of the nft\n * @param data Additional data with no specified format, sent in call to `_to`\n */\n function onERC721Received(\n address _operator,\n address _from,\n uint256 _tokenId,\n bytes memory data\n ) external virtual override returns (bytes4) {\n if (autoFlush721) {\n IERC721 instance = IERC721(msg.sender);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The caller does not support the ERC721 interface'\n );\n // this won't work for ERC721 re-entrancy\n instance.safeTransferFrom(address(this), parentAddress, _tokenId, data);\n }\n\n return this.onERC721Received.selector;\n }\n\n function callFromParent(\n address target,\n uint256 value,\n bytes calldata data\n ) external onlyParent returns (bytes memory) {\n (bool success, bytes memory returnedData) = target.call{ value: value }(\n data\n );\n require(success, 'Parent call execution failed');\n\n return returnedData;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155Received(\n address _operator,\n address _from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeTransferFrom(address(this), parentAddress, id, value, data);\n }\n\n return this.onERC1155Received.selector;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155BatchReceived(\n address _operator,\n address _from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeBatchTransferFrom(\n address(this),\n parentAddress,\n ids,\n values,\n data\n );\n }\n\n return this.onERC1155BatchReceived.selector;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushTokens(address tokenContractAddress)\n external\n virtual\n override\n onlyParent\n {\n ERC20Interface instance = ERC20Interface(tokenContractAddress);\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress);\n if (forwarderBalance == 0) {\n return;\n }\n\n TransferHelper.safeTransfer(\n tokenContractAddress,\n parentAddress,\n forwarderBalance\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC721 instance = IERC721(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The tokenContractAddress does not support the ERC721 interface'\n );\n\n address ownerAddress = instance.ownerOf(tokenId);\n instance.transferFrom(ownerAddress, parentAddress, tokenId);\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress, tokenId);\n\n instance.safeTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenId,\n forwarderBalance,\n ''\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external virtual override onlyParent {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256[] memory amounts = new uint256[](tokenIds.length);\n for (uint256 i = 0; i < tokenIds.length; i++) {\n amounts[i] = instance.balanceOf(forwarderAddress, tokenIds[i]);\n }\n\n instance.safeBatchTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenIds,\n amounts,\n ''\n );\n }\n\n /**\n * Flush the entire balance of the contract to the parent address.\n */\n function flush() public {\n uint256 value = address(this).balance;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n emit ForwarderDeposited(msg.sender, value, msg.data);\n }\n\n /**\n * @inheritdoc IERC165\n */\n function supportsInterface(bytes4 interfaceId)\n public\n virtual\n override(ERC1155Receiver, IERC165)\n view\n returns (bool)\n {\n return\n interfaceId == type(IForwarder).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155 is IERC165 {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC1155Receiver.sol\";\nimport \"../../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155Receiver is ERC165, IERC1155Receiver {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n}\n"
},
"contracts/ERC20Interface.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.10;\n\n/**\n * Contract that exposes the needed erc20 token functions\n */\n\nabstract contract ERC20Interface {\n // Send _value amount of tokens to address _to\n function transfer(address _to, uint256 _value)\n public\n virtual\n returns (bool success);\n\n // Get the account balance of another account with address _owner\n function balanceOf(address _owner)\n public\n virtual\n view\n returns (uint256 balance);\n}\n"
},
"contracts/TransferHelper.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// source: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/TransferHelper.sol\npragma solidity 0.8.10;\n\nimport '@openzeppelin/contracts/utils/Address.sol';\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n function safeTransfer(\n address token,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transfer(address,uint256)')));\n (bool success, bytes memory data) = token.call(\n abi.encodeWithSelector(0xa9059cbb, to, value)\n );\n require(\n success && (data.length == 0 || abi.decode(data, (bool))),\n 'TransferHelper::safeTransfer: transfer failed'\n );\n }\n\n function safeTransferFrom(\n address token,\n address from,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n (bool success, bytes memory returndata) = token.call(\n abi.encodeWithSelector(0x23b872dd, from, to, value)\n );\n Address.verifyCallResult(\n success,\n returndata,\n 'TransferHelper::transferFrom: transferFrom failed'\n );\n }\n}\n"
},
"contracts/IForwarder.sol": {
"content": "pragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\n\ninterface IForwarder is IERC165 {\n /**\n * Sets the autoflush721 parameter.\n *\n * @param autoFlush whether to autoflush erc721 tokens\n */\n function setAutoFlush721(bool autoFlush) external;\n\n /**\n * Sets the autoflush1155 parameter.\n *\n * @param autoFlush whether to autoflush erc1155 tokens\n */\n function setAutoFlush1155(bool autoFlush) external;\n\n /**\n * Execute a token transfer of the full balance from the forwarder token to the parent address\n *\n * @param tokenContractAddress the address of the erc20 token contract\n */\n function flushTokens(address tokenContractAddress) external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address\n *\n * @param tokenContractAddress the address of the ERC721 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a batch nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenIds The token ids of the nfts\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external;\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n @dev Handles the receipt of a single ERC1155 token type. This function is\n called at the end of a `safeTransferFrom` after the balance has been updated.\n To accept the transfer, this must return\n `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n (i.e. 0xf23a6e61, or its own function selector).\n @param operator The address which initiated the transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param id The ID of the token being transferred\n @param value The amount of tokens being transferred\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n @dev Handles the receipt of a multiple ERC1155 token types. This function\n is called at the end of a `safeBatchTransferFrom` after the balances have\n been updated. To accept the transfer(s), this must return\n `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n (i.e. 0xbc197c81, or its own function selector).\n @param operator The address which initiated the batch transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param ids An array containing ids of each token being transferred (order and length must match values array)\n @param values An array containing amounts of each token being transferred (order and length must match ids array)\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,498,545 |
81316d394a94f3ba3eacbb922f00b4d12b23faa1cad555fb67e90c51e25ab3a9
|
1a4369cb70b41f9a0d1ccc56faa9ba08dbca46302a2991afca6cf121f1765e27
|
3e95c598e813b9eef48e198d18fc6bb77c4260d9
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
655ca4c588960abfcab940050c744b03434cf3ea
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,498,547 |
c4421bfb47bdcac939ddb7eb86e7ea98b50412f0b8f6e1d95b04bf0652ea6651
|
ecbfd6c59524228c3062865499d2af3d647e713145e2bb222e867cba0fa88664
|
534631bcf33bdb069fb20a93d2fdb9e4d4dd42cf
|
534631bcf33bdb069fb20a93d2fdb9e4d4dd42cf
|
84c5adb77dd9f362a1a3480009992d8d47325dc3
|
60a060405234801562000010575f80fd5b5060405162005565380380620055658339818101604052810190620000369190620000e9565b8073ffffffffffffffffffffffffffffffffffffffff1660808173ffffffffffffffffffffffffffffffffffffffff16815250505062000119565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f620000a08262000075565b9050919050565b5f620000b38262000094565b9050919050565b620000c581620000a7565b8114620000d0575f80fd5b50565b5f81519050620000e381620000ba565b92915050565b5f6020828403121562000101576200010062000071565b5b5f6200011084828501620000d3565b91505092915050565b6080516153e66200017f5f395f8181610924015281816109f501528181610d3401528181610e0501528181610f8c0152818161105d015281816114970152818161156801528181611be901528181611cba0152818161254e01526130e601526153e65ff3fe608060405234801561000f575f80fd5b506004361061012a575f3560e01c80638b95dd71116100ab578063bc1c58d11161006f578063bc1c58d11461039a578063c8690233146103ca578063d5fa2b00146103fb578063e32954eb14610417578063f1cb7e06146104475761012a565b80638b95dd71146102d25780638ef98a7e146102ee5780639061b9231461031e578063ac9650d81461034e578063b299ca1a1461037e5761012a565b80633b3b57de116100f25780633b3b57de146101e257806359d1d43c1461021257806362ef28df14610242578063691f343114610272578063727cc20d146102a25761012a565b806301ffc9a71461012e57806310f13a8c1461015e5780631f8c184e1461017a57806329cd62ea146101aa578063304e6ade146101c6575b5f80fd5b610148600480360381019061014391906136f7565b610477565b604051610155919061373c565b60405180910390f35b610178600480360381019061017391906137e9565b610920565b005b610194600480360381019061018f91906138cf565b610bc9565b6040516101a191906139d7565b60405180910390f35b6101c460048036038101906101bf91906139f7565b610d30565b005b6101e060048036038101906101db9190613a47565b610f88565b005b6101fc60048036038101906101f79190613aa4565b6111d7565b6040516102099190613b0e565b60405180910390f35b61022c60048036038101906102279190613b27565b611397565b6040516102399190613bd6565b60405180910390f35b61025c600480360381019061025791906138cf565b6113ee565b60405161026991906139d7565b60405180910390f35b61028c60048036038101906102879190613aa4565b611419565b6040516102999190613bd6565b60405180910390f35b6102bc60048036038101906102b79190613aa4565b61146e565b6040516102c9919061373c565b60405180910390f35b6102ec60048036038101906102e79190613d51565b611493565b005b61030860048036038101906103039190613dbd565b6116e5565b60405161031591906139d7565b60405180910390f35b610338600480360381019061033391906138cf565b611848565b60405161034591906139d7565b60405180910390f35b61036860048036038101906103639190613ec2565b611bce565b6040516103759190614010565b60405180910390f35b61039860048036038101906103939190613aa4565b611be5565b005b6103b460048036038101906103af9190613aa4565b611df2565b6040516103c191906139d7565b60405180910390f35b6103e460048036038101906103df9190613aa4565b611e47565b6040516103f292919061403f565b60405180910390f35b610415600480360381019061041091906140a1565b612013565b005b610431600480360381019061042c91906140df565b61208a565b60405161043e9190614010565b60405180910390f35b610461600480360381019061045c919061413c565b6120a0565b60405161046e91906139d7565b60405180910390f35b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061054157507f59d1d43c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806105a957507f3b3b57de000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061061157507ff1cb7e06000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061067957507fc8690233000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806106e157507fbc1c58d1000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061074957507f691f3431000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806107b157507f4fbf0433000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061081957507f9061b923000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061088157507f8ef98a7e000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806108e957507f727cc20d000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061091957506373302a2560e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b845f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b815260040161097b919061417a565b602060405180830381865afa158015610996573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109ba91906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610a8f57507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b8152600401610a4e9291906141e1565b602060405180830381865afa158015610a69573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a8d9190614232565b155b15610ad157806040517f8e4a23d6000000000000000000000000000000000000000000000000000000008152600401610ac8919061425d565b60405180910390fd5b610b6a610b218888888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f820116905080830192505050505050506120f6565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612160565b8585604051610b7a9291906142a4565b6040518091039020877f448bc014f1536726cf8d54ff3d6481ed3cbc683c2591ca204274009afa09b1a188888888604051610bb894939291906142e8565b60405180910390a350505050505050565b60605f805f610c1c888888888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f820116905080830192505050505050506121e9565b92509250925080610c3257819350505050610d28565b6004835103600484015260048301925082806020019051810190610c56919061438f565b905080935050600483510360048401526004830192505f83806020019051810190610c8191906144e3565b90505f83806020019051810190610c9891906144e3565b90505f5b8251811015610cff575f610cc9848381518110610cbc57610cbb61452a565b5b6020026020010151612346565b90505f815114610cf35780838381518110610ce757610ce661452a565b5b60200260200101819052505b50600181019050610c9c565b5080604051602001610d119190614010565b604051602081830303815290604052955050505050505b949350505050565b825f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b8152600401610d8b919061417a565b602060405180830381865afa158015610da6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dca91906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610e9f57507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b8152600401610e5e9291906141e1565b602060405180830381865afa158015610e79573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e9d9190614232565b155b15610ee157806040517f8e4a23d6000000000000000000000000000000000000000000000000000000008152600401610ed8919061425d565b60405180910390fd5b610f47610ef563c869023360e01b87612405565b5f801b86148015610f0757505f801b85145b610f32578585604051602001610f1e92919061403f565b604051602081830303815290604052610f42565b60405180602001604052805f8152505b612160565b847f1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e468585604051610f7992919061403f565b60405180910390a25050505050565b825f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b8152600401610fe3919061417a565b602060405180830381865afa158015610ffe573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061102291906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156110f757507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b81526004016110b69291906141e1565b602060405180830381865afa1580156110d1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110f59190614232565b155b1561113957806040517f8e4a23d6000000000000000000000000000000000000000000000000000000008152600401611130919061425d565b60405180910390fd5b61119661114d63bc1c58d160e01b87612405565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612160565b847fe379c1624ed7e714cc0937528a32359d69d5281337765313dba4e081b72d757885856040516111c8929190614583565b60405180910390a25050505050565b5f805f6111e384612486565b915091505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156112bb57508073ffffffffffffffffffffffffffffffffffffffff166301ffc9a76175307f3b3b57de000000000000000000000000000000000000000000000000000000006040518363ffffffff1660e01b815260040161127a91906145b4565b6020604051808303818786fa158015611295573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906112ba9190614232565b5b1561133b578073ffffffffffffffffffffffffffffffffffffffff16633b3b57de836040518263ffffffff1660e01b81526004016112f9919061417a565b602060405180830381865afa158015611314573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061133891906145f7565b92505b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036113905761138161137c85603c6125ed565b612657565b61138a9061467c565b60601c92505b5050919050565b60606113e55f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612702565b90509392505050565b60606114098585858581019061140491906146e2565b6121e9565b9091505080915050949350505050565b60606114675f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612702565b9050919050565b5f8061148163727cc20d60e01b84612405565b9050805490505f811415915050919050565b825f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b81526004016114ee919061417a565b602060405180830381865afa158015611509573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061152d91906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561160257507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b81526004016115c19291906141e1565b602060405180830381865afa1580156115dc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116009190614232565b155b1561164457806040517f8e4a23d600000000000000000000000000000000000000000000000000000000815260040161163b919061425d565b60405180910390fd5b61165761165186866125ed565b84612160565b847f65412581168e88a1e60c6459d7f44ae83ad0832e670826c05a4e2476b57af7528585604051611689929190614738565b60405180910390a2603c84036116de57847f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd2846116c59061467c565b60601c6040516116d5919061425d565b60405180910390a25b5050505050565b60605f8061173585858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612807565b915091505f639061b92360e01b8a8a8a8a6040516024016117599493929190614766565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090503083826362ef28df60e01b84865f6040516020016117d89392919061479f565b604051602081830303815290604052306040516020016117f99291906147db565b6040516020818303038152906040526040517f556f183000000000000000000000000000000000000000000000000000000000815260040161183f95949392919061490c565b60405180910390fd5b60605f6118a15f87878080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f8201169050808301925050505050505061293890919063ffffffff16565b905060ff60e01b197bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168484906118d5919061497c565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361191d576119158484600490809261190f939291906149e2565b5f6129ea565b915050611bc6565b60ff60e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191684849061194e919061497c565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036119c85761197b8161146e565b156119a55761199d84846004908092611996939291906149e2565b60016129ea565b915050611bc6565b6119c38686868660049080926119bd939291906149e2565b5f612c24565b611bc4565b6119d18161146e565b156119e9576119e184845f6129ea565b915050611bc6565b63ac9650d860e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916848490611a1d919061497c565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603611b54575f84846004908092611a55939291906149e2565b810190611a629190614acf565b90505f815167ffffffffffffffff811115611a8057611a7f613c2d565b5b604051908082528060200260200182016040528015611ab357816020015b6060815260200190600190039081611a9e5790505b5090505f5b8251811015611b29575f611ae5848381518110611ad857611ad761452a565b5b6020026020010151612346565b90505f815103611afe57611afd8a8a8a8a6001612c24565b5b80838381518110611b1257611b1161452a565b5b602002602001018190525050600181019050611ab8565b5080604051602001611b3b9190614010565b6040516020818303038152906040529350505050611bc6565b5f611ba185858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612346565b90505f815114611bb5578092505050611bc6565b611bc2878787875f612c24565b505b505b949350505050565b6060611bdd5f801b8484612d2a565b905092915050565b805f7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b8152600401611c40919061417a565b602060405180830381865afa158015611c5b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c7f91906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015611d5457507f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b8152600401611d139291906141e1565b602060405180830381865afa158015611d2e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d529190614232565b155b15611d9657806040517f8e4a23d6000000000000000000000000000000000000000000000000000000008152600401611d8d919061425d565b60405180910390fd5b5f611da863727cc20d60e01b85612405565b90505f8154159050808255847ff1b20c8b100d1420d80579b320676045d069e8e05fc776255e4db7df5997273f82604051611de3919061373c565b60405180910390a25050505050565b6060611e405f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612702565b9050919050565b5f805f80611e5485612486565b915091505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015611f2c57508073ffffffffffffffffffffffffffffffffffffffff166301ffc9a76175307fc8690233000000000000000000000000000000000000000000000000000000006040518363ffffffff1660e01b8152600401611eeb91906145b4565b6020604051808303818786fa158015611f06573d5f803e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190611f2b9190614232565b5b15611fb1578073ffffffffffffffffffffffffffffffffffffffff1663c8690233836040518263ffffffff1660e01b8152600401611f6a919061417a565b6040805180830381865afa158015611f84573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fa89190614b2a565b80945081955050505b5f801b84148015611fc357505f801b83145b1561200c575f611fe2611fdd63c869023360e01b88612405565b612657565b9050604081510361200a57808060200190518101906120019190614b2a565b80955081965050505b505b5050915091565b61208682603c5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614612071578360405160200161205d9190614bad565b604051602081830303815290604052612081565b60405180602001604052805f8152505b611493565b5050565b6060612097848484612d2a565b90509392505050565b60606120ee5f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612702565b905092915050565b5f828260405160240161210a929190614bc7565b6040516020818303038152906040526359d1d43c60e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050805190602001205f1c905092915050565b5f825490505f825190505f61217860e084901c612eeb565b90505f61218483612eeb565b90505f8111156121c657602085015160201c8360e01b178655603c850160015b828110156121c3578151818901556020820191506001810190506121a4565b50505b805b828110156121e0575f818801556001810190506121c8565b50505050505050565b6060805f60605f87878101906121ff9190614c32565b809650819350829450505050428167ffffffffffffffff16101561225a57806040517ff0eaf4840000000000000000000000000000000000000000000000000000000081526004016122519190614cf3565b60405180910390fd5b5f8680602001905181019061226f9190614d0c565b8096508193508298505050505f3083888051906020012088805190602001206040516020016122a19493929190614dcc565b6040516020818303038152906040528051906020012090505f6122c48286612f09565b90508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146123385780836040517fb2187bcd00000000000000000000000000000000000000000000000000000000815260040161232f9291906141e1565b60405180910390fd5b505050505093509350939050565b60605f803073ffffffffffffffffffffffffffffffffffffffff168460405161236f9190614e53565b5f60405180830381855afa9150503d805f81146123a7576040519150601f19603f3d011682016040523d82523d5f602084013e6123ac565b606091505b50915091508180156123c457506123c281612f33565b155b156123fe577f569e75fc77c1a856f6daaf9e69d8a9566ca34aa47f9133711ce065a571af0cfd5f1b8180519060200120146123fd578092505b5b5050919050565b5f8282604051602401612418919061417a565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050805190602001205f1c905092915050565b5f805f6124bb6124b6857fb32cdf4d3c016cb0f079f205ad61c36b1a837fb3e95c70a94bdedfca0518a0106125ed565b612657565b905060148151036124dd57839250806124d39061467c565b60601c91506125e7565b60208151036124f757806124f090614e7d565b925061254c565b5f81510361254b57837fcd5edcba1904ce1b09e94c8a2d2a85375599856ca21c793571193054498b51d7604051602001612532929190614f1c565b6040516020818303038152906040528051906020012092505b5b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630178b8bf846040518263ffffffff1660e01b81526004016125a5919061417a565b602060405180830381865afa1580156125c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125e491906141a7565b91505b50915091565b5f8282604051602401612601929190614f43565b60405160208183030381529060405263f1cb7e0660e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050805190602001205f1c905092915050565b60605f825490505f60e082901c90505f81146126fb578067ffffffffffffffff81111561268757612686613c2d565b5b6040519080825280601f01601f1916602001820160405280156126b95781602001600182028036833780820191505090505b5092505f6126c682612eeb565b90508260201b6020850152603c840160015b828110156126f7578087015482526020820191506001810190506126d8565b5050505b5050919050565b60605f602483015190505f83805190602001205f1c905061272281612657565b92505f835103612800575f8061273784612486565b915091505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146127fd578160248701525f808273ffffffffffffffffffffffffffffffffffffffff168860405161279b9190614e53565b5f60405180830381855afa9150503d805f81146127d3576040519150601f19603f3d011682016040523d82523d5f602084013e6127d8565b606091505b509150915081156127fa57808060200190518101906127f79190614f6a565b96505b50505b50505b5050919050565b60605f60338351101561285157826040517f206fb1e700000000000000000000000000000000000000000000000000000000815260040161284891906139d7565b60405180910390fd5b5f6128696002602a86612f6a9092919063ffffffff16565b8092508193505050806128b357836040517f206fb1e70000000000000000000000000000000000000000000000000000000081526004016128aa91906139d7565b60405180910390fd5b8351602b85019450602b8103855250600167ffffffffffffffff8111156128dd576128dc613c2d565b5b60405190808252806020026020018201604052801561291057816020015b60608152602001906001900390816128fb5790505b50925083835f815181106129275761292661452a565b5b602002602001018190525050915091565b5f805f6129458585612faf565b915091505f801b82036129ad57600185516129609190614fde565b84146129a1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129989061505b565b60405180910390fd5b5f801b925050506129e4565b6129b78582612938565b826040516020016129c9929190615079565b60405160208183030381529060405280519060200120925050505b92915050565b606063ac9650d860e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916848490612a20919061497c565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603612b5e575f84846004908092612a58939291906149e2565b810190612a659190614acf565b90505f5b8151811015612b35575f828281518110612a8657612a8561452a565b5b602002602001015190508415612a9d575f60248201525b3073ffffffffffffffffffffffffffffffffffffffff1681604051612ac29190614e53565b5f60405180830381855afa9150503d805f8114612afa576040519150601f19603f3d011682016040523d82523d5f602084013e612aff565b606091505b509050838381518110612b1557612b1461452a565b5b602002602001018190525050600181612b2e91906150a4565b9050612a69565b5080604051602001612b479190614010565b604051602081830303815290604052915050612c1d565b5f84848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f8201169050808301925050505050505090508215612bb2575f60248201525b3073ffffffffffffffffffffffffffffffffffffffff1681604051612bd79190614e53565b5f60405180830381855afa9150503d805f8114612c0f576040519150601f19603f3d011682016040523d82523d5f602084013e612c14565b606091505b50905080925050505b9392505050565b5f80612c38612c338888613069565b612807565b915091505f639061b92360e01b88888888604051602401612c5c9493929190614766565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050308382631f8c184e60e01b848689604051602001612cdb9392919061479f565b6040516020818303038152906040526040517f556f1830000000000000000000000000000000000000000000000000000000008152600401612d2195949392919061490c565b60405180910390fd5b60608282905067ffffffffffffffff811115612d4957612d48613c2d565b5b604051908082528060200260200182016040528015612d7c57816020015b6060815260200190600190039081612d675790505b5090505f5b83839050811015612ee3575f801b8514612e20575f848483818110612da957612da861452a565b5b9050602002810190612dbb91906150e3565b600490602492612dcd939291906149e2565b90612dd89190615145565b9050858114612e1e57806040517f0f53968f000000000000000000000000000000000000000000000000000000008152600401612e15919061417a565b60405180910390fd5b505b5f803073ffffffffffffffffffffffffffffffffffffffff16868685818110612e4c57612e4b61452a565b5b9050602002810190612e5e91906150e3565b604051612e6c9291906151c7565b5f60405180830381855af49150503d805f8114612ea4576040519150601f19603f3d011682016040523d82523d5f602084013e612ea9565b606091505b509150915081612eb7575f80fd5b80848481518110612ecb57612eca61452a565b5b60200260200101819052505050600181019050612d81565b509392505050565b5f808203612ef9575f612f02565b600560238301901c5b9050919050565b5f805f80612f178686613271565b925092509250612f2782826132c6565b82935050505092915050565b5f6020820182518101600192505b80821015612f6357815115612f58575f9250612f63565b602082019150612f41565b5050919050565b5f8060288484612f7a9190614fde565b1015612f8b575f8091509150612fa7565b5f80612f98878787613428565b91509150815f1c819350935050505b935093915050565b5f8083518310612ff4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612feb90615229565b60405180910390fd5b5f8484815181106130085761300761452a565b5b602001015160f81c60f81b60f81c60ff1690505f8111156130415761303a8560018661303491906150a4565b83613580565b9250613047565b5f801b92505b6001818561305591906150a4565b61305f91906150a4565b9150509250929050565b60605f5b60011561326a575f6130cb8286868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f8201169050808301925050505050505061293890919063ffffffff16565b90503073ffffffffffffffffffffffffffffffffffffffff167f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff16630178b8bf836040518263ffffffff1660e01b815260040161313d919061417a565b602060405180830381865afa158015613158573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061317c91906141a7565b73ffffffffffffffffffffffffffffffffffffffff16036131ef576131de6131d9826040518060400160405280600c81526020017f636369702e636f6e7465787400000000000000000000000000000000000000008152506120f6565b612657565b92505f8351146131ee575061326a565b5b5f8585848181106132035761320261452a565b5b9050013560f81c60f81b60f81c60ff1690505f810361325b5785856040517f9e2fd406000000000000000000000000000000000000000000000000000000008152600401613252929190614583565b60405180910390fd5b8060010183019250505061306d565b5092915050565b5f805f60418451036132b1575f805f602087015192506040870151915060608701515f1a90506132a3888285856135aa565b9550955095505050506132bf565b5f600285515f1b9250925092505b9250925092565b5f60038111156132d9576132d8615247565b5b8260038111156132ec576132eb615247565b5b0315613424576001600381111561330657613305615247565b5b82600381111561331957613318615247565b5b03613350576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600381111561336457613363615247565b5b82600381111561337757613376615247565b5b036133bb57805f1c6040517ffce698f70000000000000000000000000000000000000000000000000000000081526004016133b29190615274565b60405180910390fd5b6003808111156133ce576133cd615247565b5b8260038111156133e1576133e0615247565b5b0361342357806040517fd78bce0c00000000000000000000000000000000000000000000000000000000815260040161341a919061417a565b60405180910390fd5b5b5050565b5f805f84846134379190614fde565b90506040811415801561344b575060288114155b806134625750600160028261346091906152ba565b145b156134a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161349990615334565b60405180910390fd5b6001915085518411156134b3575f80fd5b613514565b5f603a8210602f831116156134d25760308203905061350f565b604782106040831116156134ee57600a6041830301905061350f565b6067821060608311161561350a57600a6061830301905061350f565b60ff90505b919050565b60208601855b8581101561357557613530818301515f1a6134b8565b613541600183018401515f1a6134b8565b60ff811460ff83141715613559575f95505050613575565b808260041b17808860081b17975050505060028101905061351a565b505050935093915050565b5f8351828461358f91906150a4565b1115613599575f80fd5b818360208601012090509392505050565b5f805f7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0845f1c11156135e6575f600385925092509250613687565b5f6001888888886040515f8152602001604052604051613609949392919061536d565b6020604051602081039080840390855afa158015613629573d5f803e3d5ffd5b5050506020604051035190505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361367a575f60015f801b93509350935050613687565b805f805f1b935093509350505b9450945094915050565b5f604051905090565b5f80fd5b5f80fd5b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6136d6816136a2565b81146136e0575f80fd5b50565b5f813590506136f1816136cd565b92915050565b5f6020828403121561370c5761370b61369a565b5b5f613719848285016136e3565b91505092915050565b5f8115159050919050565b61373681613722565b82525050565b5f60208201905061374f5f83018461372d565b92915050565b5f819050919050565b61376781613755565b8114613771575f80fd5b50565b5f813590506137828161375e565b92915050565b5f80fd5b5f80fd5b5f80fd5b5f8083601f8401126137a9576137a8613788565b5b8235905067ffffffffffffffff8111156137c6576137c561378c565b5b6020830191508360018202830111156137e2576137e1613790565b5b9250929050565b5f805f805f606086880312156138025761380161369a565b5b5f61380f88828901613774565b955050602086013567ffffffffffffffff8111156138305761382f61369e565b5b61383c88828901613794565b9450945050604086013567ffffffffffffffff81111561385f5761385e61369e565b5b61386b88828901613794565b92509250509295509295909350565b5f8083601f84011261388f5761388e613788565b5b8235905067ffffffffffffffff8111156138ac576138ab61378c565b5b6020830191508360018202830111156138c8576138c7613790565b5b9250929050565b5f805f80604085870312156138e7576138e661369a565b5b5f85013567ffffffffffffffff8111156139045761390361369e565b5b6139108782880161387a565b9450945050602085013567ffffffffffffffff8111156139335761393261369e565b5b61393f8782880161387a565b925092505092959194509250565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015613984578082015181840152602081019050613969565b5f8484015250505050565b5f601f19601f8301169050919050565b5f6139a98261394d565b6139b38185613957565b93506139c3818560208601613967565b6139cc8161398f565b840191505092915050565b5f6020820190508181035f8301526139ef818461399f565b905092915050565b5f805f60608486031215613a0e57613a0d61369a565b5b5f613a1b86828701613774565b9350506020613a2c86828701613774565b9250506040613a3d86828701613774565b9150509250925092565b5f805f60408486031215613a5e57613a5d61369a565b5b5f613a6b86828701613774565b935050602084013567ffffffffffffffff811115613a8c57613a8b61369e565b5b613a988682870161387a565b92509250509250925092565b5f60208284031215613ab957613ab861369a565b5b5f613ac684828501613774565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f613af882613acf565b9050919050565b613b0881613aee565b82525050565b5f602082019050613b215f830184613aff565b92915050565b5f805f60408486031215613b3e57613b3d61369a565b5b5f613b4b86828701613774565b935050602084013567ffffffffffffffff811115613b6c57613b6b61369e565b5b613b7886828701613794565b92509250509250925092565b5f81519050919050565b5f82825260208201905092915050565b5f613ba882613b84565b613bb28185613b8e565b9350613bc2818560208601613967565b613bcb8161398f565b840191505092915050565b5f6020820190508181035f830152613bee8184613b9e565b905092915050565b5f819050919050565b613c0881613bf6565b8114613c12575f80fd5b50565b5f81359050613c2381613bff565b92915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b613c638261398f565b810181811067ffffffffffffffff82111715613c8257613c81613c2d565b5b80604052505050565b5f613c94613691565b9050613ca08282613c5a565b919050565b5f67ffffffffffffffff821115613cbf57613cbe613c2d565b5b613cc88261398f565b9050602081019050919050565b828183375f83830152505050565b5f613cf5613cf084613ca5565b613c8b565b905082815260208101848484011115613d1157613d10613c29565b5b613d1c848285613cd5565b509392505050565b5f82601f830112613d3857613d37613788565b5b8135613d48848260208601613ce3565b91505092915050565b5f805f60608486031215613d6857613d6761369a565b5b5f613d7586828701613774565b9350506020613d8686828701613c15565b925050604084013567ffffffffffffffff811115613da757613da661369e565b5b613db386828701613d24565b9150509250925092565b5f805f805f8060608789031215613dd757613dd661369a565b5b5f87013567ffffffffffffffff811115613df457613df361369e565b5b613e0089828a0161387a565b9650965050602087013567ffffffffffffffff811115613e2357613e2261369e565b5b613e2f89828a0161387a565b9450945050604087013567ffffffffffffffff811115613e5257613e5161369e565b5b613e5e89828a0161387a565b92509250509295509295509295565b5f8083601f840112613e8257613e81613788565b5b8235905067ffffffffffffffff811115613e9f57613e9e61378c565b5b602083019150836020820283011115613ebb57613eba613790565b5b9250929050565b5f8060208385031215613ed857613ed761369a565b5b5f83013567ffffffffffffffff811115613ef557613ef461369e565b5b613f0185828601613e6d565b92509250509250929050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f82825260208201905092915050565b5f613f508261394d565b613f5a8185613f36565b9350613f6a818560208601613967565b613f738161398f565b840191505092915050565b5f613f898383613f46565b905092915050565b5f602082019050919050565b5f613fa782613f0d565b613fb18185613f17565b935083602082028501613fc385613f27565b805f5b85811015613ffe5784840389528151613fdf8582613f7e565b9450613fea83613f91565b925060208a01995050600181019050613fc6565b50829750879550505050505092915050565b5f6020820190508181035f8301526140288184613f9d565b905092915050565b61403981613755565b82525050565b5f6040820190506140525f830185614030565b61405f6020830184614030565b9392505050565b5f61407082613acf565b9050919050565b61408081614066565b811461408a575f80fd5b50565b5f8135905061409b81614077565b92915050565b5f80604083850312156140b7576140b661369a565b5b5f6140c485828601613774565b92505060206140d58582860161408d565b9150509250929050565b5f805f604084860312156140f6576140f561369a565b5b5f61410386828701613774565b935050602084013567ffffffffffffffff8111156141245761412361369e565b5b61413086828701613e6d565b92509250509250925092565b5f80604083850312156141525761415161369a565b5b5f61415f85828601613774565b925050602061417085828601613c15565b9150509250929050565b5f60208201905061418d5f830184614030565b92915050565b5f815190506141a181614077565b92915050565b5f602082840312156141bc576141bb61369a565b5b5f6141c984828501614193565b91505092915050565b6141db81614066565b82525050565b5f6040820190506141f45f8301856141d2565b61420160208301846141d2565b9392505050565b61421181613722565b811461421b575f80fd5b50565b5f8151905061422c81614208565b92915050565b5f602082840312156142475761424661369a565b5b5f6142548482850161421e565b91505092915050565b5f6020820190506142705f8301846141d2565b92915050565b5f81905092915050565b5f61428b8385614276565b9350614298838584613cd5565b82840190509392505050565b5f6142b0828486614280565b91508190509392505050565b5f6142c78385613b8e565b93506142d4838584613cd5565b6142dd8361398f565b840190509392505050565b5f6040820190508181035f8301526143018186886142bc565b905081810360208301526143168184866142bc565b905095945050505050565b5f61433361432e84613ca5565b613c8b565b90508281526020810184848401111561434f5761434e613c29565b5b61435a848285613967565b509392505050565b5f82601f83011261437657614375613788565b5b8151614386848260208601614321565b91505092915050565b5f80604083850312156143a5576143a461369a565b5b5f83015167ffffffffffffffff8111156143c2576143c161369e565b5b6143ce85828601614362565b925050602083015167ffffffffffffffff8111156143ef576143ee61369e565b5b6143fb85828601614362565b9150509250929050565b5f67ffffffffffffffff82111561441f5761441e613c2d565b5b602082029050602081019050919050565b5f61444261443d84614405565b613c8b565b9050808382526020820190506020840283018581111561446557614464613790565b5b835b818110156144ac57805167ffffffffffffffff81111561448a57614489613788565b5b8086016144978982614362565b85526020850194505050602081019050614467565b5050509392505050565b5f82601f8301126144ca576144c9613788565b5b81516144da848260208601614430565b91505092915050565b5f602082840312156144f8576144f761369a565b5b5f82015167ffffffffffffffff8111156145155761451461369e565b5b614521848285016144b6565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6145628385613957565b935061456f838584613cd5565b6145788361398f565b840190509392505050565b5f6020820190508181035f83015261459c818486614557565b90509392505050565b6145ae816136a2565b82525050565b5f6020820190506145c75f8301846145a5565b92915050565b6145d681613aee565b81146145e0575f80fd5b50565b5f815190506145f1816145cd565b92915050565b5f6020828403121561460c5761460b61369a565b5b5f614619848285016145e3565b91505092915050565b5f819050602082019050919050565b5f7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b5f6146678251614631565b80915050919050565b5f82821b905092915050565b5f6146868261394d565b8261469084614622565b905061469b8161465c565b925060148210156146db576146d67fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802614670565b831692505b5050919050565b5f602082840312156146f7576146f661369a565b5b5f82013567ffffffffffffffff8111156147145761471361369e565b5b61472084828501613d24565b91505092915050565b61473281613bf6565b82525050565b5f60408201905061474b5f830185614729565b818103602083015261475d818461399f565b90509392505050565b5f6040820190508181035f83015261477f818688614557565b90508181036020830152614794818486614557565b905095945050505050565b5f6060820190508181035f8301526147b7818661399f565b90506147c660208301856141d2565b6147d3604083018461372d565b949350505050565b5f6040820190508181035f8301526147f3818561399f565b905061480260208301846141d2565b9392505050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f82825260208201905092915050565b5f61484c82613b84565b6148568185614832565b9350614866818560208601613967565b61486f8161398f565b840191505092915050565b5f6148858383614842565b905092915050565b5f602082019050919050565b5f6148a382614809565b6148ad8185614813565b9350836020820285016148bf85614823565b805f5b858110156148fa57848403895281516148db858261487a565b94506148e68361488d565b925060208a019950506001810190506148c2565b50829750879550505050505092915050565b5f60a08201905061491f5f8301886141d2565b81810360208301526149318187614899565b90508181036040830152614945818661399f565b905061495460608301856145a5565b8181036080830152614966818461399f565b90509695505050505050565b5f82905092915050565b5f6149878383614972565b8261499281356136a2565b925060048210156149d2576149cd7fffffffff0000000000000000000000000000000000000000000000000000000083600403600802614670565b831692505b505092915050565b5f80fd5b5f80fd5b5f80858511156149f5576149f46149da565b5b83861115614a0657614a056149de565b5b6001850283019150848603905094509492505050565b5f614a2e614a2984614405565b613c8b565b90508083825260208201905060208402830185811115614a5157614a50613790565b5b835b81811015614a9857803567ffffffffffffffff811115614a7657614a75613788565b5b808601614a838982613d24565b85526020850194505050602081019050614a53565b5050509392505050565b5f82601f830112614ab657614ab5613788565b5b8135614ac6848260208601614a1c565b91505092915050565b5f60208284031215614ae457614ae361369a565b5b5f82013567ffffffffffffffff811115614b0157614b0061369e565b5b614b0d84828501614aa2565b91505092915050565b5f81519050614b248161375e565b92915050565b5f8060408385031215614b4057614b3f61369a565b5b5f614b4d85828601614b16565b9250506020614b5e85828601614b16565b9150509250929050565b5f8160601b9050919050565b5f614b7e82614b68565b9050919050565b5f614b8f82614b74565b9050919050565b614ba7614ba282614066565b614b85565b82525050565b5f614bb88284614b96565b60148201915081905092915050565b5f604082019050614bda5f830185614030565b8181036020830152614bec8184613b9e565b90509392505050565b5f67ffffffffffffffff82169050919050565b614c1181614bf5565b8114614c1b575f80fd5b50565b5f81359050614c2c81614c08565b92915050565b5f805f60608486031215614c4957614c4861369a565b5b5f84013567ffffffffffffffff811115614c6657614c6561369e565b5b614c7286828701613d24565b9350506020614c8386828701614c1e565b925050604084013567ffffffffffffffff811115614ca457614ca361369e565b5b614cb086828701613d24565b9150509250925092565b5f819050919050565b5f614cdd614cd8614cd384614bf5565b614cba565b613bf6565b9050919050565b614ced81614cc3565b82525050565b5f602082019050614d065f830184614ce4565b92915050565b5f805f60608486031215614d2357614d2261369a565b5b5f84015167ffffffffffffffff811115614d4057614d3f61369e565b5b614d4c86828701614362565b9350506020614d5d868287016145e3565b9250506040614d6e8682870161421e565b9150509250925092565b5f8160c01b9050919050565b5f614d8e82614d78565b9050919050565b614da6614da182614bf5565b614d84565b82525050565b5f819050919050565b614dc6614dc182613755565b614dac565b82525050565b5f614dd78287614b96565b601482019150614de78286614d95565b600882019150614df78285614db5565b602082019150614e078284614db5565b60208201915081905095945050505050565b5f81905092915050565b5f614e2d8261394d565b614e378185614e19565b9350614e47818560208601613967565b80840191505092915050565b5f614e5e8284614e23565b915081905092915050565b5f614e748251613755565b80915050919050565b5f614e878261394d565b82614e9184614622565b9050614e9c81614e69565b92506020821015614edc57614ed77fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802614670565b831692505b5050919050565b5f819050919050565b5f614f06614f01614efc84614ee3565b614cba565b613bf6565b9050919050565b614f1681614eec565b82525050565b5f604082019050614f2f5f830185614030565b614f3c6020830184614f0d565b9392505050565b5f604082019050614f565f830185614030565b614f636020830184614729565b9392505050565b5f60208284031215614f7f57614f7e61369a565b5b5f82015167ffffffffffffffff811115614f9c57614f9b61369e565b5b614fa884828501614362565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f614fe882613bf6565b9150614ff383613bf6565b925082820390508181111561500b5761500a614fb1565b5b92915050565b7f6e616d65686173683a204a756e6b20617420656e64206f66206e616d650000005f82015250565b5f615045601d83613b8e565b915061505082615011565b602082019050919050565b5f6020820190508181035f83015261507281615039565b9050919050565b5f6150848285614db5565b6020820191506150948284614db5565b6020820191508190509392505050565b5f6150ae82613bf6565b91506150b983613bf6565b92508282019050808211156150d1576150d0614fb1565b5b92915050565b5f80fd5b5f80fd5b5f80fd5b5f80833560016020038436030381126150ff576150fe6150d7565b5b80840192508235915067ffffffffffffffff821115615121576151206150db565b5b60208301925060018202360383131561513d5761513c6150df565b5b509250929050565b5f6151508383614972565b8261515b8135613755565b9250602082101561519b576151967fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802614670565b831692505b505092915050565b5f6151ae8385614e19565b93506151bb838584613cd5565b82840190509392505050565b5f6151d38284866151a3565b91508190509392505050565b7f726561644c6162656c3a20496e646578206f7574206f6620626f756e647300005f82015250565b5f615213601e83613b8e565b915061521e826151df565b602082019050919050565b5f6020820190508181035f83015261524081615207565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f6020820190506152875f830184614729565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6152c482613bf6565b91506152cf83613bf6565b9250826152df576152de61528d565b5b828206905092915050565b7f496e76616c696420737472696e67206c656e67746800000000000000000000005f82015250565b5f61531e601583613b8e565b9150615329826152ea565b602082019050919050565b5f6020820190508181035f83015261534b81615312565b9050919050565b5f60ff82169050919050565b61536781615352565b82525050565b5f6080820190506153805f830187614030565b61538d602083018661535e565b61539a6040830185614030565b6153a76060830184614030565b9594505050505056fea2646970667358221220c1c5cd227807f2a04ab1e47ceb11db76ee86671115c4fc54dbb24d39233849c664736f6c6343000818003300000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e
|
608060405234801561000f575f80fd5b506004361061012a575f3560e01c80638b95dd71116100ab578063bc1c58d11161006f578063bc1c58d11461039a578063c8690233146103ca578063d5fa2b00146103fb578063e32954eb14610417578063f1cb7e06146104475761012a565b80638b95dd71146102d25780638ef98a7e146102ee5780639061b9231461031e578063ac9650d81461034e578063b299ca1a1461037e5761012a565b80633b3b57de116100f25780633b3b57de146101e257806359d1d43c1461021257806362ef28df14610242578063691f343114610272578063727cc20d146102a25761012a565b806301ffc9a71461012e57806310f13a8c1461015e5780631f8c184e1461017a57806329cd62ea146101aa578063304e6ade146101c6575b5f80fd5b610148600480360381019061014391906136f7565b610477565b604051610155919061373c565b60405180910390f35b610178600480360381019061017391906137e9565b610920565b005b610194600480360381019061018f91906138cf565b610bc9565b6040516101a191906139d7565b60405180910390f35b6101c460048036038101906101bf91906139f7565b610d30565b005b6101e060048036038101906101db9190613a47565b610f88565b005b6101fc60048036038101906101f79190613aa4565b6111d7565b6040516102099190613b0e565b60405180910390f35b61022c60048036038101906102279190613b27565b611397565b6040516102399190613bd6565b60405180910390f35b61025c600480360381019061025791906138cf565b6113ee565b60405161026991906139d7565b60405180910390f35b61028c60048036038101906102879190613aa4565b611419565b6040516102999190613bd6565b60405180910390f35b6102bc60048036038101906102b79190613aa4565b61146e565b6040516102c9919061373c565b60405180910390f35b6102ec60048036038101906102e79190613d51565b611493565b005b61030860048036038101906103039190613dbd565b6116e5565b60405161031591906139d7565b60405180910390f35b610338600480360381019061033391906138cf565b611848565b60405161034591906139d7565b60405180910390f35b61036860048036038101906103639190613ec2565b611bce565b6040516103759190614010565b60405180910390f35b61039860048036038101906103939190613aa4565b611be5565b005b6103b460048036038101906103af9190613aa4565b611df2565b6040516103c191906139d7565b60405180910390f35b6103e460048036038101906103df9190613aa4565b611e47565b6040516103f292919061403f565b60405180910390f35b610415600480360381019061041091906140a1565b612013565b005b610431600480360381019061042c91906140df565b61208a565b60405161043e9190614010565b60405180910390f35b610461600480360381019061045c919061413c565b6120a0565b60405161046e91906139d7565b60405180910390f35b5f7f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061054157507f59d1d43c000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806105a957507f3b3b57de000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061061157507ff1cb7e06000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061067957507fc8690233000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806106e157507fbc1c58d1000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061074957507f691f3431000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806107b157507f4fbf0433000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061081957507f9061b923000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061088157507f8ef98a7e000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806108e957507f727cc20d000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061091957506373302a2560e01b827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b9050919050565b845f7f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b815260040161097b919061417a565b602060405180830381865afa158015610996573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109ba91906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610a8f57507f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b8152600401610a4e9291906141e1565b602060405180830381865afa158015610a69573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a8d9190614232565b155b15610ad157806040517f8e4a23d6000000000000000000000000000000000000000000000000000000008152600401610ac8919061425d565b60405180910390fd5b610b6a610b218888888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f820116905080830192505050505050506120f6565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612160565b8585604051610b7a9291906142a4565b6040518091039020877f448bc014f1536726cf8d54ff3d6481ed3cbc683c2591ca204274009afa09b1a188888888604051610bb894939291906142e8565b60405180910390a350505050505050565b60605f805f610c1c888888888080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f820116905080830192505050505050506121e9565b92509250925080610c3257819350505050610d28565b6004835103600484015260048301925082806020019051810190610c56919061438f565b905080935050600483510360048401526004830192505f83806020019051810190610c8191906144e3565b90505f83806020019051810190610c9891906144e3565b90505f5b8251811015610cff575f610cc9848381518110610cbc57610cbb61452a565b5b6020026020010151612346565b90505f815114610cf35780838381518110610ce757610ce661452a565b5b60200260200101819052505b50600181019050610c9c565b5080604051602001610d119190614010565b604051602081830303815290604052955050505050505b949350505050565b825f7f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b8152600401610d8b919061417a565b602060405180830381865afa158015610da6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610dca91906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015610e9f57507f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b8152600401610e5e9291906141e1565b602060405180830381865afa158015610e79573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e9d9190614232565b155b15610ee157806040517f8e4a23d6000000000000000000000000000000000000000000000000000000008152600401610ed8919061425d565b60405180910390fd5b610f47610ef563c869023360e01b87612405565b5f801b86148015610f0757505f801b85145b610f32578585604051602001610f1e92919061403f565b604051602081830303815290604052610f42565b60405180602001604052805f8152505b612160565b847f1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e468585604051610f7992919061403f565b60405180910390a25050505050565b825f7f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b8152600401610fe3919061417a565b602060405180830381865afa158015610ffe573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061102291906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156110f757507f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b81526004016110b69291906141e1565b602060405180830381865afa1580156110d1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110f59190614232565b155b1561113957806040517f8e4a23d6000000000000000000000000000000000000000000000000000000008152600401611130919061425d565b60405180910390fd5b61119661114d63bc1c58d160e01b87612405565b85858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612160565b847fe379c1624ed7e714cc0937528a32359d69d5281337765313dba4e081b72d757885856040516111c8929190614583565b60405180910390a25050505050565b5f805f6111e384612486565b915091505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141580156112bb57508073ffffffffffffffffffffffffffffffffffffffff166301ffc9a76175307f3b3b57de000000000000000000000000000000000000000000000000000000006040518363ffffffff1660e01b815260040161127a91906145b4565b6020604051808303818786fa158015611295573d5f803e3d5ffd5b50505050506040513d601f19601f820116820180604052508101906112ba9190614232565b5b1561133b578073ffffffffffffffffffffffffffffffffffffffff16633b3b57de836040518263ffffffff1660e01b81526004016112f9919061417a565b602060405180830381865afa158015611314573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061133891906145f7565b92505b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036113905761138161137c85603c6125ed565b612657565b61138a9061467c565b60601c92505b5050919050565b60606113e55f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612702565b90509392505050565b60606114098585858581019061140491906146e2565b6121e9565b9091505080915050949350505050565b60606114675f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612702565b9050919050565b5f8061148163727cc20d60e01b84612405565b9050805490505f811415915050919050565b825f7f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b81526004016114ee919061417a565b602060405180830381865afa158015611509573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061152d91906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561160257507f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b81526004016115c19291906141e1565b602060405180830381865afa1580156115dc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116009190614232565b155b1561164457806040517f8e4a23d600000000000000000000000000000000000000000000000000000000815260040161163b919061425d565b60405180910390fd5b61165761165186866125ed565b84612160565b847f65412581168e88a1e60c6459d7f44ae83ad0832e670826c05a4e2476b57af7528585604051611689929190614738565b60405180910390a2603c84036116de57847f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd2846116c59061467c565b60601c6040516116d5919061425d565b60405180910390a25b5050505050565b60605f8061173585858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612807565b915091505f639061b92360e01b8a8a8a8a6040516024016117599493929190614766565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505090503083826362ef28df60e01b84865f6040516020016117d89392919061479f565b604051602081830303815290604052306040516020016117f99291906147db565b6040516020818303038152906040526040517f556f183000000000000000000000000000000000000000000000000000000000815260040161183f95949392919061490c565b60405180910390fd5b60605f6118a15f87878080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f8201169050808301925050505050505061293890919063ffffffff16565b905060ff60e01b197bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19168484906118d5919061497c565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361191d576119158484600490809261190f939291906149e2565b5f6129ea565b915050611bc6565b60ff60e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191684849061194e919061497c565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916036119c85761197b8161146e565b156119a55761199d84846004908092611996939291906149e2565b60016129ea565b915050611bc6565b6119c38686868660049080926119bd939291906149e2565b5f612c24565b611bc4565b6119d18161146e565b156119e9576119e184845f6129ea565b915050611bc6565b63ac9650d860e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916848490611a1d919061497c565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603611b54575f84846004908092611a55939291906149e2565b810190611a629190614acf565b90505f815167ffffffffffffffff811115611a8057611a7f613c2d565b5b604051908082528060200260200182016040528015611ab357816020015b6060815260200190600190039081611a9e5790505b5090505f5b8251811015611b29575f611ae5848381518110611ad857611ad761452a565b5b6020026020010151612346565b90505f815103611afe57611afd8a8a8a8a6001612c24565b5b80838381518110611b1257611b1161452a565b5b602002602001018190525050600181019050611ab8565b5080604051602001611b3b9190614010565b6040516020818303038152906040529350505050611bc6565b5f611ba185858080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612346565b90505f815114611bb5578092505050611bc6565b611bc2878787875f612c24565b505b505b949350505050565b6060611bdd5f801b8484612d2a565b905092915050565b805f7f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff166302571be3836040518263ffffffff1660e01b8152600401611c40919061417a565b602060405180830381865afa158015611c5b573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c7f91906141a7565b90503373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015611d5457507f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff1663e985e9c582336040518363ffffffff1660e01b8152600401611d139291906141e1565b602060405180830381865afa158015611d2e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611d529190614232565b155b15611d9657806040517f8e4a23d6000000000000000000000000000000000000000000000000000000008152600401611d8d919061425d565b60405180910390fd5b5f611da863727cc20d60e01b85612405565b90505f8154159050808255847ff1b20c8b100d1420d80579b320676045d069e8e05fc776255e4db7df5997273f82604051611de3919061373c565b60405180910390a25050505050565b6060611e405f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612702565b9050919050565b5f805f80611e5485612486565b915091505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614158015611f2c57508073ffffffffffffffffffffffffffffffffffffffff166301ffc9a76175307fc8690233000000000000000000000000000000000000000000000000000000006040518363ffffffff1660e01b8152600401611eeb91906145b4565b6020604051808303818786fa158015611f06573d5f803e3d5ffd5b50505050506040513d601f19601f82011682018060405250810190611f2b9190614232565b5b15611fb1578073ffffffffffffffffffffffffffffffffffffffff1663c8690233836040518263ffffffff1660e01b8152600401611f6a919061417a565b6040805180830381865afa158015611f84573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611fa89190614b2a565b80945081955050505b5f801b84148015611fc357505f801b83145b1561200c575f611fe2611fdd63c869023360e01b88612405565b612657565b9050604081510361200a57808060200190518101906120019190614b2a565b80955081965050505b505b5050915091565b61208682603c5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614612071578360405160200161205d9190614bad565b604051602081830303815290604052612081565b60405180602001604052805f8152505b611493565b5050565b6060612097848484612d2a565b90509392505050565b60606120ee5f368080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f82011690508083019250505050505050612702565b905092915050565b5f828260405160240161210a929190614bc7565b6040516020818303038152906040526359d1d43c60e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050805190602001205f1c905092915050565b5f825490505f825190505f61217860e084901c612eeb565b90505f61218483612eeb565b90505f8111156121c657602085015160201c8360e01b178655603c850160015b828110156121c3578151818901556020820191506001810190506121a4565b50505b805b828110156121e0575f818801556001810190506121c8565b50505050505050565b6060805f60605f87878101906121ff9190614c32565b809650819350829450505050428167ffffffffffffffff16101561225a57806040517ff0eaf4840000000000000000000000000000000000000000000000000000000081526004016122519190614cf3565b60405180910390fd5b5f8680602001905181019061226f9190614d0c565b8096508193508298505050505f3083888051906020012088805190602001206040516020016122a19493929190614dcc565b6040516020818303038152906040528051906020012090505f6122c48286612f09565b90508273ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146123385780836040517fb2187bcd00000000000000000000000000000000000000000000000000000000815260040161232f9291906141e1565b60405180910390fd5b505050505093509350939050565b60605f803073ffffffffffffffffffffffffffffffffffffffff168460405161236f9190614e53565b5f60405180830381855afa9150503d805f81146123a7576040519150601f19603f3d011682016040523d82523d5f602084013e6123ac565b606091505b50915091508180156123c457506123c281612f33565b155b156123fe577f569e75fc77c1a856f6daaf9e69d8a9566ca34aa47f9133711ce065a571af0cfd5f1b8180519060200120146123fd578092505b5b5050919050565b5f8282604051602401612418919061417a565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050805190602001205f1c905092915050565b5f805f6124bb6124b6857fb32cdf4d3c016cb0f079f205ad61c36b1a837fb3e95c70a94bdedfca0518a0106125ed565b612657565b905060148151036124dd57839250806124d39061467c565b60601c91506125e7565b60208151036124f757806124f090614e7d565b925061254c565b5f81510361254b57837fcd5edcba1904ce1b09e94c8a2d2a85375599856ca21c793571193054498b51d7604051602001612532929190614f1c565b6040516020818303038152906040528051906020012092505b5b7f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff16630178b8bf846040518263ffffffff1660e01b81526004016125a5919061417a565b602060405180830381865afa1580156125c0573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906125e491906141a7565b91505b50915091565b5f8282604051602401612601929190614f43565b60405160208183030381529060405263f1cb7e0660e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050805190602001205f1c905092915050565b60605f825490505f60e082901c90505f81146126fb578067ffffffffffffffff81111561268757612686613c2d565b5b6040519080825280601f01601f1916602001820160405280156126b95781602001600182028036833780820191505090505b5092505f6126c682612eeb565b90508260201b6020850152603c840160015b828110156126f7578087015482526020820191506001810190506126d8565b5050505b5050919050565b60605f602483015190505f83805190602001205f1c905061272281612657565b92505f835103612800575f8061273784612486565b915091505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146127fd578160248701525f808273ffffffffffffffffffffffffffffffffffffffff168860405161279b9190614e53565b5f60405180830381855afa9150503d805f81146127d3576040519150601f19603f3d011682016040523d82523d5f602084013e6127d8565b606091505b509150915081156127fa57808060200190518101906127f79190614f6a565b96505b50505b50505b5050919050565b60605f60338351101561285157826040517f206fb1e700000000000000000000000000000000000000000000000000000000815260040161284891906139d7565b60405180910390fd5b5f6128696002602a86612f6a9092919063ffffffff16565b8092508193505050806128b357836040517f206fb1e70000000000000000000000000000000000000000000000000000000081526004016128aa91906139d7565b60405180910390fd5b8351602b85019450602b8103855250600167ffffffffffffffff8111156128dd576128dc613c2d565b5b60405190808252806020026020018201604052801561291057816020015b60608152602001906001900390816128fb5790505b50925083835f815181106129275761292661452a565b5b602002602001018190525050915091565b5f805f6129458585612faf565b915091505f801b82036129ad57600185516129609190614fde565b84146129a1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016129989061505b565b60405180910390fd5b5f801b925050506129e4565b6129b78582612938565b826040516020016129c9929190615079565b60405160208183030381529060405280519060200120925050505b92915050565b606063ac9650d860e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916848490612a20919061497c565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603612b5e575f84846004908092612a58939291906149e2565b810190612a659190614acf565b90505f5b8151811015612b35575f828281518110612a8657612a8561452a565b5b602002602001015190508415612a9d575f60248201525b3073ffffffffffffffffffffffffffffffffffffffff1681604051612ac29190614e53565b5f60405180830381855afa9150503d805f8114612afa576040519150601f19603f3d011682016040523d82523d5f602084013e612aff565b606091505b509050838381518110612b1557612b1461452a565b5b602002602001018190525050600181612b2e91906150a4565b9050612a69565b5080604051602001612b479190614010565b604051602081830303815290604052915050612c1d565b5f84848080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f8201169050808301925050505050505090508215612bb2575f60248201525b3073ffffffffffffffffffffffffffffffffffffffff1681604051612bd79190614e53565b5f60405180830381855afa9150503d805f8114612c0f576040519150601f19603f3d011682016040523d82523d5f602084013e612c14565b606091505b50905080925050505b9392505050565b5f80612c38612c338888613069565b612807565b915091505f639061b92360e01b88888888604051602401612c5c9493929190614766565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050509050308382631f8c184e60e01b848689604051602001612cdb9392919061479f565b6040516020818303038152906040526040517f556f1830000000000000000000000000000000000000000000000000000000008152600401612d2195949392919061490c565b60405180910390fd5b60608282905067ffffffffffffffff811115612d4957612d48613c2d565b5b604051908082528060200260200182016040528015612d7c57816020015b6060815260200190600190039081612d675790505b5090505f5b83839050811015612ee3575f801b8514612e20575f848483818110612da957612da861452a565b5b9050602002810190612dbb91906150e3565b600490602492612dcd939291906149e2565b90612dd89190615145565b9050858114612e1e57806040517f0f53968f000000000000000000000000000000000000000000000000000000008152600401612e15919061417a565b60405180910390fd5b505b5f803073ffffffffffffffffffffffffffffffffffffffff16868685818110612e4c57612e4b61452a565b5b9050602002810190612e5e91906150e3565b604051612e6c9291906151c7565b5f60405180830381855af49150503d805f8114612ea4576040519150601f19603f3d011682016040523d82523d5f602084013e612ea9565b606091505b509150915081612eb7575f80fd5b80848481518110612ecb57612eca61452a565b5b60200260200101819052505050600181019050612d81565b509392505050565b5f808203612ef9575f612f02565b600560238301901c5b9050919050565b5f805f80612f178686613271565b925092509250612f2782826132c6565b82935050505092915050565b5f6020820182518101600192505b80821015612f6357815115612f58575f9250612f63565b602082019150612f41565b5050919050565b5f8060288484612f7a9190614fde565b1015612f8b575f8091509150612fa7565b5f80612f98878787613428565b91509150815f1c819350935050505b935093915050565b5f8083518310612ff4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612feb90615229565b60405180910390fd5b5f8484815181106130085761300761452a565b5b602001015160f81c60f81b60f81c60ff1690505f8111156130415761303a8560018661303491906150a4565b83613580565b9250613047565b5f801b92505b6001818561305591906150a4565b61305f91906150a4565b9150509250929050565b60605f5b60011561326a575f6130cb8286868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f81840152601f19601f8201169050808301925050505050505061293890919063ffffffff16565b90503073ffffffffffffffffffffffffffffffffffffffff167f00000000000000000000000000000000000c2e074ec69a0dfb2997ba6c7d2e1e73ffffffffffffffffffffffffffffffffffffffff16630178b8bf836040518263ffffffff1660e01b815260040161313d919061417a565b602060405180830381865afa158015613158573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061317c91906141a7565b73ffffffffffffffffffffffffffffffffffffffff16036131ef576131de6131d9826040518060400160405280600c81526020017f636369702e636f6e7465787400000000000000000000000000000000000000008152506120f6565b612657565b92505f8351146131ee575061326a565b5b5f8585848181106132035761320261452a565b5b9050013560f81c60f81b60f81c60ff1690505f810361325b5785856040517f9e2fd406000000000000000000000000000000000000000000000000000000008152600401613252929190614583565b60405180910390fd5b8060010183019250505061306d565b5092915050565b5f805f60418451036132b1575f805f602087015192506040870151915060608701515f1a90506132a3888285856135aa565b9550955095505050506132bf565b5f600285515f1b9250925092505b9250925092565b5f60038111156132d9576132d8615247565b5b8260038111156132ec576132eb615247565b5b0315613424576001600381111561330657613305615247565b5b82600381111561331957613318615247565b5b03613350576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600381111561336457613363615247565b5b82600381111561337757613376615247565b5b036133bb57805f1c6040517ffce698f70000000000000000000000000000000000000000000000000000000081526004016133b29190615274565b60405180910390fd5b6003808111156133ce576133cd615247565b5b8260038111156133e1576133e0615247565b5b0361342357806040517fd78bce0c00000000000000000000000000000000000000000000000000000000815260040161341a919061417a565b60405180910390fd5b5b5050565b5f805f84846134379190614fde565b90506040811415801561344b575060288114155b806134625750600160028261346091906152ba565b145b156134a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161349990615334565b60405180910390fd5b6001915085518411156134b3575f80fd5b613514565b5f603a8210602f831116156134d25760308203905061350f565b604782106040831116156134ee57600a6041830301905061350f565b6067821060608311161561350a57600a6061830301905061350f565b60ff90505b919050565b60208601855b8581101561357557613530818301515f1a6134b8565b613541600183018401515f1a6134b8565b60ff811460ff83141715613559575f95505050613575565b808260041b17808860081b17975050505060028101905061351a565b505050935093915050565b5f8351828461358f91906150a4565b1115613599575f80fd5b818360208601012090509392505050565b5f805f7f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0845f1c11156135e6575f600385925092509250613687565b5f6001888888886040515f8152602001604052604051613609949392919061536d565b6020604051602081039080840390855afa158015613629573d5f803e3d5ffd5b5050506020604051035190505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361367a575f60015f801b93509350935050613687565b805f805f1b935093509350505b9450945094915050565b5f604051905090565b5f80fd5b5f80fd5b5f7fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6136d6816136a2565b81146136e0575f80fd5b50565b5f813590506136f1816136cd565b92915050565b5f6020828403121561370c5761370b61369a565b5b5f613719848285016136e3565b91505092915050565b5f8115159050919050565b61373681613722565b82525050565b5f60208201905061374f5f83018461372d565b92915050565b5f819050919050565b61376781613755565b8114613771575f80fd5b50565b5f813590506137828161375e565b92915050565b5f80fd5b5f80fd5b5f80fd5b5f8083601f8401126137a9576137a8613788565b5b8235905067ffffffffffffffff8111156137c6576137c561378c565b5b6020830191508360018202830111156137e2576137e1613790565b5b9250929050565b5f805f805f606086880312156138025761380161369a565b5b5f61380f88828901613774565b955050602086013567ffffffffffffffff8111156138305761382f61369e565b5b61383c88828901613794565b9450945050604086013567ffffffffffffffff81111561385f5761385e61369e565b5b61386b88828901613794565b92509250509295509295909350565b5f8083601f84011261388f5761388e613788565b5b8235905067ffffffffffffffff8111156138ac576138ab61378c565b5b6020830191508360018202830111156138c8576138c7613790565b5b9250929050565b5f805f80604085870312156138e7576138e661369a565b5b5f85013567ffffffffffffffff8111156139045761390361369e565b5b6139108782880161387a565b9450945050602085013567ffffffffffffffff8111156139335761393261369e565b5b61393f8782880161387a565b925092505092959194509250565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015613984578082015181840152602081019050613969565b5f8484015250505050565b5f601f19601f8301169050919050565b5f6139a98261394d565b6139b38185613957565b93506139c3818560208601613967565b6139cc8161398f565b840191505092915050565b5f6020820190508181035f8301526139ef818461399f565b905092915050565b5f805f60608486031215613a0e57613a0d61369a565b5b5f613a1b86828701613774565b9350506020613a2c86828701613774565b9250506040613a3d86828701613774565b9150509250925092565b5f805f60408486031215613a5e57613a5d61369a565b5b5f613a6b86828701613774565b935050602084013567ffffffffffffffff811115613a8c57613a8b61369e565b5b613a988682870161387a565b92509250509250925092565b5f60208284031215613ab957613ab861369a565b5b5f613ac684828501613774565b91505092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f613af882613acf565b9050919050565b613b0881613aee565b82525050565b5f602082019050613b215f830184613aff565b92915050565b5f805f60408486031215613b3e57613b3d61369a565b5b5f613b4b86828701613774565b935050602084013567ffffffffffffffff811115613b6c57613b6b61369e565b5b613b7886828701613794565b92509250509250925092565b5f81519050919050565b5f82825260208201905092915050565b5f613ba882613b84565b613bb28185613b8e565b9350613bc2818560208601613967565b613bcb8161398f565b840191505092915050565b5f6020820190508181035f830152613bee8184613b9e565b905092915050565b5f819050919050565b613c0881613bf6565b8114613c12575f80fd5b50565b5f81359050613c2381613bff565b92915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b613c638261398f565b810181811067ffffffffffffffff82111715613c8257613c81613c2d565b5b80604052505050565b5f613c94613691565b9050613ca08282613c5a565b919050565b5f67ffffffffffffffff821115613cbf57613cbe613c2d565b5b613cc88261398f565b9050602081019050919050565b828183375f83830152505050565b5f613cf5613cf084613ca5565b613c8b565b905082815260208101848484011115613d1157613d10613c29565b5b613d1c848285613cd5565b509392505050565b5f82601f830112613d3857613d37613788565b5b8135613d48848260208601613ce3565b91505092915050565b5f805f60608486031215613d6857613d6761369a565b5b5f613d7586828701613774565b9350506020613d8686828701613c15565b925050604084013567ffffffffffffffff811115613da757613da661369e565b5b613db386828701613d24565b9150509250925092565b5f805f805f8060608789031215613dd757613dd661369a565b5b5f87013567ffffffffffffffff811115613df457613df361369e565b5b613e0089828a0161387a565b9650965050602087013567ffffffffffffffff811115613e2357613e2261369e565b5b613e2f89828a0161387a565b9450945050604087013567ffffffffffffffff811115613e5257613e5161369e565b5b613e5e89828a0161387a565b92509250509295509295509295565b5f8083601f840112613e8257613e81613788565b5b8235905067ffffffffffffffff811115613e9f57613e9e61378c565b5b602083019150836020820283011115613ebb57613eba613790565b5b9250929050565b5f8060208385031215613ed857613ed761369a565b5b5f83013567ffffffffffffffff811115613ef557613ef461369e565b5b613f0185828601613e6d565b92509250509250929050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f82825260208201905092915050565b5f613f508261394d565b613f5a8185613f36565b9350613f6a818560208601613967565b613f738161398f565b840191505092915050565b5f613f898383613f46565b905092915050565b5f602082019050919050565b5f613fa782613f0d565b613fb18185613f17565b935083602082028501613fc385613f27565b805f5b85811015613ffe5784840389528151613fdf8582613f7e565b9450613fea83613f91565b925060208a01995050600181019050613fc6565b50829750879550505050505092915050565b5f6020820190508181035f8301526140288184613f9d565b905092915050565b61403981613755565b82525050565b5f6040820190506140525f830185614030565b61405f6020830184614030565b9392505050565b5f61407082613acf565b9050919050565b61408081614066565b811461408a575f80fd5b50565b5f8135905061409b81614077565b92915050565b5f80604083850312156140b7576140b661369a565b5b5f6140c485828601613774565b92505060206140d58582860161408d565b9150509250929050565b5f805f604084860312156140f6576140f561369a565b5b5f61410386828701613774565b935050602084013567ffffffffffffffff8111156141245761412361369e565b5b61413086828701613e6d565b92509250509250925092565b5f80604083850312156141525761415161369a565b5b5f61415f85828601613774565b925050602061417085828601613c15565b9150509250929050565b5f60208201905061418d5f830184614030565b92915050565b5f815190506141a181614077565b92915050565b5f602082840312156141bc576141bb61369a565b5b5f6141c984828501614193565b91505092915050565b6141db81614066565b82525050565b5f6040820190506141f45f8301856141d2565b61420160208301846141d2565b9392505050565b61421181613722565b811461421b575f80fd5b50565b5f8151905061422c81614208565b92915050565b5f602082840312156142475761424661369a565b5b5f6142548482850161421e565b91505092915050565b5f6020820190506142705f8301846141d2565b92915050565b5f81905092915050565b5f61428b8385614276565b9350614298838584613cd5565b82840190509392505050565b5f6142b0828486614280565b91508190509392505050565b5f6142c78385613b8e565b93506142d4838584613cd5565b6142dd8361398f565b840190509392505050565b5f6040820190508181035f8301526143018186886142bc565b905081810360208301526143168184866142bc565b905095945050505050565b5f61433361432e84613ca5565b613c8b565b90508281526020810184848401111561434f5761434e613c29565b5b61435a848285613967565b509392505050565b5f82601f83011261437657614375613788565b5b8151614386848260208601614321565b91505092915050565b5f80604083850312156143a5576143a461369a565b5b5f83015167ffffffffffffffff8111156143c2576143c161369e565b5b6143ce85828601614362565b925050602083015167ffffffffffffffff8111156143ef576143ee61369e565b5b6143fb85828601614362565b9150509250929050565b5f67ffffffffffffffff82111561441f5761441e613c2d565b5b602082029050602081019050919050565b5f61444261443d84614405565b613c8b565b9050808382526020820190506020840283018581111561446557614464613790565b5b835b818110156144ac57805167ffffffffffffffff81111561448a57614489613788565b5b8086016144978982614362565b85526020850194505050602081019050614467565b5050509392505050565b5f82601f8301126144ca576144c9613788565b5b81516144da848260208601614430565b91505092915050565b5f602082840312156144f8576144f761369a565b5b5f82015167ffffffffffffffff8111156145155761451461369e565b5b614521848285016144b6565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6145628385613957565b935061456f838584613cd5565b6145788361398f565b840190509392505050565b5f6020820190508181035f83015261459c818486614557565b90509392505050565b6145ae816136a2565b82525050565b5f6020820190506145c75f8301846145a5565b92915050565b6145d681613aee565b81146145e0575f80fd5b50565b5f815190506145f1816145cd565b92915050565b5f6020828403121561460c5761460b61369a565b5b5f614619848285016145e3565b91505092915050565b5f819050602082019050919050565b5f7fffffffffffffffffffffffffffffffffffffffff00000000000000000000000082169050919050565b5f6146678251614631565b80915050919050565b5f82821b905092915050565b5f6146868261394d565b8261469084614622565b905061469b8161465c565b925060148210156146db576146d67fffffffffffffffffffffffffffffffffffffffff00000000000000000000000083601403600802614670565b831692505b5050919050565b5f602082840312156146f7576146f661369a565b5b5f82013567ffffffffffffffff8111156147145761471361369e565b5b61472084828501613d24565b91505092915050565b61473281613bf6565b82525050565b5f60408201905061474b5f830185614729565b818103602083015261475d818461399f565b90509392505050565b5f6040820190508181035f83015261477f818688614557565b90508181036020830152614794818486614557565b905095945050505050565b5f6060820190508181035f8301526147b7818661399f565b90506147c660208301856141d2565b6147d3604083018461372d565b949350505050565b5f6040820190508181035f8301526147f3818561399f565b905061480260208301846141d2565b9392505050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f82825260208201905092915050565b5f61484c82613b84565b6148568185614832565b9350614866818560208601613967565b61486f8161398f565b840191505092915050565b5f6148858383614842565b905092915050565b5f602082019050919050565b5f6148a382614809565b6148ad8185614813565b9350836020820285016148bf85614823565b805f5b858110156148fa57848403895281516148db858261487a565b94506148e68361488d565b925060208a019950506001810190506148c2565b50829750879550505050505092915050565b5f60a08201905061491f5f8301886141d2565b81810360208301526149318187614899565b90508181036040830152614945818661399f565b905061495460608301856145a5565b8181036080830152614966818461399f565b90509695505050505050565b5f82905092915050565b5f6149878383614972565b8261499281356136a2565b925060048210156149d2576149cd7fffffffff0000000000000000000000000000000000000000000000000000000083600403600802614670565b831692505b505092915050565b5f80fd5b5f80fd5b5f80858511156149f5576149f46149da565b5b83861115614a0657614a056149de565b5b6001850283019150848603905094509492505050565b5f614a2e614a2984614405565b613c8b565b90508083825260208201905060208402830185811115614a5157614a50613790565b5b835b81811015614a9857803567ffffffffffffffff811115614a7657614a75613788565b5b808601614a838982613d24565b85526020850194505050602081019050614a53565b5050509392505050565b5f82601f830112614ab657614ab5613788565b5b8135614ac6848260208601614a1c565b91505092915050565b5f60208284031215614ae457614ae361369a565b5b5f82013567ffffffffffffffff811115614b0157614b0061369e565b5b614b0d84828501614aa2565b91505092915050565b5f81519050614b248161375e565b92915050565b5f8060408385031215614b4057614b3f61369a565b5b5f614b4d85828601614b16565b9250506020614b5e85828601614b16565b9150509250929050565b5f8160601b9050919050565b5f614b7e82614b68565b9050919050565b5f614b8f82614b74565b9050919050565b614ba7614ba282614066565b614b85565b82525050565b5f614bb88284614b96565b60148201915081905092915050565b5f604082019050614bda5f830185614030565b8181036020830152614bec8184613b9e565b90509392505050565b5f67ffffffffffffffff82169050919050565b614c1181614bf5565b8114614c1b575f80fd5b50565b5f81359050614c2c81614c08565b92915050565b5f805f60608486031215614c4957614c4861369a565b5b5f84013567ffffffffffffffff811115614c6657614c6561369e565b5b614c7286828701613d24565b9350506020614c8386828701614c1e565b925050604084013567ffffffffffffffff811115614ca457614ca361369e565b5b614cb086828701613d24565b9150509250925092565b5f819050919050565b5f614cdd614cd8614cd384614bf5565b614cba565b613bf6565b9050919050565b614ced81614cc3565b82525050565b5f602082019050614d065f830184614ce4565b92915050565b5f805f60608486031215614d2357614d2261369a565b5b5f84015167ffffffffffffffff811115614d4057614d3f61369e565b5b614d4c86828701614362565b9350506020614d5d868287016145e3565b9250506040614d6e8682870161421e565b9150509250925092565b5f8160c01b9050919050565b5f614d8e82614d78565b9050919050565b614da6614da182614bf5565b614d84565b82525050565b5f819050919050565b614dc6614dc182613755565b614dac565b82525050565b5f614dd78287614b96565b601482019150614de78286614d95565b600882019150614df78285614db5565b602082019150614e078284614db5565b60208201915081905095945050505050565b5f81905092915050565b5f614e2d8261394d565b614e378185614e19565b9350614e47818560208601613967565b80840191505092915050565b5f614e5e8284614e23565b915081905092915050565b5f614e748251613755565b80915050919050565b5f614e878261394d565b82614e9184614622565b9050614e9c81614e69565b92506020821015614edc57614ed77fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802614670565b831692505b5050919050565b5f819050919050565b5f614f06614f01614efc84614ee3565b614cba565b613bf6565b9050919050565b614f1681614eec565b82525050565b5f604082019050614f2f5f830185614030565b614f3c6020830184614f0d565b9392505050565b5f604082019050614f565f830185614030565b614f636020830184614729565b9392505050565b5f60208284031215614f7f57614f7e61369a565b5b5f82015167ffffffffffffffff811115614f9c57614f9b61369e565b5b614fa884828501614362565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f614fe882613bf6565b9150614ff383613bf6565b925082820390508181111561500b5761500a614fb1565b5b92915050565b7f6e616d65686173683a204a756e6b20617420656e64206f66206e616d650000005f82015250565b5f615045601d83613b8e565b915061505082615011565b602082019050919050565b5f6020820190508181035f83015261507281615039565b9050919050565b5f6150848285614db5565b6020820191506150948284614db5565b6020820191508190509392505050565b5f6150ae82613bf6565b91506150b983613bf6565b92508282019050808211156150d1576150d0614fb1565b5b92915050565b5f80fd5b5f80fd5b5f80fd5b5f80833560016020038436030381126150ff576150fe6150d7565b5b80840192508235915067ffffffffffffffff821115615121576151206150db565b5b60208301925060018202360383131561513d5761513c6150df565b5b509250929050565b5f6151508383614972565b8261515b8135613755565b9250602082101561519b576151967fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83602003600802614670565b831692505b505092915050565b5f6151ae8385614e19565b93506151bb838584613cd5565b82840190509392505050565b5f6151d38284866151a3565b91508190509392505050565b7f726561644c6162656c3a20496e646578206f7574206f6620626f756e647300005f82015250565b5f615213601e83613b8e565b915061521e826151df565b602082019050919050565b5f6020820190508181035f83015261524081615207565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b5f6020820190506152875f830184614729565b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6152c482613bf6565b91506152cf83613bf6565b9250826152df576152de61528d565b5b828206905092915050565b7f496e76616c696420737472696e67206c656e67746800000000000000000000005f82015250565b5f61531e601583613b8e565b9150615329826152ea565b602082019050919050565b5f6020820190508181035f83015261534b81615312565b9050919050565b5f60ff82169050919050565b61536781615352565b82525050565b5f6080820190506153805f830187614030565b61538d602083018661535e565b61539a6040830185614030565b6153a76060830184614030565b9594505050505056fea2646970667358221220c1c5cd227807f2a04ab1e47ceb11db76ee86671115c4fc54dbb24d39233849c664736f6c63430008180033
|
{{
"language": "Solidity",
"sources": {
"github/resolverworks/TheOffchainResolver.sol/src/TOR.sol": {
"content": "/// @author raffy.eth\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.23;\n\n// interfaces\nimport {ENS} from \"@ensdomains/ens-contracts/contracts/registry/ENS.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport {IExtendedResolver} from \"@ensdomains/ens-contracts/contracts/resolvers/profiles/IExtendedResolver.sol\";\nimport {IExtendedDNSResolver} from \"@ensdomains/ens-contracts/contracts/resolvers/profiles/IExtendedDNSResolver.sol\";\nimport {IAddrResolver} from \"@ensdomains/ens-contracts/contracts/resolvers/profiles/IAddrResolver.sol\";\nimport {IAddressResolver} from \"@ensdomains/ens-contracts/contracts/resolvers/profiles/IAddressResolver.sol\";\nimport {ITextResolver} from \"@ensdomains/ens-contracts/contracts/resolvers/profiles/ITextResolver.sol\";\nimport {INameResolver} from \"@ensdomains/ens-contracts/contracts/resolvers/profiles/INameResolver.sol\";\nimport {IPubkeyResolver} from \"@ensdomains/ens-contracts/contracts/resolvers/profiles/IPubkeyResolver.sol\";\nimport {IContentHashResolver} from \"@ensdomains/ens-contracts/contracts/resolvers/profiles/IContentHashResolver.sol\";\nimport {IMulticallable} from \"@ensdomains/ens-contracts/contracts/resolvers/IMulticallable.sol\";\n\n// libraries\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport {BytesUtils} from \"@ensdomains/ens-contracts/contracts/wrapper/BytesUtils.sol\";\nimport {HexUtils} from \"@ensdomains/ens-contracts/contracts/utils/HexUtils.sol\";\n\n// https://eips.ethereum.org/EIPS/eip-3668\nerror OffchainLookup(address from, string[] urls, bytes request, bytes4 callback, bytes carry);\n\ninterface IOnchainResolver {\n\tfunction onchain(bytes32 node) external view returns (bool);\n\tevent OnchainChanged(bytes32 indexed node, bool on);\n}\n\ncontract TOR is IERC165, ITextResolver, IAddrResolver, IAddressResolver, IPubkeyResolver, IContentHashResolver, \n\t\tIMulticallable, IExtendedResolver, IExtendedDNSResolver, IOnchainResolver, INameResolver {\n\tusing BytesUtils for bytes;\n\tusing HexUtils for bytes;\n\n\terror Unauthorized(address owner); // not operator of node\n\terror InvalidContext(bytes context); // context too short or invalid signer\n\terror Unreachable(bytes name);\n\terror CCIPReadExpired(uint256 t); // ccip response is stale\n\terror CCIPReadUntrusted(address signed, address expect);\n\terror NodeCheck(bytes32 node);\n\n\tuint256 constant COIN_TYPE_ETH = 60;\n\tuint256 constant COIN_TYPE_FALLBACK = 0xb32cdf4d3c016cb0f079f205ad61c36b1a837fb3e95c70a94bdedfca0518a010; // https://adraffy.github.io/keccak.js/test/demo.html#algo=keccak-256&s=fallback&escape=1&encoding=utf8\n\tstring constant TEXT_CONTEXT = \"ccip.context\";\n\tbool constant REPLACE_WITH_ONCHAIN = true;\n\tbool constant OFFCHAIN_ONLY = false;\n\tbool constant CALL_WITH_NULL_NODE = true;\n\tbool constant CALL_UNMODIFIED = false;\n\tbytes4 constant PREFIX_ONLY_OFF = 0x000000FF;\n\tbytes4 constant PREFIX_ONLY_ON = ~PREFIX_ONLY_OFF;\n\tuint256 constant ERC165_GAS_LIMIT = 30000; // https://eips.ethereum.org/EIPS/eip-165\n\t\n\tENS immutable ens;\n\tconstructor(ENS a) {\n\t\tens = a;\n\n\t}\n\n\tfunction supportsInterface(bytes4 x) external pure returns (bool) {\n\t\treturn x == type(IERC165).interfaceId\n\t\t\t|| x == type(ITextResolver).interfaceId\n\t\t\t|| x == type(IAddrResolver).interfaceId\n\t\t\t|| x == type(IAddressResolver).interfaceId\n\t\t\t|| x == type(IPubkeyResolver).interfaceId\n\t\t\t|| x == type(IContentHashResolver).interfaceId\n\t\t\t|| x == type(INameResolver).interfaceId\n\t\t\t|| x == type(IMulticallable).interfaceId\n\t\t\t|| x == type(IExtendedResolver).interfaceId\n\t\t\t|| x == type(IExtendedDNSResolver).interfaceId\n\t\t\t|| x == type(IOnchainResolver).interfaceId\n\t\t\t|| x == 0x73302a25; // https://adraffy.github.io/keccak.js/test/demo.html#algo=evm&s=ccip.context&escape=1&encoding=utf8\n\t}\n\n\t// utils\n\tmodifier requireOperator(bytes32 node) {\n\t\taddress owner = ens.owner(node);\n\t\tif (owner != msg.sender && !ens.isApprovedForAll(owner, msg.sender)) revert Unauthorized(owner);\n\t\t_;\n\t}\n\tfunction slotForCoin(bytes32 node, uint256 cty) internal pure returns (uint256) {\n\t\treturn uint256(keccak256(abi.encodeCall(IAddressResolver.addr, (node, cty))));\n\t}\n\tfunction slotForText(bytes32 node, string memory key) internal pure returns (uint256) {\n\t\treturn uint256(keccak256(abi.encodeCall(ITextResolver.text, (node, key))));\n\t}\n\tfunction slotForSelector(bytes4 selector, bytes32 node) internal pure returns (uint256) {\n\t\treturn uint256(keccak256(abi.encodeWithSelector(selector, node)));\n\t}\n\n\t// getters (structured)\n\tfunction addr(bytes32 node) external view returns (address payable a) {\n\t\t(bytes32 extnode, address resolver) = determineExternalFallback(node);\n\t\tif (resolver != address(0) && IERC165(resolver).supportsInterface{gas: ERC165_GAS_LIMIT}(type(IAddrResolver).interfaceId)) {\n\t\t\ta = IAddrResolver(resolver).addr(extnode);\n\t\t}\n\t\tif (a == address(0)) {\n\t\t\ta = payable(address(bytes20(getTiny(slotForCoin(node, COIN_TYPE_ETH)))));\n\t\t}\n\t}\n\tfunction pubkey(bytes32 node) external view returns (bytes32 x, bytes32 y) {\n\t\t(bytes32 extnode, address resolver) = determineExternalFallback(node);\n\t\tif (resolver != address(0) && IERC165(resolver).supportsInterface{gas: ERC165_GAS_LIMIT}(type(IPubkeyResolver).interfaceId)) {\n\t\t\t(x, y) = IPubkeyResolver(resolver).pubkey(extnode);\n\t\t}\n\t\tif (x == 0 && y == 0) {\n\t\t\tbytes memory v = getTiny(slotForSelector(IPubkeyResolver.pubkey.selector, node));\n\t\t\tif (v.length == 64) (x, y) = abi.decode(v, (bytes32, bytes32));\n\t\t}\n\t}\n\n\t// getters (bytes-like)\n\tfunction addr(bytes32, uint256) external view returns (bytes memory) {\n\t\treturn reflectGetBytes(msg.data);\n\t}\n\tfunction text(bytes32, string calldata) external view returns (string memory) {\n\t\treturn string(reflectGetBytes(msg.data));\n\t}\n\tfunction contenthash(bytes32) external view returns (bytes memory) {\n\t\treturn reflectGetBytes(msg.data);\n\t}\n\tfunction name(bytes32) external view returns (string memory) {\n\t\treturn string(reflectGetBytes(msg.data));\n\t}\n\tfunction reflectGetBytes(bytes memory request) internal view returns (bytes memory v) {\n\t\tbytes32 node;\n\t\tassembly { node := mload(add(request, 36)) }\n\t\tuint256 slot = uint256(keccak256(request)); // hash before we mangle\n\t\tv = getTiny(slot);\n\t\tif (v.length == 0) {\n\t\t\t(bytes32 extnode, address resolver) = determineExternalFallback(node);\n\t\t\tif (resolver != address(0)) {\n\t\t\t\tassembly { mstore(add(request, 36), extnode) } // mangled\n\t\t\t\t(bool ok, bytes memory u) = resolver.staticcall(request);\n\t\t\t\tif (ok) {\n\t\t\t\t\tv = abi.decode(u, (bytes));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// TOR helpers\n\tfunction parseContext(bytes memory v) internal pure returns (string[] memory urls, address signer) {\n\t\t// {SIGNER} {ENDPOINT}\n\t\t// \"0x51050ec063d393217B436747617aD1C2285Aeeee http://a\" => (2 + 40 + 1 + 8)\n\t\tif (v.length < 51) revert InvalidContext(v);\n\t\tbool valid;\n\t\t(signer, valid) = v.hexToAddress(2, 42); // unchecked 0x-prefix\n\t\tif (!valid) revert InvalidContext(v);\n\t\tassembly {\n\t\t\tlet size := mload(v)\n\t\t\tv := add(v, 43) // drop address\n\t\t\tmstore(v, sub(size, 43))\n\t\t}\n\t\turls = new string[](1); // TODO: support multiple URLs\n\t\turls[0] = string(v);\n\t}\n\tfunction verifyOffchain(bytes calldata ccip, bytes memory carry) internal view returns (bytes memory request, bytes memory response, bool replace) {\n\t\tbytes memory sig;\n\t\tuint64 expires;\n\t\t(sig, expires, response) = abi.decode(ccip, (bytes, uint64, bytes));\n\t\tif (expires < block.timestamp) revert CCIPReadExpired(expires);\n\t\taddress signer;\n\t\t(request, signer, replace) = abi.decode(carry, (bytes, address, bool));\n\t\tbytes32 hash = keccak256(abi.encodePacked(address(this), expires, keccak256(request), keccak256(response)));\n\t\taddress signed = ECDSA.recover(hash, sig);\n\t\tif (signed != signer) revert CCIPReadUntrusted(signed, signer);\n\t}\n\n\t// IExtendedDNSResolver\n\tfunction resolve(bytes calldata dnsname, bytes calldata data, bytes calldata context) external view returns (bytes memory) {\n\t\t(string[] memory urls, address signer) = parseContext(context);\n\t\tbytes memory request = abi.encodeWithSelector(IExtendedResolver.resolve.selector, dnsname, data);\n\t\trevert OffchainLookup(address(this), urls, request, this.buggedCallback.selector, abi.encode(abi.encode(request, signer, false), address(this)));\n\t}\n\tfunction buggedCallback(bytes calldata response, bytes calldata buggedExtraData) external view returns (bytes memory v) {\n\t\t(, v, ) = verifyOffchain(response, abi.decode(buggedExtraData, (bytes)));\n\t}\n\n\t// IExtendedResolver\n\tfunction resolve(bytes calldata dnsname, bytes calldata data) external view returns (bytes memory) {\n\t\tunchecked {\n\t\t\tbytes32 node = dnsname.namehash(0);\n\t\t\tif (bytes4(data) == PREFIX_ONLY_ON) {\n\t\t\t\treturn resolveOnchain(data[4:], CALL_UNMODIFIED);\n\t\t\t} else if (bytes4(data) == PREFIX_ONLY_OFF) {\n\t\t\t\tif (onchain(node)) {\n\t\t\t\t\treturn resolveOnchain(data[4:], CALL_WITH_NULL_NODE);\n\t\t\t\t} else {\n\t\t\t\t\tresolveOffchain(dnsname, data[4:], OFFCHAIN_ONLY);\n\t\t\t\t}\n\t\t\t} else if (onchain(node)) { // manditory on-chain\n\t\t\t\treturn resolveOnchain(data, CALL_UNMODIFIED);\n\t\t\t} else { // off-chain then replace with on-chain\n\t\t\t\tif (bytes4(data) == IMulticallable.multicall.selector) {\n\t\t\t\t\tbytes[] memory a = abi.decode(data[4:], (bytes[]));\n\t\t\t\t\tbytes[] memory b = new bytes[](a.length);\n\t\t\t\t\t// if one record is missing, go off-chain\n\t\t\t\t\tfor (uint256 i; i < a.length; i += 1) {\n\t\t\t\t\t\tbytes memory v = getEncodedFallbackValue(a[i]);\n\t\t\t\t\t\tif (v.length == 0) resolveOffchain(dnsname, data, REPLACE_WITH_ONCHAIN);\n\t\t\t\t\t\tb[i] = v;\n\t\t\t\t\t}\n\t\t\t\t\treturn abi.encode(b); // multi-answerable on-chain\n\t\t\t\t} else {\n\t\t\t\t\tbytes memory v = getEncodedFallbackValue(data);\n\t\t\t\t\tif (v.length != 0) return v; // answerable on-chain\n\t\t\t\t\tresolveOffchain(dnsname, data, OFFCHAIN_ONLY);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction resolveOnchain(bytes calldata data, bool clear) internal view returns (bytes memory result) {\n\t\tif (bytes4(data) == IMulticallable.multicall.selector) {\n\t\t\tbytes[] memory a = abi.decode(data[4:], (bytes[]));\n\t\t\tfor (uint256 i; i < a.length; i += 1) {\n\t\t\t\tbytes memory v = a[i];\n\t\t\t\tif (clear) assembly { mstore(add(v, 36), 0) } // clear the node\n\t\t\t\t(, a[i]) = address(this).staticcall(v);\n\t\t\t}\n\t\t\tresult = abi.encode(a);\n\t\t} else {\n\t\t\tbytes memory v = data;\n\t\t\tif (clear) assembly { mstore(add(v, 36), 0) } // clear the node\n\t\t\t(, result) = address(this).staticcall(v);\n\t\t}\n\t}\n\tfunction resolveOffchain(bytes calldata dnsname, bytes calldata data, bool replace) internal view {\n\t\t(string[] memory urls, address signer) = parseContext(findContext(dnsname));\n\t\tbytes memory request = abi.encodeWithSelector(IExtendedResolver.resolve.selector, dnsname, data);\n\t\trevert OffchainLookup(address(this), urls, request, this.ensCallback.selector, abi.encode(request, signer, replace));\n\t}\n\tfunction findContext(bytes calldata dnsname) internal view returns (bytes memory context) {\n\t\tunchecked {\n\t\t\tuint256 offset;\n\t\t\twhile (true) {\n\t\t\t\t// find the first node in direct lineage...\n\t\t\t\tbytes32 node = dnsname.namehash(offset);\n\t\t\t\tif (ens.resolver(node) == address(this)) { // ...that is TOR\n\t\t\t\t\tcontext = getTiny(slotForText(node, TEXT_CONTEXT));\n\t\t\t\t\tif (context.length != 0) break; // ...and has non-null context\n\t\t\t\t}\n\t\t\t\tuint256 size = uint256(uint8(dnsname[offset]));\n\t\t\t\tif (size == 0) revert Unreachable(dnsname);\n\t\t\t\toffset += 1 + size;\n\t\t\t}\n\t\t}\n\t}\n\tfunction ensCallback(bytes calldata ccip, bytes calldata carry) external view returns (bytes memory) {\n\t\tunchecked {\n\t\t\t(bytes memory request, bytes memory response, bool replace) = verifyOffchain(ccip, carry);\n\t\t\t// single record calls that had on-chain values would of been answered on-chain\n\t\t\t// so we only need to handle multicall() replacement \n\t\t\tif (!replace) return response;\n\t\t\tassembly {\n\t\t\t\tmstore(add(request, 4), sub(mload(request), 4)) // trim resolve() selector\n\t\t\t\trequest := add(request, 4)\n\t\t\t}\n\t\t\t(, request) = abi.decode(request, (bytes, bytes));\n\t\t\tassembly {\n\t\t\t\tmstore(add(request, 4), sub(mload(request), 4)) // trim multicall() selector\n\t\t\t\trequest := add(request, 4)\n\t\t\t}\n\t\t\tbytes[] memory a = abi.decode(request, (bytes[]));\n\t\t\tbytes[] memory b = abi.decode(response, (bytes[]));\n\t\t\tfor (uint256 i; i < a.length; i += 1) {\n\t\t\t\tbytes memory v = getEncodedFallbackValue(a[i]);\n\t\t\t\tif (v.length != 0) b[i] = v; // replace with on-chain\n\t\t\t}\n\t\t\treturn abi.encode(b);\n\t\t}\n\t}\n\tfunction determineExternalFallback(bytes32 node) internal view returns (bytes32 extnode, address resolver) {\n\t\tbytes memory v = getTiny(slotForCoin(node, COIN_TYPE_FALLBACK));\n\t\tif (v.length == 20) { // resolver using same node\n\t\t\textnode = node;\n\t\t\tresolver = address(bytes20(v));\n\t\t} else {\n\t\t\tif (v.length == 32) { // differnt node \n\t\t\t\textnode = bytes32(v);\n\t\t\t} else if (v.length != 0) { // external fallback disabled\n\t\t\t\t// extnode = 0 => resolver = 0\n\t\t\t} else { // default\n\t\t\t\t// derived: namehash(\"_\" + node)\n\t\t\t\t// https://adraffy.github.io/keccak.js/test/demo.html#algo=keccak-256&s=_&escape=1&encoding=utf8\n\t\t\t\textnode = keccak256(abi.encode(node, 0xcd5edcba1904ce1b09e94c8a2d2a85375599856ca21c793571193054498b51d7));\n\t\t\t}\n\t\t\t// Q: should this be ENSIP-10?\n\t\t\t// A: no, since we're calling on-chain methods\n\t\t\tresolver = ens.resolver(extnode); \n\t\t}\n\t}\n\tfunction getEncodedFallbackValue(bytes memory request) internal view returns (bytes memory encoded) {\n\t\t(bool ok, bytes memory v) = address(this).staticcall(request);\n\t\tif (ok && !isNullAssumingPadded(v)) {\n\t\t\t// unfortunately it is impossible to determine if an arbitrary abi-encoded response is null\n\t\t\t// abi.encode('') = 0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000\n\t\t\t// https://adraffy.github.io/keccak.js/test/demo.html#algo=keccak-256&s=0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000&escape=1&encoding=hex\n\t\t\tif (keccak256(v) != 0x569e75fc77c1a856f6daaf9e69d8a9566ca34aa47f9133711ce065a571af0cfd) {\n\t\t\t\tencoded = v;\n\t\t\t}\n\t\t}\n\t}\n\tfunction isNullAssumingPadded(bytes memory v) internal pure returns (bool ret) {\n\t\tassembly {\n\t\t\tlet p := add(v, 32)\n\t\t\tlet e := add(p, mload(v))\n\t\t\tfor { ret := 1 } lt(p, e) { p := add(p, 32) } {\n\t\t\t\tif iszero(iszero(mload(p))) { // != 0\n\t\t\t\t\tret := 0\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// multicall (for efficient multi-record writes)\n\t// Q: allow ccip-read through this mechanism?\n\t// A: no, too complex (mixed targets) and not ENSIP-10 compatible\n\tfunction multicall(bytes[] calldata calls) external returns (bytes[] memory) {\n\t\treturn _multicall(0, calls);\n\t}\n\tfunction multicallWithNodeCheck(bytes32 nodehash, bytes[] calldata calls) external returns (bytes[] memory) {\n\t\treturn _multicall(nodehash, calls);\n\t}\n\tfunction _multicall(bytes32 node, bytes[] calldata calls) internal returns (bytes[] memory answers) {\n\t\tunchecked {\n\t\t\tanswers = new bytes[](calls.length);\n\t\t\tfor (uint256 i; i < calls.length; i += 1) {\n\t\t\t\tif (node != 0) {\n\t\t\t\t\tbytes32 check = bytes32(calls[i][4:36]);\n\t\t\t\t\tif (check != node) revert NodeCheck(check);\n\t\t\t\t}\n\t\t\t\t(bool ok, bytes memory v) = address(this).delegatecall(calls[i]);\n\t\t\t\trequire(ok);\n\t\t\t\tanswers[i] = v;\n\t\t\t}\n\t\t}\n\t}\n\n\t// setters\n\tfunction setAddr(bytes32 node, address a) external {\n\t\tsetAddr(node, COIN_TYPE_ETH, a == address(0) ? bytes('') : abi.encodePacked(a));\n\t}\n\tfunction setAddr(bytes32 node, uint256 cty, bytes memory v) requireOperator(node) public {\n\t\tsetTiny(slotForCoin(node, cty), v);\n\t\temit AddressChanged(node, cty, v);\n\t\tif (cty == COIN_TYPE_ETH) emit AddrChanged(node, address(bytes20(v)));\n\t}\n\tfunction setText(bytes32 node, string calldata key, string calldata s) requireOperator(node) external {\n\t\tsetTiny(slotForText(node, key), bytes(s));\n\t\temit TextChanged(node, key, key, s);\n\t}\n\tfunction setContenthash(bytes32 node, bytes calldata v) requireOperator(node) external {\n\t\tsetTiny(slotForSelector(IContentHashResolver.contenthash.selector, node), v);\n\t\temit ContenthashChanged(node, v);\n\t}\n\tfunction setPubkey(bytes32 node, bytes32 x, bytes32 y) requireOperator(node) external {\n\t\tsetTiny(slotForSelector(IPubkeyResolver.pubkey.selector, node), x == 0 && y == 0 ? bytes('') : abi.encode(x, y));\n\t\temit PubkeyChanged(node, x, y);\n\t}\n\n\t// IOnchainResolver\n\tfunction toggleOnchain(bytes32 node) requireOperator(node) external {\n\t\tuint256 slot = slotForSelector(IOnchainResolver.onchain.selector, node);\n\t\tbool on;\n\t\tassembly { \n\t\t\ton := iszero(sload(slot))\n\t\t\tsstore(slot, on)\n\t\t}\n\t\temit OnchainChanged(node, on);\n\t}\n\tfunction onchain(bytes32 node) public view returns (bool) {\t\t\n\t\tuint256 slot = slotForSelector(IOnchainResolver.onchain.selector, node);\n\t\tassembly { slot := sload(slot) }\n\t\treturn slot != 0;\n\t}\n\t\n\t// ************************************************************\n\t// TinyKV.sol: https://github.com/adraffy/TinyKV.sol\n\n\t// header: first 4 bytes\n\t// [00000000_00000000000000000000000000000000000000000000000000000000] // null (0 slot)\n\t// [00000001_XX000000000000000000000000000000000000000000000000000000] // 1 byte (1 slot)\n\t// [0000001C_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX] // 28 bytes (1 slot\n\t// [0000001D_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX][XX000000...] // 29 bytes (2 slots)\n\tfunction tinySlots(uint256 size) internal pure returns (uint256) {\n\t\tunchecked {\n\t\t\treturn size != 0 ? (size + 35) >> 5 : 0; // ceil((4 + size) / 32)\n\t\t}\n\t}\n\tfunction setTiny(uint256 slot, bytes memory v) internal {\n\t\tunchecked {\n\t\t\tuint256 head;\n\t\t\tassembly { head := sload(slot) }\n\t\t\tuint256 size;\n\t\t\tassembly { size := mload(v) }\n\t\t\tuint256 n0 = tinySlots(head >> 224);\n\t\t\tuint256 n1 = tinySlots(size);\n\t\t\tassembly {\n\t\t\t\t// overwrite\n\t\t\t\tif gt(n1, 0) {\n\t\t\t\t\tsstore(slot, or(shl(224, size), shr(32, mload(add(v, 32)))))\n\t\t\t\t\tlet ptr := add(v, 60)\n\t\t\t\t\tfor { let i := 1 } lt(i, n1) { i := add(i, 1) } {\n\t\t\t\t\t\tsstore(add(slot, i), mload(ptr))\n\t\t\t\t\t\tptr := add(ptr, 32)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// clear unused\n\t\t\t\tfor { let i := n1 } lt(i, n0) { i := add(i, 1) } {\n\t\t\t\t\tsstore(add(slot, i), 0)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction getTiny(uint256 slot) internal view returns (bytes memory v) {\n\t\tunchecked {\n\t\t\tuint256 head;\n\t\t\tassembly { head := sload(slot) }\n\t\t\tuint256 size = head >> 224;\n\t\t\tif (size != 0) {\n\t\t\t\tv = new bytes(size);\n\t\t\t\tuint256 n = tinySlots(size);\n\t\t\t\tassembly {\n\t\t\t\t\tmstore(add(v, 32), shl(32, head))\n\t\t\t\t\tlet p := add(v, 60)\n\t\t\t\t\tfor { let i := 1 } lt(i, n) { i := add(i, 1) } {\n\t\t\t\t\t\tmstore(p, sload(add(slot, i)))\n\t\t\t\t\t\tp := add(p, 32)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n}\n"
},
"@ensdomains/ens-contracts/contracts/utils/HexUtils.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\nlibrary HexUtils {\n /**\n * @dev Attempts to parse bytes32 from a hex string\n * @param str The string to parse\n * @param idx The offset to start parsing at\n * @param lastIdx The (exclusive) last index in `str` to consider. Use `str.length` to scan the whole string.\n */\n function hexStringToBytes32(\n bytes memory str,\n uint256 idx,\n uint256 lastIdx\n ) internal pure returns (bytes32 r, bool valid) {\n uint256 hexLength = lastIdx - idx;\n if ((hexLength != 64 && hexLength != 40) || hexLength % 2 == 1) {\n revert(\"Invalid string length\");\n }\n valid = true;\n assembly {\n // check that the index to read to is not past the end of the string\n if gt(lastIdx, mload(str)) {\n revert(0, 0)\n }\n\n function getHex(c) -> ascii {\n // chars 48-57: 0-9\n if and(gt(c, 47), lt(c, 58)) {\n ascii := sub(c, 48)\n leave\n }\n // chars 65-70: A-F\n if and(gt(c, 64), lt(c, 71)) {\n ascii := add(sub(c, 65), 10)\n leave\n }\n // chars 97-102: a-f\n if and(gt(c, 96), lt(c, 103)) {\n ascii := add(sub(c, 97), 10)\n leave\n }\n // invalid char\n ascii := 0xff\n }\n\n let ptr := add(str, 32)\n for {\n let i := idx\n } lt(i, lastIdx) {\n i := add(i, 2)\n } {\n let byte1 := getHex(byte(0, mload(add(ptr, i))))\n let byte2 := getHex(byte(0, mload(add(ptr, add(i, 1)))))\n // if either byte is invalid, set invalid and break loop\n if or(eq(byte1, 0xff), eq(byte2, 0xff)) {\n valid := false\n break\n }\n let combined := or(shl(4, byte1), byte2)\n r := or(shl(8, r), combined)\n }\n }\n }\n\n /**\n * @dev Attempts to parse an address from a hex string\n * @param str The string to parse\n * @param idx The offset to start parsing at\n * @param lastIdx The (exclusive) last index in `str` to consider. Use `str.length` to scan the whole string.\n */\n function hexToAddress(\n bytes memory str,\n uint256 idx,\n uint256 lastIdx\n ) internal pure returns (address, bool) {\n if (lastIdx - idx < 40) return (address(0x0), false);\n (bytes32 r, bool valid) = hexStringToBytes32(str, idx, lastIdx);\n return (address(uint160(uint256(r))), valid);\n }\n}\n"
},
"@ensdomains/ens-contracts/contracts/wrapper/BytesUtils.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity ~0.8.17;\n\nlibrary BytesUtils {\n /*\n * @dev Returns the keccak-256 hash of a byte range.\n * @param self The byte string to hash.\n * @param offset The position to start hashing at.\n * @param len The number of bytes to hash.\n * @return The hash of the byte range.\n */\n function keccak(\n bytes memory self,\n uint256 offset,\n uint256 len\n ) internal pure returns (bytes32 ret) {\n require(offset + len <= self.length);\n assembly {\n ret := keccak256(add(add(self, 32), offset), len)\n }\n }\n\n /**\n * @dev Returns the ENS namehash of a DNS-encoded name.\n * @param self The DNS-encoded name to hash.\n * @param offset The offset at which to start hashing.\n * @return The namehash of the name.\n */\n function namehash(\n bytes memory self,\n uint256 offset\n ) internal pure returns (bytes32) {\n (bytes32 labelhash, uint256 newOffset) = readLabel(self, offset);\n if (labelhash == bytes32(0)) {\n require(offset == self.length - 1, \"namehash: Junk at end of name\");\n return bytes32(0);\n }\n return\n keccak256(abi.encodePacked(namehash(self, newOffset), labelhash));\n }\n\n /**\n * @dev Returns the keccak-256 hash of a DNS-encoded label, and the offset to the start of the next label.\n * @param self The byte string to read a label from.\n * @param idx The index to read a label at.\n * @return labelhash The hash of the label at the specified index, or 0 if it is the last label.\n * @return newIdx The index of the start of the next label.\n */\n function readLabel(\n bytes memory self,\n uint256 idx\n ) internal pure returns (bytes32 labelhash, uint256 newIdx) {\n require(idx < self.length, \"readLabel: Index out of bounds\");\n uint256 len = uint256(uint8(self[idx]));\n if (len > 0) {\n labelhash = keccak(self, idx + 1, len);\n } else {\n labelhash = bytes32(0);\n }\n newIdx = idx + len + 1;\n }\n}\n"
},
"@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/IMulticallable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IMulticallable {\n function multicall(\n bytes[] calldata data\n ) external returns (bytes[] memory results);\n\n function multicallWithNodeCheck(\n bytes32,\n bytes[] calldata data\n ) external returns (bytes[] memory results);\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/profiles/IContentHashResolver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\ninterface IContentHashResolver {\n event ContenthashChanged(bytes32 indexed node, bytes hash);\n\n /**\n * Returns the contenthash associated with an ENS node.\n * @param node The ENS node to query.\n * @return The associated contenthash.\n */\n function contenthash(bytes32 node) external view returns (bytes memory);\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/profiles/IPubkeyResolver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\ninterface IPubkeyResolver {\n event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);\n\n /**\n * Returns the SECP256k1 public key associated with an ENS node.\n * Defined in EIP 619.\n * @param node The ENS node to query\n * @return x The X coordinate of the curve point for the public key.\n * @return y The Y coordinate of the curve point for the public key.\n */\n function pubkey(bytes32 node) external view returns (bytes32 x, bytes32 y);\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/profiles/INameResolver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\ninterface INameResolver {\n event NameChanged(bytes32 indexed node, string name);\n\n /**\n * Returns the name associated with an ENS node, for reverse records.\n * Defined in EIP181.\n * @param node The ENS node to query.\n * @return The associated name.\n */\n function name(bytes32 node) external view returns (string memory);\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/profiles/ITextResolver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\ninterface ITextResolver {\n event TextChanged(\n bytes32 indexed node,\n string indexed indexedKey,\n string key,\n string value\n );\n\n /**\n * Returns the text data associated with an ENS node and key.\n * @param node The ENS node to query.\n * @param key The text data key to query.\n * @return The associated text data.\n */\n function text(\n bytes32 node,\n string calldata key\n ) external view returns (string memory);\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/profiles/IAddressResolver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\n/**\n * Interface for the new (multicoin) addr function.\n */\ninterface IAddressResolver {\n event AddressChanged(\n bytes32 indexed node,\n uint256 coinType,\n bytes newAddress\n );\n\n function addr(\n bytes32 node,\n uint256 coinType\n ) external view returns (bytes memory);\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/profiles/IAddrResolver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\n/**\n * Interface for the legacy (ETH-only) addr function.\n */\ninterface IAddrResolver {\n event AddrChanged(bytes32 indexed node, address a);\n\n /**\n * Returns the address associated with an ENS node.\n * @param node The ENS node to query.\n * @return The associated address.\n */\n function addr(bytes32 node) external view returns (address payable);\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/profiles/IExtendedDNSResolver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IExtendedDNSResolver {\n function resolve(\n bytes memory name,\n bytes memory data,\n bytes memory context\n ) external view returns (bytes memory);\n}\n"
},
"@ensdomains/ens-contracts/contracts/resolvers/profiles/IExtendedResolver.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\ninterface IExtendedResolver {\n function resolve(\n bytes memory name,\n bytes memory data\n ) external view returns (bytes memory);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@ensdomains/ens-contracts/contracts/registry/ENS.sol": {
"content": "pragma solidity >=0.8.4;\n\ninterface ENS {\n // Logged when the owner of a node assigns a new owner to a subnode.\n event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);\n\n // Logged when the owner of a node transfers ownership to a new account.\n event Transfer(bytes32 indexed node, address owner);\n\n // Logged when the resolver for a node changes.\n event NewResolver(bytes32 indexed node, address resolver);\n\n // Logged when the TTL of a node changes\n event NewTTL(bytes32 indexed node, uint64 ttl);\n\n // Logged when an operator is added or removed.\n event ApprovalForAll(\n address indexed owner,\n address indexed operator,\n bool approved\n );\n\n function setRecord(\n bytes32 node,\n address owner,\n address resolver,\n uint64 ttl\n ) external;\n\n function setSubnodeRecord(\n bytes32 node,\n bytes32 label,\n address owner,\n address resolver,\n uint64 ttl\n ) external;\n\n function setSubnodeOwner(\n bytes32 node,\n bytes32 label,\n address owner\n ) external returns (bytes32);\n\n function setResolver(bytes32 node, address resolver) external;\n\n function setOwner(bytes32 node, address owner) external;\n\n function setTTL(bytes32 node, uint64 ttl) external;\n\n function setApprovalForAll(address operator, bool approved) external;\n\n function owner(bytes32 node) external view returns (address);\n\n function resolver(bytes32 node) external view returns (address);\n\n function ttl(bytes32 node) external view returns (uint64);\n\n function recordExists(bytes32 node) external view returns (bool);\n\n function isApprovedForAll(\n address owner,\n address operator\n ) external view returns (bool);\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,498,549 |
8a833bfa9f3745c46a29fe2fa209f11b0e48229421cb61b6ce4520ec04a23237
|
5476c91d23ed7892d532f2af81f5e94331a3d5ec5265f23da0dcce299ddb3ec2
|
a9a0b8a5e1adca0caccc63a168f053cd3be30808
|
01cd62ed13d0b666e2a10d13879a763dfd1dab99
|
33bb46f726200f4789d62ff8886662f3ffb0a2df
|
3d602d80600a3d3981f3363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
| |
1 | 19,498,552 |
1deba18246e81d166977089eb3d5e127e9b2550eef08caef14341975261d02f4
|
0ec326c5dd0bb82edb891e5a8cf3f91a2b0a7b6fe819d2a7034a139da5f01e99
|
83255b06dc6377d097eadd9ada0f69112dd79509
|
7335db10622eecdeffadaee7f2454e37aedf7002
|
3f52609a0eed35ac6cb697825eb3d130391f1f6c
|
60a03461009757601f6102cd38819003918201601f19168301916001600160401b0383118484101761009c5780849260209460405283398101031261009757516001600160a01b0381169081810361009757608052604051907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e600080a261021a90816100b382396080518181816028015260ef0152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080806040523615610016575b6100146100da565b005b635c60da1b60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156100ce57600091610071575b5061006b9061017d565b3861000c565b6020913d83116100c6575b601f8301601f191682019067ffffffffffffffff8211838310176100b2575060405261006b916100ac910161019e565b90610061565b634e487b7160e01b81526041600452602490fd5b3d925061007c565b6040513d6000823e3d90fd5b604051635c60da1b60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa80156100ce57600090610133575b610131915061017d565b565b6020903d8211610175575b601f8201601f191683019067ffffffffffffffff8211848310176100b2575060405261013191610170918101906101c5565b610127565b3d915061013e565b90506000808092368280378136915af43d82803e1561019a573d90f35b3d90fd5b602090607f1901126101c0576080516001600160a01b03811681036101c05790565b600080fd5b908160209103126101c057516001600160a01b03811681036101c0579056fea2646970667358221220c478b1615b0d76011a7874324ac15b3d7fb464e980c3c09d2d779b62a970e18664736f6c6343000811003300000000000000000000000023b0c2381075df4002bc6d3b9baf52ab0acb1e9b
|
6080806040523615610016575b6100146100da565b005b635c60da1b60e01b81526020816004817f00000000000000000000000023b0c2381075df4002bc6d3b9baf52ab0acb1e9b6001600160a01b03165afa9081156100ce57600091610071575b5061006b9061017d565b3861000c565b6020913d83116100c6575b601f8301601f191682019067ffffffffffffffff8211838310176100b2575060405261006b916100ac910161019e565b90610061565b634e487b7160e01b81526041600452602490fd5b3d925061007c565b6040513d6000823e3d90fd5b604051635c60da1b60e01b81526020816004817f00000000000000000000000023b0c2381075df4002bc6d3b9baf52ab0acb1e9b6001600160a01b03165afa80156100ce57600090610133575b610131915061017d565b565b6020903d8211610175575b601f8201601f191683019067ffffffffffffffff8211848310176100b2575060405261013191610170918101906101c5565b610127565b3d915061013e565b90506000808092368280378136915af43d82803e1561019a573d90f35b3d90fd5b602090607f1901126101c0576080516001600160a01b03811681036101c05790565b600080fd5b908160209103126101c057516001600160a01b03811681036101c0579056fea2646970667358221220c478b1615b0d76011a7874324ac15b3d7fb464e980c3c09d2d779b62a970e18664736f6c63430008110033
|
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/proxy/beacon/IBeacon.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"
},
"@openzeppelin/contracts/proxy/Proxy.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n"
},
"contracts/utils/BeaconProxy.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"@openzeppelin/contracts/proxy/Proxy.sol\";\n\n/// @custom:security-contact security@p00ls.com\ncontract BeaconProxy is Proxy {\n IBeacon private immutable _beacon;\n\n event BeaconUpgraded(IBeacon indexed beacon);\n\n constructor(IBeacon beacon)\n {\n _beacon = beacon;\n emit BeaconUpgraded(beacon);\n }\n\n function _implementation()\n internal\n view\n override\n returns (address)\n {\n return _beacon.implementation();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"debug": {
"revertStrings": "strip"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,498,552 |
1deba18246e81d166977089eb3d5e127e9b2550eef08caef14341975261d02f4
|
0ec326c5dd0bb82edb891e5a8cf3f91a2b0a7b6fe819d2a7034a139da5f01e99
|
83255b06dc6377d097eadd9ada0f69112dd79509
|
7335db10622eecdeffadaee7f2454e37aedf7002
|
164967ca7a39ad525693e0b39a774d3c5329d82b
|
60a03461009757601f6102cd38819003918201601f19168301916001600160401b0383118484101761009c5780849260209460405283398101031261009757516001600160a01b0381169081810361009757608052604051907f1cf3b03a6cf19fa2baba4df148e9dcabedea7f8a5c07840e207e5c089be95d3e600080a261021a90816100b382396080518181816028015260ef0152f35b600080fd5b634e487b7160e01b600052604160045260246000fdfe6080806040523615610016575b6100146100da565b005b635c60da1b60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa9081156100ce57600091610071575b5061006b9061017d565b3861000c565b6020913d83116100c6575b601f8301601f191682019067ffffffffffffffff8211838310176100b2575060405261006b916100ac910161019e565b90610061565b634e487b7160e01b81526041600452602490fd5b3d925061007c565b6040513d6000823e3d90fd5b604051635c60da1b60e01b81526020816004817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa80156100ce57600090610133575b610131915061017d565b565b6020903d8211610175575b601f8201601f191683019067ffffffffffffffff8211848310176100b2575060405261013191610170918101906101c5565b610127565b3d915061013e565b90506000808092368280378136915af43d82803e1561019a573d90f35b3d90fd5b602090607f1901126101c0576080516001600160a01b03811681036101c05790565b600080fd5b908160209103126101c057516001600160a01b03811681036101c0579056fea2646970667358221220c478b1615b0d76011a7874324ac15b3d7fb464e980c3c09d2d779b62a970e18664736f6c63430008110033000000000000000000000000f6fd7647cacc1d570f328fc0f09d9118041ea172
|
6080806040523615610016575b6100146100da565b005b635c60da1b60e01b81526020816004817f000000000000000000000000f6fd7647cacc1d570f328fc0f09d9118041ea1726001600160a01b03165afa9081156100ce57600091610071575b5061006b9061017d565b3861000c565b6020913d83116100c6575b601f8301601f191682019067ffffffffffffffff8211838310176100b2575060405261006b916100ac910161019e565b90610061565b634e487b7160e01b81526041600452602490fd5b3d925061007c565b6040513d6000823e3d90fd5b604051635c60da1b60e01b81526020816004817f000000000000000000000000f6fd7647cacc1d570f328fc0f09d9118041ea1726001600160a01b03165afa80156100ce57600090610133575b610131915061017d565b565b6020903d8211610175575b601f8201601f191683019067ffffffffffffffff8211848310176100b2575060405261013191610170918101906101c5565b610127565b3d915061013e565b90506000808092368280378136915af43d82803e1561019a573d90f35b3d90fd5b602090607f1901126101c0576080516001600160a01b03811681036101c05790565b600080fd5b908160209103126101c057516001600160a01b03811681036101c0579056fea2646970667358221220c478b1615b0d76011a7874324ac15b3d7fb464e980c3c09d2d779b62a970e18664736f6c63430008110033
|
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/proxy/beacon/IBeacon.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"
},
"@openzeppelin/contracts/proxy/Proxy.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n"
},
"contracts/utils/BeaconProxy.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/proxy/beacon/IBeacon.sol\";\nimport \"@openzeppelin/contracts/proxy/Proxy.sol\";\n\n/// @custom:security-contact security@p00ls.com\ncontract BeaconProxy is Proxy {\n IBeacon private immutable _beacon;\n\n event BeaconUpgraded(IBeacon indexed beacon);\n\n constructor(IBeacon beacon)\n {\n _beacon = beacon;\n emit BeaconUpgraded(beacon);\n }\n\n function _implementation()\n internal\n view\n override\n returns (address)\n {\n return _beacon.implementation();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"debug": {
"revertStrings": "strip"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,498,552 |
1deba18246e81d166977089eb3d5e127e9b2550eef08caef14341975261d02f4
|
641f17dfd0baac092659dd5ad165fba55d2f8afaae8982dbc1e9150b07fadedd
|
b02c6c40a798184d5e012fbb1dc698977671f8fc
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
58c203de25b9e971ac3a8b05a9fb934bd7bc0a36
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,559 |
8de334799bb4f030263fcdc251ee15d8aed14e7120208f583bc69d0ee3bdd940
|
7a27d48b45843b4b55ed1226fd10208063bfc74a2e8a4dbc1820654034ff8f17
|
9128a1f52d0e8c25bbc6c442d49644626f834c6e
|
1e68238ce926dec62b3fbc99ab06eb1d85ce0270
|
7a5ace72b8320142ef7b0ecd11b73fb5e569548f
|
3d602d80600a3d3981f3363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/contracts/ConsensusLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Consensus Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ConsensusLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n error NotImplemented();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ConsensusLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ConsensusLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract\n /// @param _stakingContract Address of the Staking Contract\n function initCLD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32) external payable {\n revert NotImplemented();\n /*\n uint256 balance = address(this).balance; // this has taken into account msg.value\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee;\n\n if (balance >= 32 ether) {\n // withdrawing a healthy & exited validator\n globalFee = ((balance - 32 ether) * stakingContract.getGlobalFee()) / BASIS_POINTS;\n } else if (balance <= 16 ether) {\n // withdrawing from what looks like skimming\n globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n }\n\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(withdrawer, operator, balance - globalFee, operatorFee, globalFee - operatorFee);\n */\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
},
"src/contracts/libs/DispatchersStorageLib.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\nlibrary DispatchersStorageLib {\n function getUint256(bytes32 position) internal view returns (uint256 data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setUint256(bytes32 position, uint256 data) internal {\n assembly {\n sstore(position, data)\n }\n }\n\n function getAddress(bytes32 position) internal view returns (address data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setAddress(bytes32 position, address data) internal {\n assembly {\n sstore(position, data)\n }\n }\n}\n"
},
"src/contracts/interfaces/IStakingContractFeeDetails.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IStakingContractFeeDetails {\n function getWithdrawerFromPublicKeyRoot(bytes32 _publicKeyRoot) external view returns (address);\n\n function getTreasury() external view returns (address);\n\n function getOperatorFeeRecipient(bytes32 pubKeyRoot) external view returns (address);\n\n function getGlobalFee() external view returns (uint256);\n\n function getOperatorFee() external view returns (uint256);\n}\n"
},
"src/contracts/interfaces/IFeeDispatcher.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IFeeDispatcher {\n function dispatch(bytes32 _publicKeyRoot) external payable;\n\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address);\n}\n"
},
"src/contracts/FeeRecipient.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./interfaces/IFeeDispatcher.sol\";\n\ncontract FeeRecipient {\n /// @notice Constructor replay prevention\n bool internal initialized;\n /// @notice Address where funds are sent to be dispatched\n IFeeDispatcher internal dispatcher;\n /// @notice Public Key root assigned to this receiver\n bytes32 internal publicKeyRoot;\n\n error AlreadyInitialized();\n\n /// @notice Initializes the receiver\n /// @param _dispatcher Address that will handle the fee dispatching\n /// @param _publicKeyRoot Public Key root assigned to this receiver\n function init(address _dispatcher, bytes32 _publicKeyRoot) external {\n if (initialized) {\n revert AlreadyInitialized();\n }\n initialized = true;\n dispatcher = IFeeDispatcher(_dispatcher);\n publicKeyRoot = _publicKeyRoot;\n }\n\n /// @notice Empty calldata fallback\n receive() external payable {}\n\n /// @notice Non-empty calldata fallback\n fallback() external payable {}\n\n /// @notice Triggers a withdrawal by sending its funds + its public key root to the dispatcher\n /// @dev Can be called by any wallet as recipients are not parameters\n function withdraw() external {\n dispatcher.dispatch{value: address(this).balance}(publicKeyRoot);\n }\n\n /// @notice Retrieve the assigned public key root\n function getPublicKeyRoot() external view returns (bytes32) {\n return publicKeyRoot;\n }\n\n /// @notice retrieve the assigned withdrawer\n function getWithdrawer() external view returns (address) {\n return dispatcher.getWithdrawer(publicKeyRoot);\n }\n}\n"
},
"src/contracts/ExecutionLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Execution Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ExecutionLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ExecutionLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ExecutionLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract and the public key in storage\n /// @param _stakingContract Address of the Staking Contract\n function initELD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32 _publicKeyRoot) external payable {\n uint256 balance = address(this).balance;\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(\n withdrawer,\n operator,\n _publicKeyRoot,\n balance - globalFee,\n operatorFee,\n globalFee - operatorFee\n );\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}}
|
1 | 19,498,559 |
8de334799bb4f030263fcdc251ee15d8aed14e7120208f583bc69d0ee3bdd940
|
7a27d48b45843b4b55ed1226fd10208063bfc74a2e8a4dbc1820654034ff8f17
|
9128a1f52d0e8c25bbc6c442d49644626f834c6e
|
1e68238ce926dec62b3fbc99ab06eb1d85ce0270
|
073eb9567880a4f6540d6f26c8ab80eba1f2d825
|
3d602d80600a3d3981f3363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/contracts/ConsensusLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Consensus Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ConsensusLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n error NotImplemented();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ConsensusLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ConsensusLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract\n /// @param _stakingContract Address of the Staking Contract\n function initCLD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32) external payable {\n revert NotImplemented();\n /*\n uint256 balance = address(this).balance; // this has taken into account msg.value\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee;\n\n if (balance >= 32 ether) {\n // withdrawing a healthy & exited validator\n globalFee = ((balance - 32 ether) * stakingContract.getGlobalFee()) / BASIS_POINTS;\n } else if (balance <= 16 ether) {\n // withdrawing from what looks like skimming\n globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n }\n\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(withdrawer, operator, balance - globalFee, operatorFee, globalFee - operatorFee);\n */\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
},
"src/contracts/libs/DispatchersStorageLib.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\nlibrary DispatchersStorageLib {\n function getUint256(bytes32 position) internal view returns (uint256 data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setUint256(bytes32 position, uint256 data) internal {\n assembly {\n sstore(position, data)\n }\n }\n\n function getAddress(bytes32 position) internal view returns (address data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setAddress(bytes32 position, address data) internal {\n assembly {\n sstore(position, data)\n }\n }\n}\n"
},
"src/contracts/interfaces/IStakingContractFeeDetails.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IStakingContractFeeDetails {\n function getWithdrawerFromPublicKeyRoot(bytes32 _publicKeyRoot) external view returns (address);\n\n function getTreasury() external view returns (address);\n\n function getOperatorFeeRecipient(bytes32 pubKeyRoot) external view returns (address);\n\n function getGlobalFee() external view returns (uint256);\n\n function getOperatorFee() external view returns (uint256);\n}\n"
},
"src/contracts/interfaces/IFeeDispatcher.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IFeeDispatcher {\n function dispatch(bytes32 _publicKeyRoot) external payable;\n\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address);\n}\n"
},
"src/contracts/FeeRecipient.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./interfaces/IFeeDispatcher.sol\";\n\ncontract FeeRecipient {\n /// @notice Constructor replay prevention\n bool internal initialized;\n /// @notice Address where funds are sent to be dispatched\n IFeeDispatcher internal dispatcher;\n /// @notice Public Key root assigned to this receiver\n bytes32 internal publicKeyRoot;\n\n error AlreadyInitialized();\n\n /// @notice Initializes the receiver\n /// @param _dispatcher Address that will handle the fee dispatching\n /// @param _publicKeyRoot Public Key root assigned to this receiver\n function init(address _dispatcher, bytes32 _publicKeyRoot) external {\n if (initialized) {\n revert AlreadyInitialized();\n }\n initialized = true;\n dispatcher = IFeeDispatcher(_dispatcher);\n publicKeyRoot = _publicKeyRoot;\n }\n\n /// @notice Empty calldata fallback\n receive() external payable {}\n\n /// @notice Non-empty calldata fallback\n fallback() external payable {}\n\n /// @notice Triggers a withdrawal by sending its funds + its public key root to the dispatcher\n /// @dev Can be called by any wallet as recipients are not parameters\n function withdraw() external {\n dispatcher.dispatch{value: address(this).balance}(publicKeyRoot);\n }\n\n /// @notice Retrieve the assigned public key root\n function getPublicKeyRoot() external view returns (bytes32) {\n return publicKeyRoot;\n }\n\n /// @notice retrieve the assigned withdrawer\n function getWithdrawer() external view returns (address) {\n return dispatcher.getWithdrawer(publicKeyRoot);\n }\n}\n"
},
"src/contracts/ExecutionLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Execution Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ExecutionLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ExecutionLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ExecutionLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract and the public key in storage\n /// @param _stakingContract Address of the Staking Contract\n function initELD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32 _publicKeyRoot) external payable {\n uint256 balance = address(this).balance;\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(\n withdrawer,\n operator,\n _publicKeyRoot,\n balance - globalFee,\n operatorFee,\n globalFee - operatorFee\n );\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}}
|
1 | 19,498,559 |
8de334799bb4f030263fcdc251ee15d8aed14e7120208f583bc69d0ee3bdd940
|
7a27d48b45843b4b55ed1226fd10208063bfc74a2e8a4dbc1820654034ff8f17
|
9128a1f52d0e8c25bbc6c442d49644626f834c6e
|
1e68238ce926dec62b3fbc99ab06eb1d85ce0270
|
816dbd634963e081943758bf6c3b8ffe0c82ea8f
|
3d602d80600a3d3981f3363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/contracts/ConsensusLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Consensus Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ConsensusLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n error NotImplemented();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ConsensusLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ConsensusLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract\n /// @param _stakingContract Address of the Staking Contract\n function initCLD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32) external payable {\n revert NotImplemented();\n /*\n uint256 balance = address(this).balance; // this has taken into account msg.value\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee;\n\n if (balance >= 32 ether) {\n // withdrawing a healthy & exited validator\n globalFee = ((balance - 32 ether) * stakingContract.getGlobalFee()) / BASIS_POINTS;\n } else if (balance <= 16 ether) {\n // withdrawing from what looks like skimming\n globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n }\n\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(withdrawer, operator, balance - globalFee, operatorFee, globalFee - operatorFee);\n */\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
},
"src/contracts/libs/DispatchersStorageLib.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\nlibrary DispatchersStorageLib {\n function getUint256(bytes32 position) internal view returns (uint256 data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setUint256(bytes32 position, uint256 data) internal {\n assembly {\n sstore(position, data)\n }\n }\n\n function getAddress(bytes32 position) internal view returns (address data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setAddress(bytes32 position, address data) internal {\n assembly {\n sstore(position, data)\n }\n }\n}\n"
},
"src/contracts/interfaces/IStakingContractFeeDetails.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IStakingContractFeeDetails {\n function getWithdrawerFromPublicKeyRoot(bytes32 _publicKeyRoot) external view returns (address);\n\n function getTreasury() external view returns (address);\n\n function getOperatorFeeRecipient(bytes32 pubKeyRoot) external view returns (address);\n\n function getGlobalFee() external view returns (uint256);\n\n function getOperatorFee() external view returns (uint256);\n}\n"
},
"src/contracts/interfaces/IFeeDispatcher.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IFeeDispatcher {\n function dispatch(bytes32 _publicKeyRoot) external payable;\n\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address);\n}\n"
},
"src/contracts/FeeRecipient.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./interfaces/IFeeDispatcher.sol\";\n\ncontract FeeRecipient {\n /// @notice Constructor replay prevention\n bool internal initialized;\n /// @notice Address where funds are sent to be dispatched\n IFeeDispatcher internal dispatcher;\n /// @notice Public Key root assigned to this receiver\n bytes32 internal publicKeyRoot;\n\n error AlreadyInitialized();\n\n /// @notice Initializes the receiver\n /// @param _dispatcher Address that will handle the fee dispatching\n /// @param _publicKeyRoot Public Key root assigned to this receiver\n function init(address _dispatcher, bytes32 _publicKeyRoot) external {\n if (initialized) {\n revert AlreadyInitialized();\n }\n initialized = true;\n dispatcher = IFeeDispatcher(_dispatcher);\n publicKeyRoot = _publicKeyRoot;\n }\n\n /// @notice Empty calldata fallback\n receive() external payable {}\n\n /// @notice Non-empty calldata fallback\n fallback() external payable {}\n\n /// @notice Triggers a withdrawal by sending its funds + its public key root to the dispatcher\n /// @dev Can be called by any wallet as recipients are not parameters\n function withdraw() external {\n dispatcher.dispatch{value: address(this).balance}(publicKeyRoot);\n }\n\n /// @notice Retrieve the assigned public key root\n function getPublicKeyRoot() external view returns (bytes32) {\n return publicKeyRoot;\n }\n\n /// @notice retrieve the assigned withdrawer\n function getWithdrawer() external view returns (address) {\n return dispatcher.getWithdrawer(publicKeyRoot);\n }\n}\n"
},
"src/contracts/ExecutionLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Execution Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ExecutionLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ExecutionLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ExecutionLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract and the public key in storage\n /// @param _stakingContract Address of the Staking Contract\n function initELD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32 _publicKeyRoot) external payable {\n uint256 balance = address(this).balance;\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(\n withdrawer,\n operator,\n _publicKeyRoot,\n balance - globalFee,\n operatorFee,\n globalFee - operatorFee\n );\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}}
|
1 | 19,498,559 |
8de334799bb4f030263fcdc251ee15d8aed14e7120208f583bc69d0ee3bdd940
|
7a27d48b45843b4b55ed1226fd10208063bfc74a2e8a4dbc1820654034ff8f17
|
9128a1f52d0e8c25bbc6c442d49644626f834c6e
|
1e68238ce926dec62b3fbc99ab06eb1d85ce0270
|
d09e1e04526798450c3d5266e347c4b1a4009b5c
|
3d602d80600a3d3981f3363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/contracts/ConsensusLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Consensus Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ConsensusLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n error NotImplemented();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ConsensusLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ConsensusLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract\n /// @param _stakingContract Address of the Staking Contract\n function initCLD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32) external payable {\n revert NotImplemented();\n /*\n uint256 balance = address(this).balance; // this has taken into account msg.value\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee;\n\n if (balance >= 32 ether) {\n // withdrawing a healthy & exited validator\n globalFee = ((balance - 32 ether) * stakingContract.getGlobalFee()) / BASIS_POINTS;\n } else if (balance <= 16 ether) {\n // withdrawing from what looks like skimming\n globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n }\n\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(withdrawer, operator, balance - globalFee, operatorFee, globalFee - operatorFee);\n */\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
},
"src/contracts/libs/DispatchersStorageLib.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\nlibrary DispatchersStorageLib {\n function getUint256(bytes32 position) internal view returns (uint256 data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setUint256(bytes32 position, uint256 data) internal {\n assembly {\n sstore(position, data)\n }\n }\n\n function getAddress(bytes32 position) internal view returns (address data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setAddress(bytes32 position, address data) internal {\n assembly {\n sstore(position, data)\n }\n }\n}\n"
},
"src/contracts/interfaces/IStakingContractFeeDetails.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IStakingContractFeeDetails {\n function getWithdrawerFromPublicKeyRoot(bytes32 _publicKeyRoot) external view returns (address);\n\n function getTreasury() external view returns (address);\n\n function getOperatorFeeRecipient(bytes32 pubKeyRoot) external view returns (address);\n\n function getGlobalFee() external view returns (uint256);\n\n function getOperatorFee() external view returns (uint256);\n}\n"
},
"src/contracts/interfaces/IFeeDispatcher.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IFeeDispatcher {\n function dispatch(bytes32 _publicKeyRoot) external payable;\n\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address);\n}\n"
},
"src/contracts/FeeRecipient.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./interfaces/IFeeDispatcher.sol\";\n\ncontract FeeRecipient {\n /// @notice Constructor replay prevention\n bool internal initialized;\n /// @notice Address where funds are sent to be dispatched\n IFeeDispatcher internal dispatcher;\n /// @notice Public Key root assigned to this receiver\n bytes32 internal publicKeyRoot;\n\n error AlreadyInitialized();\n\n /// @notice Initializes the receiver\n /// @param _dispatcher Address that will handle the fee dispatching\n /// @param _publicKeyRoot Public Key root assigned to this receiver\n function init(address _dispatcher, bytes32 _publicKeyRoot) external {\n if (initialized) {\n revert AlreadyInitialized();\n }\n initialized = true;\n dispatcher = IFeeDispatcher(_dispatcher);\n publicKeyRoot = _publicKeyRoot;\n }\n\n /// @notice Empty calldata fallback\n receive() external payable {}\n\n /// @notice Non-empty calldata fallback\n fallback() external payable {}\n\n /// @notice Triggers a withdrawal by sending its funds + its public key root to the dispatcher\n /// @dev Can be called by any wallet as recipients are not parameters\n function withdraw() external {\n dispatcher.dispatch{value: address(this).balance}(publicKeyRoot);\n }\n\n /// @notice Retrieve the assigned public key root\n function getPublicKeyRoot() external view returns (bytes32) {\n return publicKeyRoot;\n }\n\n /// @notice retrieve the assigned withdrawer\n function getWithdrawer() external view returns (address) {\n return dispatcher.getWithdrawer(publicKeyRoot);\n }\n}\n"
},
"src/contracts/ExecutionLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Execution Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ExecutionLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ExecutionLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ExecutionLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract and the public key in storage\n /// @param _stakingContract Address of the Staking Contract\n function initELD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32 _publicKeyRoot) external payable {\n uint256 balance = address(this).balance;\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(\n withdrawer,\n operator,\n _publicKeyRoot,\n balance - globalFee,\n operatorFee,\n globalFee - operatorFee\n );\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}}
|
1 | 19,498,559 |
8de334799bb4f030263fcdc251ee15d8aed14e7120208f583bc69d0ee3bdd940
|
7a27d48b45843b4b55ed1226fd10208063bfc74a2e8a4dbc1820654034ff8f17
|
9128a1f52d0e8c25bbc6c442d49644626f834c6e
|
1e68238ce926dec62b3fbc99ab06eb1d85ce0270
|
0496f0d418553bc1f18f5167d43b07a356728740
|
3d602d80600a3d3981f3363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/contracts/ConsensusLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Consensus Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ConsensusLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n error NotImplemented();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ConsensusLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ConsensusLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract\n /// @param _stakingContract Address of the Staking Contract\n function initCLD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32) external payable {\n revert NotImplemented();\n /*\n uint256 balance = address(this).balance; // this has taken into account msg.value\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee;\n\n if (balance >= 32 ether) {\n // withdrawing a healthy & exited validator\n globalFee = ((balance - 32 ether) * stakingContract.getGlobalFee()) / BASIS_POINTS;\n } else if (balance <= 16 ether) {\n // withdrawing from what looks like skimming\n globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n }\n\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(withdrawer, operator, balance - globalFee, operatorFee, globalFee - operatorFee);\n */\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
},
"src/contracts/libs/DispatchersStorageLib.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\nlibrary DispatchersStorageLib {\n function getUint256(bytes32 position) internal view returns (uint256 data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setUint256(bytes32 position, uint256 data) internal {\n assembly {\n sstore(position, data)\n }\n }\n\n function getAddress(bytes32 position) internal view returns (address data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setAddress(bytes32 position, address data) internal {\n assembly {\n sstore(position, data)\n }\n }\n}\n"
},
"src/contracts/interfaces/IStakingContractFeeDetails.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IStakingContractFeeDetails {\n function getWithdrawerFromPublicKeyRoot(bytes32 _publicKeyRoot) external view returns (address);\n\n function getTreasury() external view returns (address);\n\n function getOperatorFeeRecipient(bytes32 pubKeyRoot) external view returns (address);\n\n function getGlobalFee() external view returns (uint256);\n\n function getOperatorFee() external view returns (uint256);\n}\n"
},
"src/contracts/interfaces/IFeeDispatcher.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IFeeDispatcher {\n function dispatch(bytes32 _publicKeyRoot) external payable;\n\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address);\n}\n"
},
"src/contracts/FeeRecipient.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./interfaces/IFeeDispatcher.sol\";\n\ncontract FeeRecipient {\n /// @notice Constructor replay prevention\n bool internal initialized;\n /// @notice Address where funds are sent to be dispatched\n IFeeDispatcher internal dispatcher;\n /// @notice Public Key root assigned to this receiver\n bytes32 internal publicKeyRoot;\n\n error AlreadyInitialized();\n\n /// @notice Initializes the receiver\n /// @param _dispatcher Address that will handle the fee dispatching\n /// @param _publicKeyRoot Public Key root assigned to this receiver\n function init(address _dispatcher, bytes32 _publicKeyRoot) external {\n if (initialized) {\n revert AlreadyInitialized();\n }\n initialized = true;\n dispatcher = IFeeDispatcher(_dispatcher);\n publicKeyRoot = _publicKeyRoot;\n }\n\n /// @notice Empty calldata fallback\n receive() external payable {}\n\n /// @notice Non-empty calldata fallback\n fallback() external payable {}\n\n /// @notice Triggers a withdrawal by sending its funds + its public key root to the dispatcher\n /// @dev Can be called by any wallet as recipients are not parameters\n function withdraw() external {\n dispatcher.dispatch{value: address(this).balance}(publicKeyRoot);\n }\n\n /// @notice Retrieve the assigned public key root\n function getPublicKeyRoot() external view returns (bytes32) {\n return publicKeyRoot;\n }\n\n /// @notice retrieve the assigned withdrawer\n function getWithdrawer() external view returns (address) {\n return dispatcher.getWithdrawer(publicKeyRoot);\n }\n}\n"
},
"src/contracts/ExecutionLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Execution Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ExecutionLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ExecutionLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ExecutionLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract and the public key in storage\n /// @param _stakingContract Address of the Staking Contract\n function initELD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32 _publicKeyRoot) external payable {\n uint256 balance = address(this).balance;\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(\n withdrawer,\n operator,\n _publicKeyRoot,\n balance - globalFee,\n operatorFee,\n globalFee - operatorFee\n );\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}}
|
1 | 19,498,563 |
a0829c70dc9ace86d0bf314e28e6a04bff507b108d7bc953c5df4deca292f719
|
409a2ef1edccd6c1d689a811ede2438425b6ce65099a448b7fc71b60c19b2965
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
636de7c651ba04f030326cea780a496a1f1e7def
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,566 |
b71cd45e92d41d38e5acfe99013eaf9e13a81743f895c9160e81907fa8df3adc
|
8e7eca25df602cb6e8322cafa78c045d928eaef58f4a19590bf106d4fcf6e7e2
|
000099b4a4d3ceb370d3a8a6235d24e07a8c0000
|
ee2a0343e825b2e5981851299787a679ce08216d
|
7a7942b819d5cff7907657e8af93b5abbb5df10d
|
6080604052348015600f57600080fd5b50604051610211380380610211833981016040819052602c916059565b600080546001600160a01b039092166001600160a01b031992831617905560018054909116331790556087565b600060208284031215606a57600080fd5b81516001600160a01b0381168114608057600080fd5b9392505050565b61017b806100966000396000f3fe60806040526004361061002d5760003560e01c80638da5cb5b146100d9578063d4b839921461011557610034565b3661003457005b600154336001600160a01b03909116036100a257600080546040516001600160a01b03909116906100689083903690610135565b600060405180830381855af49150503d80600081146100a0576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b3480156100e557600080fd5b506001546100f9906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b34801561012157600080fd5b506000546100f9906001600160a01b031681565b818382376000910190815291905056fea264697066735822122072fb1ca36d430fdff59e91c1f28c88a6d1e6ee148f01591a2f4693fddcfb655264736f6c634300081900330000000000000000000000008906668094934bbfd0f787010fac65d8438019f5
|
60806040526004361061002d5760003560e01c80638da5cb5b146100d9578063d4b839921461011557610034565b3661003457005b600154336001600160a01b03909116036100a257600080546040516001600160a01b03909116906100689083903690610135565b600060405180830381855af49150503d80600081146100a0576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b3480156100e557600080fd5b506001546100f9906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b34801561012157600080fd5b506000546100f9906001600160a01b031681565b818382376000910190815291905056fea264697066735822122072fb1ca36d430fdff59e91c1f28c88a6d1e6ee148f01591a2f4693fddcfb655264736f6c63430008190033
| |
1 | 19,498,568 |
9403a9dce64766d697595fb4ffcea2aa5469b61c84613570546eaffb1a653069
|
92379ed3631e200998e0096b1b58b4f094f294d2b52e239d89043d72610cf5b5
|
4e565f63257d90f988e5ec9d065bab00f94d2dfd
|
9fa5c5733b53814692de4fb31fd592070de5f5f0
|
1633670cc42d33396a1f6a7c578db2e2c0be75e5
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,498,577 |
16ec2089b62b4359aa42f0170faccaecd860e6f00252e16105554f27ad1592e7
|
370fef097f47cec46b0f5a4bd9d5dd591ed12fbfe686d56c79e40bb89cafa23d
|
25cc92848281e1cbed9d21466a5b04a7995bcb43
|
25cc92848281e1cbed9d21466a5b04a7995bcb43
|
4fa4daadd032359d0b26dca068885876ac7fe4bb
|
6080604052670de0b6b3a764000060025566b1a2bc2ec500006003556004805460ff191690557f8a727dc41d83211e47d3c0de4f643835121597034f4a7c93ebf19333a48301af6007557f8a727dc41d83211e47d3c0de2a711c495996e2725d7612974eed7b758777eaab6008557f8a727dc41d83211e47d3c0de5f8b7b37c4e4163f5f773f2362872769c349730e60095534801561009d57600080fd5b50600080546001600160a01b031916331781556007546008546100be911890565b60405163e2d73ccd60e01b81523060048201529091506001600160a01b0382169063e2d73ccd90602401600060405180830381600087803b15801561010257600080fd5b505af1158015610116573d6000803e3d6000fd5b50505050506103678061012a6000396000f3fe6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212203708b67b52c1aacde61f38115a306dcb96752bf7204f30968b898d6a731ef4ae64736f6c63430008070033
|
6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212203708b67b52c1aacde61f38115a306dcb96752bf7204f30968b898d6a731ef4ae64736f6c63430008070033
| |
1 | 19,498,577 |
16ec2089b62b4359aa42f0170faccaecd860e6f00252e16105554f27ad1592e7
|
7797de05c332d82fb80d91d4011ae7f50fdb2aa95bc0ddd711b310c221c013c2
|
523bea316bbd9f0fdd0b1ac07e95660670368881
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
cdac677f4a3e04e2c714c793c174fbc018750e0c
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
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 (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,498,583 |
b3576de1b277254868393cb1626995a4b40c48608e379a2386537ac27c0a5a94
|
402cb66fb8662b7b167dcffb7041ea2579fa7caa687fad209ea02558c6911724
|
948461a52cd1c604e19e2b8308109b1355720bff
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
e76742f85cea591149ed3745b4c43e9402816bb8
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
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 (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,498,587 |
328fa8586de7f0a3a21e84c9acb3180a8f542daedb18222d98fcdca259704d5e
|
9d0b7655ba8baaf64edd928bfa95914a9a042b45c5f5e9749aa8253b98d720cf
|
a7fb5ca286fc3fd67525629048a4de3ba24cba2e
|
c77ad0a71008d7094a62cfbd250a2eb2afdf2776
|
ff3518398228ab9a05f8d6eadf45cd7cbef154a6
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,498,589 |
cca09afb3c3ec8d6f50057638f9c0c087b23abb0fbe0bc06b809a1d3bd05b42d
|
4bb2493ef24f402009d1a1b0c668c4074568bf5b68ccc9f3d81ff0648de8769c
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
3ced0801fc4ca43f80444e5d8e5d0fe643fd22b8
|
608060405234801561001057600080fd5b50612ee8806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806301ffc9a7146100515780636715f82514610079578063758c13b61461009a578063f933c72f146100ad575b600080fd5b61006461005f366004612703565b6100c2565b60405190151581526020015b60405180910390f35b61008c6100873660046128f7565b6101a7565b604051610070929190612995565b61008c6100a83660046129d1565b61023c565b6100b5610294565b6040516100709190612b67565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f9e263f0a00000000000000000000000000000000000000000000000000000000148061015557507fffffffff0000000000000000000000000000000000000000000000000000000082167f758c13b600000000000000000000000000000000000000000000000000000000145b806101a157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b606080602084901c601085901c61ffff861660006101c4846102a3565b905061ffff8316600061020b826101e58d3360009182526020526040902090565b8e8c6040518060800160405280605a8152602001612e8e605a913988949392919061034a565b6040805160008152602081019091529091506102299082908661049b565b9750975050505050505094509492505050565b606080600061ffff871690506000610275828b8d896040518060800160405280605a8152602001612e8e605a91398e949392919061034a565b905061028281868961049b565b93509350505097509795505050505050565b606061029e610609565b905090565b6060813b60008190036102e2576040517f26a9f61e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051603e83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01681019091527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90910180825290915080600160208401853c50919050565b6103af6040518061012001604052806060815260200160608152602001600081526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016060815260200160608152602001606081525090565b602087810180516040600191820184028b01818101518251600091821a808252948501870281019093526041808301968381019593600285020190910191908401905b8381101561043057875160f01c83015160408051600192831a80825283016020908102909101918290529084526002909901989290920191016103f2565b505050506040518061012001604052808281526020018481526020018b8152602001600081526020018a81526020018973ffffffffffffffffffffffffffffffffffffffff168152602001888152602001838152602001878152509450505050509695505050505050565b6060806000806104b38760e0015188604001516107bf565b91509150600087600001518860400151815181106104d3576104d3612b7a565b6020026020010151905060008751111561050a57600060208851028203915060208801905061050481838a516107e4565b5061055a565b8287511461055a5786516040517fd628439f000000000000000000000000000000000000000000000000000000008152610551918591600401918252602082015260400190565b60405180910390fd5b610564888261080c565b905060008287106105755782610577565b865b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08084018281529192508390602084028201015b808210156105e85781518151835281526020909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016105ab565b5050806105f88b60600151610a95565b965096505050505050935093915050565b604080516105c081018252602d808252610d096020830152610d5592820192909252610d90606082810191909152610da96080830152610e4760a0830152610f2b60c0830152610f6560e08301526110156101008301526110b76101208301526110e661014083015261111561016083018190526101808301526111646101a08301526111936101c08301526111f56101e083015261127d61020083015261132461022083015261133861024083015261138e6102608301526113a26102808301526113b76102a08301526113d16102c08301526113dc6102e08301526113f06103008301526114056103208301526114826103408301526114cd6103608301526114f361038083015261150a6103a08301526115216103c083018190526103e083015261156c6104008301526115b7610420830152611602610440830181905261046083015261164d61048083018190526104a08301526116986104c08301526116e36104e083015261172e61050083018190526105208301526117796105408301526118606105608301526118936105808301526118ea6105a083015291908190806107b68161191c565b94505050505090565b60008060006107ce85856119ad565b51600281901a9660039190911a95509350505050565b8060200283015b808410156108065783518352602093840193909201916107eb565b50505050565b6000808360400151905060008060008060006002896101000151516108319190612c07565b60e08a01516101008b0151602080830151600261ffff9b909b168b8102850160219081015160f01c600093841a9d909d029095019b909b019384015160258086019b50600791831a9182169182900360040290950190940198509296500193509091506126f990805b86881015610a1d57875190506002848260001a060285015160f01c925062ffffff8160e01c1691506108d18c838d8663ffffffff16565b9a506002848260041a060285015160f01c925062ffffff8160c01c1691506108fe8c838d8663ffffffff16565b9a506002848260081a060285015160f01c925062ffffff8160a01c16915061092b8c838d8663ffffffff16565b9a5060028482600c1a060285015160f01c925062ffffff8160801c1691506109588c838d8663ffffffff16565b9a506002848260101a060285015160f01c925062ffffff8160601c1691506109858c838d8663ffffffff16565b9a506002848260141a060285015160f01c925062ffffff8160401c1691506109b28c838d8663ffffffff16565b9a506002848260181a060285015160f01c925062ffffff8160201c1691506109df8c838d8663ffffffff16565b9a5060028482601c1a060285015160f01c925062ffffff81169150610a098c838d8663ffffffff16565b9a50610a16602089612c1b565b975061089a565b610a28601c89612c2e565b9750610a35866004612c41565b610a3f9089612c1b565b96505b86881015610a855750508551601c81901a83900660020284015160f01c915062ffffff811690610a718c838d86565b9a50610a7e600489612c1b565b9750610a42565b50989a9950505050505050505050565b6040805160f083901c602081810283010190925290815261ffff63ffffffff67ffffffffffffffff6fffffffffffffffffffffffffffffffff610b02565b60005b8215610afc57825182526020830151602083015260408301519250604082019150610ad6565b50919050565b602085018660101b60901c8015610bf2578060401c8015610b70578060201c8015610b3457610b318185610ad3565b93505b508086168015610b6e578060101c8015610b5557610b528186610ad3565b94505b508088168015610b6c57610b698186610ad3565b94505b505b505b508084168015610bf0578060201c8015610bb4578060101c8015610b9b57610b988186610ad3565b94505b508088168015610bb257610baf8186610ad3565b94505b505b508086168015610bee578060101c8015610bd557610bd28186610ad3565b94505b508088168015610bec57610be98186610ad3565b94505b505b505b505b508682168015610cfe578060401c8015610c7c578060201c8015610c40578060101c8015610c2757610c248186610ad3565b94505b508088168015610c3e57610c3b8186610ad3565b94505b505b508086168015610c7a578060101c8015610c6157610c5e8186610ad3565b94505b508088168015610c7857610c758186610ad3565b94505b505b505b508084168015610cfc578060201c8015610cc0578060101c8015610ca757610ca48186610ad3565b94505b508088168015610cbe57610cbb8186610ad3565b94505b505b508086168015610cfa578060101c8015610ce157610cde8186610ad3565b94505b508088168015610cf857610cf58186610ad3565b94505b505b505b505b505050505050919050565b604083015183516020600192830181029190910151918401029003517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909101908152805b9392505050565b60209283015160019290920190920201517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090910190815290565b8051600090610d9e816119de565b835250909392505050565b8251602060ff8481166001810183028401516000949193600888901c841693601089901c16929190830287015b80881015610df35760208203915087518252602088019750610dd6565b5060408901805190869052610e088a8361080c565b60408b018290526020860298899003989092508201885b81841015610e37578351815260209384019301610e1f565b50979a9950505050505050505050565b600060ff8316600884901c6020841015610ebd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f737461636b20756e646572666c6f7700000000000000000000000000000000006044820152606401610551565b60008660c001518381518110610ed557610ed5612b7a565b60200260200101518281518110610eee57610eee612b7a565b60209081029190910101517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909501948552509295945050505050565b60109190911c6020028082207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190920101908152919050565b8051602090910180516040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152929360009390929184918416906370a0823190602401602060405180830381865afa158015610fe4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110089190612c58565b8552509295945050505050565b8051602090910180516040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018290529192600092909190839073ffffffffffffffffffffffffffffffffffffffff841690636352211e90602401602060405180830381865afa158015611093573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110089190612c71565b437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190910190815292915050565b467fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190910190815292915050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190910190815292915050565b427fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190910190815292915050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601083901c602002828101918201926000925b808210156111ea57815180156111de5785526111ea565b506020820191506111c7565b509295945050505050565b6000808260208560101c0281016020810394505b80821015611232578151925082156112275760208201518552611232565b604082019150611209565b505080600003611274576040517fff86627a00000000000000000000000000000000000000000000000000000000815261ffff85166004820152602401610551565b50909392505050565b8051600090602080840190601086901c0284015b6000831181831016156112ad5781519250602082019150611291565b508160000361131b576040517f40dccdf600000000000000000000000000000000000000000000000000000000815261ffff8616600482015260208583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001046024820152604401610551565b95945050505050565b805160209091018051909114815292915050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601083901c602002828101918201926000925b808210156111ea578151806113825785526111ea565b5060208201915061136c565b805160209091018051909111815292915050565b80516020909101805190911015815292915050565b805160409015156020028203810151910190815292915050565b805115815292915050565b805160209091018051909110815292915050565b80516020909101805190911115815292915050565b80516020820151604090920191600091906114208282611ab7565b9150601085901c60025b8181101561145057855192506020860195506114468484611ab7565b935060010161142a565b5050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0929092019182525092915050565b805160208201516040909201916000919061149d8282611ad2565b9150601085901c60025b8181101561145057855192506020860195506114c38484611ad2565b93506001016114a7565b8051602090910180519091600091906114e7828287611ae1565b84525091949350505050565b8051600090610d9e8160ff8616600887901c611ae1565b8051600090610d9e8160ff8616600887901c611b66565b805160208201516040909201916000919061153c8183612c1b565b9150601085901c60025b8181101561145057855160209096019592506115628385612c1b565b9350600101611546565b80516020820151604090920191600091906115878183612c07565b9150601085901c60025b8181101561145057855160209096019592506115ad8385612c07565b9350600101611591565b80516020820151604090920191600091906115d28183612dae565b9150601085901c60025b8181101561145057855160209096019592506115f88385612dae565b93506001016115dc565b80516020820151604090920191600091908082101561161f578091505b601085901c60025b81811015611450578551925060208601955082841015611645578293505b600101611627565b80516020820151604090920191600091908082111561166a578091505b601085901c60025b81811015611450578551925060208601955082841115611690578293505b600101611672565b80516020820151604090920191600091906116b38183612dba565b9150601085901c60025b8181101561145057855160209096019592506116d98385612dba565b93506001016116bd565b80516020820151604090920191600091906116fe8183612c41565b9150601085901c60025b8181101561145057855160209096019592506117248385612c41565b9350600101611708565b80516020820151604090920191600091906117498183612c2e565b9150601085901c60025b81811015611450578551602090960195925061176f8385612c2e565b9350600101611753565b8051606084015160009190829081906117929084611bc8565b91509150816000036114e75760a087015160808801516040517f669e48aa00000000000000000000000000000000000000000000000000000000815260048101919091526024810185905260009173ffffffffffffffffffffffffffffffffffffffff169063669e48aa90604401602060405180830381865afa15801561181d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118419190612c58565b6060890151909150611854908583611c12565b606089015285526111ea565b8051602082015160608501516040909301926000929190611882908383611c12565b606087015250829150509392505050565b80516020808301516040808501516060860151600188161590940290950101936000939284806118c586858588611ca4565b9150915081885260018916156118dc578060208901525b509598975050505050505050565b80516020808301516040808501516060860151600188161590940290950101936000939284806118c586858588611ce6565b60606000825160020267ffffffffffffffff81111561193d5761193d61276a565b6040519080825280601f01601f191660200182016040528015611967576020820181803683370190505b50905061ffff80196020850160208651028101600285015b818310156119a15780518351861690851617815260209092019160020161197f565b50939695505050505050565b6000806119b984611d12565b600202600101905060006119cd8585611d30565b949091019093016020019392505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611a105750610100919050565b507f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f7f5555555555555555555555555555555555555555555555555555555555555555600183901c16909103600281901c7f3333333333333333333333333333333333333333333333333333333333333333908116911601600481901c01167f01010101010101010101010101010101010101010101010101010101010101010260f81c90565b6000610d4e611acf84670de0b6b3a764000085611d87565b90565b6000610d4e611acf8484611e92565b60008260121115611b165760128390036002831615611b0c57611b048582611f99565b915050610d4e565b611b048582612029565b6012831115611b5f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee83016001831615611b5557611b048582612061565b611b0485826120b3565b5082610d4e565b60008260121115611b895760128390036001831615611b5557611b048582612061565b6012831115611b5f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee83016002831615611b0c57611b048582611f99565b600080826000526010600f6020600020060261ffff85821c165b8015611c095780518503611c00576001935060208101519250611c09565b60400151611be2565b50509250929050565b6000826000526010600f6020600020060261ffff85821c16805b8015611c435780518614611c435760400151611c2c565b80158015611c915760405191506060820160405286825285602083015282604083015260028860f01c0161ffff60f01b1989168160f01b1798505061ffff841b19881682851b179750611c98565b8560208301525b50959695505050505050565b6000806000806000611cb78989896120d6565b92509250925085600014611cd557611cd086848461227a565b611cd8565b60005b999098509650505050505050565b6000806000806000611cf98989896120d6565b92509250925085600014611cd557611cd08684846123fa565b60008151600003611d2557506000919050565b506020015160001a90565b6000611d3b83611d12565b8210611d775782826040517f30489add000000000000000000000000000000000000000000000000000000008152600401610551929190612dce565b50600202016003015161ffff1690565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870985870292508281108382030391505080600003611ddf57838281611dd557611dd5612ba9565b0492505050610d4e565b838110611e29576040517f63a05778000000000000000000000000000000000000000000000000000000008152600481018790526024810186905260448101859052606401610551565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84860984860292508281108382030391505080600003611ee45750670de0b6b3a7640000900490506101a1565b670de0b6b3a76400008110611f2f576040517f5173648d0000000000000000000000000000000000000000000000000000000081526004810186905260248101859052604401610551565b6000670de0b6b3a7640000858709620400008185030493109091037d40000000000000000000000000000000000000000000000000000000000002919091177faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106690291505092915050565b6000604e8210611fd9578215611fcf577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611fd2565b60005b90506101a1565b50600a81900a8281029083818381611ff357611ff3612ba9565b041461201f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612021565b815b949350505050565b600a81900a6120388184612c41565b9050604e82106101a15782156120585761205382600a612dae565b610d4e565b50600092915050565b6000604e821061208557821561207857600161207b565b60005b60ff1690506101a1565b600a82900a80848161209957612099612ba9565b04915080820284146120ac576001820191505b5092915050565b6000604e8210156120585781600a0a83816120d0576120d0612ba9565b04610d4e565b6000806000806120e68686612575565b506040517fe6a4390500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152878116602483015291925060009189169063e6a4390590604401602060405180830381865afa158015612161573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121859190612c71565b905060008060008373ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156121d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121fb9190612e0e565b63ffffffff1692506dffffffffffffffffffffffffffff1692506dffffffffffffffffffffffffffff1692508473ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff161461226257818382612266565b8282825b919d909c50909a5098505050505050505050565b600080841161230b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4f60448201527f55545055545f414d4f554e5400000000000000000000000000000000000000006064820152608401610551565b60008311801561231b5750600082115b6123a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c60448201527f49515549444954590000000000000000000000000000000000000000000000006064820152608401610551565b60006123b38585612c41565b6123bf906103e8612c41565b905060006123cd8685612c2e565b6123d9906103e5612c41565b90506123e58183612c07565b6123f0906001612c1b565b9695505050505050565b600080841161248b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4960448201527f4e5055545f414d4f554e540000000000000000000000000000000000000000006064820152608401610551565b60008311801561249b5750600082115b612527576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c60448201527f49515549444954590000000000000000000000000000000000000000000000006064820152608401610551565b6000612535856103e5612c41565b905060006125438483612c41565b9050600082612554876103e8612c41565b61255e9190612c1b565b905061256a8183612c07565b979650505050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603612633576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f4144445260448201527f45535345530000000000000000000000000000000000000000000000000000006064820152608401610551565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161061266d578284612670565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff82166126f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f4144445245535300006044820152606401610551565b9250929050565b612701612e5e565b565b60006020828403121561271557600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610d4e57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461276757600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156127e0576127e061276a565b604052919050565b600067ffffffffffffffff8211156128025761280261276a565b5060051b60200190565b600082601f83011261281d57600080fd5b8135602061283261282d836127e8565b612799565b82815260059290921b8401810191818101908684111561285157600080fd5b8286015b8481101561286c5780358352918301918301612855565b509695505050505050565b600082601f83011261288857600080fd5b8135602061289861282d836127e8565b82815260059290921b840181019181810190868411156128b757600080fd5b8286015b8481101561286c57803567ffffffffffffffff8111156128db5760008081fd5b6128e98986838b010161280c565b8452509183019183016128bb565b6000806000806080858703121561290d57600080fd5b843561291881612745565b93506020850135925060408501359150606085013567ffffffffffffffff81111561294257600080fd5b61294e87828801612877565b91505092959194509250565b600081518084526020808501945080840160005b8381101561298a5781518752958201959082019060010161296e565b509495945050505050565b6040815260006129a8604083018561295a565b828103602084015261131b818561295a565b803561ffff811681146129cc57600080fd5b919050565b600080600080600080600060e0888a0312156129ec57600080fd5b87356129f781612745565b96506020888101359650604089013567ffffffffffffffff80821115612a1c57600080fd5b818b0191508b601f830112612a3057600080fd5b813581811115612a4257612a4261276a565b612a72847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612799565b8181528d85838601011115612a8657600080fd5b818585018683013760008583830101528099505050612aa760608c016129ba565b965060808b0135955060a08b0135925080831115612ac457600080fd5b612ad08c848d01612877565b945060c08b0135925080831115612ae657600080fd5b5050612af48a828b0161280c565b91505092959891949750929550565b6000815180845260005b81811015612b2957602081850181015186830182015201612b0d565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081526000610d4e6020830184612b03565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082612c1657612c16612ba9565b500490565b808201808211156101a1576101a1612bd8565b818103818111156101a1576101a1612bd8565b80820281158282048414176101a1576101a1612bd8565b600060208284031215612c6a57600080fd5b5051919050565b600060208284031215612c8357600080fd5b8151610d4e81612745565b600181815b80851115612ce757817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612ccd57612ccd612bd8565b80851615612cda57918102915b93841c9390800290612c93565b509250929050565b600082612cfe575060016101a1565b81612d0b575060006101a1565b8160018114612d215760028114612d2b57612d47565b60019150506101a1565b60ff841115612d3c57612d3c612bd8565b50506001821b6101a1565b5060208310610133831016604e8410600b8410161715612d6a575081810a6101a1565b612d748383612c8e565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612da657612da6612bd8565b029392505050565b6000610d4e8383612cef565b600082612dc957612dc9612ba9565b500690565b604081526000612de16040830185612b03565b90508260208301529392505050565b80516dffffffffffffffffffffffffffff811681146129cc57600080fd5b600080600060608486031215612e2357600080fd5b612e2c84612df0565b9250612e3a60208501612df0565b9150604084015163ffffffff81168114612e5357600080fd5b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052605160045260246000fdfe0d090d550d900da90e470f2b0f65101510b710e6111511151164119311f5127d13241338138e13a213b713d113dc13f01405148214cd14f3150a15211521156c15b716021602164d164d169816e3172e172e17791860189318ea
|
608060405234801561001057600080fd5b506004361061004c5760003560e01c806301ffc9a7146100515780636715f82514610079578063758c13b61461009a578063f933c72f146100ad575b600080fd5b61006461005f366004612703565b6100c2565b60405190151581526020015b60405180910390f35b61008c6100873660046128f7565b6101a7565b604051610070929190612995565b61008c6100a83660046129d1565b61023c565b6100b5610294565b6040516100709190612b67565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f9e263f0a00000000000000000000000000000000000000000000000000000000148061015557507fffffffff0000000000000000000000000000000000000000000000000000000082167f758c13b600000000000000000000000000000000000000000000000000000000145b806101a157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b606080602084901c601085901c61ffff861660006101c4846102a3565b905061ffff8316600061020b826101e58d3360009182526020526040902090565b8e8c6040518060800160405280605a8152602001612e8e605a913988949392919061034a565b6040805160008152602081019091529091506102299082908661049b565b9750975050505050505094509492505050565b606080600061ffff871690506000610275828b8d896040518060800160405280605a8152602001612e8e605a91398e949392919061034a565b905061028281868961049b565b93509350505097509795505050505050565b606061029e610609565b905090565b6060813b60008190036102e2576040517f26a9f61e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60408051603e83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01681019091527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90910180825290915080600160208401853c50919050565b6103af6040518061012001604052806060815260200160608152602001600081526020016000815260200160008152602001600073ffffffffffffffffffffffffffffffffffffffff1681526020016060815260200160608152602001606081525090565b602087810180516040600191820184028b01818101518251600091821a808252948501870281019093526041808301968381019593600285020190910191908401905b8381101561043057875160f01c83015160408051600192831a80825283016020908102909101918290529084526002909901989290920191016103f2565b505050506040518061012001604052808281526020018481526020018b8152602001600081526020018a81526020018973ffffffffffffffffffffffffffffffffffffffff168152602001888152602001838152602001878152509450505050509695505050505050565b6060806000806104b38760e0015188604001516107bf565b91509150600087600001518860400151815181106104d3576104d3612b7a565b6020026020010151905060008751111561050a57600060208851028203915060208801905061050481838a516107e4565b5061055a565b8287511461055a5786516040517fd628439f000000000000000000000000000000000000000000000000000000008152610551918591600401918252602082015260400190565b60405180910390fd5b610564888261080c565b905060008287106105755782610577565b865b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08084018281529192508390602084028201015b808210156105e85781518151835281526020909101907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016105ab565b5050806105f88b60600151610a95565b965096505050505050935093915050565b604080516105c081018252602d808252610d096020830152610d5592820192909252610d90606082810191909152610da96080830152610e4760a0830152610f2b60c0830152610f6560e08301526110156101008301526110b76101208301526110e661014083015261111561016083018190526101808301526111646101a08301526111936101c08301526111f56101e083015261127d61020083015261132461022083015261133861024083015261138e6102608301526113a26102808301526113b76102a08301526113d16102c08301526113dc6102e08301526113f06103008301526114056103208301526114826103408301526114cd6103608301526114f361038083015261150a6103a08301526115216103c083018190526103e083015261156c6104008301526115b7610420830152611602610440830181905261046083015261164d61048083018190526104a08301526116986104c08301526116e36104e083015261172e61050083018190526105208301526117796105408301526118606105608301526118936105808301526118ea6105a083015291908190806107b68161191c565b94505050505090565b60008060006107ce85856119ad565b51600281901a9660039190911a95509350505050565b8060200283015b808410156108065783518352602093840193909201916107eb565b50505050565b6000808360400151905060008060008060006002896101000151516108319190612c07565b60e08a01516101008b0151602080830151600261ffff9b909b168b8102850160219081015160f01c600093841a9d909d029095019b909b019384015160258086019b50600791831a9182169182900360040290950190940198509296500193509091506126f990805b86881015610a1d57875190506002848260001a060285015160f01c925062ffffff8160e01c1691506108d18c838d8663ffffffff16565b9a506002848260041a060285015160f01c925062ffffff8160c01c1691506108fe8c838d8663ffffffff16565b9a506002848260081a060285015160f01c925062ffffff8160a01c16915061092b8c838d8663ffffffff16565b9a5060028482600c1a060285015160f01c925062ffffff8160801c1691506109588c838d8663ffffffff16565b9a506002848260101a060285015160f01c925062ffffff8160601c1691506109858c838d8663ffffffff16565b9a506002848260141a060285015160f01c925062ffffff8160401c1691506109b28c838d8663ffffffff16565b9a506002848260181a060285015160f01c925062ffffff8160201c1691506109df8c838d8663ffffffff16565b9a5060028482601c1a060285015160f01c925062ffffff81169150610a098c838d8663ffffffff16565b9a50610a16602089612c1b565b975061089a565b610a28601c89612c2e565b9750610a35866004612c41565b610a3f9089612c1b565b96505b86881015610a855750508551601c81901a83900660020284015160f01c915062ffffff811690610a718c838d86565b9a50610a7e600489612c1b565b9750610a42565b50989a9950505050505050505050565b6040805160f083901c602081810283010190925290815261ffff63ffffffff67ffffffffffffffff6fffffffffffffffffffffffffffffffff610b02565b60005b8215610afc57825182526020830151602083015260408301519250604082019150610ad6565b50919050565b602085018660101b60901c8015610bf2578060401c8015610b70578060201c8015610b3457610b318185610ad3565b93505b508086168015610b6e578060101c8015610b5557610b528186610ad3565b94505b508088168015610b6c57610b698186610ad3565b94505b505b505b508084168015610bf0578060201c8015610bb4578060101c8015610b9b57610b988186610ad3565b94505b508088168015610bb257610baf8186610ad3565b94505b505b508086168015610bee578060101c8015610bd557610bd28186610ad3565b94505b508088168015610bec57610be98186610ad3565b94505b505b505b505b508682168015610cfe578060401c8015610c7c578060201c8015610c40578060101c8015610c2757610c248186610ad3565b94505b508088168015610c3e57610c3b8186610ad3565b94505b505b508086168015610c7a578060101c8015610c6157610c5e8186610ad3565b94505b508088168015610c7857610c758186610ad3565b94505b505b505b508084168015610cfc578060201c8015610cc0578060101c8015610ca757610ca48186610ad3565b94505b508088168015610cbe57610cbb8186610ad3565b94505b505b508086168015610cfa578060101c8015610ce157610cde8186610ad3565b94505b508088168015610cf857610cf58186610ad3565b94505b505b505b505b505050505050919050565b604083015183516020600192830181029190910151918401029003517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909101908152805b9392505050565b60209283015160019290920190920201517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090910190815290565b8051600090610d9e816119de565b835250909392505050565b8251602060ff8481166001810183028401516000949193600888901c841693601089901c16929190830287015b80881015610df35760208203915087518252602088019750610dd6565b5060408901805190869052610e088a8361080c565b60408b018290526020860298899003989092508201885b81841015610e37578351815260209384019301610e1f565b50979a9950505050505050505050565b600060ff8316600884901c6020841015610ebd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600f60248201527f737461636b20756e646572666c6f7700000000000000000000000000000000006044820152606401610551565b60008660c001518381518110610ed557610ed5612b7a565b60200260200101518281518110610eee57610eee612b7a565b60209081029190910101517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909501948552509295945050505050565b60109190911c6020028082207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190920101908152919050565b8051602090910180516040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8083166004830152929360009390929184918416906370a0823190602401602060405180830381865afa158015610fe4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110089190612c58565b8552509295945050505050565b8051602090910180516040517f6352211e000000000000000000000000000000000000000000000000000000008152600481018290529192600092909190839073ffffffffffffffffffffffffffffffffffffffff841690636352211e90602401602060405180830381865afa158015611093573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110089190612c71565b437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190910190815292915050565b467fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190910190815292915050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190910190815292915050565b427fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09190910190815292915050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601083901c602002828101918201926000925b808210156111ea57815180156111de5785526111ea565b506020820191506111c7565b509295945050505050565b6000808260208560101c0281016020810394505b80821015611232578151925082156112275760208201518552611232565b604082019150611209565b505080600003611274576040517fff86627a00000000000000000000000000000000000000000000000000000000815261ffff85166004820152602401610551565b50909392505050565b8051600090602080840190601086901c0284015b6000831181831016156112ad5781519250602082019150611291565b508160000361131b576040517f40dccdf600000000000000000000000000000000000000000000000000000000815261ffff8616600482015260208583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001046024820152604401610551565b95945050505050565b805160209091018051909114815292915050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601083901c602002828101918201926000925b808210156111ea578151806113825785526111ea565b5060208201915061136c565b805160209091018051909111815292915050565b80516020909101805190911015815292915050565b805160409015156020028203810151910190815292915050565b805115815292915050565b805160209091018051909110815292915050565b80516020909101805190911115815292915050565b80516020820151604090920191600091906114208282611ab7565b9150601085901c60025b8181101561145057855192506020860195506114468484611ab7565b935060010161142a565b5050507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0929092019182525092915050565b805160208201516040909201916000919061149d8282611ad2565b9150601085901c60025b8181101561145057855192506020860195506114c38484611ad2565b93506001016114a7565b8051602090910180519091600091906114e7828287611ae1565b84525091949350505050565b8051600090610d9e8160ff8616600887901c611ae1565b8051600090610d9e8160ff8616600887901c611b66565b805160208201516040909201916000919061153c8183612c1b565b9150601085901c60025b8181101561145057855160209096019592506115628385612c1b565b9350600101611546565b80516020820151604090920191600091906115878183612c07565b9150601085901c60025b8181101561145057855160209096019592506115ad8385612c07565b9350600101611591565b80516020820151604090920191600091906115d28183612dae565b9150601085901c60025b8181101561145057855160209096019592506115f88385612dae565b93506001016115dc565b80516020820151604090920191600091908082101561161f578091505b601085901c60025b81811015611450578551925060208601955082841015611645578293505b600101611627565b80516020820151604090920191600091908082111561166a578091505b601085901c60025b81811015611450578551925060208601955082841115611690578293505b600101611672565b80516020820151604090920191600091906116b38183612dba565b9150601085901c60025b8181101561145057855160209096019592506116d98385612dba565b93506001016116bd565b80516020820151604090920191600091906116fe8183612c41565b9150601085901c60025b8181101561145057855160209096019592506117248385612c41565b9350600101611708565b80516020820151604090920191600091906117498183612c2e565b9150601085901c60025b81811015611450578551602090960195925061176f8385612c2e565b9350600101611753565b8051606084015160009190829081906117929084611bc8565b91509150816000036114e75760a087015160808801516040517f669e48aa00000000000000000000000000000000000000000000000000000000815260048101919091526024810185905260009173ffffffffffffffffffffffffffffffffffffffff169063669e48aa90604401602060405180830381865afa15801561181d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118419190612c58565b6060890151909150611854908583611c12565b606089015285526111ea565b8051602082015160608501516040909301926000929190611882908383611c12565b606087015250829150509392505050565b80516020808301516040808501516060860151600188161590940290950101936000939284806118c586858588611ca4565b9150915081885260018916156118dc578060208901525b509598975050505050505050565b80516020808301516040808501516060860151600188161590940290950101936000939284806118c586858588611ce6565b60606000825160020267ffffffffffffffff81111561193d5761193d61276a565b6040519080825280601f01601f191660200182016040528015611967576020820181803683370190505b50905061ffff80196020850160208651028101600285015b818310156119a15780518351861690851617815260209092019160020161197f565b50939695505050505050565b6000806119b984611d12565b600202600101905060006119cd8585611d30565b949091019093016020019392505050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611a105750610100919050565b507f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f7f5555555555555555555555555555555555555555555555555555555555555555600183901c16909103600281901c7f3333333333333333333333333333333333333333333333333333333333333333908116911601600481901c01167f01010101010101010101010101010101010101010101010101010101010101010260f81c90565b6000610d4e611acf84670de0b6b3a764000085611d87565b90565b6000610d4e611acf8484611e92565b60008260121115611b165760128390036002831615611b0c57611b048582611f99565b915050610d4e565b611b048582612029565b6012831115611b5f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee83016001831615611b5557611b048582612061565b611b0485826120b3565b5082610d4e565b60008260121115611b895760128390036001831615611b5557611b048582612061565b6012831115611b5f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffee83016002831615611b0c57611b048582611f99565b600080826000526010600f6020600020060261ffff85821c165b8015611c095780518503611c00576001935060208101519250611c09565b60400151611be2565b50509250929050565b6000826000526010600f6020600020060261ffff85821c16805b8015611c435780518614611c435760400151611c2c565b80158015611c915760405191506060820160405286825285602083015282604083015260028860f01c0161ffff60f01b1989168160f01b1798505061ffff841b19881682851b179750611c98565b8560208301525b50959695505050505050565b6000806000806000611cb78989896120d6565b92509250925085600014611cd557611cd086848461227a565b611cd8565b60005b999098509650505050505050565b6000806000806000611cf98989896120d6565b92509250925085600014611cd557611cd08684846123fa565b60008151600003611d2557506000919050565b506020015160001a90565b6000611d3b83611d12565b8210611d775782826040517f30489add000000000000000000000000000000000000000000000000000000008152600401610551929190612dce565b50600202016003015161ffff1690565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85870985870292508281108382030391505080600003611ddf57838281611dd557611dd5612ba9565b0492505050610d4e565b838110611e29576040517f63a05778000000000000000000000000000000000000000000000000000000008152600481018790526024810186905260448101859052606401610551565b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84860984860292508281108382030391505080600003611ee45750670de0b6b3a7640000900490506101a1565b670de0b6b3a76400008110611f2f576040517f5173648d0000000000000000000000000000000000000000000000000000000081526004810186905260248101859052604401610551565b6000670de0b6b3a7640000858709620400008185030493109091037d40000000000000000000000000000000000000000000000000000000000002919091177faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac106690291505092915050565b6000604e8210611fd9578215611fcf577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff611fd2565b60005b90506101a1565b50600a81900a8281029083818381611ff357611ff3612ba9565b041461201f577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612021565b815b949350505050565b600a81900a6120388184612c41565b9050604e82106101a15782156120585761205382600a612dae565b610d4e565b50600092915050565b6000604e821061208557821561207857600161207b565b60005b60ff1690506101a1565b600a82900a80848161209957612099612ba9565b04915080820284146120ac576001820191505b5092915050565b6000604e8210156120585781600a0a83816120d0576120d0612ba9565b04610d4e565b6000806000806120e68686612575565b506040517fe6a4390500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8881166004830152878116602483015291925060009189169063e6a4390590604401602060405180830381865afa158015612161573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121859190612c71565b905060008060008373ffffffffffffffffffffffffffffffffffffffff16630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa1580156121d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121fb9190612e0e565b63ffffffff1692506dffffffffffffffffffffffffffff1692506dffffffffffffffffffffffffffff1692508473ffffffffffffffffffffffffffffffffffffffff168a73ffffffffffffffffffffffffffffffffffffffff161461226257818382612266565b8282825b919d909c50909a5098505050505050505050565b600080841161230b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602c60248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4f60448201527f55545055545f414d4f554e5400000000000000000000000000000000000000006064820152608401610551565b60008311801561231b5750600082115b6123a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c60448201527f49515549444954590000000000000000000000000000000000000000000000006064820152608401610551565b60006123b38585612c41565b6123bf906103e8612c41565b905060006123cd8685612c2e565b6123d9906103e5612c41565b90506123e58183612c07565b6123f0906001612c1b565b9695505050505050565b600080841161248b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4960448201527f4e5055545f414d4f554e540000000000000000000000000000000000000000006064820152608401610551565b60008311801561249b5750600082115b612527576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f556e697377617056324c6962726172793a20494e53554646494349454e545f4c60448201527f49515549444954590000000000000000000000000000000000000000000000006064820152608401610551565b6000612535856103e5612c41565b905060006125438483612c41565b9050600082612554876103e8612c41565b61255e9190612c1b565b905061256a8183612c07565b979650505050505050565b6000808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603612633576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f4144445260448201527f45535345530000000000000000000000000000000000000000000000000000006064820152608401610551565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161061266d578284612670565b83835b909250905073ffffffffffffffffffffffffffffffffffffffff82166126f2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f4144445245535300006044820152606401610551565b9250929050565b612701612e5e565b565b60006020828403121561271557600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610d4e57600080fd5b73ffffffffffffffffffffffffffffffffffffffff8116811461276757600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156127e0576127e061276a565b604052919050565b600067ffffffffffffffff8211156128025761280261276a565b5060051b60200190565b600082601f83011261281d57600080fd5b8135602061283261282d836127e8565b612799565b82815260059290921b8401810191818101908684111561285157600080fd5b8286015b8481101561286c5780358352918301918301612855565b509695505050505050565b600082601f83011261288857600080fd5b8135602061289861282d836127e8565b82815260059290921b840181019181810190868411156128b757600080fd5b8286015b8481101561286c57803567ffffffffffffffff8111156128db5760008081fd5b6128e98986838b010161280c565b8452509183019183016128bb565b6000806000806080858703121561290d57600080fd5b843561291881612745565b93506020850135925060408501359150606085013567ffffffffffffffff81111561294257600080fd5b61294e87828801612877565b91505092959194509250565b600081518084526020808501945080840160005b8381101561298a5781518752958201959082019060010161296e565b509495945050505050565b6040815260006129a8604083018561295a565b828103602084015261131b818561295a565b803561ffff811681146129cc57600080fd5b919050565b600080600080600080600060e0888a0312156129ec57600080fd5b87356129f781612745565b96506020888101359650604089013567ffffffffffffffff80821115612a1c57600080fd5b818b0191508b601f830112612a3057600080fd5b813581811115612a4257612a4261276a565b612a72847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612799565b8181528d85838601011115612a8657600080fd5b818585018683013760008583830101528099505050612aa760608c016129ba565b965060808b0135955060a08b0135925080831115612ac457600080fd5b612ad08c848d01612877565b945060c08b0135925080831115612ae657600080fd5b5050612af48a828b0161280c565b91505092959891949750929550565b6000815180845260005b81811015612b2957602081850181015186830182015201612b0d565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081526000610d4e6020830184612b03565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082612c1657612c16612ba9565b500490565b808201808211156101a1576101a1612bd8565b818103818111156101a1576101a1612bd8565b80820281158282048414176101a1576101a1612bd8565b600060208284031215612c6a57600080fd5b5051919050565b600060208284031215612c8357600080fd5b8151610d4e81612745565b600181815b80851115612ce757817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612ccd57612ccd612bd8565b80851615612cda57918102915b93841c9390800290612c93565b509250929050565b600082612cfe575060016101a1565b81612d0b575060006101a1565b8160018114612d215760028114612d2b57612d47565b60019150506101a1565b60ff841115612d3c57612d3c612bd8565b50506001821b6101a1565b5060208310610133831016604e8410600b8410161715612d6a575081810a6101a1565b612d748383612c8e565b807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04821115612da657612da6612bd8565b029392505050565b6000610d4e8383612cef565b600082612dc957612dc9612ba9565b500690565b604081526000612de16040830185612b03565b90508260208301529392505050565b80516dffffffffffffffffffffffffffff811681146129cc57600080fd5b600080600060608486031215612e2357600080fd5b612e2c84612df0565b9250612e3a60208501612df0565b9150604084015163ffffffff81168114612e5357600080fd5b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052605160045260246000fdfe0d090d550d900da90e470f2b0f65101510b710e6111511151164119311f5127d13241338138e13a213b713d113dc13f01405148214cd14f3150a15211521156c15b716021602164d164d169816e3172e172e17791860189318ea
|
{{
"language": "Solidity",
"sources": {
"lib/rain.flow/lib/rain.interpreter/src/concrete/RainterpreterNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity =0.8.19;\n\nimport \"openzeppelin-contracts/contracts/utils/introspection/ERC165.sol\";\n\nimport \"rain.lib.typecast/LibCast.sol\";\nimport {LibDataContract} from \"rain.datacontract/lib/LibDataContract.sol\";\n\nimport \"../interface/unstable/IDebugInterpreterV2.sol\";\n\nimport {LibEvalNP} from \"../lib/eval/LibEvalNP.sol\";\nimport \"../lib/ns/LibNamespace.sol\";\nimport {LibInterpreterStateDataContractNP} from \"../lib/state/LibInterpreterStateDataContractNP.sol\";\nimport \"../lib/caller/LibEncodedDispatch.sol\";\n\nimport {InterpreterStateNP} from \"../lib/state/LibInterpreterStateNP.sol\";\nimport {LibAllStandardOpsNP} from \"../lib/op/LibAllStandardOpsNP.sol\";\nimport {LibPointer, Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {LibStackPointer} from \"rain.solmem/lib/LibStackPointer.sol\";\nimport {LibUint256Array} from \"rain.solmem/lib/LibUint256Array.sol\";\nimport {LibMemoryKV, MemoryKV} from \"rain.lib.memkv/lib/LibMemoryKV.sol\";\n\n/// Thrown when the stack length is negative during eval.\nerror NegativeStackLength(int256 length);\n\n/// Thrown when the source index is invalid during eval. This is a runtime check\n/// for the exposed external eval entrypoint. Internally recursive evals are\n/// expected to preflight check the source index.\nerror InvalidSourceIndex(SourceIndex sourceIndex);\n\n/// @dev Hash of the known interpreter bytecode.\nbytes32 constant INTERPRETER_BYTECODE_HASH = bytes32(0x21785780ab522520aaf1921d5a177b745aa7179c67305ed963c709e79bdfbe0d);\n\n/// @dev The function pointers known to the interpreter for dynamic dispatch.\n/// By setting these as a constant they can be inlined into the interpreter\n/// and loaded at eval time for very low gas (~100) due to the compiler\n/// optimising it to a single `codecopy` to build the in memory bytes array.\nbytes constant OPCODE_FUNCTION_POINTERS =\n hex\"0d090d550d900da90e470f2b0f65101510b710e6111511151164119311f5127d13241338138e13a213b713d113dc13f01405148214cd14f3150a15211521156c15b716021602164d164d169816e3172e172e17791860189318ea\";\n\n/// @title RainterpreterNP\n/// @notice !!EXPERIMENTAL!! implementation of a Rainlang interpreter that is\n/// compatible with native onchain Rainlang parsing. Initially copied verbatim\n/// from the JS compatible Rainterpreter. This interpreter is deliberately\n/// separate from the JS Rainterpreter to allow for experimentation with the\n/// onchain interpreter without affecting the JS interpreter, up to and including\n/// a complely different execution model and opcodes.\ncontract RainterpreterNP is IInterpreterV1, IDebugInterpreterV2, ERC165 {\n using LibEvalNP for InterpreterStateNP;\n using LibNamespace for StateNamespace;\n using LibInterpreterStateDataContractNP for bytes;\n\n /// There are MANY ways that eval can be forced into undefined/corrupt\n /// behaviour by passing in invalid data. This is a deliberate design\n /// decision to allow for the interpreter to be as gas efficient as\n /// possible. The interpreter is provably read only, it contains no state\n /// changing evm opcodes reachable on any logic path. This means that\n /// the caller can only harm themselves by passing in invalid data and\n /// either reverting, exhausting gas or getting back some garbage data.\n /// The caller can trivially protect themselves from these OOB issues by\n /// ensuring the integrity check has successfully run over the bytecode\n /// before calling eval. Any smart contract caller can do this by using a\n /// trusted and appropriate deployer contract to deploy the bytecode, which\n /// will automatically run the integrity check during deployment, then\n /// keeping a registry of trusted expression addresses for itself in storage.\n ///\n /// This appears first in the contract in the hope that the compiler will\n /// put it in the most efficient internal dispatch location to save a few\n /// gas per eval call.\n ///\n /// @inheritdoc IInterpreterV1\n function eval(\n IInterpreterStoreV1 store,\n StateNamespace namespace,\n EncodedDispatch dispatch,\n uint256[][] memory context\n ) external view returns (uint256[] memory, uint256[] memory) {\n // Decode the dispatch.\n (address expression, SourceIndex sourceIndex16, uint256 maxOutputs) = LibEncodedDispatch.decode(dispatch);\n bytes memory expressionData = LibDataContract.read(expression);\n\n // Need to clean source index as it is a uint16.\n uint256 sourceIndex;\n assembly (\"memory-safe\") {\n sourceIndex := and(sourceIndex16, 0xFFFF)\n }\n\n InterpreterStateNP memory state = expressionData.unsafeDeserializeNP(\n sourceIndex, namespace.qualifyNamespace(msg.sender), store, context, OPCODE_FUNCTION_POINTERS\n );\n // We use the return by returning it. Slither false positive.\n //slither-disable-next-line unused-return\n return state.evalNP(new uint256[](0), maxOutputs);\n }\n\n // @inheritdoc ERC165\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IInterpreterV1).interfaceId || interfaceId == type(IDebugInterpreterV2).interfaceId\n || super.supportsInterface(interfaceId);\n }\n\n /// @inheritdoc IDebugInterpreterV2\n function offchainDebugEval(\n IInterpreterStoreV1 store,\n FullyQualifiedNamespace namespace,\n bytes memory expressionData,\n SourceIndex sourceIndex16,\n uint256 maxOutputs,\n uint256[][] memory context,\n uint256[] memory inputs\n ) external view returns (uint256[] memory, uint256[] memory) {\n // Need to clean source index as it is a uint16.\n uint256 sourceIndex;\n assembly (\"memory-safe\") {\n sourceIndex := and(sourceIndex16, 0xFFFF)\n }\n InterpreterStateNP memory state =\n expressionData.unsafeDeserializeNP(sourceIndex, namespace, store, context, OPCODE_FUNCTION_POINTERS);\n // We use the return by returning it. Slither false positive.\n //slither-disable-next-line unused-return\n return state.evalNP(inputs, maxOutputs);\n }\n\n /// @inheritdoc IInterpreterV1\n function functionPointers() external view virtual returns (bytes memory) {\n return LibAllStandardOpsNP.opcodeFunctionPointers();\n }\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.lib.typecast/src/LibCast.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @title LibCast\n/// @notice Additional type casting logic that the Solidity compiler doesn't\n/// give us by default. A type cast (vs. conversion) is considered one where the\n/// structure is unchanged by the cast. The cast does NOT (can't) check that the\n/// input is a valid output, for example any integer MAY be cast to a function\n/// pointer but almost all integers are NOT valid function pointers. It is the\n/// calling context that MUST ensure the validity of the data, the cast will\n/// merely retype the data in place, generally without additional checks.\n/// As most structures in solidity have the same memory structure as a `uint256`\n/// or fixed/dynamic array of `uint256` there are many conversions that can be\n/// done with near zero or minimal overhead.\nlibrary LibCast {\n /// Retype an array of `uint256[]` to `address[]`.\n /// @param us_ The array of integers to cast to addresses.\n /// @return addresses_ The array of addresses cast from each integer.\n function asAddressesArray(uint256[] memory us_) internal pure returns (address[] memory addresses_) {\n assembly (\"memory-safe\") {\n addresses_ := us_\n }\n }\n\n function asUint256Array(address[] memory addresses_) internal pure returns (uint256[] memory us_) {\n assembly (\"memory-safe\") {\n us_ := addresses_\n }\n }\n\n /// Retype an array of `uint256[]` to `bytes32[]`.\n /// @param us_ The array of integers to cast to 32 byte words.\n /// @return b32s_ The array of 32 byte words.\n function asBytes32Array(uint256[] memory us_) internal pure returns (bytes32[] memory b32s_) {\n assembly (\"memory-safe\") {\n b32s_ := us_\n }\n }\n\n function asUint256Array(bytes32[] memory b32s_) internal pure returns (uint256[] memory us_) {\n assembly (\"memory-safe\") {\n us_ := b32s_\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.datacontract/src/lib/LibDataContract.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.solmem/lib/LibPointer.sol\";\n\n/// Thrown if writing the data by creating the contract fails somehow.\nerror WriteError();\n\n/// Thrown if reading a zero length address.\nerror ReadError();\n\n/// @dev SSTORE2 Verbatim reference\n/// https://github.com/0xsequence/sstore2/blob/master/contracts/utils/Bytecode.sol#L15\n///\n/// 0x00 0x63 0x63XXXXXX PUSH4 _code.length size\n/// 0x01 0x80 0x80 DUP1 size size\n/// 0x02 0x60 0x600e PUSH1 14 14 size size\n/// 0x03 0x60 0x6000 PUSH1 00 0 14 size size\n/// 0x04 0x39 0x39 CODECOPY size\n/// 0x05 0x60 0x6000 PUSH1 00 0 size\n/// 0x06 0xf3 0xf3 RETURN\n/// <CODE>\n///\n/// However note that 00 is also prepended (although docs say append) so there's\n/// an additional byte that isn't described above.\n/// https://github.com/0xsequence/sstore2/blob/master/contracts/SSTORE2.sol#L25\n///\n/// Note also typo 0x63XXXXXX which indicates 3 bytes but instead 4 are used as\n/// 0x64XXXXXXXX.\n///\n/// Note also that we don't need 4 bytes to represent the size of a contract as\n/// 24kb is the max PUSH2 (0x61) can be used instead of PUSH4 for code length.\n/// This also changes the 0x600e to 0x600c as we've reduced prefix size by 2\n/// relative to reference implementation.\n/// https://github.com/0xsequence/sstore2/pull/5/files\nuint256 constant BASE_PREFIX = 0x61_0000_80_600C_6000_39_6000_F3_00_00000000000000000000000000000000000000;\n\n/// @dev Length of the prefix that converts in memory data to a deployable\n/// contract.\nuint256 constant PREFIX_BYTES_LENGTH = 13;\n\n/// A container is a region of memory that is directly deployable with `create`,\n/// without length prefixes or other Solidity type trappings. Where the length is\n/// needed, such as in `write` it can be read as bytes `[1,2]` from the prefix.\n/// This is just a pointer but given a new type to help avoid mistakes.\ntype DataContractMemoryContainer is uint256;\n\n/// @title DataContract\n///\n/// DataContract is a simplified reimplementation of\n/// https://github.com/0xsequence/sstore2\n///\n/// - Doesn't force additonal internal allocations with ABI encoding calls\n/// - Optimised for the case where the data to read/write and contract are 1:1\n/// - Assembly optimisations for less gas usage\n/// - Not shipped with other unrelated code to reduce dependency bloat\n/// - Fuzzed with foundry\n///\n/// It is a little more low level in that it doesn't work on `bytes` from\n/// Solidity but instead requires the caller to copy memory directy by pointer.\n/// https://github.com/rainprotocol/sol.lib.bytes can help with that.\nlibrary LibDataContract {\n /// Prepares a container ready to write exactly `length_` bytes at the\n /// returned `pointer_`. The caller MUST write exactly the number of bytes\n /// that it asks for at the pointer otherwise memory WILL be corrupted.\n /// @param length_ Caller specifies the number of bytes to allocate for the\n /// data it wants to write. The actual size of the container in memory will\n /// be larger than this due to the contract creation prefix and the padding\n /// potentially required to align the memory allocation.\n /// @return container_ The pointer to the start of the container that can be\n /// deployed as an onchain contract. Caller can pass this back to `write` to\n /// have the data contract deployed\n /// (after it copies its data to the pointer).\n /// @return pointer_ The caller can copy its data at the pointer without any\n /// additional allocations or Solidity type wrangling.\n function newContainer(uint256 length_)\n internal\n pure\n returns (DataContractMemoryContainer container_, Pointer pointer_)\n {\n unchecked {\n uint256 prefixBytesLength_ = PREFIX_BYTES_LENGTH;\n uint256 basePrefix_ = BASE_PREFIX;\n assembly (\"memory-safe\") {\n // allocate output byte array - this could also be done without assembly\n // by using container_ = new bytes(size)\n container_ := mload(0x40)\n // new \"memory end\" including padding\n mstore(0x40, add(container_, and(add(add(length_, prefixBytesLength_), 0x1f), not(0x1f))))\n // pointer is where the caller will write data to\n pointer_ := add(container_, prefixBytesLength_)\n\n // copy length into the 2 bytes gap in the base prefix\n let prefix_ :=\n or(\n basePrefix_,\n shl(\n // length sits 29 bytes from the right\n 232,\n and(\n // mask the length to 2 bytes\n 0xFFFF,\n add(length_, 1)\n )\n )\n )\n mstore(container_, prefix_)\n }\n }\n }\n\n /// Given a container prepared by `newContainer` and populated with bytes by\n /// the caller, deploy to a new onchain contract and return the contract\n /// address.\n /// @param container_ The container full of data to deploy as an onchain data\n /// contract.\n /// @return The newly deployed contract containing the data in the container.\n function write(DataContractMemoryContainer container_) internal returns (address) {\n address pointer_;\n uint256 prefixLength_ = PREFIX_BYTES_LENGTH;\n assembly (\"memory-safe\") {\n pointer_ :=\n create(\n 0,\n container_,\n add(\n prefixLength_,\n // Read length out of prefix.\n and(0xFFFF, shr(232, mload(container_)))\n )\n )\n }\n // Zero address means create failed.\n if (pointer_ == address(0)) revert WriteError();\n return pointer_;\n }\n\n /// Reads data back from a previously deployed container.\n /// Almost verbatim Solidity docs.\n /// https://docs.soliditylang.org/en/v0.8.17/assembly.html#example\n /// Notable difference is that we skip the first byte when we read as it is\n /// a `0x00` prefix injected by containers on deploy.\n /// @param pointer_ The address of the data contract to read from. MUST have\n /// a leading byte that can be safely ignored.\n /// @return data_ The data read from the data contract. First byte is skipped\n /// and contract is read completely to the end.\n function read(address pointer_) internal view returns (bytes memory data_) {\n uint256 size_;\n assembly (\"memory-safe\") {\n // Retrieve the size of the code, this needs assembly.\n size_ := extcodesize(pointer_)\n }\n if (size_ == 0) revert ReadError();\n assembly (\"memory-safe\") {\n // Skip the first byte.\n size_ := sub(size_, 1)\n // Allocate output byte array - this could also be done without\n // assembly by using data_ = new bytes(size)\n data_ := mload(0x40)\n // New \"memory end\" including padding.\n // Compiler will optimise away the double constant addition.\n mstore(0x40, add(data_, and(add(add(size_, 0x20), 0x1f), not(0x1f))))\n // Store length in memory.\n mstore(data_, size_)\n // actually retrieve the code, this needs assembly\n // skip the first byte\n extcodecopy(pointer_, add(data_, 0x20), 1, size_)\n }\n }\n\n /// Hybrid of address-only read, SSTORE2 read and Solidity docs.\n /// Unlike SSTORE2, reading past the end of the data contract WILL REVERT.\n /// @param pointer_ As per `read`.\n /// @param start_ Starting offset for reads from the data contract.\n /// @param length_ Number of bytes to read.\n function readSlice(address pointer_, uint16 start_, uint16 length_) internal view returns (bytes memory data_) {\n uint256 size_;\n // uint256 offset and end avoids overflow issues from uint16.\n uint256 offset_;\n uint256 end_;\n assembly (\"memory-safe\") {\n // Skip the first byte.\n offset_ := add(start_, 1)\n end_ := add(offset_, length_)\n // Retrieve the size of the code, this needs assembly.\n size_ := extcodesize(pointer_)\n }\n if (size_ < end_) revert ReadError();\n assembly (\"memory-safe\") {\n // Allocate output byte array - this could also be done without\n // assembly by using data_ = new bytes(size)\n data_ := mload(0x40)\n // New \"memory end\" including padding.\n // Compiler will optimise away the double constant addition.\n mstore(0x40, add(data_, and(add(add(length_, 0x20), 0x1f), not(0x1f))))\n // Store length in memory.\n mstore(data_, length_)\n // actually retrieve the code, this needs assembly\n extcodecopy(pointer_, add(data_, 0x20), offset_, length_)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/unstable/IDebugInterpreterV2.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../IInterpreterV1.sol\";\n\ninterface IDebugInterpreterV2 {\n /// A more explicit/open version of `eval` that is designed for offchain\n /// debugging. It MUST function identically to `eval` so implementations\n /// MAY call it directly internally for `eval` to ensure consistency at the\n /// expense of a small amount of gas.\n /// The affordances made for debugging are:\n /// - A fully qualified namespace is passed in. This allows for storage reads\n /// from the perspective of an arbitrary caller during `eval`. Note that it\n /// does not allow for arbitrary writes, which are still gated by the store\n /// contract itself, so this is safe to expose.\n /// - The bytecode is passed in directly. This allows for debugging of\n /// bytecode that has not been deployed to the chain yet.\n /// - The components of the encoded dispatch other than the onchain\n /// expression address are passed separately. This remove the need to\n /// provide an address at all.\n /// - Inputs to the entrypoint stack are passed in directly. This allows for\n /// debugging/simulating logic that could normally only be accessed via.\n /// some internal dispatch with a mid-flight state creating inputs for the\n /// internal call.\n function offchainDebugEval(\n IInterpreterStoreV1 store,\n FullyQualifiedNamespace namespace,\n bytes calldata expressionData,\n SourceIndex sourceIndex,\n uint256 maxOutputs,\n uint256[][] calldata context,\n uint256[] calldata inputs\n ) external view returns (uint256[] calldata finalStack, uint256[] calldata writes);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/eval/LibEvalNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../state/LibInterpreterStateNP.sol\";\n\nimport \"rain.solmem/lib/LibMemCpy.sol\";\nimport \"rain.lib.memkv/lib/LibMemoryKV.sol\";\nimport \"../bytecode/LibBytecode.sol\";\n\n/// Thrown when the inputs length does not match the expected inputs length.\n/// @param expected The expected number of inputs.\n/// @param actual The actual number of inputs.\nerror InputsLengthMismatch(uint256 expected, uint256 actual);\n\nlibrary LibEvalNP {\n using LibMemoryKV for MemoryKV;\n\n function evalLoopNP(InterpreterStateNP memory state, Pointer stackTop) internal view returns (Pointer) {\n uint256 sourceIndex = state.sourceIndex;\n uint256 cursor;\n uint256 end;\n uint256 m;\n uint256 fPointersStart;\n // We mod the indexes with the fsCount for each lookup to ensure that\n // the indexes are in bounds. A mod is cheaper than a bounds check.\n uint256 fsCount = state.fs.length / 2;\n {\n bytes memory bytecode = state.bytecode;\n bytes memory fPointers = state.fs;\n assembly (\"memory-safe\") {\n // SourceIndex is a uint16 so needs cleaning.\n sourceIndex := and(sourceIndex, 0xFFFF)\n // Cursor starts at the beginning of the source.\n cursor := add(bytecode, 0x20)\n let sourcesLength := byte(0, mload(cursor))\n cursor := add(cursor, 1)\n // Find start of sources.\n let sourcesStart := add(cursor, mul(sourcesLength, 2))\n // Find relative pointer to source.\n let sourcesPointer := shr(0xf0, mload(add(cursor, mul(sourceIndex, 2))))\n // Move cursor to start of source.\n cursor := add(sourcesStart, sourcesPointer)\n // Calculate the end.\n let opsLength := byte(0, mload(cursor))\n // Move cursor past 4 byte source prefix.\n cursor := add(cursor, 4)\n\n // Calculate the mod `m` which is the portion of the source\n // that can't be copied in 32 byte chunks.\n m := mod(opsLength, 8)\n\n // Each op is 4 bytes, and there's a 4 byte prefix for the\n // source. The initial end is only what can be processed in\n // 32 byte chunks.\n end := add(cursor, mul(sub(opsLength, m), 4))\n\n fPointersStart := add(fPointers, 0x20)\n }\n }\n\n function(InterpreterStateNP memory, Operand, Pointer)\n internal\n view\n returns (Pointer) f;\n Operand operand;\n uint256 word;\n while (cursor < end) {\n assembly (\"memory-safe\") {\n word := mload(cursor)\n }\n\n // Process high bytes [28, 31]\n // f needs to be looked up from the fn pointers table.\n // operand is 3 bytes.\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(0, word), fsCount), 2))))\n operand := and(shr(0xe0, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [24, 27].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(4, word), fsCount), 2))))\n operand := and(shr(0xc0, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [20, 23].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(8, word), fsCount), 2))))\n operand := and(shr(0xa0, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [16, 19].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(12, word), fsCount), 2))))\n operand := and(shr(0x80, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [12, 15].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(16, word), fsCount), 2))))\n operand := and(shr(0x60, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [8, 11].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(20, word), fsCount), 2))))\n operand := and(shr(0x40, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [4, 7].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(24, word), fsCount), 2))))\n operand := and(shr(0x20, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [0, 3].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(28, word), fsCount), 2))))\n operand := and(word, 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n cursor += 0x20;\n }\n\n // Loop over the remainder.\n // Need to shift the cursor back 28 bytes so that we're reading from\n // its 4 low bits rather than high bits, to make the loop logic more\n // efficient.\n cursor -= 0x1c;\n end = cursor + m * 4;\n while (cursor < end) {\n assembly (\"memory-safe\") {\n word := mload(cursor)\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(28, word), fsCount), 2))))\n // 3 bytes mask.\n operand := and(word, 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n cursor += 4;\n }\n\n return stackTop;\n }\n\n function evalNP(InterpreterStateNP memory state, uint256[] memory inputs, uint256 maxOutputs)\n internal\n view\n returns (uint256[] memory, uint256[] memory)\n {\n unchecked {\n // Use the bytecode's own definition of its IO. Clear example of\n // how the bytecode could accidentally or maliciously force OOB reads\n // if the integrity check is not run.\n (uint256 sourceInputs, uint256 sourceOutputs) =\n LibBytecode.sourceInputsOutputsLength(state.bytecode, state.sourceIndex);\n\n Pointer stackTop;\n {\n stackTop = state.stackBottoms[state.sourceIndex];\n // Copy inputs into place if needed.\n if (inputs.length > 0) {\n // Inline some logic to avoid jumping due to function calls\n // on hot path.\n Pointer inputsDataPointer;\n assembly (\"memory-safe\") {\n // Move stack top by the number of inputs.\n stackTop := sub(stackTop, mul(mload(inputs), 0x20))\n inputsDataPointer := add(inputs, 0x20)\n }\n LibMemCpy.unsafeCopyWordsTo(inputsDataPointer, stackTop, inputs.length);\n } else if (inputs.length != sourceInputs) {\n revert InputsLengthMismatch(sourceInputs, inputs.length);\n }\n }\n\n // Run the loop.\n stackTop = evalLoopNP(state, stackTop);\n\n // Convert the stack top pointer to an array with the correct length.\n // If the stack top is pointing to the base of Solidity's understanding\n // of the stack array, then this will simply write the same length over\n // the length the stack was initialized with, otherwise a shorter array\n // will be built within the bounds of the stack. After this point `tail`\n // and the original stack MUST be immutable as they're both pointing to\n // the same memory region.\n uint256 outputs = maxOutputs < sourceOutputs ? maxOutputs : sourceOutputs;\n uint256[] memory result;\n assembly (\"memory-safe\") {\n result := sub(stackTop, 0x20)\n mstore(result, outputs)\n\n // Need to reverse the result array for backwards compatibility.\n // Ideally we'd not do this, but will need to roll a new interface\n // for such a breaking change.\n for {\n let a := add(result, 0x20)\n let b := add(result, mul(outputs, 0x20))\n } lt(a, b) {\n a := add(a, 0x20)\n b := sub(b, 0x20)\n } {\n let tmp := mload(a)\n mstore(a, mload(b))\n mstore(b, tmp)\n }\n }\n\n return (result, state.stateKV.toUint256Array());\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/ns/LibNamespace.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../../interface/IInterpreterV1.sol\";\n\nlibrary LibNamespace {\n /// Standard way to elevate a caller-provided state namespace to a universal\n /// namespace that is disjoint from all other caller-provided namespaces.\n /// Essentially just hashes the `msg.sender` into the state namespace as-is.\n ///\n /// This is deterministic such that the same combination of state namespace\n /// and caller will produce the same fully qualified namespace, even across\n /// multiple transactions/blocks.\n ///\n /// @param stateNamespace The state namespace as specified by the caller.\n /// @param sender The caller this namespace is bound to.\n /// @return qualifiedNamespace A fully qualified namespace that cannot\n /// collide with any other state namespace specified by any other caller.\n function qualifyNamespace(StateNamespace stateNamespace, address sender)\n internal\n pure\n returns (FullyQualifiedNamespace qualifiedNamespace)\n {\n assembly (\"memory-safe\") {\n mstore(0, stateNamespace)\n mstore(0x20, sender)\n qualifiedNamespace := keccak256(0, 0x40)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/state/LibInterpreterStateDataContractNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.solmem/lib/LibPointer.sol\";\nimport \"rain.solmem/lib/LibMemCpy.sol\";\nimport \"rain.solmem/lib/LibBytes.sol\";\n\nimport \"../ns/LibNamespace.sol\";\nimport \"./LibInterpreterStateNP.sol\";\n\nlibrary LibInterpreterStateDataContractNP {\n using LibBytes for bytes;\n\n function serializeSizeNP(bytes memory bytecode, uint256[] memory constants) internal pure returns (uint256 size) {\n unchecked {\n size = bytecode.length + constants.length * 0x20 + 0x40;\n }\n }\n\n function unsafeSerializeNP(Pointer cursor, bytes memory bytecode, uint256[] memory constants) internal pure {\n unchecked {\n // Copy constants into place with length.\n assembly (\"memory-safe\") {\n for {\n let constantsCursor := constants\n let constantsEnd := add(constantsCursor, mul(0x20, add(mload(constants), 1)))\n } lt(constantsCursor, constantsEnd) {\n constantsCursor := add(constantsCursor, 0x20)\n cursor := add(cursor, 0x20)\n } { mstore(cursor, mload(constantsCursor)) }\n }\n // Copy the bytecode into place with length.\n LibMemCpy.unsafeCopyBytesTo(bytecode.startPointer(), cursor, bytecode.length + 0x20);\n }\n }\n\n function unsafeDeserializeNP(\n bytes memory serialized,\n uint256 sourceIndex,\n FullyQualifiedNamespace namespace,\n IInterpreterStoreV1 store,\n uint256[][] memory context,\n bytes memory fs\n ) internal pure returns (InterpreterStateNP memory) {\n unchecked {\n Pointer cursor;\n assembly (\"memory-safe\") {\n cursor := add(serialized, 0x20)\n }\n\n // Reference the constants array as-is and move cursor past it.\n uint256[] memory constants;\n assembly (\"memory-safe\") {\n constants := cursor\n cursor := add(cursor, mul(0x20, add(mload(cursor), 1)))\n }\n\n // Reference the bytecode array as-is.\n bytes memory bytecode;\n assembly (\"memory-safe\") {\n bytecode := cursor\n }\n\n // Build all the stacks.\n Pointer[] memory stackBottoms;\n assembly (\"memory-safe\") {\n cursor := add(cursor, 0x20)\n let stacksLength := byte(0, mload(cursor))\n cursor := add(cursor, 1)\n let sourcesStart := add(cursor, mul(stacksLength, 2))\n\n // Allocate the memory for stackBottoms.\n // We don't need to zero this because we're about to write to it.\n stackBottoms := mload(0x40)\n mstore(stackBottoms, stacksLength)\n mstore(0x40, add(stackBottoms, mul(add(stacksLength, 1), 0x20)))\n\n // Allocate each stack and point to it.\n let stacksCursor := add(stackBottoms, 0x20)\n for { let i := 0 } lt(i, stacksLength) {\n i := add(i, 1)\n // Move over the 2 byte source pointer.\n cursor := add(cursor, 2)\n // Move the stacks cursor forward.\n stacksCursor := add(stacksCursor, 0x20)\n } {\n // The stack size is in the prefix of the source data, which\n // is behind a relative pointer in the bytecode prefix.\n let sourcePointer := add(sourcesStart, shr(0xf0, mload(cursor)))\n // Stack size is the second byte of the source prefix.\n let stackSize := byte(1, mload(sourcePointer))\n\n // Allocate the stack.\n // We don't need to zero the stack because the interpreter\n // assumes values above the stack top are dirty anyway.\n let stack := mload(0x40)\n mstore(stack, stackSize)\n let stackBottom := add(stack, mul(add(stackSize, 1), 0x20))\n mstore(0x40, stackBottom)\n\n // Point to the stack bottom\n mstore(stacksCursor, stackBottom)\n }\n }\n\n return InterpreterStateNP(\n stackBottoms, constants, sourceIndex, MemoryKV.wrap(0), namespace, store, context, bytecode, fs\n );\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/caller/LibEncodedDispatch.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../../interface/IInterpreterV1.sol\";\n\n/// @title LibEncodedDispatch\n/// @notice Establishes and implements a convention for encoding an interpreter\n/// dispatch. Handles encoding of several things required for efficient dispatch.\nlibrary LibEncodedDispatch {\n /// Builds an `EncodedDispatch` from its constituent parts.\n /// @param expression The onchain address of the expression to run.\n /// @param sourceIndex The index of the source to run within the expression\n /// as an entrypoint.\n /// @param maxOutputs The maximum outputs the caller can meaningfully use.\n /// If the interpreter returns a larger stack than this it is merely wasting\n /// gas across the external call boundary.\n /// @return The encoded dispatch.\n function encode(address expression, SourceIndex sourceIndex, uint16 maxOutputs)\n internal\n pure\n returns (EncodedDispatch)\n {\n return EncodedDispatch.wrap(\n (uint256(uint160(expression)) << 32) | (uint256(SourceIndex.unwrap(sourceIndex)) << 16) | maxOutputs\n );\n }\n\n /// Decodes an `EncodedDispatch` to its constituent parts.\n /// @param dispatch_ The `EncodedDispatch` to decode.\n /// @return The expression, source index, and max outputs as per `encode`.\n function decode(EncodedDispatch dispatch_) internal pure returns (address, SourceIndex, uint16) {\n return (\n address(uint160(EncodedDispatch.unwrap(dispatch_) >> 32)),\n SourceIndex.wrap(uint16(EncodedDispatch.unwrap(dispatch_) >> 16)),\n uint16(EncodedDispatch.unwrap(dispatch_))\n );\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/state/LibInterpreterStateNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.solmem/lib/LibPointer.sol\";\nimport \"rain.lib.memkv/lib/LibMemoryKV.sol\";\nimport \"../ns/LibNamespace.sol\";\n\nstruct InterpreterStateNP {\n Pointer[] stackBottoms;\n uint256[] constants;\n uint256 sourceIndex;\n MemoryKV stateKV;\n FullyQualifiedNamespace namespace;\n IInterpreterStoreV1 store;\n uint256[][] context;\n bytes bytecode;\n bytes fs;\n}\n\nlibrary LibInterpreterStateNP {\n function fingerprint(InterpreterStateNP memory state) internal pure returns (bytes32) {\n return keccak256(abi.encode(state));\n }\n\n function stackBottoms(uint256[][] memory stacks) internal pure returns (Pointer[] memory) {\n Pointer[] memory bottoms = new Pointer[](stacks.length);\n assembly (\"memory-safe\") {\n for {\n let cursor := add(stacks, 0x20)\n let end := add(cursor, mul(mload(stacks), 0x20))\n let bottomsCursor := add(bottoms, 0x20)\n } lt(cursor, end) {\n cursor := add(cursor, 0x20)\n bottomsCursor := add(bottomsCursor, 0x20)\n } {\n let stack := mload(cursor)\n let stackBottom := add(stack, mul(0x20, add(mload(stack), 1)))\n mstore(bottomsCursor, stackBottom)\n }\n }\n return bottoms;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/LibAllStandardOpsNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.19;\n\nimport {LibConvert} from \"rain.lib.typecast/LibConvert.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../interface/IInterpreterV1.sol\";\nimport {LibIntegrityCheckNP, IntegrityCheckStateNP} from \"../integrity/LibIntegrityCheckNP.sol\";\nimport {LibInterpreterStateNP, InterpreterStateNP} from \"../state/LibInterpreterStateNP.sol\";\nimport {AuthoringMeta} from \"../parse/LibParseMeta.sol\";\nimport {\n OPERAND_PARSER_OFFSET_DISALLOWED,\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT,\n OPERAND_PARSER_OFFSET_M1_M1,\n OPERAND_PARSER_OFFSET_8_M1_M1\n} from \"../parse/LibParseOperand.sol\";\nimport {LibUint256Array} from \"rain.solmem/lib/LibUint256Array.sol\";\nimport {LibOpStackNP} from \"./00/LibOpStackNP.sol\";\nimport {LibOpConstantNP} from \"./00/LibOpConstantNP.sol\";\n\nimport {LibOpCtPopNP} from \"./bitwise/LibOpCtPopNP.sol\";\n\nimport {LibOpCallNP} from \"./call/LibOpCallNP.sol\";\n\nimport {LibOpContextNP} from \"./context/LibOpContextNP.sol\";\n\nimport {LibOpHashNP} from \"./crypto/LibOpHashNP.sol\";\n\nimport {LibOpERC721BalanceOfNP} from \"./erc721/LibOpERC721BalanceOfNP.sol\";\nimport {LibOpERC721OwnerOfNP} from \"./erc721/LibOpERC721OwnerOfNP.sol\";\n\nimport {LibOpBlockNumberNP} from \"./evm/LibOpBlockNumberNP.sol\";\nimport {LibOpChainIdNP} from \"./evm/LibOpChainIdNP.sol\";\nimport {LibOpMaxUint256NP} from \"./evm/LibOpMaxUint256NP.sol\";\nimport {LibOpTimestampNP} from \"./evm/LibOpTimestampNP.sol\";\n\nimport {LibOpAnyNP} from \"./logic/LibOpAnyNP.sol\";\nimport {LibOpConditionsNP} from \"./logic/LibOpConditionsNP.sol\";\nimport {EnsureFailed, LibOpEnsureNP} from \"./logic/LibOpEnsureNP.sol\";\nimport {LibOpEqualToNP} from \"./logic/LibOpEqualToNP.sol\";\nimport {LibOpEveryNP} from \"./logic/LibOpEveryNP.sol\";\nimport {LibOpGreaterThanNP} from \"./logic/LibOpGreaterThanNP.sol\";\nimport {LibOpGreaterThanOrEqualToNP} from \"./logic/LibOpGreaterThanOrEqualToNP.sol\";\nimport {LibOpIfNP} from \"./logic/LibOpIfNP.sol\";\nimport {LibOpIsZeroNP} from \"./logic/LibOpIsZeroNP.sol\";\nimport {LibOpLessThanNP} from \"./logic/LibOpLessThanNP.sol\";\nimport {LibOpLessThanOrEqualToNP} from \"./logic/LibOpLessThanOrEqualToNP.sol\";\n\nimport {LibOpDecimal18MulNP} from \"./math/decimal18/LibOpDecimal18MulNP.sol\";\nimport {LibOpDecimal18DivNP} from \"./math/decimal18/LibOpDecimal18DivNP.sol\";\nimport {LibOpDecimal18Scale18DynamicNP} from \"./math/decimal18/LibOpDecimal18Scale18DynamicNP.sol\";\nimport {LibOpDecimal18Scale18NP} from \"./math/decimal18/LibOpDecimal18Scale18NP.sol\";\nimport {LibOpDecimal18ScaleNNP} from \"./math/decimal18/LibOpDecimal18ScaleNNP.sol\";\n\nimport {LibOpIntAddNP} from \"./math/int/LibOpIntAddNP.sol\";\nimport {LibOpIntDivNP} from \"./math/int/LibOpIntDivNP.sol\";\nimport {LibOpIntExpNP} from \"./math/int/LibOpIntExpNP.sol\";\nimport {LibOpIntMaxNP} from \"./math/int/LibOpIntMaxNP.sol\";\nimport {LibOpIntMinNP} from \"./math/int/LibOpIntMinNP.sol\";\nimport {LibOpIntModNP} from \"./math/int/LibOpIntModNP.sol\";\nimport {LibOpIntMulNP} from \"./math/int/LibOpIntMulNP.sol\";\nimport {LibOpIntSubNP} from \"./math/int/LibOpIntSubNP.sol\";\n\nimport {LibOpGetNP} from \"./store/LibOpGetNP.sol\";\nimport {LibOpSetNP} from \"./store/LibOpSetNP.sol\";\n\nimport {LibOpUniswapV2AmountIn} from \"./uniswap/LibOpUniswapV2AmountIn.sol\";\nimport {LibOpUniswapV2AmountOut} from \"./uniswap/LibOpUniswapV2AmountOut.sol\";\n\n/// Thrown when a dynamic length array is NOT 1 more than a fixed length array.\n/// Should never happen outside a major breaking change to memory layouts.\nerror BadDynamicLength(uint256 dynamicLength, uint256 standardOpsLength);\n\n/// @dev Number of ops currently provided by `AllStandardOpsNP`.\nuint256 constant ALL_STANDARD_OPS_LENGTH = 45;\n\n/// @title LibAllStandardOpsNP\n/// @notice Every opcode available from the core repository laid out as a single\n/// array to easily build function pointers for `IInterpreterV1`.\nlibrary LibAllStandardOpsNP {\n function authoringMeta() internal pure returns (bytes memory) {\n AuthoringMeta memory lengthPlaceholder;\n AuthoringMeta[ALL_STANDARD_OPS_LENGTH + 1] memory wordsFixed = [\n lengthPlaceholder,\n // Stack and constant MUST be in this order for parsing to work.\n AuthoringMeta(\"stack\", OPERAND_PARSER_OFFSET_SINGLE_FULL, \"Copies an existing value from the stack.\"),\n AuthoringMeta(\"constant\", OPERAND_PARSER_OFFSET_SINGLE_FULL, \"Copies a constant value onto the stack.\"),\n // These are all ordered according to how they appear in the file system.\n AuthoringMeta(\n \"bitwise-count-ones\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Counts the number of binary bits set to 1 in the input.\"\n ),\n AuthoringMeta(\n \"call\",\n OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT,\n \"Calls a source by index in the same Rain bytecode. The inputs to call are copied to the top of the called stack and the outputs specified in the operand are copied back to the calling stack. The first operand is the source index and the second is the number of outputs.\"\n ),\n AuthoringMeta(\n \"context\",\n OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT,\n \"Copies a value from the context. The first operand is the context column and second is the context row.\"\n ),\n AuthoringMeta(\n \"hash\", OPERAND_PARSER_OFFSET_DISALLOWED, \"Hashes all inputs into a single 32 byte value using keccak256.\"\n ),\n AuthoringMeta(\n \"erc721-balance-of\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Gets the balance of an erc721 token for an account. The first input is the token address and the second is the account address.\"\n ),\n AuthoringMeta(\n \"erc721-owner-of\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Gets the owner of an erc721 token. The first input is the token address and the second is the token id.\"\n ),\n AuthoringMeta(\"block-number\", OPERAND_PARSER_OFFSET_DISALLOWED, \"The current block number.\"),\n AuthoringMeta(\"chain-id\", OPERAND_PARSER_OFFSET_DISALLOWED, \"The current chain id.\"),\n AuthoringMeta(\n \"max-int-value\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"The maximum possible non-negative integer value. 2^256 - 1.\"\n ),\n AuthoringMeta(\n \"max-decimal18-value\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"The maximum possible 18 decimal fixed point value. roughly 1.15e77.\"\n ),\n AuthoringMeta(\"block-timestamp\", OPERAND_PARSER_OFFSET_DISALLOWED, \"The current block timestamp.\"),\n AuthoringMeta(\n \"any\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"The first non-zero value out of all inputs, or 0 if every input is 0.\"\n ),\n AuthoringMeta(\n \"conditions\",\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n \"Treats inputs as pairwise condition/value pairs. The first nonzero condition's value is used. If no conditions are nonzero, the expression reverts. The operand can be used as an error code to differentiate between multiple conditions in the same expression.\"\n ),\n AuthoringMeta(\n \"ensure\",\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n \"Reverts if any input is 0. All inputs are eagerly evaluated there are no outputs. The operand can be used as an error code to differentiate between multiple conditions in the same expression.\"\n ),\n AuthoringMeta(\"equal-to\", OPERAND_PARSER_OFFSET_DISALLOWED, \"1 if all inputs are equal, 0 otherwise.\"),\n AuthoringMeta(\n \"every\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"The last nonzero value out of all inputs, or 0 if any input is 0.\"\n ),\n AuthoringMeta(\n \"greater-than\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"1 if the first input is greater than the second input, 0 otherwise.\"\n ),\n AuthoringMeta(\n \"greater-than-or-equal-to\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"1 if the first input is greater than or equal to the second input, 0 otherwise.\"\n ),\n AuthoringMeta(\n \"if\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"If the first input is nonzero, the second input is used. Otherwise, the third input is used. If is eagerly evaluated.\"\n ),\n AuthoringMeta(\"is-zero\", OPERAND_PARSER_OFFSET_DISALLOWED, \"1 if the input is 0, 0 otherwise.\"),\n AuthoringMeta(\n \"less-than\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"1 if the first input is less than the second input, 0 otherwise.\"\n ),\n AuthoringMeta(\n \"less-than-or-equal-to\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"1 if the first input is less than or equal to the second input, 0 otherwise.\"\n ),\n AuthoringMeta(\n \"decimal18-div\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Divides the first input by all other inputs as fixed point 18 decimal numbers (i.e. 'one' is 1e18). Errors if any divisor is zero.\"\n ),\n AuthoringMeta(\n \"decimal18-mul\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Multiplies all inputs together as fixed point 18 decimal numbers (i.e. 'one' is 1e18). Errors if the multiplication exceeds the maximum value (roughly 1.15e77).\"\n ),\n AuthoringMeta(\n \"decimal18-scale18-dynamic\",\n OPERAND_PARSER_OFFSET_M1_M1,\n \"Scales a value from some fixed point decimal scale to 18 decimal fixed point. The first input is the scale to scale from and the second is the value to scale. The two optional operands control rounding and saturation respectively as per `decimal18-scale18`.\"\n ),\n AuthoringMeta(\n \"decimal18-scale18\",\n OPERAND_PARSER_OFFSET_8_M1_M1,\n \"Scales an input value from some fixed point decimal scale to 18 decimal fixed point. The first operand is the scale to scale from. The second (optional) operand controls rounding where 0 (default) rounds down and 1 rounds up. The third (optional) operand controls saturation where 0 (default) errors on overflow and 1 saturates at max-decimal-value.\"\n ),\n AuthoringMeta(\n \"decimal18-scale-n\",\n OPERAND_PARSER_OFFSET_8_M1_M1,\n \"Scales an input value from 18 decimal fixed point to some other fixed point scale N. The first operand is the scale to scale to. The second (optional) operand controls rounding where 0 (default) rounds down and 1 rounds up. The third (optional) operand controls saturation where 0 (default) errors on overflow and 1 saturates at max-decimal-value.\"\n ),\n // int and decimal18 add have identical implementations and point to\n // the same function pointer. This is intentional.\n AuthoringMeta(\n \"int-add\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Adds all inputs together as non-negative integers. Errors if the addition exceeds the maximum value (roughly 1.15e77).\"\n ),\n AuthoringMeta(\n \"decimal18-add\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Adds all inputs together as fixed point 18 decimal numbers (i.e. 'one' is 1e18). Errors if the addition exceeds the maximum value (roughly 1.15e77).\"\n ),\n AuthoringMeta(\n \"int-div\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Divides the first input by all other inputs as non-negative integers. Errors if any divisor is zero.\"\n ),\n AuthoringMeta(\n \"int-exp\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Raises the first input to the power of all other inputs as non-negative integers. Errors if the exponentiation would exceed the maximum value (roughly 1.15e77).\"\n ),\n // int and decimal18 max have identical implementations and point to\n // the same function pointer. This is intentional.\n AuthoringMeta(\n \"int-max\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Finds the maximum value from all inputs as non-negative integers.\"\n ),\n AuthoringMeta(\n \"decimal18-max\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Finds the maximum value from all inputs as fixed point 18 decimal numbers (i.e. 'one' is 1e18).\"\n ),\n // int and decimal18 min have identical implementations and point to\n // the same function pointer. This is intentional.\n AuthoringMeta(\n \"int-min\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Finds the minimum value from all inputs as non-negative integers.\"\n ),\n AuthoringMeta(\n \"decimal18-min\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Finds the minimum value from all inputs as fixed point 18 decimal numbers (i.e. 'one' is 1e18).\"\n ),\n AuthoringMeta(\n \"int-mod\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Modulos the first input by all other inputs as non-negative integers. Errors if any divisor is zero.\"\n ),\n AuthoringMeta(\n \"int-mul\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Multiplies all inputs together as non-negative integers. Errors if the multiplication exceeds the maximum value (roughly 1.15e77).\"\n ),\n // int and decimal18 sub have identical implementations and point to\n // the same function pointer. This is intentional.\n AuthoringMeta(\n \"int-sub\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Subtracts all inputs from the first input as non-negative integers. Errors if the subtraction would result in a negative value.\"\n ),\n AuthoringMeta(\n \"decimal18-sub\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Subtracts all inputs from the first input as fixed point 18 decimal numbers (i.e. 'one' is 1e18). Errors if the subtraction would result in a negative value.\"\n ),\n AuthoringMeta(\n \"get\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Gets a value from storage. The first operand is the key to lookup.\"\n ),\n AuthoringMeta(\n \"set\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Sets a value in storage. The first operand is the key to set and the second operand is the value to set.\"\n ),\n AuthoringMeta(\n \"uniswap-v2-amount-in\",\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n \"Computes the minimum amount of input tokens required to get a given amount of output tokens from a UniswapV2 pair. Input/output token directions are from the perspective of the Uniswap contract. The first input is the factory address, the second is the amount of output tokens, the third is the input token address, and the fourth is the output token address. If the operand is 1 the last time the prices changed will be returned as well.\"\n ),\n AuthoringMeta(\n \"uniswap-v2-amount-out\",\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n \"Computes the maximum amount of output tokens received from a given amount of input tokens from a UniswapV2 pair. Input/output token directions are from the perspective of the Uniswap contract. The first input is the factory address, the second is the amount of input tokens, the third is the input token address, and the fourth is the output token address. If the operand is 1 the last time the prices changed will be returned as well.\"\n )\n ];\n AuthoringMeta[] memory wordsDynamic;\n uint256 length = ALL_STANDARD_OPS_LENGTH;\n assembly (\"memory-safe\") {\n wordsDynamic := wordsFixed\n mstore(wordsDynamic, length)\n }\n return abi.encode(wordsDynamic);\n }\n\n function integrityFunctionPointers() internal pure returns (bytes memory) {\n unchecked {\n function(IntegrityCheckStateNP memory, Operand)\n view\n returns (uint256, uint256) lengthPointer;\n uint256 length = ALL_STANDARD_OPS_LENGTH;\n assembly (\"memory-safe\") {\n lengthPointer := length\n }\n function(IntegrityCheckStateNP memory, Operand)\n view\n returns (uint256, uint256)[ALL_STANDARD_OPS_LENGTH + 1] memory pointersFixed = [\n lengthPointer,\n // Stack then constant are the first two ops to match the\n // field ordering in the interpreter state NOT the lexical\n // ordering of the file system.\n LibOpStackNP.integrity,\n LibOpConstantNP.integrity,\n // Everything else is alphabetical, including folders.\n LibOpCtPopNP.integrity,\n LibOpCallNP.integrity,\n LibOpContextNP.integrity,\n LibOpHashNP.integrity,\n LibOpERC721BalanceOfNP.integrity,\n LibOpERC721OwnerOfNP.integrity,\n LibOpBlockNumberNP.integrity,\n LibOpChainIdNP.integrity,\n // int and decimal18 max have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpMaxUint256NP.integrity,\n // decimal18 max.\n LibOpMaxUint256NP.integrity,\n LibOpTimestampNP.integrity,\n LibOpAnyNP.integrity,\n LibOpConditionsNP.integrity,\n LibOpEnsureNP.integrity,\n LibOpEqualToNP.integrity,\n LibOpEveryNP.integrity,\n LibOpGreaterThanNP.integrity,\n LibOpGreaterThanOrEqualToNP.integrity,\n LibOpIfNP.integrity,\n LibOpIsZeroNP.integrity,\n LibOpLessThanNP.integrity,\n LibOpLessThanOrEqualToNP.integrity,\n LibOpDecimal18DivNP.integrity,\n LibOpDecimal18MulNP.integrity,\n LibOpDecimal18Scale18DynamicNP.integrity,\n LibOpDecimal18Scale18NP.integrity,\n LibOpDecimal18ScaleNNP.integrity,\n // int and decimal18 add have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntAddNP.integrity,\n // decimal18 add.\n LibOpIntAddNP.integrity,\n LibOpIntDivNP.integrity,\n LibOpIntExpNP.integrity,\n // int and decimal18 max have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntMaxNP.integrity,\n // decimal18 max.\n LibOpIntMaxNP.integrity,\n // int and decimal18 min have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntMinNP.integrity,\n // decimal18 min.\n LibOpIntMinNP.integrity,\n LibOpIntModNP.integrity,\n LibOpIntMulNP.integrity,\n // int and decimal18 sub have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntSubNP.integrity,\n // decimal18 sub.\n LibOpIntSubNP.integrity,\n LibOpGetNP.integrity,\n LibOpSetNP.integrity,\n LibOpUniswapV2AmountIn.integrity,\n LibOpUniswapV2AmountOut.integrity\n ];\n uint256[] memory pointersDynamic;\n assembly (\"memory-safe\") {\n pointersDynamic := pointersFixed\n }\n // Sanity check that the dynamic length is correct. Should be an\n // unreachable error.\n if (pointersDynamic.length != ALL_STANDARD_OPS_LENGTH) {\n revert BadDynamicLength(pointersDynamic.length, length);\n }\n return LibConvert.unsafeTo16BitBytes(pointersDynamic);\n }\n }\n\n /// All function pointers for the standard opcodes. Intended to be used to\n /// build a `IInterpreterV1` instance, specifically the `functionPointers`\n /// method can just be a thin wrapper around this function.\n function opcodeFunctionPointers() internal pure returns (bytes memory) {\n unchecked {\n function(InterpreterStateNP memory, Operand, Pointer)\n view\n returns (Pointer) lengthPointer;\n uint256 length = ALL_STANDARD_OPS_LENGTH;\n assembly (\"memory-safe\") {\n lengthPointer := length\n }\n function(InterpreterStateNP memory, Operand, Pointer)\n view\n returns (Pointer)[ALL_STANDARD_OPS_LENGTH + 1] memory pointersFixed = [\n lengthPointer,\n // Stack then constant are the first two ops to match the\n // field ordering in the interpreter state NOT the lexical\n // ordering of the file system.\n LibOpStackNP.run,\n LibOpConstantNP.run,\n // Everything else is alphabetical, including folders.\n LibOpCtPopNP.run,\n LibOpCallNP.run,\n LibOpContextNP.run,\n LibOpHashNP.run,\n LibOpERC721BalanceOfNP.run,\n LibOpERC721OwnerOfNP.run,\n LibOpBlockNumberNP.run,\n LibOpChainIdNP.run,\n // int and decimal18 max have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpMaxUint256NP.run,\n // decimal18 max.\n LibOpMaxUint256NP.run,\n LibOpTimestampNP.run,\n LibOpAnyNP.run,\n LibOpConditionsNP.run,\n LibOpEnsureNP.run,\n LibOpEqualToNP.run,\n LibOpEveryNP.run,\n LibOpGreaterThanNP.run,\n LibOpGreaterThanOrEqualToNP.run,\n LibOpIfNP.run,\n LibOpIsZeroNP.run,\n LibOpLessThanNP.run,\n LibOpLessThanOrEqualToNP.run,\n LibOpDecimal18DivNP.run,\n LibOpDecimal18MulNP.run,\n LibOpDecimal18Scale18DynamicNP.run,\n LibOpDecimal18Scale18NP.run,\n LibOpDecimal18ScaleNNP.run,\n // int and decimal18 add have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntAddNP.run,\n // decimal18 add.\n LibOpIntAddNP.run,\n LibOpIntDivNP.run,\n LibOpIntExpNP.run,\n // int and decimal18 max have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntMaxNP.run,\n // decimal18 max.\n LibOpIntMaxNP.run,\n // int and decimal18 min have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntMinNP.run,\n // decimal18 min.\n LibOpIntMinNP.run,\n LibOpIntModNP.run,\n LibOpIntMulNP.run,\n // int and decimal18 sub have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntSubNP.run,\n // decimal18 sub.\n LibOpIntSubNP.run,\n LibOpGetNP.run,\n LibOpSetNP.run,\n LibOpUniswapV2AmountIn.run,\n LibOpUniswapV2AmountOut.run\n ];\n uint256[] memory pointersDynamic;\n assembly (\"memory-safe\") {\n pointersDynamic := pointersFixed\n }\n // Sanity check that the dynamic length is correct. Should be an\n // unreachable error.\n if (pointersDynamic.length != ALL_STANDARD_OPS_LENGTH) {\n revert BadDynamicLength(pointersDynamic.length, length);\n }\n return LibConvert.unsafeTo16BitBytes(pointersDynamic);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibPointer.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// A pointer to a location in memory. This is a `uint256` to save gas on low\n/// level operations on the evm stack. These same low level operations typically\n/// WILL NOT check for overflow or underflow, so all pointer logic MUST ensure\n/// that reads, writes and movements are not out of bounds.\ntype Pointer is uint256;\n\n/// @title LibPointer\n/// Ergonomic wrappers around common pointer movements, reading and writing. As\n/// wrappers on such low level operations often introduce too much jump gas\n/// overhead, these functions MAY find themselves used in reference\n/// implementations that more optimised code can be fuzzed against. MAY also be\n/// situationally useful on cooler performance paths.\nlibrary LibPointer {\n /// Cast a `Pointer` to `bytes` without modification or any safety checks.\n /// The caller MUST ensure the pointer is to a valid region of memory for\n /// some `bytes`.\n /// @param pointer The pointer to cast to `bytes`.\n /// @return data The cast `bytes`.\n function unsafeAsBytes(Pointer pointer) internal pure returns (bytes memory data) {\n assembly (\"memory-safe\") {\n data := pointer\n }\n }\n\n /// Increase some pointer by a number of bytes.\n ///\n /// This is UNSAFE because it can silently overflow or point beyond some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// Note that moving a pointer by some bytes offset is likely to unalign it\n /// with the 32 byte increments of the Solidity allocator.\n ///\n /// @param pointer The pointer to increase by `length`.\n /// @param length The number of bytes to increase the pointer by.\n /// @return The increased pointer.\n function unsafeAddBytes(Pointer pointer, uint256 length) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := add(pointer, length)\n }\n return pointer;\n }\n\n /// Increase some pointer by a single 32 byte word.\n ///\n /// This is UNSAFE because it can silently overflow or point beyond some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// If the original pointer is aligned to the Solidity allocator it will be\n /// aligned after the movement.\n ///\n /// @param pointer The pointer to increase by a single word.\n /// @return The increased pointer.\n function unsafeAddWord(Pointer pointer) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := add(pointer, 0x20)\n }\n return pointer;\n }\n\n /// Increase some pointer by multiple 32 byte words.\n ///\n /// This is UNSAFE because it can silently overflow or point beyond some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// If the original pointer is aligned to the Solidity allocator it will be\n /// aligned after the movement.\n ///\n /// @param pointer The pointer to increase.\n /// @param words The number of words to increase the pointer by.\n /// @return The increased pointer.\n function unsafeAddWords(Pointer pointer, uint256 words) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := add(pointer, mul(0x20, words))\n }\n return pointer;\n }\n\n /// Decrease some pointer by a single 32 byte word.\n ///\n /// This is UNSAFE because it can silently underflow or point below some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// If the original pointer is aligned to the Solidity allocator it will be\n /// aligned after the movement.\n ///\n /// @param pointer The pointer to decrease by a single word.\n /// @return The decreased pointer.\n function unsafeSubWord(Pointer pointer) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := sub(pointer, 0x20)\n }\n return pointer;\n }\n\n /// Decrease some pointer by multiple 32 byte words.\n ///\n /// This is UNSAFE because it can silently underflow or point below some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// If the original pointer is aligned to the Solidity allocator it will be\n /// aligned after the movement.\n ///\n /// @param pointer The pointer to decrease.\n /// @param words The number of words to decrease the pointer by.\n /// @return The decreased pointer.\n function unsafeSubWords(Pointer pointer, uint256 words) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := sub(pointer, mul(0x20, words))\n }\n return pointer;\n }\n\n /// Read the word at the pointer.\n ///\n /// This is UNSAFE because it can read outside any particular data stucture\n /// or even beyond allocated memory. The caller MUST ensure that this is a\n /// safe operation.\n ///\n /// @param pointer Pointer to read the word at.\n /// @return word The word read from the pointer.\n function unsafeReadWord(Pointer pointer) internal pure returns (uint256 word) {\n assembly (\"memory-safe\") {\n word := mload(pointer)\n }\n }\n\n /// Write a word at the pointer.\n ///\n /// This is UNSAFE because it can write outside any particular data stucture\n /// or even beyond allocated memory. The caller MUST ensure that this is a\n /// safe operation.\n ///\n /// @param pointer Pointer to write the word at.\n /// @param word The word to write.\n function unsafeWriteWord(Pointer pointer, uint256 word) internal pure {\n assembly (\"memory-safe\") {\n mstore(pointer, word)\n }\n }\n\n /// Get the pointer to the end of all allocated memory.\n /// As per Solidity docs, there is no guarantee that the region of memory\n /// beyond this pointer is zeroed out, as assembly MAY write beyond allocated\n /// memory for temporary use if the scratch space is insufficient.\n /// @return pointer The pointer to the end of all allocated memory.\n function allocatedMemoryPointer() internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := mload(0x40)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibStackPointer.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibUint256Array.sol\";\nimport \"./LibMemory.sol\";\nimport \"./LibMemCpy.sol\";\n\n/// Throws if a stack pointer is not aligned to 32 bytes.\nerror UnalignedStackPointer(Pointer pointer);\n\n/// @title LibStackPointer\n/// @notice A stack `Pointer` is still just a pointer to some memory, but we are\n/// going to treat it like it is pointing to a stack data structure. That means\n/// it can move \"up\" and \"down\" (increment and decrement) by `uint256` (32 bytes)\n/// increments. Structurally a stack is a `uint256[]` but we can save a lot of\n/// gas vs. default Solidity handling of array indexes by using assembly to\n/// bypass runtime bounds checks on every read and write. Of course, this means\n/// the caller is responsible for ensuring the stack reads and write are not out\n/// of bounds.\n///\n/// The pointer to the bottom of a stack points at the 0th item, NOT the length\n/// of the implied `uint256[]` and the top of a stack points AFTER the last item.\n/// e.g. consider a `uint256[]` in memory with values `3 A B C` and assume this\n/// starts at position `0` in memory, i.e. `0` points to value `3` for the\n/// array length. In this case the stack bottom would be `Pointer.wrap(0x20)`\n/// (32 bytes above 0, past the length) and the stack top would be\n/// `StackPointer.wrap(0x80)` (96 bytes above the stack bottom).\n///\n/// Most of the functions in this library are equivalent to each other via\n/// composition, i.e. everything could be achieved with just `up`, `down`,\n/// `pop`, `push`, `peek`. The reason there is so much overloaded/duplicated\n/// logic is that the Solidity compiler seems to fail at inlining equivalent\n/// logic quite a lot. Perhaps once the IR compilation of Solidity is better\n/// supported by tooling etc. we could remove a lot of this duplication as the\n/// compiler itself would handle the optimisations.\nlibrary LibStackPointer {\n using LibStackPointer for Pointer;\n using LibStackPointer for uint256[];\n using LibStackPointer for bytes;\n using LibUint256Array for uint256[];\n using LibMemory for uint256;\n\n /// Read the word immediately below the given stack pointer.\n ///\n /// Treats the given pointer as a pointer to the top of the stack, so `peek`\n /// reads the word below the pointer.\n ///\n /// https://en.wikipedia.org/wiki/Peek_(data_type_operation)\n ///\n /// The caller MUST ensure this read is not out of bounds, e.g. a `peek` to\n /// `0` will underflow (and exhaust gas attempting to read).\n ///\n /// @param pointer Pointer to the top of the stack to read below.\n /// @return word The word that was read.\n function unsafePeek(Pointer pointer) internal pure returns (uint256 word) {\n assembly (\"memory-safe\") {\n word := mload(sub(pointer, 0x20))\n }\n }\n\n /// Peeks 2 words from the top of the stack.\n ///\n /// Same as `unsafePeek` but returns 2 words instead of 1.\n ///\n /// @param pointer The stack top to peek below.\n /// @return lower The lower of the two words read.\n /// @return upper The upper of the two words read.\n function unsafePeek2(Pointer pointer) internal pure returns (uint256 lower, uint256 upper) {\n assembly (\"memory-safe\") {\n lower := mload(sub(pointer, 0x40))\n upper := mload(sub(pointer, 0x20))\n }\n }\n\n /// Pops the word from the top of the stack.\n ///\n /// Treats the given pointer as a pointer to the top of the stack, so `pop`\n /// reads the word below the pointer. The popped pointer is returned\n /// alongside the read word.\n ///\n /// https://en.wikipedia.org/wiki/Stack_(abstract_data_type)\n ///\n /// The caller MUST ensure the pop will not result in an out of bounds read.\n ///\n /// @param pointer Pointer to the top of the stack to read below.\n /// @return pointerAfter Pointer after the pop.\n /// @return word The word that was read.\n function unsafePop(Pointer pointer) internal pure returns (Pointer pointerAfter, uint256 word) {\n assembly (\"memory-safe\") {\n pointerAfter := sub(pointer, 0x20)\n word := mload(pointerAfter)\n }\n }\n\n /// Pushes a word to the top of the stack.\n ///\n /// Treats the given pointer as a pointer to the top of the stack, so `push`\n /// writes a word at the pointer. The pushed pointer is returned.\n ///\n /// https://en.wikipedia.org/wiki/Stack_(abstract_data_type)\n ///\n /// The caller MUST ensure the push will not result in an out of bounds\n /// write.\n ///\n /// @param pointer The stack pointer to write at.\n /// @param word The value to write.\n /// @return The stack pointer above where `word` was written to.\n function unsafePush(Pointer pointer, uint256 word) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n mstore(pointer, word)\n pointer := add(pointer, 0x20)\n }\n return pointer;\n }\n\n /// Returns `length` values from the stack as an array without allocating\n /// new memory. As arrays always start with their length, this requires\n /// writing the length value to the stack below the array values. The value\n /// that is overwritten in the process is also returned so that data is not\n /// lost. For example, imagine a stack `[ A B C D ]` and we list 2 values.\n /// This will write the stack to look like `[ A 2 C D ]` and return both `B`\n /// and a pointer to `2` represented as a `uint256[]`.\n /// The returned array is ONLY valid for as long as the stack DOES NOT move\n /// back into its memory. As soon as the stack moves up again and writes into\n /// the array it will be corrupt. The caller MUST ensure that it does not\n /// read from the returned array after it has been corrupted by subsequent\n /// stack writes.\n /// @param pointer The stack pointer to read the values below into an\n /// array.\n /// @param length The number of values to include in the returned array.\n /// @return head The value that was overwritten with the length.\n /// @return tail The array constructed from the stack memory.\n function unsafeList(Pointer pointer, uint256 length) internal pure returns (uint256 head, uint256[] memory tail) {\n assembly (\"memory-safe\") {\n tail := sub(pointer, add(0x20, mul(length, 0x20)))\n head := mload(tail)\n mstore(tail, length)\n }\n }\n\n /// Convert two stack pointer values to a single stack index. A stack index\n /// is the distance in 32 byte increments between two stack pointers. The\n /// calculations require the two stack pointers are aligned. If the pointers\n /// are not aligned, the function will revert.\n ///\n /// @param lower The lower of the two values.\n /// @param upper The higher of the two values.\n /// @return The stack index as 32 byte words distance between the top and\n /// bottom. Negative if `lower` is above `upper`.\n function toIndexSigned(Pointer lower, Pointer upper) internal pure returns (int256) {\n unchecked {\n if (Pointer.unwrap(lower) % 0x20 != 0) {\n revert UnalignedStackPointer(lower);\n }\n if (Pointer.unwrap(upper) % 0x20 != 0) {\n revert UnalignedStackPointer(upper);\n }\n // Dividing by 0x20 before casting to a signed int avoids the case\n // where the difference between the two pointers is greater than\n // `type(int256).max` and would overflow the signed int.\n return int256(Pointer.unwrap(upper) / 0x20) - int256(Pointer.unwrap(lower) / 0x20);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibUint256Array.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibMemCpy.sol\";\n\n/// Thrown if a truncated length is longer than the array being truncated. It is\n/// not possible to truncate something and increase its length as the memory\n/// region after the array MAY be allocated for something else already.\nerror OutOfBoundsTruncate(uint256 arrayLength, uint256 truncatedLength);\n\n/// @title Uint256Array\n/// @notice Things we want to do carefully and efficiently with uint256 arrays\n/// that Solidity doesn't give us native tools for.\nlibrary LibUint256Array {\n using LibUint256Array for uint256[];\n\n /// Pointer to the start (length prefix) of a `uint256[]`.\n /// @param array The array to get the start pointer of.\n /// @return pointer The pointer to the start of `array`.\n function startPointer(uint256[] memory array) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := array\n }\n }\n\n /// Pointer to the data of a `uint256[]` NOT the length prefix.\n /// @param array The array to get the data pointer of.\n /// @return pointer The pointer to the data of `array`.\n function dataPointer(uint256[] memory array) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(array, 0x20)\n }\n }\n\n /// Pointer to the end of the allocated memory of an array.\n /// @param array The array to get the end pointer of.\n /// @return pointer The pointer to the end of `array`.\n function endPointer(uint256[] memory array) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(array, add(0x20, mul(0x20, mload(array))))\n }\n }\n\n /// Cast a `Pointer` to `uint256[]` without modification or safety checks.\n /// The caller MUST ensure the pointer is to a valid region of memory for\n /// some `uint256[]`.\n /// @param pointer The pointer to cast to `uint256[]`.\n /// @return array The cast `uint256[]`.\n function unsafeAsUint256Array(Pointer pointer) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := pointer\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a A single integer to build an array around.\n /// @return array The newly allocated array including `a` as a single item.\n function arrayFrom(uint256 a) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 1)\n mstore(add(array, 0x20), a)\n mstore(0x40, add(array, 0x40))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @return array The newly allocated array including `a` and `b` as the only\n /// items.\n function arrayFrom(uint256 a, uint256 b) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 2)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(0x40, add(array, 0x60))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @param c The third integer to build an array around.\n /// @return array The newly allocated array including `a`, `b` and `c` as the\n /// only items.\n function arrayFrom(uint256 a, uint256 b, uint256 c) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 3)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(add(array, 0x60), c)\n mstore(0x40, add(array, 0x80))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @param c The third integer to build an array around.\n /// @param d The fourth integer to build an array around.\n /// @return array The newly allocated array including `a`, `b`, `c` and `d` as the\n /// only items.\n function arrayFrom(uint256 a, uint256 b, uint256 c, uint256 d) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 4)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(add(array, 0x60), c)\n mstore(add(array, 0x80), d)\n mstore(0x40, add(array, 0xA0))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @param c The third integer to build an array around.\n /// @param d The fourth integer to build an array around.\n /// @param e The fifth integer to build an array around.\n /// @return array The newly allocated array including `a`, `b`, `c`, `d` and\n /// `e` as the only items.\n function arrayFrom(uint256 a, uint256 b, uint256 c, uint256 d, uint256 e)\n internal\n pure\n returns (uint256[] memory array)\n {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 5)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(add(array, 0x60), c)\n mstore(add(array, 0x80), d)\n mstore(add(array, 0xA0), e)\n mstore(0x40, add(array, 0xC0))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @param c The third integer to build an array around.\n /// @param d The fourth integer to build an array around.\n /// @param e The fifth integer to build an array around.\n /// @param f The sixth integer to build an array around.\n /// @return array The newly allocated array including `a`, `b`, `c`, `d`, `e`\n /// and `f` as the only items.\n function arrayFrom(uint256 a, uint256 b, uint256 c, uint256 d, uint256 e, uint256 f)\n internal\n pure\n returns (uint256[] memory array)\n {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 6)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(add(array, 0x60), c)\n mstore(add(array, 0x80), d)\n mstore(add(array, 0xA0), e)\n mstore(add(array, 0xC0), f)\n mstore(0x40, add(array, 0xE0))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The head of the new array.\n /// @param tail The tail of the new array.\n /// @return array The new array.\n function arrayFrom(uint256 a, uint256[] memory tail) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n let length := add(mload(tail), 1)\n let outputCursor := mload(0x40)\n array := outputCursor\n let outputEnd := add(outputCursor, add(0x20, mul(length, 0x20)))\n mstore(0x40, outputEnd)\n\n mstore(outputCursor, length)\n mstore(add(outputCursor, 0x20), a)\n\n for {\n outputCursor := add(outputCursor, 0x40)\n let inputCursor := add(tail, 0x20)\n } lt(outputCursor, outputEnd) {\n outputCursor := add(outputCursor, 0x20)\n inputCursor := add(inputCursor, 0x20)\n } { mstore(outputCursor, mload(inputCursor)) }\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first item of the new array.\n /// @param b The second item of the new array.\n /// @param tail The tail of the new array.\n /// @return array The new array.\n function arrayFrom(uint256 a, uint256 b, uint256[] memory tail) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n let length := add(mload(tail), 2)\n let outputCursor := mload(0x40)\n array := outputCursor\n let outputEnd := add(outputCursor, add(0x20, mul(length, 0x20)))\n mstore(0x40, outputEnd)\n\n mstore(outputCursor, length)\n mstore(add(outputCursor, 0x20), a)\n mstore(add(outputCursor, 0x40), b)\n\n for {\n outputCursor := add(outputCursor, 0x60)\n let inputCursor := add(tail, 0x20)\n } lt(outputCursor, outputEnd) {\n outputCursor := add(outputCursor, 0x20)\n inputCursor := add(inputCursor, 0x20)\n } { mstore(outputCursor, mload(inputCursor)) }\n }\n }\n\n /// Solidity provides no way to change the length of in-memory arrays but\n /// it also does not deallocate memory ever. It is always safe to shrink an\n /// array that has already been allocated, with the caveat that the\n /// truncated items will effectively become inaccessible regions of memory.\n /// That is to say, we deliberately \"leak\" the truncated items, but that is\n /// no worse than Solidity's native behaviour of leaking everything always.\n /// The array is MUTATED in place so there is no return value and there is\n /// no new allocation or copying of data either.\n /// @param array The array to truncate.\n /// @param newLength The new length of the array after truncation.\n function truncate(uint256[] memory array, uint256 newLength) internal pure {\n if (newLength > array.length) {\n revert OutOfBoundsTruncate(array.length, newLength);\n }\n assembly (\"memory-safe\") {\n mstore(array, newLength)\n }\n }\n\n /// Extends `base_` with `extend_` by allocating only an additional\n /// `extend_.length` words onto `base_` and copying only `extend_` if\n /// possible. If `base_` is large this MAY be significantly more efficient\n /// than allocating `base_.length + extend_.length` for an entirely new array\n /// and copying both `base_` and `extend_` into the new array one item at a\n /// time in Solidity.\n ///\n /// The efficient version of extension is only possible if the free memory\n /// pointer sits at the end of the base array at the moment of extension. If\n /// there is allocated memory after the end of base then extension will\n /// require copying both the base and extend arays to a new region of memory.\n /// The caller is responsible for optimising code paths to avoid additional\n /// allocations.\n ///\n /// This function is UNSAFE because the base array IS MUTATED DIRECTLY by\n /// some code paths AND THE FINAL RETURN ARRAY MAY POINT TO THE SAME REGION\n /// OF MEMORY. It is NOT POSSIBLE to reliably see this behaviour from the\n /// caller in all cases as the Solidity compiler optimisations may switch the\n /// caller between the allocating and non-allocating logic due to subtle\n /// optimisation reasons. To use this function safely THE CALLER MUST NOT USE\n /// THE BASE ARRAY AND MUST USE THE RETURNED ARRAY ONLY. It is safe to use\n /// the extend array after calling this function as it is never mutated, it\n /// is only copied from.\n ///\n /// @param b The base integer array that will be extended by `e`.\n /// @param e The extend integer array that extends `b`.\n /// @return extended The extended array of `b` extended by `e`.\n function unsafeExtend(uint256[] memory b, uint256[] memory e) internal pure returns (uint256[] memory extended) {\n assembly (\"memory-safe\") {\n // Slither doesn't recognise assembly function names as mixed case\n // even if they are.\n // https://github.com/crytic/slither/issues/1815\n //slither-disable-next-line naming-convention\n function extendInline(base, extend) -> baseAfter {\n let outputCursor := mload(0x40)\n let baseLength := mload(base)\n let baseEnd := add(base, add(0x20, mul(baseLength, 0x20)))\n\n // If base is NOT the last thing in allocated memory, allocate,\n // copy and recurse.\n switch eq(outputCursor, baseEnd)\n case 0 {\n let newBase := outputCursor\n let newBaseEnd := add(newBase, sub(baseEnd, base))\n mstore(0x40, newBaseEnd)\n for { let inputCursor := base } lt(outputCursor, newBaseEnd) {\n inputCursor := add(inputCursor, 0x20)\n outputCursor := add(outputCursor, 0x20)\n } { mstore(outputCursor, mload(inputCursor)) }\n\n baseAfter := extendInline(newBase, extend)\n }\n case 1 {\n let totalLength_ := add(baseLength, mload(extend))\n let outputEnd_ := add(base, add(0x20, mul(totalLength_, 0x20)))\n mstore(base, totalLength_)\n mstore(0x40, outputEnd_)\n for { let inputCursor := add(extend, 0x20) } lt(outputCursor, outputEnd_) {\n inputCursor := add(inputCursor, 0x20)\n outputCursor := add(outputCursor, 0x20)\n } { mstore(outputCursor, mload(inputCursor)) }\n\n baseAfter := base\n }\n }\n\n extended := extendInline(b, e)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.lib.memkv/src/lib/LibMemoryKV.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// Entrypoint into the key/value store. Is a mutable pointer to the head of the\n/// linked list. Initially points to `0` for an empty list. The total word count\n/// of all inserts is also encoded alongside the pointer to allow efficient O(1)\n/// memory allocation for a `uint256[]` in the case of a final snapshot/export.\ntype MemoryKV is uint256;\n\n/// The key associated with the value for each item in the store.\ntype MemoryKVKey is uint256;\n\n/// The value associated with the key for each item in the store.\ntype MemoryKVVal is uint256;\n\n/// @title LibMemoryKV\nlibrary LibMemoryKV {\n /// Gets the value associated with a given key.\n /// The value returned will be `0` if the key exists and was set to zero OR\n /// the key DOES NOT exist, i.e. was never set.\n ///\n /// The caller MUST check the `exists` flag to disambiguate between zero\n /// values and unset keys.\n ///\n /// @param kv The entrypoint to the key/value store.\n /// @param key The key to lookup a `value` for.\n /// @return exists `0` if the key was not found. The `value` MUST NOT be\n /// used if the `key` does not exist.\n /// @return value The value for the `key`, if it exists, else `0`. MAY BE `0`\n /// even if the `key` exists. It is possible to set any key to a `0` value.\n function get(MemoryKV kv, MemoryKVKey key) internal pure returns (uint256 exists, MemoryKVVal value) {\n assembly (\"memory-safe\") {\n // Hash to find the internal linked list to walk.\n // Hash logic MUST match set.\n mstore(0, key)\n let bitOffset := mul(mod(keccak256(0, 0x20), 15), 0x10)\n\n // Loop until k found or give up if pointer is zero.\n for { let pointer := and(shr(bitOffset, kv), 0xFFFF) } iszero(iszero(pointer)) {\n pointer := mload(add(pointer, 0x40))\n } {\n if eq(key, mload(pointer)) {\n exists := 1\n value := mload(add(pointer, 0x20))\n break\n }\n }\n }\n }\n\n /// Upserts a value in the set by its key. I.e. if the key exists then the\n /// associated value will be mutated in place, else a new key/value pair will\n /// be inserted. The key/value store pointer will be mutated and returned as\n /// it MAY point to a new list item in memory.\n /// @param kv The key/value store pointer to modify.\n /// @param key The key to upsert against.\n /// @param value The value to associate with the upserted key.\n /// @return The final value of `kv` as it MAY be modified if the upsert\n /// resulted in an insert operation.\n function set(MemoryKV kv, MemoryKVKey key, MemoryKVVal value) internal pure returns (MemoryKV) {\n assembly (\"memory-safe\") {\n // Hash to spread inserts across internal lists.\n // This MUST remain in sync with `get` logic.\n mstore(0, key)\n let bitOffset := mul(mod(keccak256(0, 0x20), 15), 0x10)\n\n // Set aside the starting pointer as we'll need to include it in any\n // newly inserted linked list items.\n let startPointer := and(shr(bitOffset, kv), 0xFFFF)\n\n // Find a key match then break so that we populate a nonzero pointer.\n let pointer := startPointer\n for {} iszero(iszero(pointer)) { pointer := mload(add(pointer, 0x40)) } {\n if eq(key, mload(pointer)) { break }\n }\n\n // If the pointer is nonzero we have to update the associated value\n // directly, otherwise this is an insert operation.\n switch iszero(pointer)\n // Update.\n case 0 { mstore(add(pointer, 0x20), value) }\n // Insert.\n default {\n // Allocate 3 words of memory.\n pointer := mload(0x40)\n mstore(0x40, add(pointer, 0x60))\n\n // Write key/value/pointer.\n mstore(pointer, key)\n mstore(add(pointer, 0x20), value)\n mstore(add(pointer, 0x40), startPointer)\n\n // Update total stored word count.\n let length := add(shr(0xf0, kv), 2)\n\n //slither-disable-next-line incorrect-shift\n kv := or(shl(0xf0, length), and(kv, not(shl(0xf0, 0xFFFF))))\n\n // kv must point to new insertion.\n //slither-disable-next-line incorrect-shift\n kv :=\n or(\n shl(bitOffset, pointer),\n // Mask out the old pointer\n and(kv, not(shl(bitOffset, 0xFFFF)))\n )\n }\n }\n return kv;\n }\n\n /// Export/snapshot the underlying linked list of the key/value store into\n /// a standard `uint256[]`. Reads the total length to preallocate the\n /// `uint256[]` then bisects the bits of the `kv` to find non-zero pointers\n /// to linked lists, walking each found list to the end to extract all\n /// values. As a single `kv` has 15 slots for pointers to linked lists it is\n /// likely for smallish structures that many slots can simply be skipped, so\n /// the bisect approach can save ~1-1.5k gas vs. a naive linear loop over\n /// all 15 slots for every export.\n ///\n /// Note this is a one time export, if the key/value store is subsequently\n /// mutated the built array will not reflect these mutations.\n ///\n /// @param kv The entrypoint into the key/value store.\n /// @return array All the keys and values copied pairwise into a `uint256[]`.\n /// Slither is not wrong about the cyclomatic complexity but I don't know\n /// another way to implement the bisect and keep the gas savings.\n //slither-disable-next-line cyclomatic-complexity\n function toUint256Array(MemoryKV kv) internal pure returns (uint256[] memory array) {\n uint256 mask16 = type(uint16).max;\n uint256 mask32 = type(uint32).max;\n uint256 mask64 = type(uint64).max;\n uint256 mask128 = type(uint128).max;\n assembly (\"memory-safe\") {\n // Manually create an `uint256[]`.\n // No need to zero out memory as we're about to write to it.\n array := mload(0x40)\n let length := shr(0xf0, kv)\n mstore(0x40, add(array, add(0x20, mul(length, 0x20))))\n mstore(array, length)\n\n // Known false positives in slither\n // https://github.com/crytic/slither/issues/1815\n //slither-disable-next-line naming-convention\n function copyFromPtr(cursor, pointer) -> end {\n for {} iszero(iszero(pointer)) {\n pointer := mload(add(pointer, 0x40))\n cursor := add(cursor, 0x40)\n } {\n mstore(cursor, mload(pointer))\n mstore(add(cursor, 0x20), mload(add(pointer, 0x20)))\n }\n end := cursor\n }\n\n // Bisect.\n // This crazy tree saves ~1-1.5k gas vs. a simple loop with larger\n // relative savings for small-medium sized structures.\n // The internal scoping blocks are to provide some safety against\n // typos causing the incorrect symbol to be referenced by enforcing\n // each symbol is as tightly scoped as it can be.\n let cursor := add(array, 0x20)\n {\n // Remove the length from kv before iffing to save ~100 gas.\n let p0 := shr(0x90, shl(0x10, kv))\n if iszero(iszero(p0)) {\n {\n let p00 := shr(0x40, p0)\n if iszero(iszero(p00)) {\n {\n // This branch is a special case because we\n // already zeroed out the high bits which are\n // used by the length and are NOT a pointer.\n // We can skip processing where the pointer would\n // have been if it were not the length, and do\n // not need to scrub the high bits to move from\n // `p00` to `p0001`.\n let p0001 := shr(0x20, p00)\n if iszero(iszero(p0001)) { cursor := copyFromPtr(cursor, p0001) }\n }\n let p001 := and(mask32, p00)\n if iszero(iszero(p001)) {\n {\n let p0010 := shr(0x10, p001)\n if iszero(iszero(p0010)) { cursor := copyFromPtr(cursor, p0010) }\n }\n let p0011 := and(mask16, p001)\n if iszero(iszero(p0011)) { cursor := copyFromPtr(cursor, p0011) }\n }\n }\n }\n let p01 := and(mask64, p0)\n if iszero(iszero(p01)) {\n {\n let p010 := shr(0x20, p01)\n if iszero(iszero(p010)) {\n {\n let p0100 := shr(0x10, p010)\n if iszero(iszero(p0100)) { cursor := copyFromPtr(cursor, p0100) }\n }\n let p0101 := and(mask16, p010)\n if iszero(iszero(p0101)) { cursor := copyFromPtr(cursor, p0101) }\n }\n }\n\n let p011 := and(mask32, p01)\n if iszero(iszero(p011)) {\n {\n let p0110 := shr(0x10, p011)\n if iszero(iszero(p0110)) { cursor := copyFromPtr(cursor, p0110) }\n }\n\n let p0111 := and(mask16, p011)\n if iszero(iszero(p0111)) { cursor := copyFromPtr(cursor, p0111) }\n }\n }\n }\n }\n\n {\n let p1 := and(mask128, kv)\n if iszero(iszero(p1)) {\n {\n let p10 := shr(0x40, p1)\n if iszero(iszero(p10)) {\n {\n let p100 := shr(0x20, p10)\n if iszero(iszero(p100)) {\n {\n let p1000 := shr(0x10, p100)\n if iszero(iszero(p1000)) { cursor := copyFromPtr(cursor, p1000) }\n }\n let p1001 := and(mask16, p100)\n if iszero(iszero(p1001)) { cursor := copyFromPtr(cursor, p1001) }\n }\n }\n let p101 := and(mask32, p10)\n if iszero(iszero(p101)) {\n {\n let p1010 := shr(0x10, p101)\n if iszero(iszero(p1010)) { cursor := copyFromPtr(cursor, p1010) }\n }\n let p1011 := and(mask16, p101)\n if iszero(iszero(p1011)) { cursor := copyFromPtr(cursor, p1011) }\n }\n }\n }\n let p11 := and(mask64, p1)\n if iszero(iszero(p11)) {\n {\n let p110 := shr(0x20, p11)\n if iszero(iszero(p110)) {\n {\n let p1100 := shr(0x10, p110)\n if iszero(iszero(p1100)) { cursor := copyFromPtr(cursor, p1100) }\n }\n let p1101 := and(mask16, p110)\n if iszero(iszero(p1101)) { cursor := copyFromPtr(cursor, p1101) }\n }\n }\n\n let p111 := and(mask32, p11)\n if iszero(iszero(p111)) {\n {\n let p1110 := shr(0x10, p111)\n if iszero(iszero(p1110)) { cursor := copyFromPtr(cursor, p1110) }\n }\n\n let p1111 := and(mask16, p111)\n if iszero(iszero(p1111)) { cursor := copyFromPtr(cursor, p1111) }\n }\n }\n }\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/IInterpreterV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterStoreV1.sol\";\n\n/// @dev The index of a source within a deployed expression that can be evaluated\n/// by an `IInterpreterV1`. MAY be an entrypoint or the index of a source called\n/// internally such as by the `call` opcode.\ntype SourceIndex is uint16;\n\n/// @dev Encoded information about a specific evaluation including the expression\n/// address onchain, entrypoint and expected return values.\ntype EncodedDispatch is uint256;\n\n/// @dev The namespace for state changes as requested by the calling contract.\n/// The interpreter MUST apply this namespace IN ADDITION to namespacing by\n/// caller etc.\ntype StateNamespace is uint256;\n\n/// @dev Additional bytes that can be used to configure a single opcode dispatch.\n/// Commonly used to specify the number of inputs to a variadic function such\n/// as addition or multiplication.\ntype Operand is uint256;\n\n/// @dev The default state namespace MUST be used when a calling contract has no\n/// particular opinion on or need for dynamic namespaces.\nStateNamespace constant DEFAULT_STATE_NAMESPACE = StateNamespace.wrap(0);\n\n/// @title IInterpreterV1\n/// Interface into a standard interpreter that supports:\n///\n/// - evaluating `view` logic deployed onchain by an `IExpressionDeployerV1`\n/// - receiving arbitrary `uint256[][]` supporting context to be made available\n/// to the evaluated logic\n/// - handling subsequent state changes in bulk in response to evaluated logic\n/// - namespacing state changes according to the caller's preferences to avoid\n/// unwanted key collisions\n/// - exposing its internal function pointers to support external precompilation\n/// of logic for more gas efficient runtime evaluation by the interpreter\n///\n/// The interface is designed to be stable across many versions and\n/// implementations of an interpreter, balancing minimalism with features\n/// required for a general purpose onchain interpreted compute environment.\n///\n/// The security model of an interpreter is that it MUST be resilient to\n/// malicious expressions even if they dispatch arbitrary internal function\n/// pointers during an eval. The interpreter MAY return garbage or exhibit\n/// undefined behaviour or error during an eval, _provided that no state changes\n/// are persisted_ e.g. in storage, such that only the caller that specifies the\n/// malicious expression can be negatively impacted by the result. In turn, the\n/// caller must guard itself against arbitrarily corrupt/malicious reverts and\n/// return values from any interpreter that it requests an expression from. And\n/// so on and so forth up to the externally owned account (EOA) who signs the\n/// transaction and agrees to a specific combination of contracts, expressions\n/// and interpreters, who can presumably make an informed decision about which\n/// ones to trust to get the job done.\n///\n/// The state changes for an interpreter are expected to be produces by an `eval`\n/// and passed to the `IInterpreterStoreV1` returned by the eval, as-is by the\n/// caller, after the caller has had an opportunity to apply their own\n/// intermediate logic such as reentrancy defenses against malicious\n/// interpreters. The interpreter is free to structure the state changes however\n/// it wants but MUST guard against the calling contract corrupting the changes\n/// between `eval` and `set`. For example a store could sandbox storage writes\n/// per-caller so that a malicious caller can only damage their own state\n/// changes, while honest callers respect, benefit from and are protected by the\n/// interpreter store's state change handling.\n///\n/// The two step eval-state model allows eval to be read-only which provides\n/// security guarantees for the caller such as no stateful reentrancy, either\n/// from the interpreter or some contract interface used by some word, while\n/// still allowing for storage writes. As the storage writes happen on the\n/// interpreter rather than the caller (c.f. delegate call) the caller DOES NOT\n/// need to trust the interpreter, which allows for permissionless selection of\n/// interpreters by end users. Delegate call always implies an admin key on the\n/// caller because the delegatee contract can write arbitrarily to the state of\n/// the delegator, which severely limits the generality of contract composition.\ninterface IInterpreterV1 {\n /// Exposes the function pointers as `uint16` values packed into a single\n /// `bytes` in the same order as they would be indexed into by opcodes. For\n /// example, if opcode `2` should dispatch function at position `0x1234` then\n /// the start of the returned bytes would be `0xXXXXXXXX1234` where `X` is\n /// a placeholder for the function pointers of opcodes `0` and `1`.\n ///\n /// `IExpressionDeployerV1` contracts use these function pointers to\n /// \"compile\" the expression into something that an interpreter can dispatch\n /// directly without paying gas to lookup the same at runtime. As the\n /// validity of any integrity check and subsequent dispatch is highly\n /// sensitive to both the function pointers and overall bytecode of the\n /// interpreter, `IExpressionDeployerV1` contracts SHOULD implement guards\n /// against accidentally being deployed onchain paired against an unknown\n /// interpreter. It is very easy for an apparent compatible pairing to be\n /// subtly and critically incompatible due to addition/removal/reordering of\n /// opcodes and compiler optimisations on the interpreter bytecode.\n ///\n /// This MAY return different values during construction vs. all other times\n /// after the interpreter has been successfully deployed onchain. DO NOT rely\n /// on function pointers reported during contract construction.\n function functionPointers() external view returns (bytes memory);\n\n /// The raison d'etre for an interpreter. Given some expression and per-call\n /// additional contextual data, produce a stack of results and a set of state\n /// changes that the caller MAY OPTIONALLY pass back to be persisted by a\n /// call to `IInterpreterStoreV1.set`.\n /// @param store The storage contract that the returned key/value pairs\n /// MUST be passed to IF the calling contract is in a non-static calling\n /// context. Static calling contexts MUST pass `address(0)`.\n /// @param namespace The state namespace that will be fully qualified by the\n /// interpreter at runtime in order to perform gets on the underlying store.\n /// MUST be the same namespace passed to the store by the calling contract\n /// when sending the resulting key/value items to storage.\n /// @param dispatch All the information required for the interpreter to load\n /// an expression, select an entrypoint and return the values expected by the\n /// caller. The interpreter MAY encode dispatches differently to\n /// `LibEncodedDispatch` but this WILL negatively impact compatibility for\n /// calling contracts that hardcode the encoding logic.\n /// @param context A 2-dimensional array of data that can be indexed into at\n /// runtime by the interpreter. The calling contract is responsible for\n /// ensuring the authenticity and completeness of context data. The\n /// interpreter MUST revert at runtime if an expression attempts to index\n /// into some context value that is not provided by the caller. This implies\n /// that context reads cannot be checked for out of bounds reads at deploy\n /// time, as the runtime context MAY be provided in a different shape to what\n /// the expression is expecting.\n /// Same as `eval` but allowing the caller to specify a namespace under which\n /// the state changes will be applied. The interpeter MUST ensure that keys\n /// will never collide across namespaces, even if, for example:\n ///\n /// - The calling contract is malicious and attempts to craft a collision\n /// with state changes from another contract\n /// - The expression is malicious and attempts to craft a collision with\n /// other expressions evaluated by the same calling contract\n ///\n /// A malicious entity MAY have access to significant offchain resources to\n /// attempt to precompute key collisions through brute force. The collision\n /// resistance of namespaces should be comparable or equivalent to the\n /// collision resistance of the hashing algorithms employed by the blockchain\n /// itself, such as the design of `mapping` in Solidity that hashes each\n /// nested key to produce a collision resistant compound key.\n /// @return stack The list of values produced by evaluating the expression.\n /// MUST NOT be longer than the maximum length specified by `dispatch`, if\n /// applicable.\n /// @return kvs A list of pairwise key/value items to be saved in the store.\n function eval(\n IInterpreterStoreV1 store,\n StateNamespace namespace,\n EncodedDispatch dispatch,\n uint256[][] calldata context\n ) external view returns (uint256[] memory stack, uint256[] memory kvs);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibMemCpy.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibPointer.sol\";\n\nlibrary LibMemCpy {\n /// Copy an arbitrary number of bytes from one location in memory to another.\n /// As we can only read/write bytes in 32 byte chunks we first have to loop\n /// over 32 byte values to copy then handle any unaligned remaining data. The\n /// remaining data will be appropriately masked with the existing data in the\n /// final chunk so as to not write past the desired length. Note that the\n /// final unaligned write will be more gas intensive than the prior aligned\n /// writes. The writes are completely unsafe, the caller MUST ensure that\n /// sufficient memory is allocated and reading/writing the requested number\n /// of bytes from/to the requested locations WILL NOT corrupt memory in the\n /// opinion of solidity or other subsequent read/write operations.\n /// @param sourceCursor The starting pointer to read from.\n /// @param targetCursor The starting pointer to write to.\n /// @param length The number of bytes to read/write.\n function unsafeCopyBytesTo(Pointer sourceCursor, Pointer targetCursor, uint256 length) internal pure {\n assembly (\"memory-safe\") {\n // Precalculating the end here, rather than tracking the remaining\n // length each iteration uses relatively more gas for less data, but\n // scales better for more data. Copying 1-2 words is ~30 gas more\n // expensive but copying 3+ words favours a precalculated end point\n // increasingly for more data.\n let m := mod(length, 0x20)\n let end := add(sourceCursor, sub(length, m))\n for {} lt(sourceCursor, end) {\n sourceCursor := add(sourceCursor, 0x20)\n targetCursor := add(targetCursor, 0x20)\n } { mstore(targetCursor, mload(sourceCursor)) }\n\n if iszero(iszero(m)) {\n //slither-disable-next-line incorrect-shift\n let mask_ := shr(mul(m, 8), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n // preserve existing bytes\n mstore(\n targetCursor,\n or(\n // input\n and(mload(sourceCursor), not(mask_)),\n and(mload(targetCursor), mask_)\n )\n )\n }\n }\n }\n\n /// Copies `length` `uint256` values starting from `source` to `target`\n /// with NO attempt to check that this is safe to do so. The caller MUST\n /// ensure that there exists allocated memory at `target` in which it is\n /// safe and appropriate to copy `length * 32` bytes to. Anything that was\n /// already written to memory at `[target:target+(length * 32 bytes)]`\n /// will be overwritten.\n /// There is no return value as memory is modified directly.\n /// @param source The starting position in memory that data will be copied\n /// from.\n /// @param target The starting position in memory that data will be copied\n /// to.\n /// @param length The number of 32 byte (i.e. `uint256`) words that will\n /// be copied.\n function unsafeCopyWordsTo(Pointer source, Pointer target, uint256 length) internal pure {\n assembly (\"memory-safe\") {\n for { let end_ := add(source, mul(0x20, length)) } lt(source, end_) {\n source := add(source, 0x20)\n target := add(target, 0x20)\n } { mstore(target, mload(source)) }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/bytecode/LibBytecode.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.19;\n\nimport {LibPointer, Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {LibBytes} from \"rain.solmem/lib/LibBytes.sol\";\nimport {LibMemCpy} from \"rain.solmem/lib/LibMemCpy.sol\";\n\n/// Thrown when a bytecode source index is out of bounds.\n/// @param bytecode The bytecode that was inspected.\n/// @param sourceIndex The source index that was out of bounds.\nerror SourceIndexOutOfBounds(bytes bytecode, uint256 sourceIndex);\n\n/// Thrown when a bytecode reports itself as 0 sources but has more than 1 byte.\n/// @param bytecode The bytecode that was inspected.\nerror UnexpectedSources(bytes bytecode);\n\n/// Thrown when bytes are discovered between the offsets and the sources.\n/// @param bytecode The bytecode that was inspected.\nerror UnexpectedTrailingOffsetBytes(bytes bytecode);\n\n/// Thrown when the end of a source as self reported by its header doesnt match\n/// the start of the next source or the end of the bytecode.\n/// @param bytecode The bytecode that was inspected.\nerror TruncatedSource(bytes bytecode);\n\n/// Thrown when the offset to a source points to a location that cannot fit a\n/// header before the start of the next source or the end of the bytecode.\n/// @param bytecode The bytecode that was inspected.\nerror TruncatedHeader(bytes bytecode);\n\n/// Thrown when the bytecode is truncated before the end of the header offsets.\n/// @param bytecode The bytecode that was inspected.\nerror TruncatedHeaderOffsets(bytes bytecode);\n\n/// Thrown when the stack sizings, allocation, inputs and outputs, are not\n/// monotonically increasing.\n/// @param bytecode The bytecode that was inspected.\n/// @param relativeOffset The relative offset of the source that was inspected.\nerror StackSizingsNotMonotonic(bytes bytecode, uint256 relativeOffset);\n\n/// @title LibBytecode\n/// @notice A library for inspecting the bytecode of an expression. Largely\n/// focused on reading the source headers rather than the opcodes themselves.\n/// Designed to be efficient enough to be used in the interpreter directly.\n/// As such, it is not particularly safe, notably it always assumes that the\n/// headers are not lying about the structure and runtime behaviour of the\n/// bytecode. This is by design as it allows much more simple, efficient and\n/// decoupled implementation of authoring/parsing logic, which makes the author\n/// of an expression responsible for producing well formed bytecode, such as\n/// balanced LHS/RHS stacks. The deployment integrity checks are responsible for\n/// checking that the headers match the structure and behaviour of the bytecode.\nlibrary LibBytecode {\n using LibPointer for Pointer;\n using LibBytes for bytes;\n using LibMemCpy for Pointer;\n\n /// The number of sources in the bytecode.\n /// If the bytecode is empty, returns 0.\n /// Otherwise, returns the first byte of the bytecode, which is the number\n /// of sources.\n /// Implies that 0x and 0x00 are equivalent, both having 0 sources. For this\n /// reason, contracts that handle bytecode MUST NOT rely on simple data\n /// length checks to determine if the bytecode is empty or not.\n /// DOES NOT check the integrity or even existence of the sources.\n /// @param bytecode The bytecode to inspect.\n /// @return count The number of sources in the bytecode.\n function sourceCount(bytes memory bytecode) internal pure returns (uint256 count) {\n if (bytecode.length == 0) {\n return 0;\n }\n assembly {\n // The first byte of rain bytecode is the count of how many sources\n // there are.\n count := byte(0, mload(add(bytecode, 0x20)))\n }\n }\n\n /// Checks the structural integrity of the bytecode from the perspective of\n /// potential out of bounds reads. Will revert if the bytecode is not\n /// well-formed. This check MUST be done BEFORE any attempts at per-opcode\n /// integrity checks, as the per-opcode checks assume that the headers define\n /// valid regions in memory to iterate over.\n ///\n /// Checks:\n /// - The offsets are populated according to the source count.\n /// - The offsets point to positions within the bytecode `bytes`.\n /// - There exists at least the 4 byte header for each source at the offset,\n /// within the bounds of the bytecode `bytes`.\n /// - The number of opcodes specified in the header of each source locates\n /// the end of the source exactly at either the offset of the next source\n /// or the end of the bytecode `bytes`.\n function checkNoOOBPointers(bytes memory bytecode) internal pure {\n unchecked {\n uint256 count = sourceCount(bytecode);\n // The common case is that there are more than 0 sources.\n if (count > 0) {\n uint256 sourcesRelativeStart = 1 + count * 2;\n if (sourcesRelativeStart > bytecode.length) {\n revert TruncatedHeaderOffsets(bytecode);\n }\n uint256 sourcesStart;\n assembly (\"memory-safe\") {\n sourcesStart := add(bytecode, add(0x20, sourcesRelativeStart))\n }\n\n // Start at the end of the bytecode and work backwards. Find the\n // last unchecked relative offset, follow it, read the opcode\n // count from the header, and check that ends at the end cursor.\n // Set the end cursor to the relative offset then repeat until\n // there are no more unchecked relative offsets. The endCursor\n // as a relative offset must be 0 at the end of this process\n // (i.e. the first relative offset is always 0).\n uint256 endCursor;\n assembly (\"memory-safe\") {\n endCursor := add(bytecode, add(0x20, mload(bytecode)))\n }\n // This cursor points at the 2 byte relative offset that we need\n // to check next.\n uint256 uncheckedOffsetCursor;\n uint256 end;\n assembly (\"memory-safe\") {\n uncheckedOffsetCursor := add(bytecode, add(0x21, mul(sub(count, 1), 2)))\n end := add(bytecode, 0x21)\n }\n\n while (uncheckedOffsetCursor >= end) {\n // Read the relative offset from the bytecode.\n uint256 relativeOffset;\n assembly (\"memory-safe\") {\n relativeOffset := shr(0xF0, mload(uncheckedOffsetCursor))\n }\n uint256 absoluteOffset = sourcesStart + relativeOffset;\n\n // Check that the 4 byte header is within the upper bound\n // established by the end cursor before attempting to read\n // from it.\n uint256 headerEnd = absoluteOffset + 4;\n if (headerEnd > endCursor) {\n revert TruncatedHeader(bytecode);\n }\n\n // The ops count is the first byte of the header.\n uint256 opsCount;\n {\n // The stack allocation, inputs, and outputs are the next\n // 3 bytes of the header. We can't know exactly what they\n // need to be according to the opcodes without checking\n // every opcode implementation, but we can check that\n // they satisfy the invariant\n // `inputs <= outputs <= stackAllocation`.\n // Note that the outputs may include the inputs, as the\n // outputs is merely the final stack size.\n uint256 stackAllocation;\n uint256 inputs;\n uint256 outputs;\n assembly (\"memory-safe\") {\n let data := mload(absoluteOffset)\n opsCount := byte(0, data)\n stackAllocation := byte(1, data)\n inputs := byte(2, data)\n outputs := byte(3, data)\n }\n\n if (inputs > outputs || outputs > stackAllocation) {\n revert StackSizingsNotMonotonic(bytecode, relativeOffset);\n }\n }\n\n // The ops count is the number of 4 byte opcodes in the\n // source. Check that the end of the source is at the end\n // cursor.\n uint256 sourceEnd = headerEnd + opsCount * 4;\n if (sourceEnd != endCursor) {\n revert TruncatedSource(bytecode);\n }\n\n // Move the end cursor to the start of the header.\n endCursor = absoluteOffset;\n // Move the unchecked offset cursor to the previous offset.\n uncheckedOffsetCursor -= 2;\n }\n\n // If the end cursor is not pointing at the absolute start of the\n // sources, then somehow the bytecode has malformed data between\n // the offsets and the sources.\n if (endCursor != sourcesStart) {\n revert UnexpectedTrailingOffsetBytes(bytecode);\n }\n } else {\n // If there are no sources the bytecode is either 0 length or a\n // single 0 byte, which we already implicity checked by reaching\n // this code path. Ensure the bytecode has no trailing bytes.\n if (bytecode.length > 1) {\n revert UnexpectedSources(bytecode);\n }\n }\n }\n }\n\n /// The relative byte offset of a source in the bytecode.\n /// This is the offset from the start of the first source header, which is\n /// after the source count byte and the source offsets.\n /// This function DOES NOT check that the relative offset is within the\n /// bounds of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE\n /// attempting to traverse the bytecode, otherwise the relative offset MAY\n /// point to memory outside the bytecode `bytes`.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return offset The relative byte offset of the source in the bytecode.\n function sourceRelativeOffset(bytes memory bytecode, uint256 sourceIndex) internal pure returns (uint256 offset) {\n // If the source index requested is out of bounds, revert.\n if (sourceIndex >= sourceCount(bytecode)) {\n revert SourceIndexOutOfBounds(bytecode, sourceIndex);\n }\n assembly {\n // After the first byte, all the relative offset pointers are\n // stored sequentially as 16 bit values.\n offset := and(mload(add(add(bytecode, 3), mul(sourceIndex, 2))), 0xFFFF)\n }\n }\n\n /// The absolute byte pointer of a source in the bytecode. Points to the\n /// header of the source, NOT the first opcode.\n /// This function DOES NOT check that the source index is within the bounds\n /// of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE attempting to\n /// traverse the bytecode, otherwise the relative offset MAY point to memory\n /// outside the bytecode `bytes`.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return pointer The absolute byte pointer of the source in the bytecode.\n function sourcePointer(bytes memory bytecode, uint256 sourceIndex) internal pure returns (Pointer pointer) {\n unchecked {\n uint256 sourcesStartOffset = 1 + sourceCount(bytecode) * 2;\n uint256 offset = sourceRelativeOffset(bytecode, sourceIndex);\n assembly {\n pointer := add(add(add(bytecode, 0x20), sourcesStartOffset), offset)\n }\n }\n }\n\n /// The number of opcodes in a source.\n /// This function DOES NOT check that the source index is within the bounds\n /// of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE attempting to\n /// traverse the bytecode, otherwise the relative offset MAY point to memory\n /// outside the bytecode `bytes`.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return opsCount The number of opcodes in the source.\n function sourceOpsCount(bytes memory bytecode, uint256 sourceIndex) internal pure returns (uint256 opsCount) {\n unchecked {\n Pointer pointer = sourcePointer(bytecode, sourceIndex);\n assembly (\"memory-safe\") {\n opsCount := byte(0, mload(pointer))\n }\n }\n }\n\n /// The number of stack slots allocated by a source. This is the number of\n /// 32 byte words that MUST be allocated for the stack for the given source\n /// index to avoid memory corruption when executing the source.\n /// This function DOES NOT check that the source index is within the bounds\n /// of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE attempting to\n /// traverse the bytecode, otherwise the relative offset MAY point to memory\n /// outside the bytecode `bytes`.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return allocation The number of stack slots allocated by the source.\n function sourceStackAllocation(bytes memory bytecode, uint256 sourceIndex)\n internal\n pure\n returns (uint256 allocation)\n {\n unchecked {\n Pointer pointer = sourcePointer(bytecode, sourceIndex);\n assembly (\"memory-safe\") {\n allocation := byte(1, mload(pointer))\n }\n }\n }\n\n /// The number of inputs and outputs of a source.\n /// This function DOES NOT check that the source index is within the bounds\n /// of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE attempting to\n /// traverse the bytecode, otherwise the relative offset MAY point to memory\n /// outside the bytecode `bytes`.\n /// Note that both the inputs and outputs are always returned togther, this\n /// is because the caller SHOULD be checking both together whenever using\n /// some bytecode. Returning two values is more efficient than two separate\n /// function calls.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return inputs The number of inputs of the source.\n /// @return outputs The number of outputs of the source.\n function sourceInputsOutputsLength(bytes memory bytecode, uint256 sourceIndex)\n internal\n pure\n returns (uint256 inputs, uint256 outputs)\n {\n unchecked {\n Pointer pointer = sourcePointer(bytecode, sourceIndex);\n assembly (\"memory-safe\") {\n let data := mload(pointer)\n inputs := byte(2, data)\n outputs := byte(3, data)\n }\n }\n }\n\n /// Backwards compatibility with the old way of representing sources.\n /// Requires allocation and copying so it isn't particularly efficient, but\n /// allows us to use the new bytecode format with old interpreter code. Not\n /// recommended for production code but useful for testing.\n function bytecodeToSources(bytes memory bytecode) internal pure returns (bytes[] memory) {\n unchecked {\n uint256 count = sourceCount(bytecode);\n bytes[] memory sources = new bytes[](count);\n for (uint256 i = 0; i < count; i++) {\n // Skip over the prefix 4 bytes.\n Pointer pointer = sourcePointer(bytecode, i).unsafeAddBytes(4);\n uint256 length = sourceOpsCount(bytecode, i) * 4;\n bytes memory source = new bytes(length);\n pointer.unsafeCopyBytesTo(source.dataPointer(), length);\n // Move the opcode index one byte for each opcode, into the input\n // position, as legacly sources did not have input bytes.\n assembly (\"memory-safe\") {\n for {\n let cursor := add(source, 0x20)\n let end := add(cursor, length)\n } lt(cursor, end) { cursor := add(cursor, 4) } {\n mstore8(add(cursor, 1), byte(0, mload(cursor)))\n mstore8(cursor, 0)\n }\n }\n sources[i] = source;\n }\n return sources;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibBytes.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibPointer.sol\";\n\n/// Thrown when asked to truncate data to a longer length.\n/// @param length Actual bytes length.\n/// @param truncate Attempted truncation length.\nerror TruncateError(uint256 length, uint256 truncate);\n\n/// @title LibBytes\n/// @notice Tools for working directly with memory in a Solidity compatible way.\nlibrary LibBytes {\n /// Truncates bytes of data by mutating its length directly.\n /// Any excess bytes are leaked\n function truncate(bytes memory data, uint256 length) internal pure {\n if (data.length < length) {\n revert TruncateError(data.length, length);\n }\n assembly (\"memory-safe\") {\n mstore(data, length)\n }\n }\n\n /// Pointer to the data of a bytes array NOT the length prefix.\n /// @param data Bytes to get the data pointer for.\n /// @return pointer Pointer to the data of the bytes in memory.\n function dataPointer(bytes memory data) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(data, 0x20)\n }\n }\n\n /// Pointer to the start of a bytes array (the length prefix).\n /// @param data Bytes to get the pointer to.\n /// @return pointer Pointer to the start of the bytes data structure.\n function startPointer(bytes memory data) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := data\n }\n }\n\n /// Pointer to the end of some bytes.\n ///\n /// Note that this pointer MAY NOT BE ALIGNED, i.e. it MAY NOT point to the\n /// start of a multiple of 32, UNLIKE the free memory pointer at 0x40.\n ///\n /// @param data Bytes to get the pointer to the end of.\n /// @return pointer Pointer to the end of the bytes data structure.\n function endDataPointer(bytes memory data) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(data, add(0x20, mload(data)))\n }\n }\n\n /// Pointer to the end of the memory allocated for bytes.\n ///\n /// The allocator is ALWAYS aligned to whole words, i.e. 32 byte multiples,\n /// for data structures allocated by Solidity. This includes `bytes` which\n /// means that any time the length of some `bytes` is NOT a multiple of 32\n /// the alloation will point past the end of the `bytes` data.\n ///\n /// There is no guarantee that the memory region between `endDataPointer`\n /// and `endAllocatedPointer` is zeroed out. It is best to think of that\n /// space as leaked garbage.\n ///\n /// Almost always, e.g. for the purpose of copying data between regions, you\n /// will want `endDataPointer` rather than this function.\n /// @param data Bytes to get the end of the allocated data region for.\n /// @return pointer Pointer to the end of the allocated data region.\n function endAllocatedPointer(bytes memory data) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(data, and(add(add(mload(data), 0x20), 0x1f), not(0x1f)))\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.lib.typecast/src/LibConvert.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @title LibConvert\n/// @notice Type conversions that require additional structural changes to\n/// complete safely. These are NOT mere type casts and involve additional\n/// reads and writes to complete, such as recalculating the length of an array.\n/// The convention \"toX\" is adopted from Rust to imply the additional costs and\n/// consumption of the source to produce the target.\nlibrary LibConvert {\n /// Convert an array of integers to `bytes` data. This requires modifying\n /// the length in situ as the integer array length is measured in 32 byte\n /// increments while the length of `bytes` is the literal number of bytes.\n ///\n /// It is unsafe for the caller to use `us_` after it has been converted to\n /// bytes because there is now two pointers to the same mutable data\n /// structure AND the length prefix for the `uint256[]` version is corrupt.\n ///\n /// @param us_ The integer array to convert to `bytes`.\n /// @return bytes_ The integer array converted to `bytes` data.\n function unsafeToBytes(uint256[] memory us_) internal pure returns (bytes memory bytes_) {\n assembly (\"memory-safe\") {\n bytes_ := us_\n // Length in bytes is 32x the length in uint256\n mstore(bytes_, mul(0x20, mload(bytes_)))\n }\n }\n\n /// Truncate `uint256[]` values down to `uint16[]` then pack this to `bytes`\n /// without padding or length prefix. Unsafe because the starting `uint256`\n /// values are not checked for overflow due to the truncation. The caller\n /// MUST ensure that all values fit in `type(uint16).max` or that silent\n /// overflow is safe.\n /// @param us_ The `uint256[]` to truncate and concatenate to 16 bit `bytes`.\n /// @return The concatenated 2-byte chunks.\n function unsafeTo16BitBytes(uint256[] memory us_) internal pure returns (bytes memory) {\n unchecked {\n // We will keep 2 bytes (16 bits) from each integer.\n bytes memory bytes_ = new bytes(us_.length * 2);\n assembly (\"memory-safe\") {\n let replaceMask_ := 0xFFFF\n let preserveMask_ := not(replaceMask_)\n for {\n let cursor_ := add(us_, 0x20)\n let end_ := add(cursor_, mul(mload(us_), 0x20))\n let bytesCursor_ := add(bytes_, 0x02)\n } lt(cursor_, end_) {\n cursor_ := add(cursor_, 0x20)\n bytesCursor_ := add(bytesCursor_, 0x02)\n } {\n let data_ := mload(bytesCursor_)\n mstore(bytesCursor_, or(and(preserveMask_, data_), and(replaceMask_, mload(cursor_))))\n }\n }\n return bytes_;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/integrity/LibIntegrityCheckNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.19;\n\nimport \"../../interface/IInterpreterV1.sol\";\nimport \"../../lib/bytecode/LibBytecode.sol\";\n\n/// @dev There are more entrypoints defined by the minimum stack outputs than\n/// there are provided sources. This means the calling contract WILL attempt to\n/// eval a dangling reference to a non-existent source at some point, so this\n/// MUST REVERT.\nerror EntrypointMissing(uint256 expectedEntrypoints, uint256 actualEntrypoints);\n\n/// Thrown when some entrypoint has non-zero inputs. This is not allowed as\n/// only internal dispatches can have source level inputs.\nerror EntrypointNonZeroInput(uint256 entrypointIndex, uint256 inputsLength);\n\n/// Thrown when some entrypoint has less outputs than the minimum required.\nerror EntrypointMinOutputs(uint256 entrypointIndex, uint256 outputsLength, uint256 minOutputs);\n\n/// The bytecode and integrity function disagree on number of inputs.\nerror BadOpInputsLength(uint256 opIndex, uint256 calculatedInputs, uint256 bytecodeInputs);\n\n/// The stack underflowed during integrity check.\nerror StackUnderflow(uint256 opIndex, uint256 stackIndex, uint256 calculatedInputs);\n\n/// The stack underflowed the highwater during integrity check.\nerror StackUnderflowHighwater(uint256 opIndex, uint256 stackIndex, uint256 stackHighwater);\n\n/// The bytecode stack allocation does not match the allocation calculated by\n/// the integrity check.\nerror StackAllocationMismatch(uint256 stackMaxIndex, uint256 bytecodeAllocation);\n\n/// The final stack index does not match the bytecode outputs.\nerror StackOutputsMismatch(uint256 stackIndex, uint256 bytecodeOutputs);\n\nstruct IntegrityCheckStateNP {\n uint256 stackIndex;\n uint256 stackMaxIndex;\n uint256 readHighwater;\n uint256 constantsLength;\n uint256 opIndex;\n bytes bytecode;\n}\n\nlibrary LibIntegrityCheckNP {\n using LibIntegrityCheckNP for IntegrityCheckStateNP;\n\n function newState(bytes memory bytecode, uint256 stackIndex, uint256 constantsLength)\n internal\n pure\n returns (IntegrityCheckStateNP memory)\n {\n return IntegrityCheckStateNP(\n // stackIndex\n stackIndex,\n // stackMaxIndex\n stackIndex,\n // highwater (source inputs are always immutable)\n stackIndex,\n // constantsLength\n constantsLength,\n // opIndex\n 0,\n // bytecode\n bytecode\n );\n }\n\n // The cyclomatic complexity here comes from all the `if` checks for each\n // integrity check. While the scanner isn't wrong, if we broke the checks\n // out into functions it would be a mostly superficial reduction in\n // complexity, and would make the code harder to read, as well as cost gas.\n //slither-disable-next-line cyclomatic-complexity\n function integrityCheck(\n bytes memory fPointers,\n bytes memory bytecode,\n uint256[] memory constants,\n uint256[] memory minOutputs\n ) internal view {\n unchecked {\n uint256 sourceCount = LibBytecode.sourceCount(bytecode);\n\n // Ensure that we are not missing any entrypoints expected by the calling\n // contract.\n if (minOutputs.length > sourceCount) {\n revert EntrypointMissing(minOutputs.length, sourceCount);\n }\n\n uint256 fPointersStart;\n assembly {\n fPointersStart := add(fPointers, 0x20)\n }\n\n // Ensure that the bytecode has no out of bounds pointers BEFORE we\n // start attempting to iterate over opcodes. This ensures the\n // integrity of the source count, relative offset pointers,\n // ops count per source, and that there is no garbage bytes at the\n // end or between these things. Basically everything structural about\n // the bytecode is confirmed here.\n LibBytecode.checkNoOOBPointers(bytecode);\n\n // Run the integrity check over each source. This needs to ensure\n // the integrity of each source's inputs, outputs, and stack\n // allocation, as well as the integrity of the bytecode itself on\n // a per-opcode basis, according to each opcode's implementation.\n for (uint256 i = 0; i < sourceCount; i++) {\n (uint256 inputsLength, uint256 outputsLength) = LibBytecode.sourceInputsOutputsLength(bytecode, i);\n\n // This is an entrypoint so has additional restrictions.\n if (i < minOutputs.length) {\n if (inputsLength != 0) {\n revert EntrypointNonZeroInput(i, inputsLength);\n }\n\n if (outputsLength < minOutputs[i]) {\n revert EntrypointMinOutputs(i, outputsLength, minOutputs[i]);\n }\n }\n\n IntegrityCheckStateNP memory state =\n LibIntegrityCheckNP.newState(bytecode, inputsLength, constants.length);\n\n // Have low 4 bytes of cursor overlap the first op, skipping the\n // prefix.\n uint256 cursor = Pointer.unwrap(LibBytecode.sourcePointer(bytecode, i)) - 0x18;\n uint256 end = cursor + LibBytecode.sourceOpsCount(bytecode, i) * 4;\n\n while (cursor < end) {\n Operand operand;\n uint256 bytecodeOpInputs;\n function(IntegrityCheckStateNP memory, Operand)\n view\n returns (uint256, uint256) f;\n assembly (\"memory-safe\") {\n let word := mload(cursor)\n f := shr(0xf0, mload(add(fPointersStart, mul(byte(28, word), 2))))\n // 3 bytes mask.\n operand := and(word, 0xFFFFFF)\n bytecodeOpInputs := byte(29, word)\n }\n (uint256 calcOpInputs, uint256 calcOpOutputs) = f(state, operand);\n if (calcOpInputs != bytecodeOpInputs) {\n revert BadOpInputsLength(state.opIndex, calcOpInputs, bytecodeOpInputs);\n }\n\n if (calcOpInputs > state.stackIndex) {\n revert StackUnderflow(state.opIndex, state.stackIndex, calcOpInputs);\n }\n state.stackIndex -= calcOpInputs;\n\n // The stack index can't move below the highwater.\n if (state.stackIndex < state.readHighwater) {\n revert StackUnderflowHighwater(state.opIndex, state.stackIndex, state.readHighwater);\n }\n\n // Let's assume that sane opcode implementations don't\n // overflow uint256 due to their outputs.\n state.stackIndex += calcOpOutputs;\n\n // Ensure the max stack index is updated if needed.\n if (state.stackIndex > state.stackMaxIndex) {\n state.stackMaxIndex = state.stackIndex;\n }\n\n // If there are multiple outputs the highwater MUST move.\n if (calcOpOutputs > 1) {\n state.readHighwater = state.stackIndex;\n }\n\n state.opIndex++;\n cursor += 4;\n }\n\n // The final stack max index MUST match the bytecode allocation.\n if (state.stackMaxIndex != LibBytecode.sourceStackAllocation(bytecode, i)) {\n revert StackAllocationMismatch(state.stackMaxIndex, LibBytecode.sourceStackAllocation(bytecode, i));\n }\n\n // The final stack index MUST match the bytecode source outputs.\n if (state.stackIndex != outputsLength) {\n revert StackOutputsMismatch(state.stackIndex, outputsLength);\n }\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseMeta.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../bitwise/LibCtPop.sol\";\nimport \"../../interface/IInterpreterV1.sol\";\nimport \"./LibParseOperand.sol\";\n\n/// @dev For metadata builder.\nerror DuplicateFingerprint();\n\n/// @dev Words and io fn pointers aren't the same length.\nerror WordIOFnPointerMismatch(uint256 wordsLength, uint256 ioFnPointersLength);\n\n/// @dev 0xFFFFFF = 3 byte fingerprint\n/// The fingerprint is 3 bytes because we're targetting the same collision\n/// resistance on words as solidity functions. As we already use a fully byte to\n/// map words across the expander, we only need 3 bytes for the fingerprint to\n/// achieve 4 bytes of collision resistance, which is the same as a solidity\n/// selector. This assumes that the byte selected to expand is uncorrelated with\n/// the fingerprint bytes, which is a reasonable assumption as long as we use\n/// different bytes from a keccak256 hash for each.\n/// This assumes a single expander, if there are multiple expanders, then the\n/// collision resistance only improves, so this is still safe.\nuint256 constant FINGERPRINT_MASK = 0xFFFFFF;\n/// @dev 4 = 1 byte opcode index + 1 byte operand parser offset + 3 byte fingerprint\nuint256 constant META_ITEM_SIZE = 5;\nuint256 constant META_ITEM_MASK = (1 << META_ITEM_SIZE) - 1;\n/// @dev 33 = 32 bytes for expansion + 1 byte for seed\nuint256 constant META_EXPANSION_SIZE = 0x21;\n/// @dev 1 = 1 byte for depth\nuint256 constant META_PREFIX_SIZE = 1;\n\nstruct AuthoringMeta {\n // `word` is referenced directly in assembly so don't move the field.\n bytes32 word;\n uint8 operandParserOffset;\n string description;\n}\n\nlibrary LibParseMeta {\n function wordBitmapped(uint256 seed, bytes32 word) internal pure returns (uint256 bitmap, uint256 hashed) {\n assembly (\"memory-safe\") {\n mstore(0, word)\n mstore8(0x20, seed)\n hashed := keccak256(0, 0x21)\n // We have to be careful here to avoid using the same byte for both\n // the expansion and the fingerprint. This is because we are relying\n // on the combined effect of both for collision resistance. We do\n // this by using the high byte of the hash for the bitmap, and the\n // low 3 bytes for the fingerprint.\n //slither-disable-next-line incorrect-shift\n bitmap := shl(byte(0, hashed), 1)\n }\n }\n\n function copyWordsFromAuthoringMeta(AuthoringMeta[] memory authoringMeta)\n internal\n pure\n returns (bytes32[] memory)\n {\n bytes32[] memory words = new bytes32[](authoringMeta.length);\n for (uint256 i = 0; i < authoringMeta.length; i++) {\n words[i] = authoringMeta[i].word;\n }\n return words;\n }\n\n function findBestExpander(AuthoringMeta[] memory metas)\n internal\n pure\n returns (uint8 bestSeed, uint256 bestExpansion, AuthoringMeta[] memory remaining)\n {\n unchecked {\n {\n uint256 bestCt = 0;\n for (uint256 seed = 0; seed < type(uint8).max; seed++) {\n uint256 expansion = 0;\n for (uint256 i = 0; i < metas.length; i++) {\n (uint256 shifted, uint256 hashed) = wordBitmapped(seed, metas[i].word);\n (hashed);\n expansion = shifted | expansion;\n }\n uint256 ct = LibCtPop.ctpop(expansion);\n if (ct > bestCt) {\n bestCt = ct;\n bestSeed = uint8(seed);\n bestExpansion = expansion;\n }\n // perfect expansion.\n if (ct == metas.length) {\n break;\n }\n }\n\n uint256 remainingLength = metas.length - bestCt;\n assembly (\"memory-safe\") {\n remaining := mload(0x40)\n mstore(remaining, remainingLength)\n mstore(0x40, add(remaining, mul(0x20, add(1, remainingLength))))\n }\n }\n uint256 usedExpansion = 0;\n uint256 j = 0;\n for (uint256 i = 0; i < metas.length; i++) {\n (uint256 shifted, uint256 hashed) = wordBitmapped(bestSeed, metas[i].word);\n (hashed);\n if ((shifted & usedExpansion) == 0) {\n usedExpansion = shifted | usedExpansion;\n } else {\n remaining[j] = metas[i];\n j++;\n }\n }\n }\n }\n\n function buildParseMeta(AuthoringMeta[] memory authoringMeta, uint8 maxDepth)\n internal\n pure\n returns (bytes memory parseMeta)\n {\n unchecked {\n // Write out expansions.\n uint8[] memory seeds;\n uint256[] memory expansions;\n uint256 dataStart;\n {\n uint256 depth = 0;\n seeds = new uint8[](maxDepth);\n expansions = new uint256[](maxDepth);\n {\n AuthoringMeta[] memory remainingAuthoringMeta = authoringMeta;\n while (remainingAuthoringMeta.length > 0) {\n uint8 seed;\n uint256 expansion;\n (seed, expansion, remainingAuthoringMeta) = findBestExpander(remainingAuthoringMeta);\n seeds[depth] = seed;\n expansions[depth] = expansion;\n depth++;\n }\n }\n\n uint256 parseMetaLength =\n META_PREFIX_SIZE + depth * META_EXPANSION_SIZE + authoringMeta.length * META_ITEM_SIZE;\n parseMeta = new bytes(parseMetaLength);\n assembly (\"memory-safe\") {\n mstore8(add(parseMeta, 0x20), depth)\n }\n for (uint256 j = 0; j < depth; j++) {\n assembly (\"memory-safe\") {\n // Write each seed immediately before its expansion.\n let seedWriteAt := add(add(parseMeta, 0x21), mul(0x21, j))\n mstore8(seedWriteAt, mload(add(seeds, add(0x20, mul(0x20, j)))))\n mstore(add(seedWriteAt, 1), mload(add(expansions, add(0x20, mul(0x20, j)))))\n }\n }\n\n {\n uint256 dataOffset = META_PREFIX_SIZE + META_ITEM_SIZE + depth * META_EXPANSION_SIZE;\n assembly (\"memory-safe\") {\n dataStart := add(parseMeta, dataOffset)\n }\n }\n }\n\n // Write words.\n for (uint256 k = 0; k < authoringMeta.length; k++) {\n uint256 s = 0;\n uint256 cumulativePos = 0;\n while (true) {\n uint256 toWrite;\n uint256 writeAt;\n\n // Need some careful scoping here to avoid stack too deep.\n {\n uint256 expansion = expansions[s];\n\n uint256 hashed;\n {\n uint256 shifted;\n (shifted, hashed) = wordBitmapped(seeds[s], authoringMeta[k].word);\n\n uint256 metaItemSize = META_ITEM_SIZE;\n uint256 pos = LibCtPop.ctpop(expansion & (shifted - 1)) + cumulativePos;\n assembly (\"memory-safe\") {\n writeAt := add(dataStart, mul(pos, metaItemSize))\n }\n }\n\n {\n uint256 wordFingerprint = hashed & FINGERPRINT_MASK;\n uint256 posFingerprint;\n assembly (\"memory-safe\") {\n posFingerprint := mload(writeAt)\n }\n posFingerprint &= FINGERPRINT_MASK;\n if (posFingerprint != 0) {\n if (posFingerprint == wordFingerprint) {\n revert DuplicateFingerprint();\n }\n // Collision, try next expansion.\n s++;\n cumulativePos = cumulativePos + LibCtPop.ctpop(expansion);\n continue;\n }\n // Not collision, start preparing the write with the\n // fingerprint.\n toWrite = wordFingerprint;\n }\n }\n\n // Write the io fn pointer and index offset.\n toWrite |= (k << 0x20) | (uint256(authoringMeta[k].operandParserOffset) << 0x18);\n\n uint256 mask = ~META_ITEM_MASK;\n assembly (\"memory-safe\") {\n mstore(writeAt, or(and(mload(writeAt), mask), toWrite))\n }\n // We're done with this word.\n break;\n }\n }\n }\n }\n\n /// Given the parse meta and a word, return the index and io fn pointer for\n /// the word. If the word is not found, then `exists` will be false. The\n /// caller MUST check `exists` before using the other return values.\n /// @param meta The parse meta.\n /// @param word The word to lookup.\n /// @return True if the word exists in the parse meta.\n /// @return The index of the word in the parse meta.\n function lookupWord(bytes memory meta, uint256 operandParsers, bytes32 word)\n internal\n pure\n returns (bool, uint256, function(uint256, bytes memory, uint256) pure returns (uint256, Operand))\n {\n unchecked {\n uint256 dataStart;\n uint256 cursor;\n uint256 end;\n {\n uint256 metaExpansionSize = META_EXPANSION_SIZE;\n uint256 metaItemSize = META_ITEM_SIZE;\n assembly (\"memory-safe\") {\n // Read depth from first meta byte.\n cursor := add(meta, 1)\n let depth := and(mload(cursor), 0xFF)\n // 33 bytes per depth\n end := add(cursor, mul(depth, metaExpansionSize))\n dataStart := add(end, metaItemSize)\n }\n }\n\n uint256 cumulativeCt = 0;\n while (cursor < end) {\n uint256 expansion;\n uint256 posData;\n uint256 wordFingerprint;\n // Lookup the data at pos.\n {\n uint256 seed;\n assembly (\"memory-safe\") {\n cursor := add(cursor, 1)\n seed := and(mload(cursor), 0xFF)\n cursor := add(cursor, 0x20)\n expansion := mload(cursor)\n }\n\n (uint256 shifted, uint256 hashed) = wordBitmapped(seed, word);\n uint256 pos = LibCtPop.ctpop(expansion & (shifted - 1)) + cumulativeCt;\n wordFingerprint = hashed & FINGERPRINT_MASK;\n uint256 metaItemSize = META_ITEM_SIZE;\n assembly (\"memory-safe\") {\n posData := mload(add(dataStart, mul(pos, metaItemSize)))\n }\n }\n\n // Match\n if (wordFingerprint == posData & FINGERPRINT_MASK) {\n uint256 index;\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParser;\n assembly (\"memory-safe\") {\n index := byte(27, posData)\n operandParser := and(shr(byte(28, posData), operandParsers), 0xFFFF)\n }\n return (true, index, operandParser);\n } else {\n cumulativeCt += LibCtPop.ctpop(expansion);\n }\n }\n // The caller MUST NOT use this operand parser as `exists` is false.\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParserZero;\n assembly (\"memory-safe\") {\n operandParserZero := 0\n }\n return (false, 0, operandParserZero);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseOperand.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../../interface/IInterpreterV1.sol\";\nimport \"./LibParseCMask.sol\";\nimport \"./LibParse.sol\";\nimport \"./LibParseLiteral.sol\";\n\nuint8 constant OPERAND_PARSER_OFFSET_DISALLOWED = 0;\nuint8 constant OPERAND_PARSER_OFFSET_SINGLE_FULL = 0x10;\nuint8 constant OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT = 0x20;\nuint8 constant OPERAND_PARSER_OFFSET_M1_M1 = 0x30;\nuint8 constant OPERAND_PARSER_OFFSET_8_M1_M1 = 0x40;\n\nerror UnexpectedOperand(uint256 offset);\n\nerror ExpectedOperand(uint256 offset);\n\nerror OperandOverflow(uint256 offset);\n\nerror UnclosedOperand(uint256 offset);\n\nlibrary LibParseOperand {\n function buildOperandParsers() internal pure returns (uint256 operandParsers) {\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParserDisallowed =\n LibParseOperand.parseOperandDisallowed;\n uint256 parseOperandDisallowedOffset = OPERAND_PARSER_OFFSET_DISALLOWED;\n assembly {\n operandParsers := or(operandParsers, shl(parseOperandDisallowedOffset, operandParserDisallowed))\n }\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParserSingleFull =\n LibParseOperand.parseOperandSingleFull;\n uint256 parseOperandSingleFullOffset = OPERAND_PARSER_OFFSET_SINGLE_FULL;\n assembly {\n operandParsers := or(operandParsers, shl(parseOperandSingleFullOffset, operandParserSingleFull))\n }\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParserDoublePerByteNoDefault =\n LibParseOperand.parseOperandDoublePerByteNoDefault;\n uint256 parseOperandDoublePerByteNoDefaultOffset = OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT;\n assembly {\n operandParsers :=\n or(operandParsers, shl(parseOperandDoublePerByteNoDefaultOffset, operandParserDoublePerByteNoDefault))\n }\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParser_m1_m1 =\n LibParseOperand.parseOperandM1M1;\n uint256 parseOperand_m1_m1Offset = OPERAND_PARSER_OFFSET_M1_M1;\n assembly {\n operandParsers := or(operandParsers, shl(parseOperand_m1_m1Offset, operandParser_m1_m1))\n }\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParser_8_m1_m1 =\n LibParseOperand.parseOperand8M1M1;\n uint256 parseOperand_8_m1_m1Offset = OPERAND_PARSER_OFFSET_8_M1_M1;\n assembly {\n operandParsers := or(operandParsers, shl(parseOperand_8_m1_m1Offset, operandParser_8_m1_m1))\n }\n }\n\n /// Parse a literal for an operand.\n function parseOperandLiteral(uint256 literalParsers, bytes memory data, uint256 max, uint256 cursor)\n internal\n pure\n returns (uint256, uint256)\n {\n uint256 char;\n assembly {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n revert ExpectedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n (\n function(bytes memory, uint256, uint256) pure returns (uint256) literalParser,\n uint256 innerStart,\n uint256 innerEnd,\n uint256 outerEnd\n ) = LibParseLiteral.boundLiteral(literalParsers, data, cursor);\n uint256 value = literalParser(data, innerStart, innerEnd);\n if (value > max) {\n revert OperandOverflow(LibParse.parseErrorOffset(data, cursor));\n }\n cursor = outerEnd;\n return (cursor, value);\n }\n\n /// Operand is disallowed for this word.\n function parseOperandDisallowed(uint256, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n uint256 char;\n assembly {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n revert UnexpectedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n // Don't move the cursor. This is a no-op.\n return (cursor, Operand.wrap(0));\n }\n\n /// Operand is a 16-bit unsigned integer.\n function parseOperandSingleFull(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n unchecked {\n uint256 char;\n uint256 end;\n assembly {\n end := add(data, add(mload(data), 0x20))\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n cursor = LibParse.skipMask(cursor + 1, end, CMASK_WHITESPACE);\n\n uint256 value;\n (cursor, value) = parseOperandLiteral(literalParsers, data, type(uint16).max, cursor);\n\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char != CMASK_OPERAND_END) {\n revert UnclosedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n return (cursor + 1, Operand.wrap(value));\n }\n // Default is 0.\n else {\n return (cursor, Operand.wrap(0));\n }\n }\n }\n\n /// Operand is two bytes.\n function parseOperandDoublePerByteNoDefault(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n unchecked {\n uint256 char;\n uint256 end;\n assembly (\"memory-safe\") {\n end := add(data, add(mload(data), 0x20))\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n cursor = LibParse.skipMask(cursor + 1, end, CMASK_WHITESPACE);\n\n uint256 a;\n (cursor, a) = parseOperandLiteral(literalParsers, data, type(uint8).max, cursor);\n Operand operand = Operand.wrap(a);\n\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n\n uint256 b;\n (cursor, b) = parseOperandLiteral(literalParsers, data, type(uint8).max, cursor);\n operand = Operand.wrap(Operand.unwrap(operand) | (b << 8));\n\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char != CMASK_OPERAND_END) {\n revert UnclosedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n return (cursor + 1, operand);\n }\n // There is no default fallback value.\n else {\n revert ExpectedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n }\n }\n\n /// 8 bit value, maybe 1 bit flag, maybe 1 big flag.\n function parseOperand8M1M1(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n unchecked {\n uint256 char;\n uint256 end;\n assembly {\n end := add(data, add(mload(data), 0x20))\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n cursor = LibParse.skipMask(cursor + 1, end, CMASK_WHITESPACE);\n\n // 8 bit value. Required.\n uint256 a;\n (cursor, a) = parseOperandLiteral(literalParsers, data, type(uint8).max, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n\n // Maybe 1 bit flag.\n uint256 b;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n b = 0;\n } else {\n (cursor, b) = parseOperandLiteral(literalParsers, data, 1, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n }\n\n // Maybe 1 bit flag.\n uint256 c;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n c = 0;\n } else {\n (cursor, c) = parseOperandLiteral(literalParsers, data, 1, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n }\n\n Operand operand = Operand.wrap(a | (b << 8) | (c << 9));\n\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char != CMASK_OPERAND_END) {\n revert UnclosedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n return (cursor + 1, operand);\n }\n // There is no default fallback value. The first 8 bits are\n // required.\n else {\n revert ExpectedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n }\n }\n\n /// 2x maybe 1 bit flags.\n function parseOperandM1M1(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n unchecked {\n uint256 char;\n uint256 end;\n assembly {\n end := add(data, add(mload(data), 0x20))\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n cursor = LibParse.skipMask(cursor + 1, end, CMASK_WHITESPACE);\n\n uint256 a;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n a = 0;\n } else {\n (cursor, a) = parseOperandLiteral(literalParsers, data, 1, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n }\n\n uint256 b;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n b = 0;\n } else {\n (cursor, b) = parseOperandLiteral(literalParsers, data, 1, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n }\n\n Operand operand = Operand.wrap(a | (b << 1));\n\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char != CMASK_OPERAND_END) {\n revert UnclosedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n return (cursor + 1, operand);\n }\n // Default is 0.\n else {\n return (cursor, Operand.wrap(0));\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/00/LibOpStackNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\n\n/// Thrown when a stack read index is outside the current stack top.\nerror OutOfBoundsStackRead(uint256 opIndex, uint256 stackTopIndex, uint256 stackRead);\n\n/// @title LibOpStackNP\n/// Implementation of copying a stack item from the stack to the stack.\n/// Integrated deeply into LibParse, which requires this opcode or a variant\n/// to be present at a known opcode index.\nlibrary LibOpStackNP {\n function integrity(IntegrityCheckStateNP memory state, Operand operand) internal pure returns (uint256, uint256) {\n uint256 readIndex = Operand.unwrap(operand);\n // Operand is the index so ensure it doesn't exceed the stack index.\n if (readIndex >= state.stackIndex) {\n revert OutOfBoundsStackRead(state.opIndex, state.stackIndex, readIndex);\n }\n\n // Move the read highwater if needed.\n if (readIndex > state.readHighwater) {\n state.readHighwater = readIndex;\n }\n\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory state, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 sourceIndex = state.sourceIndex;\n assembly (\"memory-safe\") {\n let stackBottom := mload(add(mload(state), mul(0x20, add(sourceIndex, 1))))\n let stackValue := mload(sub(stackBottom, mul(0x20, add(operand, 1))))\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, stackValue)\n }\n return stackTop;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/00/LibOpConstantNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// Thrown when a constant read index is outside the constants array.\nerror OutOfBoundsConstantRead(uint256 opIndex, uint256 constantsLength, uint256 constantRead);\n\n/// @title LibOpConstantNP\n/// Implementation of copying a constant from the constants array to the stack.\n/// Integrated deeply into LibParse, which requires this opcode or a variant\n/// to be present at a known opcode index.\nlibrary LibOpConstantNP {\n function integrity(IntegrityCheckStateNP memory state, Operand operand) internal pure returns (uint256, uint256) {\n // Operand is the index so ensure it doesn't exceed the constants length.\n if (Operand.unwrap(operand) >= state.constantsLength) {\n revert OutOfBoundsConstantRead(state.opIndex, state.constantsLength, Operand.unwrap(operand));\n }\n // As inputs MUST always be 0, we don't have to check the high byte of\n // the operand here, the integrity check will do that for us.\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory state, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256[] memory constants = state.constants;\n // Skip index OOB check and rely on integrity check for that.\n assembly (\"memory-safe\") {\n let value := mload(add(constants, mul(add(operand, 1), 0x20)))\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, value)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory state, Operand operand, uint256[] memory)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n uint256 index = Operand.unwrap(operand);\n outputs = new uint256[](1);\n outputs[0] = state.constants[index];\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/bitwise/LibOpCtPopNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {LibCtPop} from \"../../bitwise/LibCtPop.sol\";\n\n/// @title LibOpCtPopNP\n/// @notice An opcode that counts the number of bits set in a word. This is\n/// called ctpop because that's the name of this kind of thing elsewhere, but\n/// the more common name is \"population count\" or \"Hamming weight\". The word\n/// in the standard ops lib is called `bitwise-count-ones`, which follows the\n/// Rust naming convention.\n/// There is no evm opcode for this, so we have to implement it ourselves.\nlibrary LibOpCtPopNP {\n /// ctpop unconditionally takes one value and returns one value.\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (1, 1);\n }\n\n /// Output is the number of bits set to one in the input. Thin wrapper around\n /// `LibCtPop.ctpop`.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 value;\n assembly (\"memory-safe\") {\n value := mload(stackTop)\n }\n value = LibCtPop.ctpop(value);\n assembly (\"memory-safe\") {\n mstore(stackTop, value)\n }\n return stackTop;\n }\n\n /// The reference implementation of ctpop.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory)\n {\n inputs[0] = LibCtPop.ctpopSlow(inputs[0]);\n return inputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/call/LibOpCallNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {LibInterpreterStateNP, InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {LibIntegrityCheckNP, IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Pointer, LibPointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {LibBytecode} from \"../../bytecode/LibBytecode.sol\";\nimport {LibEvalNP} from \"../../eval/LibEvalNP.sol\";\n\n/// Thrown when the outputs requested by the operand exceed the outputs\n/// available from the source.\n/// @param sourceOutputs The number of outputs available from the source.\n/// @param outputs The number of outputs requested by the operand.\nerror CallOutputsExceedSource(uint256 sourceOutputs, uint256 outputs);\n\n/// @title LibOpCallNP\n/// @notice Contains the call operation. This allows sources to be treated in a\n/// function-like manner. Primarily intended as a way for expression authors to\n/// create reusable logic inline with their expression, in a way that mimics how\n/// words and stack consumption works at the Solidity level.\n///\n/// Similarities between `call` and a traditional function:\n/// - The source is called with a set of 0+ inputs.\n/// - The source returns a set of 0+ outputs.\n/// - The source has a fixed number of inputs and outputs.\n/// - When the source executes it has its own stack/scope.\n/// - Sources use lexical scoping rules for named LHS items.\n/// - The source can be called from multiple places.\n/// - The source can `call` other sources.\n/// - The source is stateless across calls\n/// (although it can use words like get/set to read/write external state).\n/// - The caller and callee have to agree on the number of inputs\n/// (but not outputs, see below).\n/// - Generally speaking, the behaviour of a source can be reasoned about\n/// without needing to know the context in which it is called. Which is the\n/// basic requirement for reusability.\n///\n/// Differences between `call` and a traditional function:\n/// - The caller defines the number of outputs to be returned, NOT the callee.\n/// This is because the caller is responsible for allocating space on the\n/// stack for the outputs, and the callee is responsible for providing the\n/// outputs. The only limitation is that the caller cannot request more\n/// outputs than the callee has available. This means that two calls to the\n/// same source can return different numbers of outputs in different contexts.\n/// - The inputs to a source are considered to be the top of the callee's stack\n/// from the perspective of the caller. This means that the inputs are eligible\n/// to be read as outputs, if the caller chooses to do so.\n/// - The sources are not named, they are identified by their index in the\n/// bytecode. Tooling can provide sugar over this but the underlying\n/// representation is just an index.\n/// - Sources are not \"first class\" like functions often are, i.e. they cannot\n/// be passed as arguments to other sources or otherwise be treated as values.\n/// - Recursion is not supported. This is because currently there is no laziness\n/// in the interpreter, so a recursive call would result in an infinite loop\n/// unconditionally (even when wrapped in an `if`). This may change in the\n/// future.\n/// - The memory allocation for a source must be known at compile time.\n/// - There's no way to return early from a source.\n///\n/// The order of inputs and outputs is designed so that the visual representation\n/// of a source call matches the visual representation of a function call. This\n/// requires some reversals of order \"under the hood\" while copying data around\n/// but it makes the behaviour of `call` more intuitive.\n///\n/// Illustrative example:\n/// ```\n/// /* Final result */\n/// /* a = 2 */\n/// /* b = 9 */\n/// a b: call<1 2>(10 5); ten five:, a b: int-div(ten five) 9;\n/// ```\nlibrary LibOpCallNP {\n using LibPointer for Pointer;\n\n function integrity(IntegrityCheckStateNP memory state, Operand operand) internal pure returns (uint256, uint256) {\n uint256 sourceIndex = Operand.unwrap(operand) & 0xFF;\n uint256 outputs = (Operand.unwrap(operand) >> 8) & 0xFF;\n\n (uint256 sourceInputs, uint256 sourceOutputs) =\n LibBytecode.sourceInputsOutputsLength(state.bytecode, sourceIndex);\n\n if (sourceOutputs < outputs) {\n revert CallOutputsExceedSource(sourceOutputs, outputs);\n }\n\n return (sourceInputs, outputs);\n }\n\n /// The `call` word is conceptually very simple. It takes a source index, a\n /// number of outputs, and a number of inputs. It then runs the standard\n /// eval loop for the source, with a starting stack pointer above the inputs,\n /// and then copies the outputs to the calling stack.\n function run(InterpreterStateNP memory state, Operand operand, Pointer stackTop) internal view returns (Pointer) {\n // Extract config from the operand.\n uint256 sourceIndex = Operand.unwrap(operand) & 0xFF;\n uint256 outputs = (Operand.unwrap(operand) >> 8) & 0xFF;\n uint256 inputs = (Operand.unwrap(operand) >> 0x10) & 0xFF;\n\n // Copy inputs in. The inputs have to be copied in reverse order so that\n // the top of the stack from the perspective of `call`, i.e. the first\n // input to call, is the bottom of the stack from the perspective of the\n // callee.\n Pointer[] memory stackBottoms = state.stackBottoms;\n Pointer evalStackTop;\n assembly (\"memory-safe\") {\n evalStackTop := mload(add(stackBottoms, mul(add(sourceIndex, 1), 0x20)))\n let end := add(stackTop, mul(inputs, 0x20))\n for {} lt(stackTop, end) { stackTop := add(stackTop, 0x20) } {\n evalStackTop := sub(evalStackTop, 0x20)\n mstore(evalStackTop, mload(stackTop))\n }\n }\n\n // Keep a copy of the current source index so that we can restore it\n // after the call.\n uint256 currentSourceIndex = state.sourceIndex;\n\n // Set the state to the source we are calling.\n state.sourceIndex = sourceIndex;\n\n // Run the eval loop.\n evalStackTop = LibEvalNP.evalLoopNP(state, evalStackTop);\n\n // Restore the source index in the state.\n state.sourceIndex = currentSourceIndex;\n\n // Copy outputs out.\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, mul(outputs, 0x20))\n let end := add(evalStackTop, mul(outputs, 0x20))\n let cursor := stackTop\n for {} lt(evalStackTop, end) {\n cursor := add(cursor, 0x20)\n evalStackTop := add(evalStackTop, 0x20)\n } { mstore(cursor, mload(evalStackTop)) }\n }\n\n return stackTop;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/context/LibOpContextNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\nlibrary LibOpContextNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Context doesn't have any inputs. The operand defines the reads.\n // Unfortunately we don't know the shape of the context that we will\n // receive at runtime, so we can't check the reads at integrity time.\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory state, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 i = Operand.unwrap(operand) & 0xFF;\n // Integrity check enforces the inputs byte is 0.\n uint256 j = Operand.unwrap(operand) >> 8;\n // We want these indexes to be checked at runtime for OOB accesses\n // because we don't know the shape of the context at compile time.\n // Solidity handles that for us as long as we don't invoke yul for the\n // reads.\n if (Pointer.unwrap(stackTop) < 0x20) {\n revert(\"stack underflow\");\n }\n uint256 v = state.context[i][j];\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, v)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory state, Operand operand, uint256[] memory)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n uint256 i = Operand.unwrap(operand) & 0xFF;\n uint256 j = (Operand.unwrap(operand) >> 8) & 0xFF;\n // We want these indexes to be checked at runtime for OOB accesses\n // because we don't know the shape of the context at compile time.\n // Solidity handles that for us as long as we don't invoke yul for the\n // reads.\n uint256 v = state.context[i][j];\n outputs = new uint256[](1);\n outputs[0] = v;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/crypto/LibOpHashNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpHashNP\n/// Implementation of keccak256 hashing as a standard Rainlang opcode.\nlibrary LibOpHashNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // Any number of inputs are valid.\n // 0 inputs will be the hash of empty (0 length) bytes.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n return (inputs, 1);\n }\n\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let length := mul(shr(0x10, operand), 0x20)\n let value := keccak256(stackTop, length)\n stackTop := sub(add(stackTop, length), 0x20)\n mstore(stackTop, value)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = uint256(keccak256(abi.encodePacked(inputs)));\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/erc721/LibOpERC721BalanceOfNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IERC721} from \"openzeppelin-contracts/contracts/token/ERC721/IERC721.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title OpERC721BalanceOfNP\n/// @notice Opcode for getting the current erc721 balance of an account.\nlibrary LibOpERC721BalanceOfNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Always 2 inputs, the token and the account.\n // Always 1 output, the balance.\n return (2, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 token;\n uint256 account;\n assembly {\n token := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n account := mload(stackTop)\n }\n uint256 tokenBalance = IERC721(address(uint160(token))).balanceOf(address(uint160(account)));\n assembly {\n mstore(stackTop, tokenBalance)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory)\n {\n uint256 token = inputs[0];\n uint256 account = inputs[1];\n uint256 tokenBalance = IERC721(address(uint160(token))).balanceOf(address(uint160(account)));\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = tokenBalance;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/erc721/LibOpERC721OwnerOfNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IERC721} from \"openzeppelin-contracts/contracts/token/ERC721/IERC721.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpERC721OwnerOfNP\n/// @notice Opcode for getting the current owner of an erc721 token.\nlibrary LibOpERC721OwnerOfNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Always 2 inputs, the token and the tokenId.\n // Always 1 output, the owner.\n return (2, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 token;\n uint256 tokenId;\n assembly {\n token := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n tokenId := mload(stackTop)\n }\n address tokenOwner = IERC721(address(uint160(token))).ownerOf(tokenId);\n assembly {\n mstore(stackTop, tokenOwner)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory)\n {\n uint256 token = inputs[0];\n uint256 tokenId = inputs[1];\n address tokenOwner = IERC721(address(uint160(token))).ownerOf(tokenId);\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = uint256(uint160(tokenOwner));\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/evm/LibOpBlockNumberNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpBlockNumberNP\n/// Implementation of the EVM `BLOCKNUMBER` opcode as a standard Rainlang opcode.\nlibrary LibOpBlockNumberNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, number())\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory)\n internal\n view\n returns (uint256[] memory)\n {\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = block.number;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/evm/LibOpChainIdNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpChainIdNP\n/// Implementation of the EVM `CHAINID` opcode as a standard Rainlang opcode.\nlibrary LibOpChainIdNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, chainid())\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory)\n internal\n view\n returns (uint256[] memory)\n {\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = block.chainid;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/evm/LibOpMaxUint256NP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpMaxUint256NP\n/// Exposes `type(uint256).max` as a Rainlang opcode.\nlibrary LibOpMaxUint256NP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 value = type(uint256).max;\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, value)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory)\n internal\n pure\n returns (uint256[] memory)\n {\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = type(uint256).max;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/evm/LibOpTimestampNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP, LibInterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpTimestampNP\n/// Implementation of the EVM `TIMESTAMP` opcode as a standard Rainlang opcode.\nlibrary LibOpTimestampNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, timestamp())\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory)\n internal\n view\n returns (uint256[] memory)\n {\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = block.timestamp;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpAnyNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpAnyNP\n/// @notice Opcode to return the first nonzero item on the stack up to the inputs\n/// limit.\nlibrary LibOpAnyNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least one input.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 0 ? inputs : 1;\n return (inputs, 1);\n }\n\n /// ANY\n /// ANY is the first nonzero item, else 0.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let length := mul(shr(0x10, operand), 0x20)\n let cursor := stackTop\n stackTop := sub(add(stackTop, length), 0x20)\n for { let end := add(cursor, length) } lt(cursor, end) { cursor := add(cursor, 0x20) } {\n let item := mload(cursor)\n if gt(item, 0) {\n mstore(stackTop, item)\n break\n }\n }\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of ANY for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Zero length inputs is not supported so this 0 will always be written\n // over.\n uint256 value = 0;\n for (uint256 i = 0; i < inputs.length; i++) {\n value = inputs[i];\n if (value != 0) {\n break;\n }\n }\n outputs = new uint256[](1);\n outputs[0] = value;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpConditionsNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// Thrown if no nonzero condition is found.\n/// @param condCode The condition code that was evaluated. This is the low 16\n/// bits of the operand. Allows the author to provide more context about which\n/// condition failed if there is more than one in the expression.\nerror NoConditionsMet(uint256 condCode);\n\n/// @title LibOpConditionsNP\n/// @notice Opcode to return the first nonzero item on the stack up to the inputs\n/// limit.\nlibrary LibOpConditionsNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 0 ? inputs : 2;\n // Odd inputs are not allowed.\n unchecked {\n inputs = inputs % 2 == 0 ? inputs : inputs + 1;\n }\n return (inputs, 1);\n }\n\n /// `conditions`\n /// Pairwise list of conditions and values. The first nonzero condition\n /// evaluated puts its corresponding value on the stack. `conditions` is\n /// eagerly evaluated. If no condition is nonzero, the expression will\n /// revert. The number of inputs must be even. The number of outputs is 1.\n /// If an author wants to provide some default value, they can set the last\n /// condition to some nonzero constant value such as 1.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 condition;\n assembly (\"memory-safe\") {\n let cursor := stackTop\n for {\n let end := add(cursor, mul(shr(0x10, operand), 0x20))\n stackTop := sub(end, 0x20)\n } lt(cursor, end) { cursor := add(cursor, 0x40) } {\n condition := mload(cursor)\n if condition {\n mstore(stackTop, mload(add(cursor, 0x20)))\n break\n }\n }\n }\n if (condition == 0) {\n revert NoConditionsMet(uint16(Operand.unwrap(operand)));\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of `condition` for testing.\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that any overflow errors come from the real\n // implementation.\n unchecked {\n uint256 length = inputs.length;\n require(length % 2 == 0, \"Odd number of inputs\");\n outputs = new uint256[](1);\n for (uint256 i = 0; i < length; i += 2) {\n if (inputs[i] != 0) {\n outputs[0] = inputs[i + 1];\n return outputs;\n }\n }\n revert NoConditionsMet(uint16(Operand.unwrap(operand)));\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpEnsureNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// Thrown if a zero condition is found.\n/// @param ensureCode The ensure code that was evaluated. This is the low 16\n/// bits of the operand. Allows the author to provide more context about which\n/// condition failed if there is more than one in the expression.\n/// @param errorIndex The index of the condition that failed.\nerror EnsureFailed(uint256 ensureCode, uint256 errorIndex);\n\n/// @title LibOpEnsureNP\n/// @notice Opcode to revert if any condition is zero.\nlibrary LibOpEnsureNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least one input.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 0 ? inputs : 1;\n return (inputs, 0);\n }\n\n /// `ensure`\n /// List of conditions. If any condition is zero, the expression will revert.\n /// All conditions are eagerly evaluated and there are no outputs.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 condition;\n Pointer cursor = stackTop;\n assembly (\"memory-safe\") {\n for {\n let end := add(cursor, mul(shr(0x10, operand), 0x20))\n condition := mload(cursor)\n cursor := add(cursor, 0x20)\n } and(lt(cursor, end), gt(condition, 0)) {} {\n condition := mload(cursor)\n cursor := add(cursor, 0x20)\n }\n }\n if (condition == 0) {\n // If somehow we hit an underflow on the pointer math, we'd still\n // prefer to see our ensure error rather than the generic underflow\n // error.\n unchecked {\n revert EnsureFailed(\n uint16(Operand.unwrap(operand)), (Pointer.unwrap(cursor) - Pointer.unwrap(stackTop) - 0x20) / 0x20\n );\n }\n }\n return cursor;\n }\n\n /// Gas intensive reference implementation of `ensure` for testing.\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that any overflow errors come from the real\n // implementation.\n unchecked {\n for (uint256 i = 0; i < inputs.length; i++) {\n if (inputs[i] == 0) {\n revert EnsureFailed(uint16(Operand.unwrap(operand)), i);\n }\n }\n outputs = new uint256[](0);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpEqualToNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpEqualToNP\n/// @notice Opcode to return 1 if the first item on the stack is equal to\n/// the second item on the stack, else 0.\nlibrary LibOpEqualToNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// EQ\n /// EQ is 1 if the first item is equal to the second item, else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, eq(a, mload(stackTop)))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of EQ for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] == inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpEveryNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpEveryNP\n/// @notice Opcode to return the last item out of N items if they are all true,\n/// else 0.\nlibrary LibOpEveryNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least one input.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 0 ? inputs : 1;\n return (inputs, 1);\n }\n\n /// EVERY is the last nonzero item, else 0.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let length := mul(shr(0x10, operand), 0x20)\n let cursor := stackTop\n stackTop := sub(add(stackTop, length), 0x20)\n for { let end := add(cursor, length) } lt(cursor, end) { cursor := add(cursor, 0x20) } {\n let item := mload(cursor)\n if iszero(item) {\n mstore(stackTop, item)\n break\n }\n }\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of EVERY for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Zero length inputs is not supported so this 0 will always be written\n // over.\n uint256 value = 0;\n for (uint256 i = 0; i < inputs.length; i++) {\n value = inputs[i];\n if (value == 0) {\n break;\n }\n }\n outputs = new uint256[](1);\n outputs[0] = value;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpGreaterThanNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpGreaterThanNP\n/// @notice Opcode to return 1 if the first item on the stack is greater than\n/// the second item on the stack, else 0.\nlibrary LibOpGreaterThanNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// GT\n /// GT is 1 if the first item is greater than the second item, else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, gt(a, mload(stackTop)))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of GT for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] > inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpGreaterThanOrEqualToNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpGreaterThanOrEqualToNP\n/// @notice Opcode to return 1 if the first item on the stack is greater than or\n/// equal to the second item on the stack, else 0.\nlibrary LibOpGreaterThanOrEqualToNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// GTE\n /// GTE is 1 if the first item is greater than or equal to the second item,\n /// else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, iszero(lt(a, mload(stackTop))))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of GTE for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] >= inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpIfNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIfNP\n/// @notice Opcode to choose between two values based on a condition. If is\n/// eager, meaning both values are evaluated before the condition is checked.\nlibrary LibOpIfNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (3, 1);\n }\n\n /// IF\n /// IF is a conditional. If the first item on the stack is nonero, the second\n /// item is returned, else the third item is returned.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let condition := mload(stackTop)\n stackTop := add(stackTop, 0x40)\n mstore(stackTop, mload(sub(stackTop, mul(0x20, iszero(iszero(condition))))))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of IF for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] > 0 ? inputs[1] : inputs[2];\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpIsZeroNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIsZeroNP\n/// @notice Opcode to return 1 if the top item on the stack is zero, else 0.\nlibrary LibOpIsZeroNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (1, 1);\n }\n\n /// ISZERO\n /// ISZERO is 1 if the top item is zero, else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n mstore(stackTop, iszero(mload(stackTop)))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of ISZERO for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] == 0 ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpLessThanNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpLessThanNP\n/// @notice Opcode to return 1 if the first item on the stack is less than\n/// the second item on the stack, else 0.\nlibrary LibOpLessThanNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// LT\n /// LT is 1 if the first item is less than the second item, else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, lt(a, mload(stackTop)))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of LT for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] < inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpLessThanOrEqualToNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpLessThanOrEqualToNP\n/// @notice Opcode to return 1 if the first item on the stack is less than or\n/// equal to the second item on the stack, else 0.\nlibrary LibOpLessThanOrEqualToNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// LTE\n /// LTE is 1 if the first item is less than or equal to the second item,\n /// else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, iszero(gt(a, mload(stackTop))))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of LTE for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] <= inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18MulNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// Used for reference implementation so that we have two independent\n/// upstreams to compare against.\nimport {Math as OZMath} from \"openzeppelin-contracts/contracts/utils/math/Math.sol\";\nimport {UD60x18, mul} from \"prb-math/UD60x18.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {LibWillOverflow} from \"rain.math.fixedpoint/lib/LibWillOverflow.sol\";\n\n/// @title LibOpDecimal18MulNP\n/// @notice Opcode to mul N 18 decimal fixed point values. Errors on overflow.\nlibrary LibOpDecimal18MulNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// decimal18-mul\n /// 18 decimal fixed point multiplication with implied overflow checks from\n /// PRB Math.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a = UD60x18.unwrap(mul(UD60x18.wrap(a), UD60x18.wrap(b)));\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a = UD60x18.unwrap(mul(UD60x18.wrap(a), UD60x18.wrap(b)));\n unchecked {\n i++;\n }\n }\n }\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of multiplication for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 a = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n uint256 b = inputs[i];\n if (LibWillOverflow.mulDivWillOverflow(a, b, 1e18)) {\n a = uint256(keccak256(abi.encodePacked(\"overflow sentinel\")));\n break;\n }\n a = OZMath.mulDiv(a, b, 1e18);\n }\n outputs = new uint256[](1);\n outputs[0] = a;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18DivNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// Used for reference implementation so that we have two independent\n/// upstreams to compare against.\nimport {Math as OZMath} from \"openzeppelin-contracts/contracts/utils/math/Math.sol\";\nimport {LibWillOverflow} from \"rain.math.fixedpoint/lib/LibWillOverflow.sol\";\nimport {UD60x18, div} from \"prb-math/UD60x18.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpDecimal18DivNP\n/// @notice Opcode to div N 18 decimal fixed point values. Errors on overflow.\nlibrary LibOpDecimal18DivNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// decimal18-div\n /// 18 decimal fixed point division with implied overflow checks from PRB\n /// Math.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a = UD60x18.unwrap(div(UD60x18.wrap(a), UD60x18.wrap(b)));\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a = UD60x18.unwrap(div(UD60x18.wrap(a), UD60x18.wrap(b)));\n unchecked {\n i++;\n }\n }\n }\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of division for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 a = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n uint256 b = inputs[i];\n // Just bail out with a = some sentinel value if we're going to\n // overflow or divide by zero. This gives the real implementation\n // space to throw its own error that the test harness is expecting.\n // We don't want the real implementation to fail to throw the\n // error and also produce the same result, so a needs to have\n // some collision resistant value.\n if (b == 0 || LibWillOverflow.mulDivWillOverflow(a, 1e18, b)) {\n a = uint256(keccak256(abi.encodePacked(\"overflow sentinel\")));\n break;\n }\n a = OZMath.mulDiv(a, 1e18, b);\n }\n outputs = new uint256[](1);\n outputs[0] = a;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18Scale18DynamicNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {LibFixedPointDecimalScale} from \"rain.math.fixedpoint/lib/LibFixedPointDecimalScale.sol\";\nimport {MASK_2BIT} from \"sol.lib.binmaskflag/Binary.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpDecimal18Scale18DynamicNP\n/// @notice Opcode for scaling a number to 18 decimal fixed point based on\n/// runtime scale input.\nlibrary LibOpDecimal18Scale18DynamicNP {\n using LibFixedPointDecimalScale for uint256;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// decimal18-scale18-dynamic\n /// 18 decimal fixed point scaling from runtime value.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 scale;\n assembly (\"memory-safe\") {\n scale := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n a := mload(stackTop)\n }\n a = a.scale18(scale, Operand.unwrap(operand));\n assembly (\"memory-safe\") {\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[1].scale18(inputs[0], Operand.unwrap(operand) & MASK_2BIT);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18Scale18NP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {LibFixedPointDecimalScale} from \"rain.math.fixedpoint/lib/LibFixedPointDecimalScale.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpDecimal18Scale18NP\n/// @notice Opcode for scaling a number to 18 decimal fixed point.\nlibrary LibOpDecimal18Scale18NP {\n using LibFixedPointDecimalScale for uint256;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (1, 1);\n }\n\n /// decimal18-scale18\n /// 18 decimal fixed point scaling.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n }\n a = a.scale18(Operand.unwrap(operand) & 0xFF, Operand.unwrap(operand) >> 8);\n assembly (\"memory-safe\") {\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0].scale18(Operand.unwrap(operand) & 0xFF, Operand.unwrap(operand) >> 8);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18ScaleNNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {LibFixedPointDecimalScale} from \"rain.math.fixedpoint/lib/LibFixedPointDecimalScale.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpDecimal18ScaleNNP\n/// @notice Opcode for scaling a decimal18 number to some other scale N.\nlibrary LibOpDecimal18ScaleNNP {\n using LibFixedPointDecimalScale for uint256;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (1, 1);\n }\n\n /// decimal18-scale-n\n /// Scale from 18 decimal to n decimal.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n }\n a = a.scaleN(Operand.unwrap(operand) & 0xFF, Operand.unwrap(operand) >> 8);\n assembly (\"memory-safe\") {\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0].scaleN(Operand.unwrap(operand) & 0xFF, Operand.unwrap(operand) >> 8);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntAddNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIntAddNP\n/// @notice Opcode to add N integers. Errors on overflow.\nlibrary LibOpIntAddNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-add\n /// Addition with implied overflow checks from the Solidity 0.8.x compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a += b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a += b;\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of addition for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc += inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntDivNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpIntDivNP\n/// @notice Opcode to divide N integers. Errors on divide by zero. Truncates\n/// towards zero.\nlibrary LibOpIntDivNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-div\n /// Division with implied checks from the Solidity 0.8.x compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a /= b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a /= b;\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of division for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc /= inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntExpNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIntExpNP\n/// @notice Opcode to raise x successively to N integers. Errors on overflow.\nlibrary LibOpIntExpNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-exp\n /// Exponentiation with implied overflow checks from the Solidity 0.8.x\n /// compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a = a ** b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a = a ** b;\n unchecked {\n i++;\n }\n }\n }\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of exponentiation for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc = acc ** inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntMaxNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIntMaxNP\n/// @notice Opcode to find the max from N integers.\nlibrary LibOpIntMaxNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-max\n /// Finds the maximum value from N integers.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n if (a < b) {\n a = b;\n }\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n if (a < b) {\n a = b;\n }\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of maximum for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc = acc < inputs[i] ? inputs[i] : acc;\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntMinNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIntMinNP\n/// @notice Opcode to find the min from N integers.\nlibrary LibOpIntMinNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-min\n /// Finds the minimum value from N integers.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n if (a > b) {\n a = b;\n }\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n if (a > b) {\n a = b;\n }\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of minimum for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc = acc > inputs[i] ? inputs[i] : acc;\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntModNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer, LibPointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpIntModNP\n/// @notice Opcode to modulo N integers. Errors on modulo by zero.\nlibrary LibOpIntModNP {\n using LibPointer for Pointer;\n\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-mod\n /// Modulo with implied checks from the Solidity 0.8.x compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a %= b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a %= b;\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of modulo for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc %= inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntMulNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpIntMulNP\n/// @notice Opcode to mul N integers. Errors on overflow.\nlibrary LibOpIntMulNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-mul\n /// Multiplication with implied overflow checks from the Solidity 0.8.x\n /// compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a *= b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a *= b;\n unchecked {\n i++;\n }\n }\n }\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of multiplication for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc *= inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntSubNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpIntSubNP\n/// @notice Opcode to subtract N integers.\nlibrary LibOpIntSubNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-sub\n /// Subtraction with implied overflow checks from the Solidity 0.8.x compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a -= b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a -= b;\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of subtraction for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc -= inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/store/LibOpGetNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {MemoryKVKey, MemoryKVVal, MemoryKV, LibMemoryKV} from \"rain.lib.memkv/lib/LibMemoryKV.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpGetNP\n/// @notice Opcode for reading from storage.\nlibrary LibOpGetNP {\n using LibMemoryKV for MemoryKV;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Always 1 input. The key. `hash()` is recommended to build compound\n // keys.\n return (1, 1);\n }\n\n /// Implements runtime behaviour of the `get` opcode. Attempts to lookup the\n /// key in the memory key/value store then falls back to the interpreter's\n /// storage interface as an external call. If the key is not found in either,\n /// the value will fallback to `0` as per default Solidity/EVM behaviour.\n /// @param state The interpreter state of the current eval.\n /// @param stackTop Pointer to the current stack top.\n function run(InterpreterStateNP memory state, Operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 key;\n assembly (\"memory-safe\") {\n key := mload(stackTop)\n }\n (uint256 exists, MemoryKVVal value) = state.stateKV.get(MemoryKVKey.wrap(key));\n\n // Cache MISS, get from external store.\n if (exists == 0) {\n uint256 storeValue = state.store.get(state.namespace, key);\n\n // Push fetched value to memory to make subsequent lookups on the\n // same key find a cache HIT.\n state.stateKV = state.stateKV.set(MemoryKVKey.wrap(key), MemoryKVVal.wrap(storeValue));\n\n assembly (\"memory-safe\") {\n mstore(stackTop, storeValue)\n }\n }\n // Cache HIT.\n else {\n assembly (\"memory-safe\") {\n mstore(stackTop, value)\n }\n }\n\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory state, Operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory)\n {\n uint256 key = inputs[0];\n (uint256 exists, MemoryKVVal value) = state.stateKV.get(MemoryKVKey.wrap(key));\n uint256[] memory outputs = new uint256[](1);\n // Cache MISS, get from external store.\n if (exists == 0) {\n uint256 storeValue = state.store.get(state.namespace, key);\n\n // Push fetched value to memory to make subsequent lookups on the\n // same key find a cache HIT.\n state.stateKV = state.stateKV.set(MemoryKVKey.wrap(key), MemoryKVVal.wrap(storeValue));\n\n outputs[0] = storeValue;\n }\n // Cache HIT.\n else {\n outputs[0] = MemoryKVVal.unwrap(value);\n }\n\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/store/LibOpSetNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {MemoryKV, MemoryKVKey, MemoryKVVal, LibMemoryKV} from \"rain.lib.memkv/lib/LibMemoryKV.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpSetNP\n/// @notice Opcode for recording k/v state changes to be set in storage.\nlibrary LibOpSetNP {\n using LibMemoryKV for MemoryKV;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Always 2 inputs. The key and the value. `hash()` is recommended to\n // build compound keys.\n return (2, 0);\n }\n\n function run(InterpreterStateNP memory state, Operand, Pointer stackTop) internal pure returns (Pointer) {\n unchecked {\n uint256 key;\n uint256 value;\n assembly {\n key := mload(stackTop)\n value := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n\n state.stateKV = state.stateKV.set(MemoryKVKey.wrap(key), MemoryKVVal.wrap(value));\n return stackTop;\n }\n }\n\n function referenceFn(InterpreterStateNP memory state, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory)\n {\n uint256 key = inputs[0];\n uint256 value = inputs[1];\n state.stateKV = state.stateKV.set(MemoryKVKey.wrap(key), MemoryKVVal.wrap(value));\n return new uint256[](0);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/uniswap/LibOpUniswapV2AmountIn.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {LibUniswapV2} from \"../../uniswap/LibUniswapV2.sol\";\n\n/// @title LibOpUniswapV2AmountIn\n/// @notice Opcode to calculate the amount in for a Uniswap V2 pair.\nlibrary LibOpUniswapV2AmountIn {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n unchecked {\n // Outputs is 1 if we don't want the timestamp (operand 0) or 2 if we\n // do (operand 1).\n uint256 outputs = 1 + (Operand.unwrap(operand) & 1);\n return (4, outputs);\n }\n }\n\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 factory;\n uint256 amountOut;\n uint256 tokenIn;\n uint256 tokenOut;\n assembly (\"memory-safe\") {\n factory := mload(stackTop)\n amountOut := mload(add(stackTop, 0x20))\n tokenIn := mload(add(stackTop, 0x40))\n tokenOut := mload(add(stackTop, 0x60))\n stackTop := add(stackTop, add(0x40, mul(0x20, iszero(and(operand, 1)))))\n }\n (uint256 amountIn, uint256 reserveTimestamp) = LibUniswapV2.getAmountInByTokenWithTime(\n address(uint160(factory)), address(uint160(tokenIn)), address(uint160(tokenOut)), amountOut\n );\n\n assembly (\"memory-safe\") {\n mstore(stackTop, amountIn)\n if and(operand, 1) { mstore(add(stackTop, 0x20), reserveTimestamp) }\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory outputs)\n {\n uint256 factory = inputs[0];\n uint256 amountOut = inputs[1];\n uint256 tokenIn = inputs[2];\n uint256 tokenOut = inputs[3];\n (uint256 amountIn, uint256 reserveTimestamp) = LibUniswapV2.getAmountInByTokenWithTime(\n address(uint160(factory)), address(uint160(tokenIn)), address(uint160(tokenOut)), amountOut\n );\n outputs = new uint256[](1 + (Operand.unwrap(operand) & 1));\n outputs[0] = amountIn;\n if (Operand.unwrap(operand) & 1 == 1) outputs[1] = reserveTimestamp;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/uniswap/LibOpUniswapV2AmountOut.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {LibUniswapV2} from \"../../uniswap/LibUniswapV2.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpUniswapV2AmountOut\n/// @notice Opcode to calculate the amount out for a Uniswap V2 pair.\nlibrary LibOpUniswapV2AmountOut {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n unchecked {\n // Outputs is 1 if we don't want the timestamp (operand 0) or 2 if we\n // do (operand 1).\n uint256 outputs = 1 + (Operand.unwrap(operand) & 1);\n return (4, outputs);\n }\n }\n\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 factory;\n uint256 amountIn;\n uint256 tokenIn;\n uint256 tokenOut;\n assembly (\"memory-safe\") {\n factory := mload(stackTop)\n amountIn := mload(add(stackTop, 0x20))\n tokenIn := mload(add(stackTop, 0x40))\n tokenOut := mload(add(stackTop, 0x60))\n stackTop := add(stackTop, add(0x40, mul(0x20, iszero(and(operand, 1)))))\n }\n (uint256 amountOut, uint256 reserveTimestamp) = LibUniswapV2.getAmountOutByTokenWithTime(\n address(uint160(factory)), address(uint160(tokenIn)), address(uint160(tokenOut)), amountIn\n );\n\n assembly (\"memory-safe\") {\n mstore(stackTop, amountOut)\n if and(operand, 1) { mstore(add(stackTop, 0x20), reserveTimestamp) }\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory outputs)\n {\n uint256 factory = inputs[0];\n uint256 amountIn = inputs[1];\n uint256 tokenIn = inputs[2];\n uint256 tokenOut = inputs[3];\n (uint256 amountOut, uint256 reserveTimestamp) = LibUniswapV2.getAmountOutByTokenWithTime(\n address(uint160(factory)), address(uint160(tokenIn)), address(uint160(tokenOut)), amountIn\n );\n outputs = new uint256[](1 + (Operand.unwrap(operand) & 1));\n outputs[0] = amountOut;\n if (Operand.unwrap(operand) & 1 == 1) outputs[1] = reserveTimestamp;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibMemory.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nlibrary LibMemory {\n /// Returns true if the free memory pointer is pointing at a multiple of 32\n /// bytes, false otherwise. If all memory allocations are handled by Solidity\n /// then this will always be true, but assembly blocks can violate this, so\n /// this is a useful tool to test compliance of a custom assembly block with\n /// the solidity allocator.\n /// @return isAligned true if the memory is currently aligned to 32 bytes.\n function memoryIsAligned() internal pure returns (bool isAligned) {\n assembly (\"memory-safe\") {\n isAligned := iszero(mod(mload(0x40), 0x20))\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/IInterpreterStoreV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterV1.sol\";\n\n/// A fully qualified namespace includes the interpreter's own namespacing logic\n/// IN ADDITION to the calling contract's requested `StateNamespace`. Typically\n/// this involves hashing the `msg.sender` into the `StateNamespace` so that each\n/// caller operates within its own disjoint state universe. Intepreters MUST NOT\n/// allow either the caller nor any expression/word to modify this directly on\n/// pain of potential key collisions on writes to the interpreter's own storage.\ntype FullyQualifiedNamespace is uint256;\n\nIInterpreterStoreV1 constant NO_STORE = IInterpreterStoreV1(address(0));\n\n/// @title IInterpreterStoreV1\n/// @notice Tracks state changes on behalf of an interpreter. A single store can\n/// handle state changes for many calling contracts, many interpreters and many\n/// expressions. The store is responsible for ensuring that applying these state\n/// changes is safe from key collisions with calls to `set` from different\n/// `msg.sender` callers. I.e. it MUST NOT be possible for a caller to modify the\n/// state changes associated with some other caller.\n///\n/// The store defines the shape of its own state changes, which is opaque to the\n/// calling contract. For example, some store may treat the list of state changes\n/// as a pairwise key/value set, and some other store may treat it as a literal\n/// list to be stored as-is.\n///\n/// Each interpreter decides for itself which store to use based on the\n/// compatibility of its own opcodes.\n///\n/// The store MUST assume the state changes have been corrupted by the calling\n/// contract due to bugs or malicious intent, and enforce state isolation between\n/// callers despite arbitrarily invalid state changes. The store MUST revert if\n/// it can detect invalid state changes, such as a key/value list having an odd\n/// number of items, but this MAY NOT be possible if the corruption is\n/// undetectable.\ninterface IInterpreterStoreV1 {\n /// Mutates the interpreter store in bulk. The bulk values are provided in\n /// the form of a `uint256[]` which can be treated e.g. as pairwise keys and\n /// values to be stored in a Solidity mapping. The `IInterpreterStoreV1`\n /// defines the meaning of the `uint256[]` for its own storage logic.\n ///\n /// @param namespace The unqualified namespace for the set that MUST be\n /// fully qualified by the `IInterpreterStoreV1` to prevent key collisions\n /// between callers. The fully qualified namespace forms a compound key with\n /// the keys for each value to set.\n /// @param kvs The list of changes to apply to the store's internal state.\n function set(StateNamespace namespace, uint256[] calldata kvs) external;\n\n /// Given a fully qualified namespace and key, return the associated value.\n /// Ostensibly the interpreter can use this to implement opcodes that read\n /// previously set values. The interpreter MUST apply the same qualification\n /// logic as the store that it uses to guarantee consistent round tripping of\n /// data and prevent malicious behaviours. Technically also allows onchain\n /// reads of any set value from any contract, not just interpreters, but in\n /// this case readers MUST be aware and handle inconsistencies between get\n /// and set while the state changes are still in memory in the calling\n /// context and haven't yet been persisted to the store.\n ///\n /// `IInterpreterStoreV1` uses the same fallback behaviour for unset keys as\n /// Solidity. Specifically, any UNSET VALUES SILENTLY FALLBACK TO `0`.\n /// @param namespace The fully qualified namespace to get a single value for.\n /// @param key The key to get the value for within the namespace.\n /// @return The value OR ZERO IF NOT SET.\n function get(FullyQualifiedNamespace namespace, uint256 key) external view returns (uint256);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/bitwise/LibCtPop.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev 010101... for ctpop\nuint256 constant CTPOP_M1 = 0x5555555555555555555555555555555555555555555555555555555555555555;\n/// @dev 00110011.. for ctpop\nuint256 constant CTPOP_M2 = 0x3333333333333333333333333333333333333333333333333333333333333333;\n/// @dev 4 bits alternating for ctpop\nuint256 constant CTPOP_M4 = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F;\n/// @dev 8 bits alternating for ctpop\nuint256 constant CTPOP_M8 = 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF;\n/// @dev 16 bits alternating for ctpop\nuint256 constant CTPOP_M16 = 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF;\n/// @dev 32 bits alternating for ctpop\nuint256 constant CTPOP_M32 = 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF;\n/// @dev 64 bits alternating for ctpop\nuint256 constant CTPOP_M64 = 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF;\n/// @dev 128 bits alternating for ctpop\nuint256 constant CTPOP_M128 = 0x00000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n/// @dev 1 bytes for ctpop\nuint256 constant CTPOP_H01 = 0x0101010101010101010101010101010101010101010101010101010101010101;\n\nlibrary LibCtPop {\n /// Optimised version of ctpop.\n /// https://en.wikipedia.org/wiki/Hamming_weight\n function ctpop(uint256 x) internal pure returns (uint256) {\n // This edge case is not handled by the algorithm below.\n if (x == type(uint256).max) {\n return 256;\n }\n unchecked {\n x -= (x >> 1) & CTPOP_M1;\n x = (x & CTPOP_M2) + ((x >> 2) & CTPOP_M2);\n x = (x + (x >> 4)) & CTPOP_M4;\n x = (x * CTPOP_H01) >> 248;\n }\n return x;\n }\n\n /// This is the slowest possible implementation of ctpop. It is used to\n /// verify the correctness of the optimized implementation in LibCtPop.\n /// It should be obviously correct by visual inspection, referencing the\n /// wikipedia article.\n /// https://en.wikipedia.org/wiki/Hamming_weight\n function ctpopSlow(uint256 x) internal pure returns (uint256) {\n unchecked {\n x = (x & CTPOP_M1) + ((x >> 1) & CTPOP_M1);\n x = (x & CTPOP_M2) + ((x >> 2) & CTPOP_M2);\n x = (x & CTPOP_M4) + ((x >> 4) & CTPOP_M4);\n x = (x & CTPOP_M8) + ((x >> 8) & CTPOP_M8);\n x = (x & CTPOP_M16) + ((x >> 16) & CTPOP_M16);\n x = (x & CTPOP_M32) + ((x >> 32) & CTPOP_M32);\n x = (x & CTPOP_M64) + ((x >> 64) & CTPOP_M64);\n x = (x & CTPOP_M128) + ((x >> 128) & CTPOP_M128);\n }\n return x;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseCMask.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev ASCII null\nuint128 constant CMASK_NULL = uint128(1) << uint128(uint8(bytes1(\"\\x00\")));\n\n/// @dev ASCII start of heading\nuint128 constant CMASK_START_OF_HEADING = uint128(1) << uint128(uint8(bytes1(\"\\x01\")));\n\n/// @dev ASCII start of text\nuint128 constant CMASK_START_OF_TEXT = uint128(1) << uint128(uint8(bytes1(\"\\x02\")));\n\n/// @dev ASCII end of text\nuint128 constant CMASK_END_OF_TEXT = uint128(1) << uint128(uint8(bytes1(\"\\x03\")));\n\n/// @dev ASCII end of transmission\nuint128 constant CMASK_END_OF_TRANSMISSION = uint128(1) << uint128(uint8(bytes1(\"\\x04\")));\n\n/// @dev ASCII enquiry\nuint128 constant CMASK_ENQUIRY = uint128(1) << uint128(uint8(bytes1(\"\\x05\")));\n\n/// @dev ASCII acknowledge\nuint128 constant CMASK_ACKNOWLEDGE = uint128(1) << uint128(uint8(bytes1(\"\\x06\")));\n\n/// @dev ASCII bell\nuint128 constant CMASK_BELL = uint128(1) << uint128(uint8(bytes1(\"\\x07\")));\n\n/// @dev ASCII backspace\nuint128 constant CMASK_BACKSPACE = uint128(1) << uint128(uint8(bytes1(\"\\x08\")));\n\n/// @dev ASCII horizontal tab\nuint128 constant CMASK_HORIZONTAL_TAB = uint128(1) << uint128(uint8(bytes1(\"\\t\")));\n\n/// @dev ASCII line feed\nuint128 constant CMASK_LINE_FEED = uint128(1) << uint128(uint8(bytes1(\"\\n\")));\n\n/// @dev ASCII vertical tab\nuint128 constant CMASK_VERTICAL_TAB = uint128(1) << uint128(uint8(bytes1(\"\\x0B\")));\n\n/// @dev ASCII form feed\nuint128 constant CMASK_FORM_FEED = uint128(1) << uint128(uint8(bytes1(\"\\x0C\")));\n\n/// @dev ASCII carriage return\nuint128 constant CMASK_CARRIAGE_RETURN = uint128(1) << uint128(uint8(bytes1(\"\\r\")));\n\n/// @dev ASCII shift out\nuint128 constant CMASK_SHIFT_OUT = uint128(1) << uint128(uint8(bytes1(\"\\x0E\")));\n\n/// @dev ASCII shift in\nuint128 constant CMASK_SHIFT_IN = uint128(1) << uint128(uint8(bytes1(\"\\x0F\")));\n\n/// @dev ASCII data link escape\nuint128 constant CMASK_DATA_LINK_ESCAPE = uint128(1) << uint128(uint8(bytes1(\"\\x10\")));\n\n/// @dev ASCII device control 1\nuint128 constant CMASK_DEVICE_CONTROL_1 = uint128(1) << uint128(uint8(bytes1(\"\\x11\")));\n\n/// @dev ASCII device control 2\nuint128 constant CMASK_DEVICE_CONTROL_2 = uint128(1) << uint128(uint8(bytes1(\"\\x12\")));\n\n/// @dev ASCII device control 3\nuint128 constant CMASK_DEVICE_CONTROL_3 = uint128(1) << uint128(uint8(bytes1(\"\\x13\")));\n\n/// @dev ASCII device control 4\nuint128 constant CMASK_DEVICE_CONTROL_4 = uint128(1) << uint128(uint8(bytes1(\"\\x14\")));\n\n/// @dev ASCII negative acknowledge\nuint128 constant CMASK_NEGATIVE_ACKNOWLEDGE = uint128(1) << uint128(uint8(bytes1(\"\\x15\")));\n\n/// @dev ASCII synchronous idle\nuint128 constant CMASK_SYNCHRONOUS_IDLE = uint128(1) << uint128(uint8(bytes1(\"\\x16\")));\n\n/// @dev ASCII end of transmission block\nuint128 constant CMASK_END_OF_TRANSMISSION_BLOCK = uint128(1) << uint128(uint8(bytes1(\"\\x17\")));\n\n/// @dev ASCII cancel\nuint128 constant CMASK_CANCEL = uint128(1) << uint128(uint8(bytes1(\"\\x18\")));\n\n/// @dev ASCII end of medium\nuint128 constant CMASK_END_OF_MEDIUM = uint128(1) << uint128(uint8(bytes1(\"\\x19\")));\n\n/// @dev ASCII substitute\nuint128 constant CMASK_SUBSTITUTE = uint128(1) << uint128(uint8(bytes1(\"\\x1A\")));\n\n/// @dev ASCII escape\nuint128 constant CMASK_ESCAPE = uint128(1) << uint128(uint8(bytes1(\"\\x1B\")));\n\n/// @dev ASCII file separator\nuint128 constant CMASK_FILE_SEPARATOR = uint128(1) << uint128(uint8(bytes1(\"\\x1C\")));\n\n/// @dev ASCII group separator\nuint128 constant CMASK_GROUP_SEPARATOR = uint128(1) << uint128(uint8(bytes1(\"\\x1D\")));\n\n/// @dev ASCII record separator\nuint128 constant CMASK_RECORD_SEPARATOR = uint128(1) << uint128(uint8(bytes1(\"\\x1E\")));\n\n/// @dev ASCII unit separator\nuint128 constant CMASK_UNIT_SEPARATOR = uint128(1) << uint128(uint8(bytes1(\"\\x1F\")));\n\n/// @dev ASCII space\nuint128 constant CMASK_SPACE = uint128(1) << uint128(uint8(bytes1(\" \")));\n\n/// @dev ASCII !\nuint128 constant CMASK_EXCLAMATION_MARK = uint128(1) << uint128(uint8(bytes1(\"!\")));\n\n/// @dev ASCII \"\nuint128 constant CMASK_QUOTATION_MARK = uint128(1) << uint128(uint8(bytes1(\"\\\"\")));\n\n/// @dev ASCII #\nuint128 constant CMASK_NUMBER_SIGN = uint128(1) << uint128(uint8(bytes1(\"#\")));\n\n/// @dev ASCII $\nuint128 constant CMASK_DOLLAR_SIGN = uint128(1) << uint128(uint8(bytes1(\"$\")));\n\n/// @dev ASCII %\nuint128 constant CMASK_PERCENT_SIGN = uint128(1) << uint128(uint8(bytes1(\"%\")));\n\n/// @dev ASCII &\nuint128 constant CMASK_AMPERSAND = uint128(1) << uint128(uint8(bytes1(\"&\")));\n\n/// @dev ASCII '\nuint128 constant CMASK_APOSTROPHE = uint128(1) << uint128(uint8(bytes1(\"'\")));\n\n/// @dev ASCII (\nuint128 constant CMASK_LEFT_PAREN = uint128(1) << uint128(uint8(bytes1(\"(\")));\n\n/// @dev ASCII )\nuint128 constant CMASK_RIGHT_PAREN = uint128(1) << uint128(uint8(bytes1(\")\")));\n\n/// @dev ASCII *\nuint128 constant CMASK_ASTERISK = uint128(1) << uint128(uint8(bytes1(\"*\")));\n\n/// @dev ASCII +\nuint128 constant CMASK_PLUS_SIGN = uint128(1) << uint128(uint8(bytes1(\"+\")));\n\n/// @dev ASCII ,\nuint128 constant CMASK_COMMA = uint128(1) << uint128(uint8(bytes1(\",\")));\n\n/// @dev ASCII -\nuint128 constant CMASK_DASH = uint128(1) << uint128(uint8(bytes1(\"-\")));\n\n/// @dev ASCII .\nuint128 constant CMASK_FULL_STOP = uint128(1) << uint128(uint8(bytes1(\".\")));\n\n/// @dev ASCII /\nuint128 constant CMASK_SLASH = uint128(1) << uint128(uint8(bytes1(\"/\")));\n\n/// @dev ASCII 0\nuint128 constant CMASK_ZERO = uint128(1) << uint128(uint8(bytes1(\"0\")));\n\n/// @dev ASCII 1\nuint128 constant CMASK_ONE = uint128(1) << uint128(uint8(bytes1(\"1\")));\n\n/// @dev ASCII 2\nuint128 constant CMASK_TWO = uint128(1) << uint128(uint8(bytes1(\"2\")));\n\n/// @dev ASCII 3\nuint128 constant CMASK_THREE = uint128(1) << uint128(uint8(bytes1(\"3\")));\n\n/// @dev ASCII 4\nuint128 constant CMASK_FOUR = uint128(1) << uint128(uint8(bytes1(\"4\")));\n\n/// @dev ASCII 5\nuint128 constant CMASK_FIVE = uint128(1) << uint128(uint8(bytes1(\"5\")));\n\n/// @dev ASCII 6\nuint128 constant CMASK_SIX = uint128(1) << uint128(uint8(bytes1(\"6\")));\n\n/// @dev ASCII 7\nuint128 constant CMASK_SEVEN = uint128(1) << uint128(uint8(bytes1(\"7\")));\n\n/// @dev ASCII 8\nuint128 constant CMASK_EIGHT = uint128(1) << uint128(uint8(bytes1(\"8\")));\n\n/// @dev ASCII 9\nuint128 constant CMASK_NINE = uint128(1) << uint128(uint8(bytes1(\"9\")));\n\n/// @dev ASCII :\nuint128 constant CMASK_COLON = uint128(1) << uint128(uint8(bytes1(\":\")));\n\n/// @dev ASCII ;\nuint128 constant CMASK_SEMICOLON = uint128(1) << uint128(uint8(bytes1(\";\")));\n\n/// @dev ASCII <\nuint128 constant CMASK_LESS_THAN_SIGN = uint128(1) << uint128(uint8(bytes1(\"<\")));\n\n/// @dev ASCII =\nuint128 constant CMASK_EQUALS_SIGN = uint128(1) << uint128(uint8(bytes1(\"=\")));\n\n/// @dev ASCII >\nuint128 constant CMASK_GREATER_THAN_SIGN = uint128(1) << uint128(uint8(bytes1(\">\")));\n\n/// @dev ASCII ?\nuint128 constant CMASK_QUESTION_MARK = uint128(1) << uint128(uint8(bytes1(\"?\")));\n\n/// @dev ASCII @\nuint128 constant CMASK_AT_SIGN = uint128(1) << uint128(uint8(bytes1(\"@\")));\n\n/// @dev ASCII A\nuint128 constant CMASK_UPPER_A = uint128(1) << uint128(uint8(bytes1(\"A\")));\n\n/// @dev ASCII B\nuint128 constant CMASK_UPPER_B = uint128(1) << uint128(uint8(bytes1(\"B\")));\n\n/// @dev ASCII C\nuint128 constant CMASK_UPPER_C = uint128(1) << uint128(uint8(bytes1(\"C\")));\n\n/// @dev ASCII D\nuint128 constant CMASK_UPPER_D = uint128(1) << uint128(uint8(bytes1(\"D\")));\n\n/// @dev ASCII E\nuint128 constant CMASK_UPPER_E = uint128(1) << uint128(uint8(bytes1(\"E\")));\n\n/// @dev ASCII F\nuint128 constant CMASK_UPPER_F = uint128(1) << uint128(uint8(bytes1(\"F\")));\n\n/// @dev ASCII G\nuint128 constant CMASK_UPPER_G = uint128(1) << uint128(uint8(bytes1(\"G\")));\n\n/// @dev ASCII H\nuint128 constant CMASK_UPPER_H = uint128(1) << uint128(uint8(bytes1(\"H\")));\n\n/// @dev ASCII I\nuint128 constant CMASK_UPPER_I = uint128(1) << uint128(uint8(bytes1(\"I\")));\n\n/// @dev ASCII J\nuint128 constant CMASK_UPPER_J = uint128(1) << uint128(uint8(bytes1(\"J\")));\n\n/// @dev ASCII K\nuint128 constant CMASK_UPPER_K = uint128(1) << uint128(uint8(bytes1(\"K\")));\n\n/// @dev ASCII L\nuint128 constant CMASK_UPPER_L = uint128(1) << uint128(uint8(bytes1(\"L\")));\n\n/// @dev ASCII M\nuint128 constant CMASK_UPPER_M = uint128(1) << uint128(uint8(bytes1(\"M\")));\n\n/// @dev ASCII N\nuint128 constant CMASK_UPPER_N = uint128(1) << uint128(uint8(bytes1(\"N\")));\n\n/// @dev ASCII O\nuint128 constant CMASK_UPPER_O = uint128(1) << uint128(uint8(bytes1(\"O\")));\n\n/// @dev ASCII P\nuint128 constant CMASK_UPPER_P = uint128(1) << uint128(uint8(bytes1(\"P\")));\n\n/// @dev ASCII Q\nuint128 constant CMASK_UPPER_Q = uint128(1) << uint128(uint8(bytes1(\"Q\")));\n\n/// @dev ASCII R\nuint128 constant CMASK_UPPER_R = uint128(1) << uint128(uint8(bytes1(\"R\")));\n\n/// @dev ASCII S\nuint128 constant CMASK_UPPER_S = uint128(1) << uint128(uint8(bytes1(\"S\")));\n\n/// @dev ASCII T\nuint128 constant CMASK_UPPER_T = uint128(1) << uint128(uint8(bytes1(\"T\")));\n\n/// @dev ASCII U\nuint128 constant CMASK_UPPER_U = uint128(1) << uint128(uint8(bytes1(\"U\")));\n\n/// @dev ASCII V\nuint128 constant CMASK_UPPER_V = uint128(1) << uint128(uint8(bytes1(\"V\")));\n\n/// @dev ASCII W\nuint128 constant CMASK_UPPER_W = uint128(1) << uint128(uint8(bytes1(\"W\")));\n\n/// @dev ASCII X\nuint128 constant CMASK_UPPER_X = uint128(1) << uint128(uint8(bytes1(\"X\")));\n\n/// @dev ASCII Y\nuint128 constant CMASK_UPPER_Y = uint128(1) << uint128(uint8(bytes1(\"Y\")));\n\n/// @dev ASCII Z\nuint128 constant CMASK_UPPER_Z = uint128(1) << uint128(uint8(bytes1(\"Z\")));\n\n/// @dev ASCII [\nuint128 constant CMASK_LEFT_SQUARE_BRACKET = uint128(1) << uint128(uint8(bytes1(\"[\")));\n\n/// @dev ASCII \\\nuint128 constant CMASK_BACKSLASH = uint128(1) << uint128(uint8(bytes1(\"\\\\\")));\n\n/// @dev ASCII ]\nuint128 constant CMASK_RIGHT_SQUARE_BRACKET = uint128(1) << uint128(uint8(bytes1(\"]\")));\n\n/// @dev ASCII ^\nuint128 constant CMASK_CIRCUMFLEX_ACCENT = uint128(1) << uint128(uint8(bytes1(\"^\")));\n\n/// @dev ASCII _\nuint128 constant CMASK_UNDERSCORE = uint128(1) << uint128(uint8(bytes1(\"_\")));\n\n/// @dev ASCII `\nuint128 constant CMASK_GRAVE_ACCENT = uint128(1) << uint128(uint8(bytes1(\"`\")));\n\n/// @dev ASCII a\nuint128 constant CMASK_LOWER_A = uint128(1) << uint128(uint8(bytes1(\"a\")));\n\n/// @dev ASCII b\nuint128 constant CMASK_LOWER_B = uint128(1) << uint128(uint8(bytes1(\"b\")));\n\n/// @dev ASCII c\nuint128 constant CMASK_LOWER_C = uint128(1) << uint128(uint8(bytes1(\"c\")));\n\n/// @dev ASCII d\nuint128 constant CMASK_LOWER_D = uint128(1) << uint128(uint8(bytes1(\"d\")));\n\n/// @dev ASCII e\nuint128 constant CMASK_LOWER_E = uint128(1) << uint128(uint8(bytes1(\"e\")));\n\n/// @dev ASCII f\nuint128 constant CMASK_LOWER_F = uint128(1) << uint128(uint8(bytes1(\"f\")));\n\n/// @dev ASCII g\nuint128 constant CMASK_LOWER_G = uint128(1) << uint128(uint8(bytes1(\"g\")));\n\n/// @dev ASCII h\nuint128 constant CMASK_LOWER_H = uint128(1) << uint128(uint8(bytes1(\"h\")));\n\n/// @dev ASCII i\nuint128 constant CMASK_LOWER_I = uint128(1) << uint128(uint8(bytes1(\"i\")));\n\n/// @dev ASCII j\nuint128 constant CMASK_LOWER_J = uint128(1) << uint128(uint8(bytes1(\"j\")));\n\n/// @dev ASCII k\nuint128 constant CMASK_LOWER_K = uint128(1) << uint128(uint8(bytes1(\"k\")));\n\n/// @dev ASCII l\nuint128 constant CMASK_LOWER_L = uint128(1) << uint128(uint8(bytes1(\"l\")));\n\n/// @dev ASCII m\nuint128 constant CMASK_LOWER_M = uint128(1) << uint128(uint8(bytes1(\"m\")));\n\n/// @dev ASCII n\nuint128 constant CMASK_LOWER_N = uint128(1) << uint128(uint8(bytes1(\"n\")));\n\n/// @dev ASCII o\nuint128 constant CMASK_LOWER_O = uint128(1) << uint128(uint8(bytes1(\"o\")));\n\n/// @dev ASCII p\nuint128 constant CMASK_LOWER_P = uint128(1) << uint128(uint8(bytes1(\"p\")));\n\n/// @dev ASCII q\nuint128 constant CMASK_LOWER_Q = uint128(1) << uint128(uint8(bytes1(\"q\")));\n\n/// @dev ASCII r\nuint128 constant CMASK_LOWER_R = uint128(1) << uint128(uint8(bytes1(\"r\")));\n\n/// @dev ASCII s\nuint128 constant CMASK_LOWER_S = uint128(1) << uint128(uint8(bytes1(\"s\")));\n\n/// @dev ASCII t\nuint128 constant CMASK_LOWER_T = uint128(1) << uint128(uint8(bytes1(\"t\")));\n\n/// @dev ASCII u\nuint128 constant CMASK_LOWER_U = uint128(1) << uint128(uint8(bytes1(\"u\")));\n\n/// @dev ASCII v\nuint128 constant CMASK_LOWER_V = uint128(1) << uint128(uint8(bytes1(\"v\")));\n\n/// @dev ASCII w\nuint128 constant CMASK_LOWER_W = uint128(1) << uint128(uint8(bytes1(\"w\")));\n\n/// @dev ASCII x\nuint128 constant CMASK_LOWER_X = uint128(1) << uint128(uint8(bytes1(\"x\")));\n\n/// @dev ASCII y\nuint128 constant CMASK_LOWER_Y = uint128(1) << uint128(uint8(bytes1(\"y\")));\n\n/// @dev ASCII z\nuint128 constant CMASK_LOWER_Z = uint128(1) << uint128(uint8(bytes1(\"z\")));\n\n/// @dev ASCII {\nuint128 constant CMASK_LEFT_CURLY_BRACKET = uint128(1) << uint128(uint8(bytes1(\"{\")));\n\n/// @dev ASCII |\nuint128 constant CMASK_VERTICAL_BAR = uint128(1) << uint128(uint8(bytes1(\"|\")));\n\n/// @dev ASCII }\nuint128 constant CMASK_RIGHT_CURLY_BRACKET = uint128(1) << uint128(uint8(bytes1(\"}\")));\n\n/// @dev ASCII ~\nuint128 constant CMASK_TILDE = uint128(1) << uint128(uint8(bytes1(\"~\")));\n\n/// @dev ASCII delete\nuint128 constant CMASK_DELETE = uint128(1) << uint128(uint8(bytes1(\"\\x7F\")));\n\n/// @dev numeric 0-9\nuint128 constant CMASK_NUMERIC_0_9 = CMASK_ZERO | CMASK_ONE | CMASK_TWO | CMASK_THREE | CMASK_FOUR | CMASK_FIVE\n | CMASK_SIX | CMASK_SEVEN | CMASK_EIGHT | CMASK_NINE;\n\n/// @dev e notation eE\nuint128 constant CMASK_E_NOTATION = CMASK_LOWER_E | CMASK_UPPER_E;\n\n/// @dev lower alpha a-z\nuint128 constant CMASK_LOWER_ALPHA_A_Z = CMASK_LOWER_A | CMASK_LOWER_B | CMASK_LOWER_C | CMASK_LOWER_D | CMASK_LOWER_E\n | CMASK_LOWER_F | CMASK_LOWER_G | CMASK_LOWER_H | CMASK_LOWER_I | CMASK_LOWER_J | CMASK_LOWER_K | CMASK_LOWER_L\n | CMASK_LOWER_M | CMASK_LOWER_N | CMASK_LOWER_O | CMASK_LOWER_P | CMASK_LOWER_Q | CMASK_LOWER_R | CMASK_LOWER_S\n | CMASK_LOWER_T | CMASK_LOWER_U | CMASK_LOWER_V | CMASK_LOWER_W | CMASK_LOWER_X | CMASK_LOWER_Y | CMASK_LOWER_Z;\n\n/// @dev upper alpha A-Z\nuint128 constant CMASK_UPPER_ALPHA_A_Z = CMASK_UPPER_A | CMASK_UPPER_B | CMASK_UPPER_C | CMASK_UPPER_D | CMASK_UPPER_E\n | CMASK_UPPER_F | CMASK_UPPER_G | CMASK_UPPER_H | CMASK_UPPER_I | CMASK_UPPER_J | CMASK_UPPER_K | CMASK_UPPER_L\n | CMASK_UPPER_M | CMASK_UPPER_N | CMASK_UPPER_O | CMASK_UPPER_P | CMASK_UPPER_Q | CMASK_UPPER_R | CMASK_UPPER_S\n | CMASK_UPPER_T | CMASK_UPPER_U | CMASK_UPPER_V | CMASK_UPPER_W | CMASK_UPPER_X | CMASK_UPPER_Y | CMASK_UPPER_Z;\n\n/// @dev lower alpha a-f (hex)\nuint128 constant CMASK_LOWER_ALPHA_A_F =\n CMASK_LOWER_A | CMASK_LOWER_B | CMASK_LOWER_C | CMASK_LOWER_D | CMASK_LOWER_E | CMASK_LOWER_F;\n\n/// @dev upper alpha A-F (hex)\nuint128 constant CMASK_UPPER_ALPHA_A_F =\n CMASK_UPPER_A | CMASK_UPPER_B | CMASK_UPPER_C | CMASK_UPPER_D | CMASK_UPPER_E | CMASK_UPPER_F;\n\n/// @dev hex 0-9 a-f A-F\nuint128 constant CMASK_HEX = CMASK_NUMERIC_0_9 | CMASK_LOWER_ALPHA_A_F | CMASK_UPPER_ALPHA_A_F;\n\n/// @dev Rainlang end of line is ,\nuint128 constant CMASK_EOL = CMASK_COMMA;\n\n/// @dev Rainlang LHS/RHS delimiter is :\nuint128 constant CMASK_LHS_RHS_DELIMITER = CMASK_COLON;\n\n/// @dev Rainlang end of source is ;\nuint128 constant CMASK_EOS = CMASK_SEMICOLON;\n\n/// @dev Rainlang stack head is lower alpha and underscore a-z _\nuint128 constant CMASK_LHS_STACK_HEAD = CMASK_LOWER_ALPHA_A_Z | CMASK_UNDERSCORE;\n\n/// @dev Rainlang identifier head is lower alpha a-z\nuint128 constant CMASK_IDENTIFIER_HEAD = CMASK_LOWER_ALPHA_A_Z;\nuint128 constant CMASK_RHS_WORD_HEAD = CMASK_IDENTIFIER_HEAD;\n\n/// @dev Rainlang stack/identifier tail is lower alphanumeric kebab a-z 0-9 -\nuint128 constant CMASK_IDENTIFIER_TAIL = CMASK_IDENTIFIER_HEAD | CMASK_NUMERIC_0_9 | CMASK_DASH;\nuint128 constant CMASK_LHS_STACK_TAIL = CMASK_IDENTIFIER_TAIL;\nuint128 constant CMASK_RHS_WORD_TAIL = CMASK_IDENTIFIER_TAIL;\n\n/// @dev Rainlang operand start is <\nuint128 constant CMASK_OPERAND_START = CMASK_LESS_THAN_SIGN;\n\n/// @dev Rainlang operand end is >\nuint128 constant CMASK_OPERAND_END = CMASK_GREATER_THAN_SIGN;\n\n/// @dev NOT lower alphanumeric kebab\nuint128 constant CMASK_NOT_IDENTIFIER_TAIL = ~CMASK_IDENTIFIER_TAIL;\n\n/// @dev Rainlang whitespace is \\n \\r \\t space\nuint128 constant CMASK_WHITESPACE = CMASK_LINE_FEED | CMASK_CARRIAGE_RETURN | CMASK_HORIZONTAL_TAB | CMASK_SPACE;\n\n/// @dev Rainlang stack item delimiter is whitespace\nuint128 constant CMASK_LHS_STACK_DELIMITER = CMASK_WHITESPACE;\n\n/// @dev Rainlang supports numeric literals as anything starting with 0-9\nuint128 constant CMASK_NUMERIC_LITERAL_HEAD = CMASK_NUMERIC_0_9;\n\n/// @dev Rainlang literal head\nuint128 constant CMASK_LITERAL_HEAD = CMASK_NUMERIC_LITERAL_HEAD;\n\n/// @dev Rainlang comment head is /\nuint128 constant CMASK_COMMENT_HEAD = CMASK_SLASH;\n\n/// @dev Rainlang comment starting sequence is /*\nuint256 constant COMMENT_START_SEQUENCE = uint256(uint16(bytes2(\"/*\")));\n\n/// @dev Rainlang comment ending sequence is */\nuint256 constant COMMENT_END_SEQUENCE = uint256(uint16(bytes2(\"*/\")));\n\n/// @dev Rainlang literal hexadecimal dispatch is 0x\n/// We compare the head and dispatch together to avoid a second comparison.\n/// This is safe because the head is prefiltered to be 0-9 due to the numeric\n/// literal head, therefore the only possible match is 0x (not x0).\nuint128 constant CMASK_LITERAL_HEX_DISPATCH = CMASK_ZERO | CMASK_LOWER_X;\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParse.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.solmem/lib/LibPointer.sol\";\nimport \"rain.solmem/lib/LibMemCpy.sol\";\n\nimport \"../bitwise/LibCtPop.sol\";\nimport \"./LibParseMeta.sol\";\nimport \"./LibParseCMask.sol\";\nimport \"./LibParseLiteral.sol\";\nimport \"./LibParseOperand.sol\";\nimport \"../../interface/IInterpreterV1.sol\";\nimport \"./LibParseStackName.sol\";\n\n/// The expression does not finish with a semicolon (EOF).\nerror MissingFinalSemi(uint256 offset);\n\n/// Enountered an unexpected character on the LHS.\nerror UnexpectedLHSChar(uint256 offset);\n\n/// Encountered an unexpected character on the RHS.\nerror UnexpectedRHSChar(uint256 offset);\n\n/// More specific version of UnexpectedRHSChar where we specifically expected\n/// a left paren but got some other char.\nerror ExpectedLeftParen(uint256 offset);\n\n/// Encountered a right paren without a matching left paren.\nerror UnexpectedRightParen(uint256 offset);\n\n/// Encountered an unclosed left paren.\nerror UnclosedLeftParen(uint256 offset);\n\n/// Encountered a comment outside the interstitial space between lines.\nerror UnexpectedComment(uint256 offset);\n\n/// Encountered a comment start sequence that is malformed.\nerror MalformedCommentStart(uint256 offset);\n\n/// @dev Thrown when a stack name is duplicated. Shadowing in all forms is\n/// disallowed in Rainlang.\nerror DuplicateLHSItem(uint256 errorOffset);\n\n/// Encountered too many LHS items.\nerror ExcessLHSItems(uint256 offset);\n\n/// Encountered inputs where they can't be handled.\nerror NotAcceptingInputs(uint256 offset);\n\n/// Encountered too many RHS items.\nerror ExcessRHSItems(uint256 offset);\n\n/// Encountered a word that is longer than 32 bytes.\nerror WordSize(string word);\n\n/// Parsed a word that is not in the meta.\nerror UnknownWord(uint256 offset);\n\n/// The parser exceeded the maximum number of sources that it can build.\nerror MaxSources();\n\n/// The parser encountered a dangling source. This is a bug in the parser.\nerror DanglingSource();\n\n/// The parser moved past the end of the data.\nerror ParserOutOfBounds();\n\n/// The parser encountered a stack deeper than it can process in the memory\n/// region allocated for stack names.\nerror StackOverflow();\n\n/// The parser encountered a stack underflow.\nerror StackUnderflow();\n\n/// The parser encountered a paren group deeper than it can process in the\n/// memory region allocated for paren tracking.\nerror ParenOverflow();\n\nuint256 constant NOT_LOW_16_BIT_MASK = ~uint256(0xFFFF);\nuint256 constant ACTIVE_SOURCE_MASK = NOT_LOW_16_BIT_MASK;\n\nuint256 constant FSM_RHS_MASK = 1;\nuint256 constant FSM_YANG_MASK = 1 << 1;\nuint256 constant FSM_WORD_END_MASK = 1 << 2;\nuint256 constant FSM_ACCEPTING_INPUTS_MASK = 1 << 3;\n\n/// @dev The space between lines where comments and whitespace is allowed.\n/// The first LHS item breaks us out of the interstitial.\nuint256 constant FSM_INTERSTITIAL_MASK = 1 << 4;\n\n/// @dev If a source is active we cannot finish parsing without a semi to trigger\n/// finalisation.\nuint256 constant FSM_ACTIVE_SOURCE_MASK = 1 << 5;\n\n/// @dev fsm default state is:\n/// - LHS\n/// - yin\n/// - not word end\n/// - accepting inputs\n/// - interstitial\nuint256 constant FSM_DEFAULT = FSM_ACCEPTING_INPUTS_MASK | FSM_INTERSTITIAL_MASK;\n\nuint256 constant EMPTY_ACTIVE_SOURCE = 0x20;\n\n/// @dev The opcode that will be used in the source to represent a stack copy\n/// implied by named LHS stack items.\n/// @dev @todo support the meta defining the opcode.\nuint256 constant OPCODE_STACK = 0;\n\n/// @dev The opcode that will be used in the source to read a constant.\n/// @dev @todo support the meta defining the opcode.\nuint256 constant OPCODE_CONSTANT = 1;\n\ntype StackTracker is uint256;\n\n/// The parser is stateful. This struct keeps track of the entire state.\n/// @param activeSourcePtr The pointer to the current source being built.\n/// The active source being pointed to is:\n/// - low 16 bits: bitwise offset into the source for the next word to be\n/// written. Starts at 0x20. Once a source is no longer the active source, i.e.\n/// it is full and a member of the LL tail, the offset is replaced with a\n/// pointer to the next source (towards the head) to build a doubly linked\n/// list.\n/// - mid 16 bits: pointer to the previous active source (towards the tail). This\n/// is a linked list of sources that are built RTL and then reversed to LTR to\n/// eval.\n/// - high bits: 4 byte opcodes and operand pairs.\n/// @param sourcesBuilder A builder for the sources array. This is a 256 bit\n/// integer where each 16 bits is a literal memory pointer to a source.\n/// @param fsm The finite state machine representation of the parser.\n/// - bit 0: LHS/RHS => 0 = LHS, 1 = RHS\n/// - bit 1: yang/yin => 0 = yin, 1 = yang\n/// - bit 2: word end => 0 = not end, 1 = end\n/// - bit 3: accepting inputs => 0 = not accepting, 1 = accepting\n/// - bit 4: interstitial => 0 = not interstitial, 1 = interstitial\n/// @param topLevel0 Memory region for stack word counters. The first byte is a\n/// counter/offset into the region, which increments for every top level item\n/// parsed on the RHS. The remaining 31 bytes are the word counters for each\n/// stack item, which are incremented for every op pushed to the source. This is\n/// reset to 0 for every new source.\n/// @param topLevel1 31 additional bytes of stack words, allowing for 62 top\n/// level stack items total per source. The final byte is used to count the\n/// stack height according to the LHS for the current source. This is reset to 0\n/// for every new source.\n/// @param parenTracker0 Memory region for tracking pointers to words in the\n/// source, and counters for the number of words in each paren group. The first\n/// byte is a counter/offset into the region. The second byte is a phantom\n/// counter for the root level, the remaining 30 bytes are the paren group words.\n/// @param parenTracker1 32 additional bytes of paren group words.\n/// @param lineTracker A 32 byte memory region for tracking the current line.\n/// Will be partially reset for each line when `balanceLine` is called. Fully\n/// reset when a new source is started.\n/// Bytes from low to high:\n/// - byte 0: Lowest byte is the number of LHS items parsed. This is the low\n/// byte so that a simple ++ is a valid operation on the line tracker while\n/// parsing the LHS. This is reset to 0 for each new line.\n/// - byte 1: A snapshot of the first high byte of `topLevel0`, i.e. the offset\n/// of top level items as at the beginning of the line. This is reset to the high\n/// byte of `topLevel0` on each new line.\n/// - bytes 2+: A sequence of 2 byte pointers to before the start of each top\n/// level item, which is implictly after the end of the previous top level item.\n/// Allows us to quickly find the start of the RHS source for each top level\n/// item.\n/// @param stackNames A linked list of stack names. As the parser encounters\n/// named stack items it pushes them onto this linked list. The linked list is\n/// in FILO order, so the first item on the stack is the last item in the list.\n/// This makes it more efficient to reference more recent stack names on the RHS.\n/// @param literalBloom A bloom filter of all the literals that have been\n/// encountered so far. This is used to quickly dedupe literals.\n/// @param constantsBuilder A builder for the constants array.\n/// @param literalParsers A 256 bit integer where each 16 bits is a function\n/// pointer to a literal parser.\nstruct ParseState {\n /// @dev START things that are referenced directly in assembly by hardcoded\n /// offsets. E.g.\n /// - `pushOpToSource`\n /// - `snapshotSourceHeadToLineTracker`\n /// - `newSource`\n uint256 activeSourcePtr;\n uint256 topLevel0;\n uint256 topLevel1;\n uint256 parenTracker0;\n uint256 parenTracker1;\n uint256 lineTracker;\n /// @dev END things that are referenced directly in assembly by hardcoded\n /// offsets.\n uint256 sourcesBuilder;\n uint256 fsm;\n uint256 stackNames;\n uint256 stackNameBloom;\n uint256 literalBloom;\n uint256 constantsBuilder;\n uint256 literalParsers;\n uint256 operandParsers;\n StackTracker stackTracker;\n}\n\nlibrary LibStackTracker {\n using LibStackTracker for StackTracker;\n\n /// Pushing inputs requires special handling as the inputs need to be tallied\n /// separately and in addition to the regular stack pushes.\n function pushInputs(StackTracker tracker, uint256 n) internal pure returns (StackTracker) {\n unchecked {\n tracker = tracker.push(n);\n uint256 inputs = (StackTracker.unwrap(tracker) >> 8) & 0xFF;\n inputs += n;\n return StackTracker.wrap((StackTracker.unwrap(tracker) & ~uint256(0xFF00)) | (inputs << 8));\n }\n }\n\n function push(StackTracker tracker, uint256 n) internal pure returns (StackTracker) {\n unchecked {\n uint256 current = StackTracker.unwrap(tracker) & 0xFF;\n uint256 inputs = (StackTracker.unwrap(tracker) >> 8) & 0xFF;\n uint256 max = StackTracker.unwrap(tracker) >> 0x10;\n current += n;\n if (current > max) {\n max = current;\n }\n return StackTracker.wrap(current | (inputs << 8) | (max << 0x10));\n }\n }\n\n function pop(StackTracker tracker, uint256 n) internal pure returns (StackTracker) {\n unchecked {\n uint256 current = StackTracker.unwrap(tracker) & 0xFF;\n if (current < n) {\n revert StackUnderflow();\n }\n return StackTracker.wrap(StackTracker.unwrap(tracker) - n);\n }\n }\n}\n\nlibrary LibParseState {\n using LibParseState for ParseState;\n using LibStackTracker for StackTracker;\n\n function resetSource(ParseState memory state) internal pure {\n uint256 activeSourcePtr;\n uint256 emptyActiveSource = EMPTY_ACTIVE_SOURCE;\n assembly (\"memory-safe\") {\n activeSourcePtr := mload(0x40)\n mstore(activeSourcePtr, emptyActiveSource)\n mstore(0x40, add(activeSourcePtr, 0x20))\n }\n state.activeSourcePtr = activeSourcePtr;\n state.topLevel0 = 0;\n state.topLevel1 = 0;\n state.parenTracker0 = 0;\n state.parenTracker1 = 0;\n state.lineTracker = 0;\n state.stackNames = 0;\n state.stackNameBloom = 0;\n state.stackTracker = StackTracker.wrap(0);\n }\n\n function newState() internal pure returns (ParseState memory) {\n ParseState memory state = ParseState(\n // activeSource\n // (will be built in `newActiveSource`)\n 0,\n // topLevel0\n 0,\n // topLevel1\n 0,\n // parenTracker0\n 0,\n // parenTracker1\n 0,\n // lineTracker\n // (will be built in `newActiveSource`)\n 0,\n // sourcesBuilder\n 0,\n // fsm\n FSM_DEFAULT,\n // stackNames\n 0,\n // stackNameBloom\n 0,\n // literalBloom\n 0,\n // constantsBuilder\n 0,\n // literalParsers\n LibParseLiteral.buildLiteralParsers(),\n // operandParsers\n LibParseOperand.buildOperandParsers(),\n // stackTracker\n StackTracker.wrap(0)\n );\n state.resetSource();\n return state;\n }\n\n // Find the pointer to the first opcode in the source LL. Put it in the line\n // tracker at the appropriate offset.\n function snapshotSourceHeadToLineTracker(ParseState memory state) internal pure {\n assembly (\"memory-safe\") {\n let topLevel0Pointer := add(state, 0x20)\n let totalRHSTopLevel := byte(0, mload(topLevel0Pointer))\n // Only do stuff if the current word counter is zero.\n if iszero(byte(0, mload(add(topLevel0Pointer, add(totalRHSTopLevel, 1))))) {\n let sourceHead := mload(state)\n let byteOffset := div(and(mload(sourceHead), 0xFFFF), 8)\n sourceHead := add(sourceHead, sub(0x20, byteOffset))\n\n let lineTracker := mload(add(state, 0xa0))\n let lineRHSTopLevel := sub(totalRHSTopLevel, byte(30, lineTracker))\n let offset := mul(0x10, add(lineRHSTopLevel, 1))\n lineTracker := or(lineTracker, shl(offset, sourceHead))\n mstore(add(state, 0xa0), lineTracker)\n }\n }\n }\n\n function endLine(ParseState memory state, bytes memory data, uint256 cursor) internal pure {\n unchecked {\n {\n uint256 parenOffset;\n assembly (\"memory-safe\") {\n parenOffset := byte(0, mload(add(state, 0x60)))\n }\n if (parenOffset > 0) {\n revert UnclosedLeftParen(LibParse.parseErrorOffset(data, cursor));\n }\n }\n\n // This will snapshot the current head of the source, which will be\n // the start of where we want to read for the final line RHS item,\n // if it exists.\n state.snapshotSourceHeadToLineTracker();\n\n // Preserve the accepting inputs flag but set\n // everything else back to defaults. Also set that\n // there is an active source.\n state.fsm = (FSM_DEFAULT & ~FSM_ACCEPTING_INPUTS_MASK) | (state.fsm & FSM_ACCEPTING_INPUTS_MASK)\n | FSM_ACTIVE_SOURCE_MASK;\n\n uint256 lineLHSItems = state.lineTracker & 0xFF;\n // Total number of RHS at top level is the top byte of topLevel0.\n uint256 totalRHSTopLevel = state.topLevel0 >> 0xf8;\n // Snapshot for RHS from start of line is second low byte of\n // lineTracker.\n uint256 lineRHSTopLevel = totalRHSTopLevel - ((state.lineTracker >> 8) & 0xFF);\n\n // If:\n // - we are accepting inputs\n // - the RHS on this line is empty\n // Then we treat the LHS items as inputs to the source. This means that\n // we need to move the RHS offset to the end of the LHS items. There MAY\n // be 0 LHS items, e.g. if the entire source is empty. This can only\n // happen at the start of the source, as any RHS item immediately flips\n // the FSM to not accepting inputs.\n if (lineRHSTopLevel == 0) {\n if (state.fsm & FSM_ACCEPTING_INPUTS_MASK == 0) {\n revert NotAcceptingInputs(LibParse.parseErrorOffset(data, cursor));\n } else {\n // As there are no RHS opcodes yet we can simply set topLevel0 directly.\n // This is the only case where we defer to the LHS to tell\n // us how many top level items there are.\n totalRHSTopLevel += lineLHSItems;\n state.topLevel0 = totalRHSTopLevel << 0xf8;\n\n // Push the inputs onto the stack tracker.\n state.stackTracker = state.stackTracker.pushInputs(lineLHSItems);\n }\n }\n // If:\n // - there are multiple RHS items on this line\n // Then there must be the same number of LHS items. Multi or zero output\n // RHS top level items are NOT supported unless they are the only RHS\n // item on that line.\n else if (lineRHSTopLevel > 1) {\n if (lineLHSItems < lineRHSTopLevel) {\n revert ExcessRHSItems(LibParse.parseErrorOffset(data, cursor));\n } else if (lineLHSItems > lineRHSTopLevel) {\n revert ExcessLHSItems(LibParse.parseErrorOffset(data, cursor));\n }\n }\n\n // Follow pointers to the start of the RHS item.\n uint256 topLevelOffset = 1 + totalRHSTopLevel - lineRHSTopLevel;\n uint256 end = (0x10 * lineRHSTopLevel) + 0x20;\n for (uint256 offset = 0x20; offset < end; offset += 0x10) {\n uint256 itemSourceHead = (state.lineTracker >> offset) & 0xFFFF;\n uint256 opsDepth;\n assembly (\"memory-safe\") {\n opsDepth := byte(0, mload(add(state, add(0x20, topLevelOffset))))\n }\n for (uint256 i = 1; i <= opsDepth; i++) {\n {\n // We've hit the end of a LL item so have to jump towards the\n // tail to keep going.\n if (itemSourceHead % 0x20 == 0x1c) {\n assembly (\"memory-safe\") {\n itemSourceHead := shr(0xf0, mload(itemSourceHead))\n }\n }\n uint256 opInputs;\n assembly (\"memory-safe\") {\n opInputs := byte(1, mload(itemSourceHead))\n }\n state.stackTracker = state.stackTracker.pop(opInputs);\n // Nested multi or zero output RHS items are NOT\n // supported. If the top level RHS item is the ONLY RHS\n // item on the line then it MAY have multiple or zero\n // outputs. In this case we defer to the LHS to tell us\n // how many outputs there are. If the LHS is wrong then\n // later integrity checks will need to flag it.\n state.stackTracker =\n state.stackTracker.push(i == opsDepth && lineRHSTopLevel == 1 ? lineLHSItems : 1);\n }\n itemSourceHead += 4;\n }\n topLevelOffset++;\n }\n\n state.lineTracker = totalRHSTopLevel << 8;\n }\n }\n\n /// We potentially just closed out some group of arbitrarily nested parens\n /// OR a lone literal value at the top level. IF we are at the top level we\n /// move the immutable stack highwater mark forward 1 item, which moves the\n /// RHS offset forward 1 byte to start a new word counter.\n function highwater(ParseState memory state) internal pure {\n uint256 parenOffset;\n assembly (\"memory-safe\") {\n parenOffset := byte(0, mload(add(state, 0x60)))\n }\n if (parenOffset == 0) {\n uint256 newStackRHSOffset;\n assembly (\"memory-safe\") {\n let stackRHSOffsetPtr := add(state, 0x20)\n newStackRHSOffset := add(byte(0, mload(stackRHSOffsetPtr)), 1)\n mstore8(stackRHSOffsetPtr, newStackRHSOffset)\n }\n if (newStackRHSOffset == 0x3f) {\n revert StackOverflow();\n }\n }\n }\n\n function pushLiteral(ParseState memory state, bytes memory data, uint256 cursor) internal pure returns (uint256) {\n unchecked {\n (\n function(bytes memory, uint256, uint256) pure returns (uint256) parser,\n uint256 innerStart,\n uint256 innerEnd,\n uint256 outerEnd\n ) = LibParseLiteral.boundLiteral(state.literalParsers, data, cursor);\n uint256 fingerprint;\n uint256 fingerprintBloom;\n assembly (\"memory-safe\") {\n fingerprint := and(keccak256(cursor, sub(outerEnd, cursor)), not(0xFFFF))\n //slither-disable-next-line incorrect-shift\n fingerprintBloom := shl(byte(0, fingerprint), 1)\n }\n\n // Whether the literal is a duplicate.\n bool exists = false;\n\n // The index of the literal in the linked list of literals. This is\n // starting from the top of the linked list, so the final index is\n // the height of the linked list minus this value.\n uint256 t = 1;\n\n // If the literal is in the bloom filter, then it MAY be a duplicate.\n // Try to find the literal in the linked list of literals using the\n // full fingerprint for better collision resistance than the bloom.\n //\n // If the literal is NOT in the bloom filter, then it is definitely\n // NOT a duplicate, so avoid traversing the linked list.\n //\n // Worst case is a false positive in the bloom filter, which means\n // we traverse the linked list and find no match. This is O(1) for\n // the bloom filter and O(n) for the linked list traversal, then\n // O(m) for the per-char literal parsing. The bloom filter is\n // 256 bits, so the chance of there being at least one false positive\n // over 10 literals is ~15% due to the birthday paradox.\n if (state.literalBloom & fingerprintBloom != 0) {\n uint256 tailPtr = state.constantsBuilder >> 0x10;\n while (tailPtr != 0) {\n uint256 tailKey;\n assembly (\"memory-safe\") {\n tailKey := mload(tailPtr)\n }\n // If the fingerprint matches, then the literal IS a duplicate,\n // with 240 bits of collision resistance. The value sits alongside\n // the key in memory.\n if (fingerprint == (tailKey & ~uint256(0xFFFF))) {\n exists = true;\n break;\n }\n\n assembly (\"memory-safe\") {\n // Tail pointer is the low 16 bits of the key.\n tailPtr := and(mload(tailPtr), 0xFFFF)\n }\n t++;\n }\n }\n\n // Push the literal opcode to the source.\n // The index is either the height of the constants, if the literal\n // is NOT a duplicate, or the height minus the index of the\n // duplicate. This is because the final constants array is built\n // 0 indexed from the bottom of the linked list to the top.\n {\n uint256 constantsHeight = state.constantsBuilder & 0xFFFF;\n state.pushOpToSource(OPCODE_CONSTANT, Operand.wrap(exists ? constantsHeight - t : constantsHeight));\n }\n\n // If the literal is not a duplicate, then we need to add it to the\n // linked list of literals so that `t` can point to it, and we can\n // build the constants array from the values in the linked list\n // later.\n if (!exists) {\n uint256 ptr;\n assembly (\"memory-safe\") {\n // Allocate two words.\n ptr := mload(0x40)\n mstore(0x40, add(ptr, 0x40))\n }\n // First word is the key.\n {\n // tail key is the fingerprint with the low 16 bits set to\n // the pointer to the next item in the linked list. If there\n // is no next item then the pointer is 0.\n uint256 tailKey = state.constantsBuilder >> 0x10 | fingerprint;\n assembly (\"memory-safe\") {\n mstore(ptr, tailKey)\n }\n }\n // Second word is the value.\n {\n uint256 tailValue = parser(data, innerStart, innerEnd);\n\n assembly (\"memory-safe\") {\n // Second word is the value\n mstore(add(ptr, 0x20), tailValue)\n }\n }\n\n state.constantsBuilder = ((state.constantsBuilder & 0xFFFF) + 1) | (ptr << 0x10);\n state.literalBloom |= fingerprintBloom;\n }\n\n return outerEnd;\n }\n }\n\n function pushOpToSource(ParseState memory state, uint256 opcode, Operand operand) internal pure {\n unchecked {\n // This might be a top level item so try to snapshot its pointer to\n // the line tracker before writing the stack counter.\n state.snapshotSourceHeadToLineTracker();\n\n // As soon as we push an op to source we can no longer accept inputs.\n state.fsm &= ~FSM_ACCEPTING_INPUTS_MASK;\n // We also have an active source;\n state.fsm |= FSM_ACTIVE_SOURCE_MASK;\n\n // Increment the top level stack counter for the current top level\n // word. MAY be setting 0 to 1 if this is the top level.\n assembly (\"memory-safe\") {\n // Hardcoded offset into the state struct.\n let counterOffset := add(state, 0x20)\n let counterPointer := add(counterOffset, add(byte(0, mload(counterOffset)), 1))\n // Increment the counter.\n mstore8(counterPointer, add(byte(0, mload(counterPointer)), 1))\n }\n\n uint256 activeSource;\n uint256 offset;\n assembly (\"memory-safe\") {\n let activeSourcePointer := mload(state)\n activeSource := mload(activeSourcePointer)\n // The low 16 bits of the active source is the current offset.\n offset := and(activeSource, 0xFFFF)\n\n // The offset is in bits so for a byte pointer we need to divide\n // by 8, then add 4 to move to the operand low byte.\n let inputsBytePointer := sub(add(activeSourcePointer, 0x20), add(div(offset, 8), 4))\n\n // Increment the paren input counter. The input counter is for the paren\n // group that is currently being built. This means the counter is for\n // the paren group that is one level above the current paren offset.\n // Assumes that every word has exactly 1 output, therefore the input\n // counter always increases by 1.\n // Hardcoded offset into the state struct.\n let inputCounterPos := add(state, 0x60)\n inputCounterPos :=\n add(\n add(\n inputCounterPos,\n // the offset\n byte(0, mload(inputCounterPos))\n ),\n // +2 for the reserved bytes -1 to move back to the counter\n // for the previous paren group.\n 1\n )\n // Increment the parent counter.\n mstore8(inputCounterPos, add(byte(0, mload(inputCounterPos)), 1))\n // Zero out the current counter.\n mstore8(add(inputCounterPos, 3), 0)\n\n // Write the operand low byte pointer into the paren tracker.\n // Move 3 bytes after the input counter pos, then shift down 32\n // bytes to accomodate the full mload.\n let parenTrackerPointer := sub(inputCounterPos, 29)\n mstore(parenTrackerPointer, or(and(mload(parenTrackerPointer), not(0xFFFF)), inputsBytePointer))\n }\n\n // We write sources RTL so they can run LTR.\n activeSource =\n // increment offset. We have 16 bits allocated to the offset and stop\n // processing at 0x100 so this never overflows into the actual source\n // data.\n activeSource + 0x20\n // include the operand. The operand is assumed to be 16 bits, so we shift\n // it into the correct position.\n | Operand.unwrap(operand) << offset\n // include new op. The opcode is assumed to be 8 bits, so we shift it\n // into the correct position, beyond the operand.\n | opcode << (offset + 0x18);\n assembly (\"memory-safe\") {\n mstore(mload(state), activeSource)\n }\n\n // We have filled the current source slot. Need to create a new active\n // source and fulfill the doubly linked list.\n if (offset == 0xe0) {\n // Pointer to a newly allocated active source.\n uint256 newTailPtr;\n // Pointer to the old head of the LL tail.\n uint256 oldTailPtr;\n uint256 emptyActiveSource = EMPTY_ACTIVE_SOURCE;\n assembly (\"memory-safe\") {\n oldTailPtr := mload(state)\n\n // Build the new tail head.\n newTailPtr := mload(0x40)\n mstore(state, newTailPtr)\n mstore(newTailPtr, or(emptyActiveSource, shl(0x10, oldTailPtr)))\n mstore(0x40, add(newTailPtr, 0x20))\n\n // The old tail head must now point back to the new tail head.\n mstore(oldTailPtr, or(and(mload(oldTailPtr), not(0xFFFF)), newTailPtr))\n }\n }\n }\n }\n\n function endSource(ParseState memory state) internal pure {\n uint256 sourcesBuilder = state.sourcesBuilder;\n uint256 offset = sourcesBuilder >> 0xf0;\n\n // End is the number of top level words in the source, which is the\n // byte offset index + 1.\n uint256 end;\n assembly (\"memory-safe\") {\n end := add(byte(0, mload(add(state, 0x20))), 1)\n }\n\n if (offset == 0xf0) {\n revert MaxSources();\n }\n // Follow the word counters to build the source with the correct\n // combination of LTR and RTL words. The stack needs to be built\n // LTR at the top level, so that as the evaluation proceeds LTR it\n // can reference previous items in subsequent items. However, the\n // stack is built RTL within each item, so that nested parens are\n // evaluated correctly similar to reverse polish notation.\n else {\n uint256 source;\n StackTracker stackTracker = state.stackTracker;\n assembly (\"memory-safe\") {\n // find the end of the LL tail.\n let cursor := mload(state)\n\n let tailPointer := and(shr(0x10, mload(cursor)), 0xFFFF)\n for {} iszero(iszero(tailPointer)) {} {\n cursor := tailPointer\n tailPointer := and(shr(0x10, mload(cursor)), 0xFFFF)\n }\n\n // Move cursor to the end of the end of the LL tail item.\n // This is 4 bytes from the end of the EVM word, to compensate\n // for the offset and pointer positions.\n tailPointer := cursor\n cursor := add(cursor, 0x1C)\n // leave space for the source prefix in the bytecode output.\n let length := 4\n source := mload(0x40)\n // Move over the source 32 byte length and the 4 byte prefix.\n let writeCursor := add(source, 0x20)\n writeCursor := add(writeCursor, 4)\n\n let counterCursor := add(state, 0x21)\n for {\n let i := 0\n let wordsTotal := byte(0, mload(counterCursor))\n let wordsRemaining := wordsTotal\n } lt(i, end) {\n i := add(i, 1)\n counterCursor := add(counterCursor, 1)\n wordsTotal := byte(0, mload(counterCursor))\n wordsRemaining := wordsTotal\n } {\n length := add(length, mul(wordsTotal, 4))\n {\n // 4 bytes per source word.\n let tailItemWordsRemaining := div(sub(cursor, tailPointer), 4)\n // loop to the tail item that contains the start of the words\n // that we need to copy.\n for {} gt(wordsRemaining, tailItemWordsRemaining) {} {\n wordsRemaining := sub(wordsRemaining, tailItemWordsRemaining)\n tailPointer := and(mload(tailPointer), 0xFFFF)\n tailItemWordsRemaining := 7\n cursor := add(tailPointer, 0x1C)\n }\n }\n\n // Now the words remaining is lte the words remaining in the\n // tail item. Move the cursor back to the start of the words\n // and copy the passed over bytes to the write cursor.\n {\n let forwardTailPointer := tailPointer\n let size := mul(wordsRemaining, 4)\n cursor := sub(cursor, size)\n mstore(writeCursor, mload(cursor))\n writeCursor := add(writeCursor, size)\n\n // Redefine wordsRemaining to be the number of words\n // left to copy.\n wordsRemaining := sub(wordsTotal, wordsRemaining)\n // Move over whole tail items.\n for {} gt(wordsRemaining, 7) {} {\n wordsRemaining := sub(wordsRemaining, 7)\n // Follow the forward tail pointer.\n forwardTailPointer := and(shr(0x10, mload(forwardTailPointer)), 0xFFFF)\n mstore(writeCursor, mload(forwardTailPointer))\n writeCursor := add(writeCursor, 0x1c)\n }\n // Move over the remaining words in the tail item.\n if gt(wordsRemaining, 0) {\n forwardTailPointer := and(shr(0x10, mload(forwardTailPointer)), 0xFFFF)\n mstore(writeCursor, mload(forwardTailPointer))\n writeCursor := add(writeCursor, mul(wordsRemaining, 4))\n }\n }\n }\n // Store the bytes length in the source.\n mstore(source, length)\n // Store the opcodes length and stack tracker in the source\n // prefix.\n let prefixWritePointer := add(source, 4)\n mstore(\n prefixWritePointer,\n or(\n and(mload(prefixWritePointer), not(0xFFFFFFFF)),\n or(shl(0x18, sub(div(length, 4), 1)), stackTracker)\n )\n )\n\n // Round up to the nearest 32 bytes to realign memory.\n mstore(0x40, and(add(writeCursor, 0x1f), not(0x1f)))\n }\n\n //slither-disable-next-line incorrect-shift\n state.sourcesBuilder =\n ((offset + 0x10) << 0xf0) | (source << offset) | (sourcesBuilder & ((1 << offset) - 1));\n\n // Reset source as we're done with this one.\n state.fsm &= ~FSM_ACTIVE_SOURCE_MASK;\n state.resetSource();\n }\n }\n\n function buildBytecode(ParseState memory state) internal pure returns (bytes memory bytecode) {\n unchecked {\n uint256 sourcesBuilder = state.sourcesBuilder;\n uint256 offsetEnd = (sourcesBuilder >> 0xf0);\n\n // Somehow the parser state for the active source was not reset\n // correctly, or the finalised offset is dangling. This implies that\n // we are building the overall sources array while still trying to\n // build one of the individual sources. This is a bug in the parser.\n uint256 activeSource;\n assembly (\"memory-safe\") {\n activeSource := mload(mload(state))\n }\n if (activeSource != EMPTY_ACTIVE_SOURCE) {\n revert DanglingSource();\n }\n\n uint256 cursor;\n uint256 sourcesCount;\n uint256 sourcesStart;\n assembly (\"memory-safe\") {\n cursor := mload(0x40)\n bytecode := cursor\n // Move past the bytecode length, we will write this at the end.\n cursor := add(cursor, 0x20)\n\n // First byte is the number of sources.\n sourcesCount := div(offsetEnd, 0x10)\n mstore8(cursor, sourcesCount)\n cursor := add(cursor, 1)\n\n let pointersCursor := cursor\n\n // Skip past the pointer space. We'll back fill it.\n // Divide offsetEnd to convert from a bit to a byte shift.\n cursor := add(cursor, div(offsetEnd, 8))\n sourcesStart := cursor\n\n // Write total bytes length into bytecode. We do ths and handle\n // the allocation in this same assembly block for memory safety\n // for the compiler optimiser.\n let sourcesLength := 0\n let sourcePointers := 0\n for { let offset := 0 } lt(offset, offsetEnd) { offset := add(offset, 0x10) } {\n let currentSourcePointer := and(shr(offset, sourcesBuilder), 0xFFFF)\n // add 4 byte prefix to the length of the sources, all as\n // bytes.\n sourcePointers := or(sourcePointers, shl(sub(0xf0, offset), sourcesLength))\n let currentSourceLength := mload(currentSourcePointer)\n\n // Put the reference source pointer and length into the\n // prefix so that we can use them to copy the actual data\n // into the bytecode.\n let tmpPrefix := shl(0xe0, or(shl(0x10, currentSourcePointer), currentSourceLength))\n mstore(add(sourcesStart, sourcesLength), tmpPrefix)\n sourcesLength := add(sourcesLength, currentSourceLength)\n }\n mstore(pointersCursor, or(mload(pointersCursor), sourcePointers))\n mstore(bytecode, add(sourcesLength, sub(sub(sourcesStart, 0x20), bytecode)))\n\n // Round up to the nearest 32 bytes past cursor to realign and\n // allocate memory.\n mstore(0x40, and(add(add(add(0x20, mload(bytecode)), bytecode), 0x1f), not(0x1f)))\n }\n\n // Loop over the sources and write them into the bytecode. Perhaps\n // there is a more efficient way to do this in the future that won't\n // cause each source to be written twice in memory.\n for (uint256 i = 0; i < sourcesCount; i++) {\n Pointer sourcePointer;\n uint256 length;\n Pointer targetPointer;\n assembly (\"memory-safe\") {\n let relativePointer := and(mload(add(bytecode, add(3, mul(i, 2)))), 0xFFFF)\n targetPointer := add(sourcesStart, relativePointer)\n let tmpPrefix := mload(targetPointer)\n sourcePointer := add(0x20, shr(0xf0, tmpPrefix))\n length := and(shr(0xe0, tmpPrefix), 0xFFFF)\n }\n LibMemCpy.unsafeCopyBytesTo(sourcePointer, targetPointer, length);\n }\n }\n }\n\n function buildConstants(ParseState memory state) internal pure returns (uint256[] memory constants) {\n uint256 constantsHeight = state.constantsBuilder & 0xFFFF;\n uint256 tailPtr = state.constantsBuilder >> 0x10;\n\n assembly (\"memory-safe\") {\n let cursor := mload(0x40)\n constants := cursor\n mstore(cursor, constantsHeight)\n let end := cursor\n // Move the cursor to the end of the array. Write in reverse order\n // of the linked list traversal so that the constants are built\n // according to the stable indexes in the source from the linked\n // list base.\n cursor := add(cursor, mul(constantsHeight, 0x20))\n // Allocate one word past the cursor. This will be just after the\n // length if the constants array is empty. Otherwise it will be\n // just after the last constant.\n mstore(0x40, add(cursor, 0x20))\n // It MUST be equivalent to say that the cursor is above the end,\n // and that we are following tail pointers until they point to 0,\n // and that the cursor is moving as far as the constants height.\n // This is ensured by the fact that the constants height is only\n // incremented when a new constant is added to the linked list.\n for {} gt(cursor, end) {\n // Next item in the linked list.\n cursor := sub(cursor, 0x20)\n // tail pointer in tail keys is the low 16 bits under the\n // fingerprint, which is different from the tail pointer in\n // the constants builder, where it sits above the constants\n // height.\n tailPtr := and(mload(tailPtr), 0xFFFF)\n } {\n // Store the values not the keys.\n mstore(cursor, mload(add(tailPtr, 0x20)))\n }\n }\n }\n}\n\nlibrary LibParse {\n using LibPointer for Pointer;\n using LibParseState for ParseState;\n using LibParseStackName for ParseState;\n\n function parseErrorOffset(bytes memory data, uint256 cursor) internal pure returns (uint256 offset) {\n assembly (\"memory-safe\") {\n offset := sub(cursor, add(data, 0x20))\n }\n }\n\n function parseWord(uint256 cursor, uint256 mask) internal pure returns (uint256, bytes32) {\n bytes32 word;\n uint256 i = 1;\n assembly (\"memory-safe\") {\n // word is head + tail\n word := mload(cursor)\n // loop over the tail\n //slither-disable-next-line incorrect-shift\n for {} and(lt(i, 0x20), iszero(and(shl(byte(i, word), 1), not(mask)))) { i := add(i, 1) } {}\n let scrub := mul(sub(0x20, i), 8)\n word := shl(scrub, shr(scrub, word))\n cursor := add(cursor, i)\n }\n if (i == 0x20) {\n revert WordSize(string(abi.encodePacked(word)));\n }\n return (cursor, word);\n }\n\n /// Skip an unlimited number of chars until we find one that is not in the\n /// mask.\n function skipMask(uint256 cursor, uint256 end, uint256 mask) internal pure returns (uint256) {\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n for {} and(lt(cursor, end), gt(and(shl(byte(0, mload(cursor)), 1), mask), 0)) { cursor := add(cursor, 1) } {}\n }\n return cursor;\n }\n\n /// The cursor currently points at the head of a comment. We need to skip\n /// over all data until we find the end of the comment. This MAY REVERT if\n /// the comment is malformed, e.g. if the comment doesn't start with `/*`.\n /// @param data The source data.\n /// @param cursor The current cursor position.\n /// @return The new cursor position.\n function skipComment(bytes memory data, uint256 cursor) internal pure returns (uint256) {\n // First check the comment opening sequence is not malformed.\n uint256 startSequence;\n assembly (\"memory-safe\") {\n startSequence := shr(0xf0, mload(cursor))\n }\n if (startSequence != COMMENT_START_SEQUENCE) {\n revert MalformedCommentStart(parseErrorOffset(data, cursor));\n }\n uint256 commentEndSequenceStart = COMMENT_END_SEQUENCE >> 8;\n uint256 commentEndSequenceEnd = COMMENT_END_SEQUENCE & 0xFF;\n uint256 max;\n assembly (\"memory-safe\") {\n // Move past the start sequence.\n cursor := add(cursor, 2)\n max := add(data, add(mload(data), 0x20))\n\n // Loop until we find the end sequence.\n let done := 0\n for {} iszero(done) {} {\n for {} and(iszero(eq(byte(0, mload(cursor)), commentEndSequenceStart)), lt(cursor, max)) {} {\n cursor := add(cursor, 1)\n }\n // We have found the start of the end sequence. Now check the\n // end sequence is correct.\n cursor := add(cursor, 1)\n // Only exit the loop if the end sequence is correct. We don't\n // move the cursor forward unless we haven exact match on the\n // end byte. E.g. consider the sequence `/** comment **/`.\n if or(eq(byte(0, mload(cursor)), commentEndSequenceEnd), iszero(lt(cursor, max))) {\n done := 1\n cursor := add(cursor, 1)\n }\n }\n }\n // If the cursor is past the max we either never even started an end\n // sequence, or we started parsing an end sequence but couldn't complete\n // it. Either way, the comment is malformed, and the parser is OOB.\n if (cursor > max) {\n revert ParserOutOfBounds();\n }\n return cursor;\n }\n\n //slither-disable-next-line cyclomatic-complexity\n function parse(bytes memory data, bytes memory meta)\n internal\n pure\n returns (bytes memory bytecode, uint256[] memory)\n {\n unchecked {\n ParseState memory state = LibParseState.newState();\n if (data.length > 0) {\n bytes32 word;\n uint256 cursor;\n uint256 end;\n uint256 char;\n assembly (\"memory-safe\") {\n cursor := add(data, 0x20)\n end := add(cursor, mload(data))\n }\n while (cursor < end) {\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n\n // LHS\n if (state.fsm & FSM_RHS_MASK == 0) {\n if (char & CMASK_LHS_STACK_HEAD > 0) {\n // if yang we can't start new stack item\n if (state.fsm & FSM_YANG_MASK > 0) {\n revert UnexpectedLHSChar(parseErrorOffset(data, cursor));\n }\n\n // Named stack item.\n if (char & CMASK_IDENTIFIER_HEAD > 0) {\n (cursor, word) = parseWord(cursor, CMASK_LHS_STACK_TAIL);\n (bool exists, uint256 index) = state.pushStackName(word);\n (index);\n // If the stack name already exists, then we\n // revert as shadowing is not allowed.\n if (exists) {\n revert DuplicateLHSItem(parseErrorOffset(data, cursor));\n }\n }\n // Anon stack item.\n else {\n cursor = skipMask(cursor + 1, end, CMASK_LHS_STACK_TAIL);\n }\n // Bump the index regardless of whether the stack\n // item is named or not.\n state.topLevel1++;\n state.lineTracker++;\n\n // Set yang as we are now building a stack item.\n // We are also no longer interstitial\n state.fsm = (state.fsm | FSM_YANG_MASK | FSM_ACTIVE_SOURCE_MASK) & ~FSM_INTERSTITIAL_MASK;\n } else if (char & CMASK_WHITESPACE != 0) {\n cursor = skipMask(cursor + 1, end, CMASK_WHITESPACE);\n // Set ying as we now open to possibilities.\n state.fsm &= ~FSM_YANG_MASK;\n } else if (char & CMASK_LHS_RHS_DELIMITER != 0) {\n // Set RHS and yin. Move out of the interstitial if\n // we haven't already.\n state.fsm = (state.fsm | FSM_RHS_MASK | FSM_ACTIVE_SOURCE_MASK)\n & ~(FSM_YANG_MASK | FSM_INTERSTITIAL_MASK);\n cursor++;\n } else if (char & CMASK_COMMENT_HEAD != 0) {\n if (state.fsm & FSM_INTERSTITIAL_MASK == 0) {\n revert UnexpectedComment(parseErrorOffset(data, cursor));\n }\n cursor = skipComment(data, cursor);\n // Set yang for comments to force a little breathing\n // room between comments and the next item.\n state.fsm |= FSM_YANG_MASK;\n } else {\n revert UnexpectedLHSChar(parseErrorOffset(data, cursor));\n }\n }\n // RHS\n else {\n if (char & CMASK_RHS_WORD_HEAD > 0) {\n // If yang we can't start a new word.\n if (state.fsm & FSM_YANG_MASK > 0) {\n revert UnexpectedRHSChar(parseErrorOffset(data, cursor));\n }\n\n (cursor, word) = parseWord(cursor, CMASK_RHS_WORD_TAIL);\n\n // First check if this word is in meta.\n (\n bool exists,\n uint256 opcodeIndex,\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParser\n ) = LibParseMeta.lookupWord(meta, state.operandParsers, word);\n if (exists) {\n Operand operand;\n (cursor, operand) = operandParser(state.literalParsers, data, cursor);\n state.pushOpToSource(opcodeIndex, operand);\n // This is a real word so we expect to see parens\n // after it.\n state.fsm |= FSM_WORD_END_MASK;\n }\n // Fallback to LHS items.\n else {\n (exists, opcodeIndex) = LibParseStackName.stackNameIndex(state, word);\n if (exists) {\n state.pushOpToSource(OPCODE_STACK, Operand.wrap(opcodeIndex));\n // Need to process highwater here because we\n // don't have any parens to open or close.\n state.highwater();\n } else {\n revert UnknownWord(parseErrorOffset(data, cursor));\n }\n }\n\n state.fsm |= FSM_YANG_MASK;\n }\n // If this is the end of a word we MUST start a paren.\n else if (state.fsm & FSM_WORD_END_MASK > 0) {\n if (char & CMASK_LEFT_PAREN == 0) {\n revert ExpectedLeftParen(parseErrorOffset(data, cursor));\n }\n // Increase the paren depth by 1.\n // i.e. move the byte offset by 3\n // There MAY be garbage at this new offset due to\n // a previous paren group being deallocated. The\n // deallocation process writes the input counter\n // to zero but leaves a garbage word in place, with\n // the expectation that it will be overwritten by\n // the next paren group.\n uint256 newParenOffset;\n assembly (\"memory-safe\") {\n newParenOffset := add(byte(0, mload(add(state, 0x60))), 3)\n mstore8(add(state, 0x60), newParenOffset)\n }\n // first 2 bytes are reserved, then remaining 62\n // bytes are for paren groups, so the offset MUST NOT\n // imply writing to the 63rd byte.\n if (newParenOffset > 59) {\n revert ParenOverflow();\n }\n cursor++;\n\n // We've moved past the paren, so we are no longer at\n // the end of a word and are yin.\n state.fsm &= ~(FSM_WORD_END_MASK | FSM_YANG_MASK);\n } else if (char & CMASK_RIGHT_PAREN > 0) {\n uint256 parenOffset;\n assembly (\"memory-safe\") {\n parenOffset := byte(0, mload(add(state, 0x60)))\n }\n if (parenOffset == 0) {\n revert UnexpectedRightParen(parseErrorOffset(data, cursor));\n }\n // Decrease the paren depth by 1.\n // i.e. move the byte offset by -3.\n // This effectively deallocates the paren group, so\n // write the input counter out to the operand pointed\n // to by the pointer we deallocated.\n assembly (\"memory-safe\") {\n // State field offset.\n let stateOffset := add(state, 0x60)\n parenOffset := sub(parenOffset, 3)\n mstore8(stateOffset, parenOffset)\n mstore8(\n // Add 2 for the reserved bytes to the offset\n // then read top 16 bits from the pointer.\n // Add 1 to sandwitch the inputs byte between\n // the opcode index byte and the operand low\n // bytes.\n add(1, shr(0xf0, mload(add(add(stateOffset, 2), parenOffset)))),\n // Store the input counter, which is 2 bytes\n // after the operand write pointer.\n byte(0, mload(add(add(stateOffset, 4), parenOffset)))\n )\n }\n state.highwater();\n cursor++;\n } else if (char & CMASK_WHITESPACE > 0) {\n cursor = skipMask(cursor + 1, end, CMASK_WHITESPACE);\n // Set yin as we now open to possibilities.\n state.fsm &= ~FSM_YANG_MASK;\n }\n // Handle all literals.\n else if (char & CMASK_LITERAL_HEAD > 0) {\n cursor = state.pushLiteral(data, cursor);\n state.highwater();\n // We are yang now. Need the next char to release to\n // yin.\n state.fsm |= FSM_YANG_MASK;\n } else if (char & CMASK_EOL > 0) {\n state.endLine(data, cursor);\n cursor++;\n }\n // End of source.\n else if (char & CMASK_EOS > 0) {\n state.endLine(data, cursor);\n state.endSource();\n cursor++;\n\n state.fsm = FSM_DEFAULT;\n }\n // Comments aren't allowed in the RHS but we can give a\n // nicer error message than the default.\n else if (char & CMASK_COMMENT_HEAD != 0) {\n revert UnexpectedComment(parseErrorOffset(data, cursor));\n } else {\n revert UnexpectedRHSChar(parseErrorOffset(data, cursor));\n }\n }\n }\n if (cursor != end) {\n revert ParserOutOfBounds();\n }\n if (state.fsm & FSM_ACTIVE_SOURCE_MASK != 0) {\n revert MissingFinalSemi(parseErrorOffset(data, cursor));\n }\n }\n return (state.buildBytecode(), state.buildConstants());\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseLiteral.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibParseCMask.sol\";\nimport \"./LibParse.sol\";\n\n/// The parser tried to bound an unsupported literal that we have no type for.\nerror UnsupportedLiteralType(uint256 offset);\n\n/// Encountered a literal that is larger than supported.\nerror HexLiteralOverflow(uint256 offset);\n\n/// Encountered a zero length hex literal.\nerror ZeroLengthHexLiteral(uint256 offset);\n\n/// Encountered an odd sized hex literal.\nerror OddLengthHexLiteral(uint256 offset);\n\n/// Encountered a hex literal with an invalid character.\nerror MalformedHexLiteral(uint256 offset);\n\n/// Encountered a decimal literal that is larger than supported.\nerror DecimalLiteralOverflow(uint256 offset);\n\n/// Encountered a decimal literal with an exponent that has too many or no\n/// digits.\nerror MalformedExponentDigits(uint256 offset);\n\n/// Encountered a zero length decimal literal.\nerror ZeroLengthDecimal(uint256 offset);\n\n/// @dev The type of a literal is both a unique value and a literal offset used\n/// to index into the literal parser array as a uint256.\nuint256 constant LITERAL_TYPE_INTEGER_HEX = 0;\n/// @dev The type of a literal is both a unique value and a literal offset used\n/// to index into the literal parser array as a uint256.\nuint256 constant LITERAL_TYPE_INTEGER_DECIMAL = 0x10;\n\nlibrary LibParseLiteral {\n function buildLiteralParsers() internal pure returns (uint256 literalParsers) {\n // Register all the literal parsers in the parse state. Each is a 16 bit\n // function pointer so we can have up to 16 literal types. This needs to\n // be done at runtime because the library code doesn't know the bytecode\n // offsets of the literal parsers until it is compiled into a contract.\n {\n function(bytes memory, uint256, uint256) pure returns (uint256) literalParserHex =\n LibParseLiteral.parseLiteralHex;\n uint256 parseLiteralHexOffset = LITERAL_TYPE_INTEGER_HEX;\n function(bytes memory, uint256, uint256) pure returns (uint256) literalParserDecimal =\n LibParseLiteral.parseLiteralDecimal;\n uint256 parseLiteralDecimalOffset = LITERAL_TYPE_INTEGER_DECIMAL;\n\n assembly (\"memory-safe\") {\n literalParsers :=\n or(shl(parseLiteralHexOffset, literalParserHex), shl(parseLiteralDecimalOffset, literalParserDecimal))\n }\n }\n }\n\n /// Find the bounds for some literal at the cursor. The caller is responsible\n /// for checking that the cursor is at the start of a literal. As each\n /// literal type has a different format, this function returns the bounds\n /// for the literal and the type of the literal. The bounds are:\n /// - innerStart: the start of the literal, e.g. after the 0x in 0x1234\n /// - innerEnd: the end of the literal, e.g. after the 1234 in 0x1234\n /// - outerEnd: the end of the literal including any suffixes, MAY be the\n /// same as innerEnd if there is no suffix.\n /// The outerStart is the cursor, so it is not returned.\n /// @param cursor The start of the literal.\n /// @return The literal parser. This function can be called to convert the\n /// bounds into a uint256 value.\n /// @return The inner start.\n /// @return The inner end.\n /// @return The outer end.\n function boundLiteral(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (function(bytes memory, uint256, uint256) pure returns (uint256), uint256, uint256, uint256)\n {\n unchecked {\n uint256 word;\n uint256 head;\n assembly (\"memory-safe\") {\n word := mload(cursor)\n //slither-disable-next-line incorrect-shift\n head := shl(byte(0, word), 1)\n }\n\n // numeric literal head is 0-9\n if (head & CMASK_NUMERIC_LITERAL_HEAD != 0) {\n uint256 dispatch;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n dispatch := shl(byte(1, word), 1)\n }\n\n // hexadecimal literal dispatch is 0x\n if ((head | dispatch) == CMASK_LITERAL_HEX_DISPATCH) {\n uint256 innerStart = cursor + 2;\n uint256 innerEnd = innerStart;\n {\n uint256 hexCharMask = CMASK_HEX;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n for {} iszero(iszero(and(shl(byte(0, mload(innerEnd)), 1), hexCharMask))) {\n innerEnd := add(innerEnd, 1)\n } {}\n }\n }\n\n function(bytes memory, uint256, uint256) pure returns (uint256) parser;\n {\n uint256 p = (literalParsers >> LITERAL_TYPE_INTEGER_HEX) & 0xFFFF;\n assembly {\n parser := p\n }\n }\n {\n uint256 endHex;\n assembly (\"memory-safe\") {\n endHex := add(data, add(mload(data), 0x20))\n }\n if (innerEnd > endHex) {\n revert ParserOutOfBounds();\n }\n }\n return (parser, innerStart, innerEnd, innerEnd);\n }\n // decimal is the fallback as continuous numeric digits 0-9.\n else {\n uint256 innerStart = cursor;\n // We know the head is a numeric so we can move past it.\n uint256 innerEnd = innerStart + 1;\n uint256 ePosition = 0;\n\n {\n uint256 decimalCharMask = CMASK_NUMERIC_0_9;\n uint256 eMask = CMASK_E_NOTATION;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n for {} iszero(iszero(and(shl(byte(0, mload(innerEnd)), 1), decimalCharMask))) {\n innerEnd := add(innerEnd, 1)\n } {}\n\n // If we're now pointing at an e notation, then we need\n // to move past it. Negative exponents are not supported.\n //slither-disable-next-line incorrect-shift\n if iszero(iszero(and(shl(byte(0, mload(innerEnd)), 1), eMask))) {\n ePosition := innerEnd\n innerEnd := add(innerEnd, 1)\n\n // Move past the exponent digits.\n //slither-disable-next-line incorrect-shift\n for {} iszero(iszero(and(shl(byte(0, mload(innerEnd)), 1), decimalCharMask))) {\n innerEnd := add(innerEnd, 1)\n } {}\n }\n }\n }\n if (ePosition != 0 && (innerEnd > ePosition + 3 || innerEnd == ePosition + 1)) {\n revert MalformedExponentDigits(LibParse.parseErrorOffset(data, ePosition));\n }\n\n function(bytes memory, uint256, uint256) pure returns (uint256) parser;\n {\n uint256 p = (literalParsers >> LITERAL_TYPE_INTEGER_DECIMAL) & 0xFFFF;\n assembly {\n parser := p\n }\n }\n {\n uint256 endDecimal;\n assembly (\"memory-safe\") {\n endDecimal := add(data, add(mload(data), 0x20))\n }\n if (innerEnd > endDecimal) {\n revert ParserOutOfBounds();\n }\n }\n return (parser, innerStart, innerEnd, innerEnd);\n }\n }\n\n uint256 endUnknown;\n assembly (\"memory-safe\") {\n endUnknown := add(data, add(mload(data), 0x20))\n }\n if (cursor >= endUnknown) {\n revert ParserOutOfBounds();\n } else {\n revert UnsupportedLiteralType(LibParse.parseErrorOffset(data, cursor));\n }\n }\n }\n\n /// Algorithm for parsing hexadecimal literals:\n /// - start at the end of the literal\n /// - for each character:\n /// - convert the character to a nybble\n /// - shift the nybble into the total at the correct position\n /// (4 bits per nybble)\n /// - return the total\n function parseLiteralHex(bytes memory data, uint256 start, uint256 end) internal pure returns (uint256 value) {\n unchecked {\n uint256 length = end - start;\n if (length > 0x40) {\n revert HexLiteralOverflow(LibParse.parseErrorOffset(data, start));\n } else if (length == 0) {\n revert ZeroLengthHexLiteral(LibParse.parseErrorOffset(data, start));\n } else if (length % 2 == 1) {\n revert OddLengthHexLiteral(LibParse.parseErrorOffset(data, start));\n } else {\n uint256 cursor = end - 1;\n uint256 valueOffset = 0;\n while (cursor >= start) {\n uint256 hexCharByte;\n assembly (\"memory-safe\") {\n hexCharByte := byte(0, mload(cursor))\n }\n //slither-disable-next-line incorrect-shift\n uint256 hexChar = 1 << hexCharByte;\n\n uint256 nybble;\n // 0-9\n if (hexChar & CMASK_NUMERIC_0_9 != 0) {\n nybble = hexCharByte - uint256(uint8(bytes1(\"0\")));\n }\n // a-f\n else if (hexChar & CMASK_LOWER_ALPHA_A_F != 0) {\n nybble = hexCharByte - uint256(uint8(bytes1(\"a\"))) + 10;\n }\n // A-F\n else if (hexChar & CMASK_UPPER_ALPHA_A_F != 0) {\n nybble = hexCharByte - uint256(uint8(bytes1(\"A\"))) + 10;\n } else {\n revert MalformedHexLiteral(LibParse.parseErrorOffset(data, cursor));\n }\n\n value |= nybble << valueOffset;\n valueOffset += 4;\n cursor--;\n }\n }\n }\n }\n\n /// Algorithm for parsing decimal literals:\n /// - start at the end of the literal\n /// - for each digit:\n /// - multiply the digit by 10^digit position\n /// - add the result to the total\n /// - return the total\n ///\n /// This algorithm is ONLY safe if the caller has already checked that the\n /// start/end span a non-zero length of valid decimal chars. The caller\n /// can most easily do this by using the `boundLiteral` function.\n ///\n /// Unsafe behavior is undefined and can easily result in out of bounds\n /// reads as there are no checks that start/end are within `data`.\n function parseLiteralDecimal(bytes memory data, uint256 start, uint256 end) internal pure returns (uint256 value) {\n unchecked {\n // Tracks which digit we're on.\n uint256 cursor;\n // The ASCII byte can be translated to a numeric digit by subtracting\n // the digit offset.\n uint256 digitOffset = uint256(uint8(bytes1(\"0\")));\n // Tracks the exponent of the current digit. Can start above 0 if\n // the literal is in e notation.\n uint256 exponent;\n {\n uint256 word;\n //slither-disable-next-line similar-names\n uint256 decimalCharByte;\n uint256 length = end - start;\n assembly (\"memory-safe\") {\n word := mload(sub(end, 3))\n decimalCharByte := byte(0, word)\n }\n // If the last 3 bytes are e notation, then we need to parse\n // the exponent as a 2 digit number.\n //slither-disable-next-line incorrect-shift\n if (length > 3 && ((1 << decimalCharByte) & CMASK_E_NOTATION) != 0) {\n cursor = end - 4;\n assembly (\"memory-safe\") {\n exponent := add(sub(byte(2, word), digitOffset), mul(sub(byte(1, word), digitOffset), 10))\n }\n } else {\n assembly (\"memory-safe\") {\n decimalCharByte := byte(1, word)\n }\n // If the last 2 bytes are e notation, then we need to parse\n // the exponent as a 1 digit number.\n //slither-disable-next-line incorrect-shift\n if (length > 2 && ((1 << decimalCharByte) & CMASK_E_NOTATION) != 0) {\n cursor = end - 3;\n assembly (\"memory-safe\") {\n exponent := sub(byte(2, word), digitOffset)\n }\n }\n // Otherwise, we're not in e notation and we can start at the\n // end of the literal with 0 starting exponent.\n else if (length > 0) {\n cursor = end - 1;\n exponent = 0;\n } else {\n revert ZeroLengthDecimal(LibParse.parseErrorOffset(data, start));\n }\n }\n }\n\n // Anything under 10^77 is safe to raise to its power of 10 without\n // overflowing a uint256.\n while (cursor >= start && exponent < 77) {\n // We don't need to check the bounds of the byte because\n // we know it is a decimal literal as long as the bounds\n // are correct (calculated in `boundLiteral`).\n assembly (\"memory-safe\") {\n value := add(value, mul(sub(byte(0, mload(cursor)), digitOffset), exp(10, exponent)))\n }\n exponent++;\n cursor--;\n }\n\n // If we didn't consume the entire literal, then we have\n // to check if the remaining digit is safe to multiply\n // by 10 without overflowing a uint256.\n if (cursor >= start) {\n {\n uint256 digit;\n assembly (\"memory-safe\") {\n digit := sub(byte(0, mload(cursor)), digitOffset)\n }\n // If the digit is greater than 1, then we know that\n // multiplying it by 10^77 will overflow a uint256.\n if (digit > 1) {\n revert DecimalLiteralOverflow(LibParse.parseErrorOffset(data, cursor));\n } else {\n uint256 scaled = digit * (10 ** exponent);\n if (value + scaled < value) {\n revert DecimalLiteralOverflow(LibParse.parseErrorOffset(data, cursor));\n }\n value += scaled;\n }\n cursor--;\n }\n\n {\n // If we didn't consume the entire literal, then only\n // leading zeros are allowed.\n while (cursor >= start) {\n //slither-disable-next-line similar-names\n uint256 decimalCharByte;\n assembly (\"memory-safe\") {\n decimalCharByte := byte(0, mload(cursor))\n }\n if (decimalCharByte != uint256(uint8(bytes1(\"0\")))) {\n revert DecimalLiteralOverflow(LibParse.parseErrorOffset(data, cursor));\n }\n cursor--;\n }\n }\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/utils/math/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1, \"Math: mulDiv overflow\");\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/UD60x18.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/lib/LibWillOverflow.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./FixedPointDecimalConstants.sol\";\n\n/// @title LibWillOverflow\n/// @notice Often we want to know if some calculation is expected to overflow.\n/// Notably this is important for fuzzing as we have to be able to set\n/// expectations for arbitrary inputs over as broad a range of values as\n/// possible.\nlibrary LibWillOverflow {\n /// Relevant logic taken direct from Open Zeppelin.\n /// @param x As per Open Zeppelin.\n /// @param y As per Open Zeppelin.\n /// @param denominator As per Open Zeppelin.\n /// @return True if mulDiv will overflow.\n function mulDivWillOverflow(uint256 x, uint256 y, uint256 denominator) internal pure returns (bool) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n return !(denominator > prod1);\n }\n\n /// True if `scaleUp` will overflow.\n /// @param a The number to scale up.\n /// @param scaleBy The number of orders of magnitude to scale up by.\n /// @return True if `scaleUp` will overflow.\n function scaleUpWillOverflow(uint256 a, uint256 scaleBy) internal pure returns (bool) {\n unchecked {\n if (a == 0) {\n return false;\n }\n if (scaleBy >= OVERFLOW_RESCALE_OOMS) {\n return true;\n }\n uint256 b = 10 ** scaleBy;\n uint256 c = a * b;\n return c / b != a;\n }\n }\n\n /// True if `scaleDown` will round.\n /// @param a The number to scale down.\n /// @param scaleDownBy The number of orders of magnitude to scale down by.\n /// @return True if `scaleDown` will round.\n function scaleDownWillRound(uint256 a, uint256 scaleDownBy) internal pure returns (bool) {\n if (scaleDownBy >= OVERFLOW_RESCALE_OOMS) {\n return a != 0;\n }\n uint256 b = 10 ** scaleDownBy;\n uint256 c = a / b;\n // Discovering precision loss is the whole point of this check so the\n // thing slither is complaining about is exactly what we're measuring.\n //slither-disable-next-line divide-before-multiply\n return c * b != a;\n }\n\n /// True if `scale18` will overflow.\n /// @param a The number to scale.\n /// @param decimals The current number of decimals of `a`.\n /// @param flags The flags to use.\n /// @return True if `scale18` will overflow.\n function scale18WillOverflow(uint256 a, uint256 decimals, uint256 flags) internal pure returns (bool) {\n if (decimals < FIXED_POINT_DECIMALS && (FLAG_SATURATE & flags == 0)) {\n return scaleUpWillOverflow(a, FIXED_POINT_DECIMALS - decimals);\n } else {\n return false;\n }\n }\n\n /// True if `scaleN` will overflow.\n /// @param a The number to scale.\n /// @param decimals The current number of decimals of `a`.\n /// @param flags The flags to use.\n /// @return True if `scaleN` will overflow.\n function scaleNWillOverflow(uint256 a, uint256 decimals, uint256 flags) internal pure returns (bool) {\n if (decimals > FIXED_POINT_DECIMALS && (FLAG_SATURATE & flags == 0)) {\n return scaleUpWillOverflow(a, decimals - FIXED_POINT_DECIMALS);\n } else {\n return false;\n }\n }\n\n /// True if `scaleBy` will overflow.\n /// @param a The number to scale.\n /// @param scaleBy The number of orders of magnitude to scale by.\n /// @param flags The flags to use.\n /// @return True if `scaleBy` will overflow.\n function scaleByWillOverflow(uint256 a, int8 scaleBy, uint256 flags) internal pure returns (bool) {\n // If we're scaling up and not saturating check the overflow.\n if (scaleBy > 0 && (FLAG_SATURATE & flags == 0)) {\n return scaleUpWillOverflow(a, uint8(scaleBy));\n } else {\n return false;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/lib/LibFixedPointDecimalScale.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./FixedPointDecimalConstants.sol\";\n\n/// @title FixedPointDecimalScale\n/// @notice Tools to scale unsigned values to/from 18 decimal fixed point\n/// representation.\n///\n/// Overflows error and underflows are rounded up or down explicitly.\n///\n/// The max uint256 as decimal is roughly 1e77 so scaling values comparable to\n/// 1e18 is unlikely to ever overflow in most contexts. For a typical use case\n/// involving tokens, the entire supply of a token rescaled up a full 18 decimals\n/// would still put it \"only\" in the region of ~1e40 which has a full 30 orders\n/// of magnitude buffer before running into saturation issues. However, there's\n/// no theoretical reason that a token or any other use case couldn't use large\n/// numbers or extremely precise decimals that would push this library to\n/// overflow point, so it MUST be treated with caution around the edge cases.\n///\n/// Scaling down ANY fixed point decimal also reduces the precision which can\n/// lead to dust or in the worst case trapped funds if subsequent subtraction\n/// overflows a rounded-down number. Consider using saturating subtraction for\n/// safety against previously downscaled values, and whether trapped dust is a\n/// significant issue. If you need to retain full/arbitrary precision in the case\n/// of downscaling DO NOT use this library.\n///\n/// All rescaling and/or division operations in this library require a rounding\n/// flag. This allows and forces the caller to specify where dust sits due to\n/// rounding. For example the caller could round up when taking tokens from\n/// `msg.sender` and round down when returning them, ensuring that any dust in\n/// the round trip accumulates in the contract rather than opening an exploit or\n/// reverting and trapping all funds. This is exactly how the ERC4626 vault spec\n/// handles dust and is a good reference point in general. Typically the contract\n/// holding tokens and non-interactive participants should be favoured by\n/// rounding calculations rather than active participants. This is because we\n/// assume that an active participant, e.g. `msg.sender`, knowns something we\n/// don't and is carefully crafting an attack, so we are most conservative and\n/// suspicious of their inputs and actions.\nlibrary LibFixedPointDecimalScale {\n /// Scales `a` up by a specified number of decimals.\n /// @param a The number to scale up.\n /// @param scaleUpBy Number of orders of magnitude to scale `b_` up by.\n /// Errors if overflows.\n /// @return b `a` scaled up by `scaleUpBy`.\n function scaleUp(uint256 a, uint256 scaleUpBy) internal pure returns (uint256 b) {\n // Checked power is expensive so don't do that.\n unchecked {\n b = 10 ** scaleUpBy;\n }\n b = a * b;\n\n // We know exactly when 10 ** X overflows so replay the checked version\n // to get the standard Solidity overflow behaviour. The branching logic\n // here is still ~230 gas cheaper than unconditionally running the\n // overflow checks. We're optimising for standardisation rather than gas\n // in the unhappy revert case.\n if (scaleUpBy >= OVERFLOW_RESCALE_OOMS) {\n b = a == 0 ? 0 : 10 ** scaleUpBy;\n }\n }\n\n /// Identical to `scaleUp` but saturates instead of reverting on overflow.\n /// @param a As per `scaleUp`.\n /// @param scaleUpBy As per `scaleUp`.\n /// @return c As per `scaleUp` but saturates as `type(uint256).max` on\n /// overflow.\n function scaleUpSaturating(uint256 a, uint256 scaleUpBy) internal pure returns (uint256 c) {\n unchecked {\n if (scaleUpBy >= OVERFLOW_RESCALE_OOMS) {\n c = a == 0 ? 0 : type(uint256).max;\n } else {\n // Adapted from saturatingMath.\n // Inlining everything here saves ~250-300+ gas relative to slow.\n uint256 b_ = 10 ** scaleUpBy;\n c = a * b_;\n // Checking b_ here allows us to skip an \"is zero\" check because even\n // 10 ** 0 = 1, so we have a positive lower bound on b_.\n c = c / b_ == a ? c : type(uint256).max;\n }\n }\n }\n\n /// Scales `a` down by a specified number of decimals, rounding down.\n /// Used internally by several other functions in this lib.\n /// @param a The number to scale down.\n /// @param scaleDownBy Number of orders of magnitude to scale `a` down by.\n /// Overflows if greater than 77.\n /// @return c `a` scaled down by `scaleDownBy` and rounded down.\n function scaleDown(uint256 a, uint256 scaleDownBy) internal pure returns (uint256) {\n unchecked {\n return scaleDownBy >= OVERFLOW_RESCALE_OOMS ? 0 : a / (10 ** scaleDownBy);\n }\n }\n\n /// Scales `a` down by a specified number of decimals, rounding up.\n /// Used internally by several other functions in this lib.\n /// @param a The number to scale down.\n /// @param scaleDownBy Number of orders of magnitude to scale `a` down by.\n /// Overflows if greater than 77.\n /// @return c `a` scaled down by `scaleDownBy` and rounded up.\n function scaleDownRoundUp(uint256 a, uint256 scaleDownBy) internal pure returns (uint256 c) {\n unchecked {\n if (scaleDownBy >= OVERFLOW_RESCALE_OOMS) {\n c = a == 0 ? 0 : 1;\n } else {\n uint256 b = 10 ** scaleDownBy;\n c = a / b;\n\n // Intentionally doing a divide before multiply here to detect\n // the need to round up.\n //slither-disable-next-line divide-before-multiply\n if (a != c * b) {\n c += 1;\n }\n }\n }\n }\n\n /// Scale a fixed point decimal of some scale factor to 18 decimals.\n /// @param a Some fixed point decimal value.\n /// @param decimals The number of fixed decimals of `a`.\n /// @param flags Controls rounding and saturation.\n /// @return `a` scaled to 18 decimals.\n function scale18(uint256 a, uint256 decimals, uint256 flags) internal pure returns (uint256) {\n unchecked {\n if (FIXED_POINT_DECIMALS > decimals) {\n uint256 scaleUpBy = FIXED_POINT_DECIMALS - decimals;\n if (flags & FLAG_SATURATE > 0) {\n return scaleUpSaturating(a, scaleUpBy);\n } else {\n return scaleUp(a, scaleUpBy);\n }\n } else if (decimals > FIXED_POINT_DECIMALS) {\n uint256 scaleDownBy = decimals - FIXED_POINT_DECIMALS;\n if (flags & FLAG_ROUND_UP > 0) {\n return scaleDownRoundUp(a, scaleDownBy);\n } else {\n return scaleDown(a, scaleDownBy);\n }\n } else {\n return a;\n }\n }\n }\n\n /// Scale an 18 decimal fixed point value to some other scale.\n /// Exactly the inverse behaviour of `scale18`. Where `scale18` would scale\n /// up, `scaleN` scales down, and vice versa.\n /// @param a An 18 decimal fixed point number.\n /// @param targetDecimals The new scale of `a`.\n /// @param flags Controls rounding and saturation.\n /// @return `a` rescaled from 18 to `targetDecimals`.\n function scaleN(uint256 a, uint256 targetDecimals, uint256 flags) internal pure returns (uint256) {\n unchecked {\n if (FIXED_POINT_DECIMALS > targetDecimals) {\n uint256 scaleDownBy = FIXED_POINT_DECIMALS - targetDecimals;\n if (flags & FLAG_ROUND_UP > 0) {\n return scaleDownRoundUp(a, scaleDownBy);\n } else {\n return scaleDown(a, scaleDownBy);\n }\n } else if (targetDecimals > FIXED_POINT_DECIMALS) {\n uint256 scaleUpBy = targetDecimals - FIXED_POINT_DECIMALS;\n if (flags & FLAG_SATURATE > 0) {\n return scaleUpSaturating(a, scaleUpBy);\n } else {\n return scaleUp(a, scaleUpBy);\n }\n } else {\n return a;\n }\n }\n }\n\n /// Scale a fixed point up or down by `ooms` orders of magnitude.\n /// Notably `scaleBy` is a SIGNED integer so scaling down by negative OOMS\n /// IS supported.\n /// @param a Some integer of any scale.\n /// @param ooms OOMs to scale `a` up or down by. This is a SIGNED int8\n /// which means it can be negative, and also means that sign extension MUST\n /// be considered if changing it to another type.\n /// @param flags Controls rounding and saturating.\n /// @return `a` rescaled according to `ooms`.\n function scaleBy(uint256 a, int8 ooms, uint256 flags) internal pure returns (uint256) {\n unchecked {\n if (ooms > 0) {\n if (flags & FLAG_SATURATE > 0) {\n return scaleUpSaturating(a, uint8(ooms));\n } else {\n return scaleUp(a, uint8(ooms));\n }\n } else if (ooms < 0) {\n // We know that ooms is negative here, so we can convert it\n // to an absolute value with bitwise NOT + 1.\n // This is slightly less gas than multiplying by negative 1 and\n // casting it, and handles the case of -128 without overflow.\n uint8 scaleDownBy = uint8(~ooms) + 1;\n if (flags & FLAG_ROUND_UP > 0) {\n return scaleDownRoundUp(a, scaleDownBy);\n } else {\n return scaleDown(a, scaleDownBy);\n }\n } else {\n return a;\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/sol.lib.binmaskflag/src/Binary.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev Binary 1.\nuint256 constant B_1 = 2 ** 1 - 1;\n/// @dev Binary 11.\nuint256 constant B_11 = 2 ** 2 - 1;\n/// @dev Binary 111.\nuint256 constant B_111 = 2 ** 3 - 1;\n/// @dev Binary 1111.\nuint256 constant B_1111 = 2 ** 4 - 1;\n/// @dev Binary 11111.\nuint256 constant B_11111 = 2 ** 5 - 1;\n/// @dev Binary 111111.\nuint256 constant B_111111 = 2 ** 6 - 1;\n/// @dev Binary 1111111.\nuint256 constant B_1111111 = 2 ** 7 - 1;\n/// @dev Binary 11111111.\nuint256 constant B_11111111 = 2 ** 8 - 1;\n/// @dev Binary 111111111.\nuint256 constant B_111111111 = 2 ** 9 - 1;\n/// @dev Binary 1111111111.\nuint256 constant B_1111111111 = 2 ** 10 - 1;\n/// @dev Binary 11111111111.\nuint256 constant B_11111111111 = 2 ** 11 - 1;\n/// @dev Binary 111111111111.\nuint256 constant B_111111111111 = 2 ** 12 - 1;\n/// @dev Binary 1111111111111.\nuint256 constant B_1111111111111 = 2 ** 13 - 1;\n/// @dev Binary 11111111111111.\nuint256 constant B_11111111111111 = 2 ** 14 - 1;\n/// @dev Binary 111111111111111.\nuint256 constant B_111111111111111 = 2 ** 15 - 1;\n/// @dev Binary 1111111111111111.\nuint256 constant B_1111111111111111 = 2 ** 16 - 1;\n\n/// @dev Bitmask for 1 bit.\nuint256 constant MASK_1BIT = B_1;\n/// @dev Bitmask for 2 bits.\nuint256 constant MASK_2BIT = B_11;\n/// @dev Bitmask for 3 bits.\nuint256 constant MASK_3BIT = B_111;\n/// @dev Bitmask for 4 bits.\nuint256 constant MASK_4BIT = B_1111;\n/// @dev Bitmask for 5 bits.\nuint256 constant MASK_5BIT = B_11111;\n/// @dev Bitmask for 6 bits.\nuint256 constant MASK_6BIT = B_111111;\n/// @dev Bitmask for 7 bits.\nuint256 constant MASK_7BIT = B_1111111;\n/// @dev Bitmask for 8 bits.\nuint256 constant MASK_8BIT = B_11111111;\n/// @dev Bitmask for 9 bits.\nuint256 constant MASK_9BIT = B_111111111;\n/// @dev Bitmask for 10 bits.\nuint256 constant MASK_10BIT = B_1111111111;\n/// @dev Bitmask for 11 bits.\nuint256 constant MASK_11BIT = B_11111111111;\n/// @dev Bitmask for 12 bits.\nuint256 constant MASK_12BIT = B_111111111111;\n/// @dev Bitmask for 13 bits.\nuint256 constant MASK_13BIT = B_1111111111111;\n/// @dev Bitmask for 14 bits.\nuint256 constant MASK_14BIT = B_11111111111111;\n/// @dev Bitmask for 15 bits.\nuint256 constant MASK_15BIT = B_111111111111111;\n/// @dev Bitmask for 16 bits.\nuint256 constant MASK_16BIT = B_1111111111111111;\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/uniswap/LibUniswapV2.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"v2-core/interfaces/IUniswapV2Pair.sol\";\nimport \"v2-core/interfaces/IUniswapV2Factory.sol\";\n\n/// UniswapV2Library from uniswap/v2-periphery is compiled with a version of\n/// SafeMath that is locked to Solidity 0.6.x which means we can't use it in\n/// Solidity 0.8.x. This is a copy of the library with the SafeMath dependency\n/// removed, using Solidity's built-in overflow checking.\n/// Some minor modifications have been made to the reference functions. These\n/// are noted in the comments and/or made explicit by descriptively renaming the\n/// functions to differentiate them from the original.\nlibrary LibUniswapV2 {\n /// Copy of UniswapV2Library.sortTokens for solidity 0.8.x support.\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\n require(tokenA != tokenB, \"UniswapV2Library: IDENTICAL_ADDRESSES\");\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n require(token0 != address(0), \"UniswapV2Library: ZERO_ADDRESS\");\n }\n\n /// Copy of UniswapV2Library.pairFor for solidity 0.8.x support.\n function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {\n (address token0, address token1) = sortTokens(tokenA, tokenB);\n pair = address(\n uint160(\n uint256(\n keccak256(\n abi.encodePacked(\n hex\"ff\",\n factory,\n keccak256(abi.encodePacked(token0, token1)),\n hex\"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f\" // init code hash\n )\n )\n )\n )\n );\n }\n\n /// UniswapV2Library.sol has a `getReserves` function but it discards the\n /// timestamp that the pair reserves were last updated at. This function\n /// duplicates the logic of `getReserves` but returns the timestamp as well.\n function getReservesWithTime(address factory, address tokenA, address tokenB)\n internal\n view\n returns (uint256 reserveA, uint256 reserveB, uint256 timestamp)\n {\n (address token0,) = sortTokens(tokenA, tokenB);\n // Reference implementation uses `pairFor` but for some reason this\n // doesn't seem to work on sushi's factory. Using `getPair` instead.\n // @todo investigate the discrepency.\n address pair = IUniswapV2Factory(factory).getPair(tokenA, tokenB);\n (uint256 reserve0, uint256 reserve1, uint256 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();\n (reserveA, reserveB, timestamp) =\n tokenA == token0 ? (reserve0, reserve1, blockTimestampLast) : (reserve1, reserve0, blockTimestampLast);\n }\n\n /// Copy of UniswapV2Library.getAmountIn for solidity 0.8.x support.\n function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)\n internal\n pure\n returns (uint256 amountIn)\n {\n require(amountOut > 0, \"UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 numerator = reserveIn * amountOut * 1000;\n uint256 denominator = (reserveOut - amountOut) * 997;\n amountIn = (numerator / denominator) + 1;\n }\n\n /// Copy of UniswapV2Library.getAmountOut for solidity 0.8.x support.\n function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)\n internal\n pure\n returns (uint256 amountOut)\n {\n require(amountIn > 0, \"UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 amountInWithFee = amountIn * 997;\n uint256 numerator = amountInWithFee * reserveOut;\n uint256 denominator = (reserveIn * 1000) + amountInWithFee;\n amountOut = numerator / denominator;\n }\n\n /// Bundles the key library logic together to produce amounts based on tokens\n /// and amounts out rather than needing to handle reserves directly.\n /// Also maps 0 amountOut to 0 amountIn unconditionally, which is different\n /// to the reference implementation.\n function getAmountInByTokenWithTime(address factory, address tokenIn, address tokenOut, uint256 amountOut)\n internal\n view\n returns (uint256 amountIn, uint256 timestamp)\n {\n (uint256 reserveIn, uint256 reserveOut, uint256 reserveTimestamp) =\n getReservesWithTime(factory, tokenIn, tokenOut);\n // Perform the 0 amountOut to 0 amountIn mapping after getting the\n // reserves so that we still error on invalid reserves.\n amountIn = amountOut == 0 ? 0 : getAmountIn(amountOut, reserveIn, reserveOut);\n timestamp = reserveTimestamp;\n }\n\n /// Bundles the key library logic together to produce amounts based on tokens\n /// and amounts in rather than needing to handle reserves directly.\n /// Also maps 0 amountIn to 0 amountOut unconditionally, which is different\n /// to the reference implementation.\n function getAmountOutByTokenWithTime(address factory, address tokenIn, address tokenOut, uint256 amountIn)\n internal\n view\n returns (uint256 amountOut, uint256 timestamp)\n {\n (uint256 reserveIn, uint256 reserveOut, uint256 reserveTimestamp) =\n getReservesWithTime(factory, tokenIn, tokenOut);\n // Perform the 0 amountIn to 0 amountOut mapping after getting the\n // reserves so that we still error on invalid reserves.\n amountOut = amountIn == 0 ? 0 : getAmountOut(amountIn, reserveIn, reserveOut);\n timestamp = reserveTimestamp;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseStackName.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibParse.sol\";\n\nlibrary LibParseStackName {\n /// Push a word onto the stack name stack.\n /// @return exists Whether the word already existed.\n /// @return index The new index after the word was pushed. Will be unchanged\n /// if the word already existed.\n function pushStackName(ParseState memory state, bytes32 word) internal pure returns (bool exists, uint256 index) {\n unchecked {\n (exists, index) = stackNameIndex(state, word);\n if (!exists) {\n uint256 fingerprint;\n uint256 ptr;\n uint256 oldStackNames = state.stackNames;\n assembly (\"memory-safe\") {\n ptr := mload(0x40)\n mstore(ptr, word)\n fingerprint := and(keccak256(ptr, 0x20), not(0xFFFFFFFF))\n mstore(ptr, oldStackNames)\n mstore(0x40, add(ptr, 0x20))\n }\n // Add the start of line height to the LHS line parse count.\n uint256 stackLHSIndex = state.topLevel1 & 0xFF;\n state.stackNames = fingerprint | (stackLHSIndex << 0x10) | ptr;\n index = stackLHSIndex + 1;\n }\n }\n }\n\n /// Retrieve the index of a previously pushed stack name.\n function stackNameIndex(ParseState memory state, bytes32 word) internal pure returns (bool exists, uint256 index) {\n uint256 fingerprint;\n uint256 stackNames = state.stackNames;\n uint256 stackNameBloom = state.stackNameBloom;\n uint256 bloom;\n assembly (\"memory-safe\") {\n mstore(0, word)\n fingerprint := shr(0x20, keccak256(0, 0x20))\n //slither-disable-next-line incorrect-shift\n bloom := shl(and(fingerprint, 0xFF), 1)\n\n // If the bloom matches then maybe the stack name is in the stack.\n if and(bloom, stackNameBloom) {\n for { let ptr := and(stackNames, 0xFFFF) } iszero(iszero(ptr)) {\n stackNames := mload(ptr)\n ptr := and(stackNames, 0xFFFF)\n } {\n if eq(fingerprint, shr(0x20, stackNames)) {\n exists := true\n index := and(shr(0x10, stackNames), 0xFFFF)\n break\n }\n }\n }\n }\n state.stackNameBloom = bloom | stackNameBloom;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Casting.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Conversions.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Errors.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Helpers.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n//\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/ValueType.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/lib/FixedPointDecimalConstants.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev The scale of all fixed point math. This is adopting the conventions of\n/// both ETH (wei) and most ERC20 tokens, so is hopefully uncontroversial.\nuint256 constant FIXED_POINT_DECIMALS = 18;\n\n/// @dev Value of \"one\" for fixed point math.\nuint256 constant FIXED_POINT_ONE = 1e18;\n\n/// @dev Calculations MUST round up.\nuint256 constant FLAG_ROUND_UP = 1;\n\n/// @dev Calculations MUST saturate NOT overflow.\nuint256 constant FLAG_SATURATE = 1 << 1;\n\n/// @dev Flags MUST NOT exceed this value.\nuint256 constant FLAG_MAX_INT = FLAG_SATURATE | FLAG_ROUND_UP;\n\n/// @dev Can't represent this many OOMs of decimals in `uint256`.\nuint256 constant OVERFLOW_RESCALE_OOMS = 78;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/v2-core/contracts/interfaces/IUniswapV2Pair.sol": {
"content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n function name() external pure returns (string memory);\n function symbol() external pure returns (string memory);\n function decimals() external pure returns (uint8);\n function totalSupply() external view returns (uint);\n function balanceOf(address owner) external view returns (uint);\n function allowance(address owner, address spender) external view returns (uint);\n\n function approve(address spender, uint value) external returns (bool);\n function transfer(address to, uint value) external returns (bool);\n function transferFrom(address from, address to, uint value) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n function nonces(address owner) external view returns (uint);\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n event Mint(address indexed sender, uint amount0, uint amount1);\n event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint amount0In,\n uint amount1In,\n uint amount0Out,\n uint amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint);\n function factory() external view returns (address);\n function token0() external view returns (address);\n function token1() external view returns (address);\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n function price0CumulativeLast() external view returns (uint);\n function price1CumulativeLast() external view returns (uint);\n function kLast() external view returns (uint);\n\n function mint(address to) external returns (uint liquidity);\n function burn(address to) external returns (uint amount0, uint amount1);\n function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n function skim(address to) external;\n function sync() external;\n\n function initialize(address, address) external;\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/v2-core/contracts/interfaces/IUniswapV2Factory.sol": {
"content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Factory {\n event PairCreated(address indexed token0, address indexed token1, address pair, uint);\n\n function feeTo() external view returns (address);\n function feeToSetter() external view returns (address);\n\n function getPair(address tokenA, address tokenB) external view returns (address pair);\n function allPairs(uint) external view returns (address pair);\n function allPairsLength() external view returns (uint);\n\n function createPair(address tokenA, address tokenB) external returns (address pair);\n\n function setFeeTo(address) external;\n function setFeeToSetter(address) external;\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/Common.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions needed by both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd1x18/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd1x18/ValueType.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/ValueType.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud2x18/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud2x18/ValueType.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd1x18/Casting.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Casting.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Helpers.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than this is truncated to zero.\n if (xInt < -59_794705707972522261) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud2x18/Casting.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd1x18/Errors.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Errors.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and hte intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud2x18/Errors.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n"
}
},
"settings": {
"remappings": [
"@prb/test/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/lib/prb-test/src/",
"bitwise/=lib/rain.flow/lib/rain.interpreter/src/lib/bitwise/",
"bytecode/=lib/rain.flow/lib/rain.interpreter/src/lib/bytecode/",
"caller/=lib/rain.flow/lib/rain.interpreter/src/lib/caller/",
"compile/=lib/rain.flow/lib/rain.interpreter/src/lib/compile/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"eval/=lib/rain.flow/lib/rain.interpreter/src/lib/eval/",
"extern/=lib/rain.flow/lib/rain.interpreter/src/lib/extern/",
"forge-std/=lib/forge-std/src/",
"integrity/=lib/rain.flow/lib/rain.interpreter/src/lib/integrity/",
"ns/=lib/rain.flow/lib/rain.interpreter/src/lib/ns/",
"op/=lib/rain.flow/lib/rain.interpreter/src/lib/op/",
"openzeppelin-contracts-upgradeable/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/",
"openzeppelin/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/contracts/",
"parse/=lib/rain.flow/lib/rain.interpreter/src/lib/parse/",
"prb-math/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/",
"prb-test/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/lib/prb-test/src/",
"rain.chainlink/=lib/rain.flow/lib/rain.interpreter/lib/rain.chainlink/src/",
"rain.datacontract/=lib/rain.flow/lib/rain.interpreter/lib/rain.datacontract/src/",
"rain.erc1820/=lib/rain.flow/lib/rain.interpreter/lib/rain.erc1820/src/",
"rain.extrospection/=lib/rain.flow/lib/rain.factory/lib/rain.extrospection/",
"rain.factory/=lib/rain.flow/lib/rain.factory/",
"rain.flow/=lib/rain.flow/",
"rain.interpreter/=lib/rain.flow/lib/rain.interpreter/",
"rain.lib.hash/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.memkv/lib/rain.lib.hash/src/",
"rain.lib.memkv/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.memkv/src/",
"rain.lib.typecast/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.typecast/src/",
"rain.math.fixedpoint/=lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/",
"rain.math.saturating/=lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/lib/rain.math.saturating/src/",
"rain.metadata/=lib/rain.flow/lib/rain.interpreter/lib/rain.metadata/src/",
"rain.solmem/=lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/",
"sol.lib.binmaskflag/=lib/rain.flow/lib/rain.interpreter/lib/sol.lib.binmaskflag/src/",
"state/=lib/rain.flow/lib/rain.interpreter/src/lib/state/",
"uniswap/=lib/rain.flow/lib/rain.interpreter/src/lib/uniswap/",
"v2-core/=lib/rain.flow/lib/rain.interpreter/lib/v2-core/contracts/",
"v2-periphery/=lib/rain.flow/lib/rain.interpreter/lib/v2-periphery/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}
}}
|
1 | 19,498,589 |
cca09afb3c3ec8d6f50057638f9c0c087b23abb0fbe0bc06b809a1d3bd05b42d
|
84a7c31e47cc76abbee268c6e5367d11ec3bd03507520596cdc944d5e16eefea
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
d9543dc7ac39f540c2b3f5cc92d8542a2d9339c3
|
608060405234801561001057600080fd5b50610372806100206000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806301ffc9a714610046578063669e48aa1461006e578063946aadc6146100a5575b600080fd5b61005961005436600461021e565b6100ba565b60405190151581526020015b60405180910390f35b61009761007c366004610267565b60009182526020828152604080842092845291905290205490565b604051908152602001610065565b6100b86100b3366004610289565b610153565b005b60007fffffffff0000000000000000000000000000000000000000000000000000000082167ff2f4e56c00000000000000000000000000000000000000000000000000000000148061014d57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b61015e600282610308565b1561019c576040517f042a603d0000000000000000000000000000000000000000000000000000000081526004810182905260240160405180910390fd5b60008381523360205260408120905b82811015610217578383826001018181106101c8576101c8610343565b9050602002013560008084815260200190815260200160002060008686858181106101f5576101f5610343565b60209081029290920135835250810191909152604001600020556002016101ab565b5050505050565b60006020828403121561023057600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461026057600080fd5b9392505050565b6000806040838503121561027a57600080fd5b50508035926020909101359150565b60008060006040848603121561029e57600080fd5b83359250602084013567ffffffffffffffff808211156102bd57600080fd5b818601915086601f8301126102d157600080fd5b8135818111156102e057600080fd5b8760208260051b85010111156102f557600080fd5b6020830194508093505050509250925092565b60008261033e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd
|
608060405234801561001057600080fd5b50600436106100415760003560e01c806301ffc9a714610046578063669e48aa1461006e578063946aadc6146100a5575b600080fd5b61005961005436600461021e565b6100ba565b60405190151581526020015b60405180910390f35b61009761007c366004610267565b60009182526020828152604080842092845291905290205490565b604051908152602001610065565b6100b86100b3366004610289565b610153565b005b60007fffffffff0000000000000000000000000000000000000000000000000000000082167ff2f4e56c00000000000000000000000000000000000000000000000000000000148061014d57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b92915050565b61015e600282610308565b1561019c576040517f042a603d0000000000000000000000000000000000000000000000000000000081526004810182905260240160405180910390fd5b60008381523360205260408120905b82811015610217578383826001018181106101c8576101c8610343565b9050602002013560008084815260200190815260200160002060008686858181106101f5576101f5610343565b60209081029290920135835250810191909152604001600020556002016101ab565b5050505050565b60006020828403121561023057600080fd5b81357fffffffff000000000000000000000000000000000000000000000000000000008116811461026057600080fd5b9392505050565b6000806040838503121561027a57600080fd5b50508035926020909101359150565b60008060006040848603121561029e57600080fd5b83359250602084013567ffffffffffffffff808211156102bd57600080fd5b818601915086601f8301126102d157600080fd5b8135818111156102e057600080fd5b8760208260051b85010111156102f557600080fd5b6020830194508093505050509250925092565b60008261033e577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd
|
{{
"language": "Solidity",
"sources": {
"lib/rain.flow/lib/rain.interpreter/src/concrete/RainterpreterStore.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity =0.8.19;\n\nimport \"openzeppelin-contracts/contracts/utils/introspection/ERC165.sol\";\n\nimport \"../interface/IInterpreterStoreV1.sol\";\nimport \"../lib/ns/LibNamespace.sol\";\n\n/// Thrown when a `set` call is made with an odd number of arguments.\nerror RainterpreterStoreOddSetLength(uint256 length);\n\n/// @title RainterpreterStore\n/// @notice Simplest possible `IInterpreterStoreV1` that could work.\n/// Takes key/value pairings from the input array and stores each in an internal\n/// mapping. `StateNamespace` is fully qualified only by `msg.sender` on set and\n/// doesn't attempt to do any deduping etc. if the same key appears twice it will\n/// be set twice.\ncontract RainterpreterStore is IInterpreterStoreV1, ERC165 {\n using LibNamespace for StateNamespace;\n\n /// Store is several tiers of sandbox.\n ///\n /// 0. Address hashed into `FullyQualifiedNamespace` is `msg.sender` so that\n /// callers cannot attack each other\n /// 1. StateNamespace is caller-provided namespace so that expressions cannot\n /// attack each other\n /// 2. `uint256` is expression-provided key\n /// 3. `uint256` is expression-provided value\n ///\n /// tiers 0 and 1 are both embodied in the `FullyQualifiedNamespace`.\n // Slither doesn't like the leading underscore.\n //solhint-disable-next-line private-vars-leading-underscore\n mapping(FullyQualifiedNamespace fullyQualifiedNamespace => mapping(uint256 key => uint256 value)) internal sStore;\n\n // @inheritdoc ERC165\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IInterpreterStoreV1).interfaceId || super.supportsInterface(interfaceId);\n }\n\n /// @inheritdoc IInterpreterStoreV1\n function set(StateNamespace namespace, uint256[] calldata kvs) external {\n /// This would be picked up by an out of bounds index below, but it's\n /// nice to have a more specific error message.\n if (kvs.length % 2 != 0) {\n revert RainterpreterStoreOddSetLength(kvs.length);\n }\n unchecked {\n FullyQualifiedNamespace fullyQualifiedNamespace = namespace.qualifyNamespace(msg.sender);\n for (uint256 i = 0; i < kvs.length; i += 2) {\n sStore[fullyQualifiedNamespace][kvs[i]] = kvs[i + 1];\n }\n }\n }\n\n /// @inheritdoc IInterpreterStoreV1\n function get(FullyQualifiedNamespace namespace, uint256 key) external view returns (uint256) {\n return sStore[namespace][key];\n }\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/IInterpreterStoreV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterV1.sol\";\n\n/// A fully qualified namespace includes the interpreter's own namespacing logic\n/// IN ADDITION to the calling contract's requested `StateNamespace`. Typically\n/// this involves hashing the `msg.sender` into the `StateNamespace` so that each\n/// caller operates within its own disjoint state universe. Intepreters MUST NOT\n/// allow either the caller nor any expression/word to modify this directly on\n/// pain of potential key collisions on writes to the interpreter's own storage.\ntype FullyQualifiedNamespace is uint256;\n\nIInterpreterStoreV1 constant NO_STORE = IInterpreterStoreV1(address(0));\n\n/// @title IInterpreterStoreV1\n/// @notice Tracks state changes on behalf of an interpreter. A single store can\n/// handle state changes for many calling contracts, many interpreters and many\n/// expressions. The store is responsible for ensuring that applying these state\n/// changes is safe from key collisions with calls to `set` from different\n/// `msg.sender` callers. I.e. it MUST NOT be possible for a caller to modify the\n/// state changes associated with some other caller.\n///\n/// The store defines the shape of its own state changes, which is opaque to the\n/// calling contract. For example, some store may treat the list of state changes\n/// as a pairwise key/value set, and some other store may treat it as a literal\n/// list to be stored as-is.\n///\n/// Each interpreter decides for itself which store to use based on the\n/// compatibility of its own opcodes.\n///\n/// The store MUST assume the state changes have been corrupted by the calling\n/// contract due to bugs or malicious intent, and enforce state isolation between\n/// callers despite arbitrarily invalid state changes. The store MUST revert if\n/// it can detect invalid state changes, such as a key/value list having an odd\n/// number of items, but this MAY NOT be possible if the corruption is\n/// undetectable.\ninterface IInterpreterStoreV1 {\n /// Mutates the interpreter store in bulk. The bulk values are provided in\n /// the form of a `uint256[]` which can be treated e.g. as pairwise keys and\n /// values to be stored in a Solidity mapping. The `IInterpreterStoreV1`\n /// defines the meaning of the `uint256[]` for its own storage logic.\n ///\n /// @param namespace The unqualified namespace for the set that MUST be\n /// fully qualified by the `IInterpreterStoreV1` to prevent key collisions\n /// between callers. The fully qualified namespace forms a compound key with\n /// the keys for each value to set.\n /// @param kvs The list of changes to apply to the store's internal state.\n function set(StateNamespace namespace, uint256[] calldata kvs) external;\n\n /// Given a fully qualified namespace and key, return the associated value.\n /// Ostensibly the interpreter can use this to implement opcodes that read\n /// previously set values. The interpreter MUST apply the same qualification\n /// logic as the store that it uses to guarantee consistent round tripping of\n /// data and prevent malicious behaviours. Technically also allows onchain\n /// reads of any set value from any contract, not just interpreters, but in\n /// this case readers MUST be aware and handle inconsistencies between get\n /// and set while the state changes are still in memory in the calling\n /// context and haven't yet been persisted to the store.\n ///\n /// `IInterpreterStoreV1` uses the same fallback behaviour for unset keys as\n /// Solidity. Specifically, any UNSET VALUES SILENTLY FALLBACK TO `0`.\n /// @param namespace The fully qualified namespace to get a single value for.\n /// @param key The key to get the value for within the namespace.\n /// @return The value OR ZERO IF NOT SET.\n function get(FullyQualifiedNamespace namespace, uint256 key) external view returns (uint256);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/ns/LibNamespace.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../../interface/IInterpreterV1.sol\";\n\nlibrary LibNamespace {\n /// Standard way to elevate a caller-provided state namespace to a universal\n /// namespace that is disjoint from all other caller-provided namespaces.\n /// Essentially just hashes the `msg.sender` into the state namespace as-is.\n ///\n /// This is deterministic such that the same combination of state namespace\n /// and caller will produce the same fully qualified namespace, even across\n /// multiple transactions/blocks.\n ///\n /// @param stateNamespace The state namespace as specified by the caller.\n /// @param sender The caller this namespace is bound to.\n /// @return qualifiedNamespace A fully qualified namespace that cannot\n /// collide with any other state namespace specified by any other caller.\n function qualifyNamespace(StateNamespace stateNamespace, address sender)\n internal\n pure\n returns (FullyQualifiedNamespace qualifiedNamespace)\n {\n assembly (\"memory-safe\") {\n mstore(0, stateNamespace)\n mstore(0x20, sender)\n qualifiedNamespace := keccak256(0, 0x40)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/IInterpreterV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterStoreV1.sol\";\n\n/// @dev The index of a source within a deployed expression that can be evaluated\n/// by an `IInterpreterV1`. MAY be an entrypoint or the index of a source called\n/// internally such as by the `call` opcode.\ntype SourceIndex is uint16;\n\n/// @dev Encoded information about a specific evaluation including the expression\n/// address onchain, entrypoint and expected return values.\ntype EncodedDispatch is uint256;\n\n/// @dev The namespace for state changes as requested by the calling contract.\n/// The interpreter MUST apply this namespace IN ADDITION to namespacing by\n/// caller etc.\ntype StateNamespace is uint256;\n\n/// @dev Additional bytes that can be used to configure a single opcode dispatch.\n/// Commonly used to specify the number of inputs to a variadic function such\n/// as addition or multiplication.\ntype Operand is uint256;\n\n/// @dev The default state namespace MUST be used when a calling contract has no\n/// particular opinion on or need for dynamic namespaces.\nStateNamespace constant DEFAULT_STATE_NAMESPACE = StateNamespace.wrap(0);\n\n/// @title IInterpreterV1\n/// Interface into a standard interpreter that supports:\n///\n/// - evaluating `view` logic deployed onchain by an `IExpressionDeployerV1`\n/// - receiving arbitrary `uint256[][]` supporting context to be made available\n/// to the evaluated logic\n/// - handling subsequent state changes in bulk in response to evaluated logic\n/// - namespacing state changes according to the caller's preferences to avoid\n/// unwanted key collisions\n/// - exposing its internal function pointers to support external precompilation\n/// of logic for more gas efficient runtime evaluation by the interpreter\n///\n/// The interface is designed to be stable across many versions and\n/// implementations of an interpreter, balancing minimalism with features\n/// required for a general purpose onchain interpreted compute environment.\n///\n/// The security model of an interpreter is that it MUST be resilient to\n/// malicious expressions even if they dispatch arbitrary internal function\n/// pointers during an eval. The interpreter MAY return garbage or exhibit\n/// undefined behaviour or error during an eval, _provided that no state changes\n/// are persisted_ e.g. in storage, such that only the caller that specifies the\n/// malicious expression can be negatively impacted by the result. In turn, the\n/// caller must guard itself against arbitrarily corrupt/malicious reverts and\n/// return values from any interpreter that it requests an expression from. And\n/// so on and so forth up to the externally owned account (EOA) who signs the\n/// transaction and agrees to a specific combination of contracts, expressions\n/// and interpreters, who can presumably make an informed decision about which\n/// ones to trust to get the job done.\n///\n/// The state changes for an interpreter are expected to be produces by an `eval`\n/// and passed to the `IInterpreterStoreV1` returned by the eval, as-is by the\n/// caller, after the caller has had an opportunity to apply their own\n/// intermediate logic such as reentrancy defenses against malicious\n/// interpreters. The interpreter is free to structure the state changes however\n/// it wants but MUST guard against the calling contract corrupting the changes\n/// between `eval` and `set`. For example a store could sandbox storage writes\n/// per-caller so that a malicious caller can only damage their own state\n/// changes, while honest callers respect, benefit from and are protected by the\n/// interpreter store's state change handling.\n///\n/// The two step eval-state model allows eval to be read-only which provides\n/// security guarantees for the caller such as no stateful reentrancy, either\n/// from the interpreter or some contract interface used by some word, while\n/// still allowing for storage writes. As the storage writes happen on the\n/// interpreter rather than the caller (c.f. delegate call) the caller DOES NOT\n/// need to trust the interpreter, which allows for permissionless selection of\n/// interpreters by end users. Delegate call always implies an admin key on the\n/// caller because the delegatee contract can write arbitrarily to the state of\n/// the delegator, which severely limits the generality of contract composition.\ninterface IInterpreterV1 {\n /// Exposes the function pointers as `uint16` values packed into a single\n /// `bytes` in the same order as they would be indexed into by opcodes. For\n /// example, if opcode `2` should dispatch function at position `0x1234` then\n /// the start of the returned bytes would be `0xXXXXXXXX1234` where `X` is\n /// a placeholder for the function pointers of opcodes `0` and `1`.\n ///\n /// `IExpressionDeployerV1` contracts use these function pointers to\n /// \"compile\" the expression into something that an interpreter can dispatch\n /// directly without paying gas to lookup the same at runtime. As the\n /// validity of any integrity check and subsequent dispatch is highly\n /// sensitive to both the function pointers and overall bytecode of the\n /// interpreter, `IExpressionDeployerV1` contracts SHOULD implement guards\n /// against accidentally being deployed onchain paired against an unknown\n /// interpreter. It is very easy for an apparent compatible pairing to be\n /// subtly and critically incompatible due to addition/removal/reordering of\n /// opcodes and compiler optimisations on the interpreter bytecode.\n ///\n /// This MAY return different values during construction vs. all other times\n /// after the interpreter has been successfully deployed onchain. DO NOT rely\n /// on function pointers reported during contract construction.\n function functionPointers() external view returns (bytes memory);\n\n /// The raison d'etre for an interpreter. Given some expression and per-call\n /// additional contextual data, produce a stack of results and a set of state\n /// changes that the caller MAY OPTIONALLY pass back to be persisted by a\n /// call to `IInterpreterStoreV1.set`.\n /// @param store The storage contract that the returned key/value pairs\n /// MUST be passed to IF the calling contract is in a non-static calling\n /// context. Static calling contexts MUST pass `address(0)`.\n /// @param namespace The state namespace that will be fully qualified by the\n /// interpreter at runtime in order to perform gets on the underlying store.\n /// MUST be the same namespace passed to the store by the calling contract\n /// when sending the resulting key/value items to storage.\n /// @param dispatch All the information required for the interpreter to load\n /// an expression, select an entrypoint and return the values expected by the\n /// caller. The interpreter MAY encode dispatches differently to\n /// `LibEncodedDispatch` but this WILL negatively impact compatibility for\n /// calling contracts that hardcode the encoding logic.\n /// @param context A 2-dimensional array of data that can be indexed into at\n /// runtime by the interpreter. The calling contract is responsible for\n /// ensuring the authenticity and completeness of context data. The\n /// interpreter MUST revert at runtime if an expression attempts to index\n /// into some context value that is not provided by the caller. This implies\n /// that context reads cannot be checked for out of bounds reads at deploy\n /// time, as the runtime context MAY be provided in a different shape to what\n /// the expression is expecting.\n /// Same as `eval` but allowing the caller to specify a namespace under which\n /// the state changes will be applied. The interpeter MUST ensure that keys\n /// will never collide across namespaces, even if, for example:\n ///\n /// - The calling contract is malicious and attempts to craft a collision\n /// with state changes from another contract\n /// - The expression is malicious and attempts to craft a collision with\n /// other expressions evaluated by the same calling contract\n ///\n /// A malicious entity MAY have access to significant offchain resources to\n /// attempt to precompute key collisions through brute force. The collision\n /// resistance of namespaces should be comparable or equivalent to the\n /// collision resistance of the hashing algorithms employed by the blockchain\n /// itself, such as the design of `mapping` in Solidity that hashes each\n /// nested key to produce a collision resistant compound key.\n /// @return stack The list of values produced by evaluating the expression.\n /// MUST NOT be longer than the maximum length specified by `dispatch`, if\n /// applicable.\n /// @return kvs A list of pairwise key/value items to be saved in the store.\n function eval(\n IInterpreterStoreV1 store,\n StateNamespace namespace,\n EncodedDispatch dispatch,\n uint256[][] calldata context\n ) external view returns (uint256[] memory stack, uint256[] memory kvs);\n}\n"
}
},
"settings": {
"remappings": [
"@prb/test/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/lib/prb-test/src/",
"bitwise/=lib/rain.flow/lib/rain.interpreter/src/lib/bitwise/",
"bytecode/=lib/rain.flow/lib/rain.interpreter/src/lib/bytecode/",
"caller/=lib/rain.flow/lib/rain.interpreter/src/lib/caller/",
"compile/=lib/rain.flow/lib/rain.interpreter/src/lib/compile/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"eval/=lib/rain.flow/lib/rain.interpreter/src/lib/eval/",
"extern/=lib/rain.flow/lib/rain.interpreter/src/lib/extern/",
"forge-std/=lib/forge-std/src/",
"integrity/=lib/rain.flow/lib/rain.interpreter/src/lib/integrity/",
"ns/=lib/rain.flow/lib/rain.interpreter/src/lib/ns/",
"op/=lib/rain.flow/lib/rain.interpreter/src/lib/op/",
"openzeppelin-contracts-upgradeable/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/",
"openzeppelin/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/contracts/",
"parse/=lib/rain.flow/lib/rain.interpreter/src/lib/parse/",
"prb-math/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/",
"prb-test/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/lib/prb-test/src/",
"rain.chainlink/=lib/rain.flow/lib/rain.interpreter/lib/rain.chainlink/src/",
"rain.datacontract/=lib/rain.flow/lib/rain.interpreter/lib/rain.datacontract/src/",
"rain.erc1820/=lib/rain.flow/lib/rain.interpreter/lib/rain.erc1820/src/",
"rain.extrospection/=lib/rain.flow/lib/rain.factory/lib/rain.extrospection/",
"rain.factory/=lib/rain.flow/lib/rain.factory/",
"rain.flow/=lib/rain.flow/",
"rain.interpreter/=lib/rain.flow/lib/rain.interpreter/",
"rain.lib.hash/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.memkv/lib/rain.lib.hash/src/",
"rain.lib.memkv/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.memkv/src/",
"rain.lib.typecast/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.typecast/src/",
"rain.math.fixedpoint/=lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/",
"rain.math.saturating/=lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/lib/rain.math.saturating/src/",
"rain.metadata/=lib/rain.flow/lib/rain.interpreter/lib/rain.metadata/src/",
"rain.solmem/=lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/",
"sol.lib.binmaskflag/=lib/rain.flow/lib/rain.interpreter/lib/sol.lib.binmaskflag/src/",
"state/=lib/rain.flow/lib/rain.interpreter/src/lib/state/",
"uniswap/=lib/rain.flow/lib/rain.interpreter/src/lib/uniswap/",
"v2-core/=lib/rain.flow/lib/rain.interpreter/lib/v2-core/contracts/",
"v2-periphery/=lib/rain.flow/lib/rain.interpreter/lib/v2-periphery/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}
}}
|
1 | 19,498,589 |
cca09afb3c3ec8d6f50057638f9c0c087b23abb0fbe0bc06b809a1d3bd05b42d
|
3aa8bbad2dbf0eee1987f214b49c93d2b086dd1433d6427d30b81e0a77c595cc
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
d039bc83136011e3b6017cda4d4d597865b13bed
|
60c06040523480156200001157600080fd5b5060405162004e4838038062004e4883398101604081905262000034916200046e565b80516020808301516001600160a01b03808416608052811660a0526040840151805192019190912060008051602062004e088339815191528114620000a9576040516358e779d360e01b815260008051602062004e088339815191526004820152602481018290526044015b60405180910390fd5b6000836001600160a01b031663f933c72f6040518163ffffffff1660e01b8152600401600060405180830381865afa158015620000ea573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526200011491908101906200051f565b90506040518060800160405280605a815260200162004dae605a913980519060200120818051906020012014620001625780604051634c1af20160e11b8152600401620000a091906200058d565b833f60008051602062004e288339815191528114620001ad57604051630fc2051760e11b815260008051602062004e28833981519152600482015260248101829052604401620000a0565b833f60008051602062004d8e8339815191528114620001f8576040516348616a9b60e01b815260008051602062004d8e833981519152600482015260248101829052604401620000a0565b7f1788931a083e1bfada6cb062b5426ea97c7866b814b4d1173909e4018f2122f1333088888b6040015160405162000235959493929190620005a9565b60405180910390a1731820a4b7618bde71dce8cdc73aab6c95905fad243b156200037757604080518082018252601581527f4945787072657373696f6e4465706c6f79657256320000000000000000000000602082015290516365ba36c160e01b8152731820a4b7618bde71dce8cdc73aab6c95905fad24916329965a1d91309184916365ba36c191620002cc916004016200058d565b602060405180830381865afa158015620002ea573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620003109190620005f2565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152306044820152606401600060405180830381600087803b1580156200035d57600080fd5b505af115801562000372573d6000803e3d6000fd5b505050505b505050505050506200060c565b634e487b7160e01b600052604160045260246000fd5b80516001600160a01b0381168114620003b257600080fd5b919050565b60005b83811015620003d4578181015183820152602001620003ba565b50506000910152565b600082601f830112620003ef57600080fd5b81516001600160401b03808211156200040c576200040c62000384565b604051601f8301601f19908116603f0116810190828211818310171562000437576200043762000384565b816040528381528660208588010111156200045157600080fd5b62000464846020830160208901620003b7565b9695505050505050565b6000602082840312156200048157600080fd5b81516001600160401b03808211156200049957600080fd5b9083019060608286031215620004ae57600080fd5b604051606081018181108382111715620004cc57620004cc62000384565b604052620004da836200039a565b8152620004ea602084016200039a565b60208201526040830151828111156200050257600080fd5b6200051087828601620003dd565b60408301525095945050505050565b6000602082840312156200053257600080fd5b81516001600160401b038111156200054957600080fd5b6200055784828501620003dd565b949350505050565b6000815180845262000579816020860160208601620003b7565b601f01601f19169290920160200192915050565b602081526000620005a260208301846200055f565b9392505050565b6001600160a01b038681168252858116602083015284811660408301528316606082015260a060808201819052600090620005e7908301846200055f565b979650505050505050565b6000602082840312156200060557600080fd5b5051919050565b60805160a05161474e6200064060003960008181610190015261044d0152600081816101f1015261042a015261474e6000f3fe608060405234801561001057600080fd5b50600436106100be5760003560e01c8063c19423bc11610076578063f0cfdd371161005b578063f0cfdd37146101ec578063fab4087a14610213578063ffc257041461023457600080fd5b8063c19423bc1461018b578063cbb7d173146101d757600080fd5b80638d614591116100a75780638d61459114610135578063a600bd0a1461014a578063b6c7175a1461015d57600080fd5b806301ffc9a7146100c357806331a66b65146100eb575b600080fd5b6100d66100d1366004613f98565b61023c565b60405190151581526020015b60405180910390f35b6100fe6100f93660046141ae565b6102d5565b6040805173ffffffffffffffffffffffffffffffffffffffff948516815292841660208401529216918101919091526060016100e2565b61013d61047c565b6040516100e291906142a4565b61013d6101583660046142b7565b61048b565b6040517fb16774f25e8070712c15ff6f551827d0c112a45d880c2aa8b63b1c2f89a13f7b81526020016100e2565b6101b27f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100e2565b6101ea6101e53660046141ae565b610547565b005b6101b27f000000000000000000000000000000000000000000000000000000000000000081565b6102266102213660046142b7565b610570565b6040516100e2929190614327565b61013d61058d565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f31a66b650000000000000000000000000000000000000000000000000000000014806102cf57507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b60008060006102e5868686610547565b7f4a48f556905d90b4a58742999556994182322843167010b59bf8149724db51cf3387878760405161031a9493929190614355565b60405180910390a18451865160009182916103bd916020020160400160408051602c83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01681019091527effff0000000000000000000000000000000000000000000000000000000000600190920160e81b919091167f61000080600c6000396000f3000000000000000000000000000000000000000017815290600d820190565b915091506103cc8189896105b0565b60006103d7836105ee565b6040805133815273ffffffffffffffffffffffffffffffffffffffff831660208201529192507fce6e4a4a7b561c65155990775d2faf8a581292f97859ce67e366fd53686b31f1910160405180910390a17f000000000000000000000000000000000000000000000000000000000000000095507f00000000000000000000000000000000000000000000000000000000000000009450925050505b93509350939050565b606061048661065c565b905090565b805160208201206060907fb16774f25e8070712c15ff6f551827d0c112a45d880c2aa8b63b1c2f89a13f7b811461051c576040517f26cc0fec0000000000000000000000000000000000000000000000000000000081527fb16774f25e8070712c15ff6f551827d0c112a45d880c2aa8b63b1c2f89a13f7b6004820152602481018290526044015b60405180910390fd5b60008380602001905181019061053291906143b5565b905061053f816002610859565b949350505050565b61056b6040518060800160405280605a81526020016146f4605a9139848484610b86565b505050565b6060806105848361057f61058d565b610f43565b91509150915091565b606060405180610140016040528061010381526020016145f16101039139905090565b80600182510160200281015b808210156105d75781518552602094850194909101906105bc565b505061056b6105e38390565b8484516020016117ab565b6000806000600d9050835160e81c61ffff168101846000f0915073ffffffffffffffffffffffffffffffffffffffff8216610655576040517f08d4abb600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5092915050565b6060613f8e6000602d90508091506000604051806105c001604052808467ffffffffffffffff1667ffffffffffffffff168152602001611811815260200161188b81526020016118f281526020016118fb81526020016119778152602001611981815260200161198b815260200161198b81526020016119778152602001611977815260200161197781526020016119778152602001611977815260200161199581526020016119b781526020016119e1815260200161198b8152602001611995815260200161198b815260200161198b8152602001611a0381526020016118f2815260200161198b815260200161198b8152602001611a0d8152602001611a0d815260200161198b81526020016118f281526020016118f28152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d81526020016118f28152602001611a248152602001611a2e8152602001611a2e81525090506060819050602d8151146108475780516040517fc8b56901000000000000000000000000000000000000000000000000000000008152600481019190915260248101849052604401610513565b61085081611a3d565b94505050505090565b6060808060008060ff861667ffffffffffffffff81111561087c5761087c613fe1565b6040519080825280602002602001820160405280156108a5578160200160208202803683370190505b5093508560ff1667ffffffffffffffff8111156108c4576108c4613fe1565b6040519080825280602002602001820160405280156108ed578160200160208202803683370190505b509250865b8051156109625760008061090583611ace565b8951909550919350915082908890869081106109235761092361451b565b602002602001019060ff16908160ff16815250508086858151811061094a5761094a61451b565b602090810291909101015250506001909101906108f2565b5060006005885102602183026001010190508067ffffffffffffffff81111561098d5761098d613fe1565b6040519080825280601f01601f1916602001820160405280156109b7576020820181803683370190505b50955081602087015360005b828110156109f557806021026021880101816020026020018701518153602080830287010151600191820152016109c3565b50506021028401600601905060005b8651811015610b7c576000805b6000806000878581518110610a2857610a2861451b565b60200260200101519050600080610a788b8881518110610a4a57610a4a61451b565b602002602001015160ff168f8a81518110610a6757610a6761451b565b602002602001015160000151611bfc565b925090506005600087610aae7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85018716611c1e565b01919091028a01805190955062ffffff84811693501690508015610b2357818103610b05576040517f59293c5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600190970196610b1484611c1e565b87019650505050505050610a11565b8195505050505060188b8681518110610b3e57610b3e61451b565b60200260200101516020015160ff16901b602086901b17821791506000600160056001901b0319905082818351161782525050505050600101610a04565b5050505092915050565b6000610b9184611cf7565b90508082511115610bdb5781516040517ffd9e1af4000000000000000000000000000000000000000000000000000000008152600481019190915260248101829052604401610513565b60208501610be885611d15565b60005b82811015610f3a57600080610c008884611f2b565b915091508551831015610cd2578115610c4f576040517fee8d10810000000000000000000000000000000000000000000000000000000081526004810184905260248101839052604401610513565b858381518110610c6157610c6161451b565b6020026020010151811015610cd2578281878581518110610c8457610c8461451b565b60200260200101516040517ff7dd619f000000000000000000000000000000000000000000000000000000008152600401610513939291909283526020830191909152604082015260600190565b6000610ce089848a51611f50565b905060006018610cf08b87611fbc565b0390506000610cff8b87611fed565b600402820190505b80821015610e84578151601c81901a60020288015162ffffff821691601d1a9060f01c600080610d35888685565b91509150838214610d895760808801516040517fddf5607100000000000000000000000000000000000000000000000000000000815260048101919091526024810183905260448101859052606401610513565b8751821115610ddb57608088015188516040517f2cab6bff0000000000000000000000000000000000000000000000000000000081526004810192909252602482015260448101839052606401610513565b875182900380895260408901511115610e3d57608088015188516040808b015190517f1bc5ab0f000000000000000000000000000000000000000000000000000000008152600481019390935260248301919091526044820152606401610513565b8751810180895260208901511015610e5757875160208901525b6001811115610e6857875160408901525b5050506080850180516001019052505060049190910190610d07565b610e8e8b87612006565b836020015114610ee2578260200151610ea78c88612006565b6040517f4d9c18dc00000000000000000000000000000000000000000000000000000000815260048101929092526024820152604401610513565b82518414610f295782516040517f4689f0b3000000000000000000000000000000000000000000000000000000008152600481019190915260248101859052604401610513565b505060019093019250610beb915050565b50505050505050565b6060806000610f5061201f565b85519091501561178c578451600090602087810191880101825b818310156116e9576001835160001a1b905060018560e001511660000361127b576f07fffffe8000000000000000000000008116156111235760e08501516002161561100b578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f5520a51700000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b6f07fffffe0000000000000000000000008116156110b75761103d836f07fffffe0000000003ff20000000000061218e565b9450925060008061104e878761223f565b9150915081156110b0576040517f53e6feba0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08c8703016004820152602401610513565b50506110d8565b6110d560018401836f07fffffe0000000003ff2000000000006122b6565b92505b604085018051600190810190915260a086018051909101905260e0850180516022177fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef169052610f6a565b6401000026008116156111745761114360018401836401000026006122b6565b60e0860180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd1690529250610f6a565b6704000000000000008116156111bd5760e0850180516021177fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed16905260019290920191610f6a565b658000000000008116156112515760108560e0015116600003611235578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517fedad0c5800000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b61123f89846122e2565b60e08601805160021790529250610f6a565b8883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001610fd6565b6f07fffffe0000000000000000000000008116156114105760e0850151600216156112fb578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f4e803df600000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b611315836f07fffffe0000000003ff20000000000061218e565b8095508194505050600080613f8e6113338b896101a00151896123ee565b92509250925082156113765760006113558961018001518e898563ffffffff16565b90975090506113658984836124ba565b5060e08801805160041790526113fd565b61138088886125f7565b909350915082156113a557611397886000846124ba565b6113a088612672565b6113fd565b6040517f81bd48db0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08d8803016004820152602401610513565b50505060e0850180516002179052610f6a565b60e08501516004161561150657650100000000008116600003611485576040517f23b5c6ea0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08a8503016004820152602401610513565b60608501805160001a60030190819053603b8111156114d0576040517f6232f2d900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5060e0850180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9169052600190920191610f6a565b650200000000008116156115d7576000606086015160001a905080600003611580576040517f7f9db5420000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08b8603016004820152602401610513565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd01606086018181538160048201015160001a8260028301015160f01c60010153506115cb86612672565b50600190920191610f6a565b6401000026008116156115f75761114360018401836401000026006122b6565b6703ff00000000000081161561162d57611612858a856126d1565b925061161d85612672565b60e0850180516002179052610f6a565b6510000000000081161561165157611646858a85612823565b600190920191610f6a565b6708000000000000008116156116875761166c858a85612823565b61167585612af6565b601860e0860152600190920191610f6a565b658000000000008116156116bf578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001611200565b8883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016112c6565b818314611722576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60e085015160201615611787576040517ff06f54cf0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08a8503016004820152602401610513565b505050505b61179581612d38565b61179e82612e70565b92509250505b9250929050565b6020810680820384015b808510156117d05784518452602094850194909301926117b5565b50801561180b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600882021c808451168119865116178452505b50505050565b815160009081908390811061186957608085015185516040517feaa16f330000000000000000000000000000000000000000000000000000000081526004810192909252602482015260448101829052606401610513565b846040015181111561187d57604085018190525b506000946001945092505050565b600080836060015183106118e557608084015160608501516040517feb7894540000000000000000000000000000000000000000000000000000000081526004810192909252602482015260448101849052606401610513565b5060009360019350915050565b50600191829150565b60008060008360ff1690506000600885901c60ff1690506000806119238860a0015185611f2b565b915091508281101561196b576040517fff1371080000000000000000000000000000000000000000000000000000000081526004810182905260248101849052604401610513565b50969095509350505050565b5060009160019150565b60101c9160019150565b5060029160019150565b600080601083901c806119a95760016119ab565b805b95600195509350505050565b600080601083901c806119cb5760026119cd565b805b905060028106156119a957806001016119ab565b600080601083901c806119f55760016119f7565b805b95600095509350505050565b5060039160019150565b600080601083901c600181116119a95760026119ab565b5060029160009150565b60046001808316019250929050565b60606000825160020267ffffffffffffffff811115611a5e57611a5e613fe1565b6040519080825280601f01601f191660200182016040528015611a88576020820181803683370190505b50905061ffff80196020850160208651028101600285015b81831015611ac257805183518616908516178152602090920191600201611aa0565b50939695505050505050565b60008060606000805b60ff811015611b4f576000805b8751811015611b1657600080611b06858b8581518110610a6757610a6761451b565b5093909317925050600101611ae4565b506000611b2282611c1e565b905083811115611b36578093508296508195505b87518103611b45575050611b4f565b5050600101611ad7565b5084516040805192909103808352600101602002820190529050600080805b8651811015611bf257600080611b938860ff168a8581518110610a6757610a6761451b565b91509150848216600003611baa5793811793611be8565b888381518110611bbc57611bbc61451b565b6020026020010151868581518110611bd657611bd661451b565b60209081029190910101526001909301925b5050600101611b6e565b5050509193909250565b60008082600052836020536021600020905060018160001a1b91509250929050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611c505750610100919050565b507f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f7f5555555555555555555555555555555555555555555555555555555555555555600183901c16909103600281901c7f3333333333333333333333333333333333333333333333333333333333333333908116911601600481901c01167f01010101010101010101010101010101010101010101010101010101010101010260f81c90565b60008151600003611d0a57506000919050565b506020015160001a90565b6000611d2082611cf7565b90508015611ee95781516001600283020190811115611d6d57826040517f17f4bc5e00000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b82516020828501810191850101602160027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860102860181019086015b808210611eae57815160f01c8481016004810185811115611df857896040517e39ba5600000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b8151600081901a90600181901a90600281901a9060031a80821180611e1c57508281115b15611e57578d876040517feaf45f4f00000000000000000000000000000000000000000000000000000000815260040161051392919061454a565b505050600481028201878114611e9b578b6040517ffbb8027a00000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b8397506002870396505050505050611daa565b838314610f3a57866040517fde67b29a00000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b600182511115611f2757816040517fd013da5d00000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b5050565b6000806000611f3a8585611fbc565b51600281901a9660039190911a95509350505050565b611f896040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001606081525090565b506040805160c081018252838152602081018490529081019290925260608201526000608082015260a081019190915290565b600080611fc884611cf7565b60020260010190506000611fdc8585612ee5565b949091019093016020019392505050565b600080611ffa8484611fbc565b5160001a949350505050565b6000806120138484611fbc565b5160011a949350505050565b612098604051806101e001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6000604051806101e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001601060081781526020016000815260200160008152602001600081526020016000815260200161210d6135bc60101b6133101790565b8152602001612137613cf360401b613b8260301b613a2660201b61391860101b61387b1717171790565b8152600060209182018190526040805183815280840182528452918301819052908201819052606082018190526080820181905260a08201819052610100820181905261012082018190526101c082015292915050565b8151600090819060015b8419600183831a1b16156020821016156121b457600101612198565b9485019460208190036008810292831c90921b9161223657604080516020810184905201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527fe47fe8b7000000000000000000000000000000000000000000000000000000008252610513916004016142a4565b50939492505050565b60008061224c84846125f7565b9092509050816117a457506101008301805160408051948552602080862092865285018152909401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000909416601085901b62ff000016179092179091529160ff90911660010190565b60005b6000826001865160001a1b161183851016156122da576001840193506122b9565b509192915050565b805160009060f01c612f2a811461234b576040517f3e47169c0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0858503016004820152602401610513565b835160029390930192602a90602f90860160200160005b806123a8575b81871084885160001a1415161561238457600187019650612368565b6001870196508187101583885160001a1417156123a357506001958601955b612362565b50808611156123e3576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b509395945050505050565b600183810180516000928392613f8e92602160ff909116028801600681019201845b818310156124a6576001830151602190930180519093600090819060ff16818061243a838f611bfc565b9150915060008761244f600185038916611c1e565b016005028b015195505062ffffff90811693508416830391506124919050575060019850601b81901a9750601c1a8a901c61ffff169550610473945050505050565b61249a83611c1e565b84019350505050612410565b506000998a99508998509650505050505050565b6124c383612f3c565b60e08301805160207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff79190911681179091528301516021600091821a850101805190911a600101815350825180516060850151600090811a86016061018051929361ffff85169360088504909103601c0192600191901a018153600060038201537fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe30180517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001690911790528451602090920183821b176018820185901b179182905260e08190036125f0578451604080518088526020601084901b81178252810190915281517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000161790525b5050505050565b61010082015161012083015160008381526020808220919384939290911c91600160ff84161b8082161561265d5761ffff83165b801561265b578360201c850361264e576001965061ffff8460101c16955061265b565b51925061ffff831661262b565b505b17610120909601959095525090939092509050565b6000606082015160001a905080600003611f275760208201805160001a600101908181535080603f0361056b576040517fa25cba3100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000613f8e60008060006126eb8861018001518888612f86565b8981038a206101408d015194985092965090945092507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016906001600083811a82901b92909190831615612791576101608c015160101c5b801561278f5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008116860361277e57600193505061278f565b505160019091019061ffff16612743565b505b6101608c015161ffff166127b76001846127ab57826127af565b8383035b8f91906124ba565b508161281357604080518082019091526101608d015160101c8517815260006127e58d8a8a63ffffffff8e16565b6020830152506101608d018051600161ffff9091160160109290921b9190911790526101408c018051841790525b50929a9950505050505050505050565b606083015160001a8015612889576040517f6fb11cdc0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848403016004820152602401610513565b5061289383612f3c565b60e083018051603060089182161790915260a0840151602085015160ff8083169360f89290921c9290911c168103600081900361295c5760088660e0015116600003612931576040517fab1d3ea70000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b90820160f881901b60208701526101c08601519091906129519084613249565b6101c0870152612a25565b6001811115612a2557808310156129c5576040517f78ef27820000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b80831115612a25576040517f43168e680000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b8082036001016020601083028101905b81811015612ae15760a08901516020848b01015190821c61ffff169060001a60015b818111612ad05760208306601c03612a7057915160f01c915b82516101c08d015160019190911a90612a899082613291565b6101c08e0152612aba8284148015612aa15750886001145b612aac576001612aae565b8a5b6101c08f0151906132d8565b6101c08e01525060049290920191600101612a57565b505060019093019250601001612a35565b5050505060081b60a090940193909352505050565b60c0810151602082015160f082811c9160001a60010190829003612b46576040517fa806284100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080856101c001519050855161ffff815160101c165b8015612b7457805190915060101c61ffff16612b5d565b50604051602188018051919450601c830192916004916024870191600090811a805b8a831015612c5c5760048202860195506004878903045b80821115612bcb57965161ffff16601c810198509690036007612bad565b506004810297889003805186529794909401938103865b6007821115612c27575160101c61ffff1680518652601c909501947ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff990910190612be2565b8115612c42575160101c61ffff168051865260048202909501945b505050600191820180519092919091019060001a80612b96565b50505050818652600486019350846001600484040360181b1763ffffffff19855116178452601f19601f820116604052505050506001846001901b612ca1919061459b565b851682851b60f0612cb38760106145ae565b901b171760c087015260e0860180517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf16905260408051602080825280820183529088526000908801819052908701819052606087018190526080870181905260a08701819052610100870181905261012087018190526101c0870152505050505050565b60c08101518151516060919060f082901c9060208114612d84576040517f858f2dcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604051935060208401601083046000818353506001600885048301810192839101600080805b88811015612de35789811c61ffff81165163ffff0000601092831b16811760e01b8786015284019360f08390031b929092179101612daa565b50825117909152878203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08181018952908801601f011660405260005b82811015612e64576002810288016003015161ffff90811683018051602060f082901c019260e09190911c1690612e598382846117ab565b505050600101612e21565b50505050505050919050565b6101608101516040805161ffff8316808252602080820283019081019093529092909160109190911c90835b80821115612edc5760208301518252915161ffff16917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090910190612e9c565b50505050919050565b6000612ef083611cf7565b8210612f2c5782826040517f30489add00000000000000000000000000000000000000000000000000000000815260040161051392919061454a565b50600202016003015161ffff1690565b60208101805160001a6001810182015160001a61056b578251805160a085018051600861ffff939093169290920460200390920160106001601e84901a860301021b179052505050565b8051613f8e9060009081908190600181831a1b6703ff0000000000008116156131a857600182811a1b7ffffffffffffffffffffffffffffffffffeffffffffffffffffff000000000000828217016130625760028801806c7e0000007e03ff0000000000005b806001835160001a1b161561300657600182019150612fec565b508a5161ffff8d16908c016020018083111561304e576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b509850909650945084935061324092505050565b876001810160006703ff0000000000006c200000002000000000000000005b816001855160001a1b161561309b57600184019350613081565b806001855160001a1b16156130cc57600184019392505b816001855160001a1b16156130cc576001840193506130b2565b505080158015906130eb5750806003018211806130eb57508060010182145b15613148576040517f013b2aaa0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08d8303016004820152602401610513565b8b5161ffff60108f901c16908d0160200180841115613193576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50995091975095508594506132409350505050565b875188016020018088106131e8576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fb0e4e5b30000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08a8a03016004820152602401610513565b93509350935093565b600061325583836132d8565b9250507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff821660ff600884811c919091168301901b1792915050565b600060ff8316828110156132d1576040517f04671d0000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050900390565b600060ff808416830190600885901c16601085901c808311156132f85750815b601081901b600883901b841717935050505092915050565b60008282036040811115613376576040517fff2f59490000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b806000036133d6576040517fc75cd5090000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b60028106600103613439576040517fd76d9b570000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff830160005b8582106135b2578151600090811a906001821b906703ff0000000000008216156134ac57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd0820161357c565b6c7e0000000000000000000000008216156134ea57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa9820161357c565b687e000000000000000082161561352457507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc9820161357c565b6040517f69f1e3e60000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08b8703016004820152602401610513565b831b959095179450507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091019060040161345f565b5050509392505050565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd8101516000908190603090829080821a87870360038111801561361157506001821b6c200000002000000000000000001615155b1561363357600488039550600a858460011a0302858460021a030193506136df565b8260011a915060028111801561365a57506001821b6c200000002000000000000000001615155b1561367257600388039550848360021a0393506136df565b801561368757600188039550600093506136df565b6040517ffa65827e0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08b8b03016004820152602401610513565b5050505b8583101580156136f35750604d81105b1561373857825160001a829003600a82900a0293909301927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201916001016136e3565b8583106135b257825160001a82900360018111156137ab578784037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f8f2b5ffd00000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b600a82900a81028581018611156137e6578885037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001613776565b9490940193507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201915b8583106135b257825160001a60308114613850578784037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001613776565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90920191613812565b80516000908190600190821a1b7ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008101613907576040517ff8216c550000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b83600092509250505b935093915050565b815181516000918291600190831a1b9085016020017ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008201613a185761396760018601826401000026006122b6565b94506000613979888861ffff89613e91565b909650905061398e86836401000026006122b6565b8051909650600160009190911a1b92506740000000000000008314613a08578686037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f722cd24a00000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b6001860194509250613910915050565b846000935093505050613910565b815181516000918291600190831a1b9085016020017ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008201613b2757613a7560018601826401000026006122b6565b94506000613a86888860ff89613e91565b909650905080613a9c87846401000026006122b6565b96506000613aad8a8a60ff8b613e91565b909850600881901b92909217919050613acc88856401000026006122b6565b8051909850600160009190911a1b94506740000000000000008514613b15578888037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016139d3565b50600187019550935061391092505050565b8585037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f24027dc400000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b815181516000918291600190831a1b9085016020017ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008201613a1857613bd160018601826401000026006122b6565b80519095506001600091821a1b92507fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008301613c0f57506000613c34565b613c1c8888600189613e91565b9096509050613c3186836401000026006122b6565b95505b85516001600091821a1b93507fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008401613c6f57506000613c94565b613c7c898960018a613e91565b9097509050613c9187846401000026006122b6565b96505b8651600160009190911a81901b945081901b82176740000000000000008514613ce1578888037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016139d3565b60018801965094506139109350505050565b815181516000918291600190831a1b9085016020017ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008201613b2757613d4260018601826401000026006122b6565b94506000613d53888860ff89613e91565b9096509050613d6886836401000026006122b6565b80519096506001600091821a1b93507fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008401613da657506000613dcb565b613db3898960018a613e91565b9097509050613dc887846401000026006122b6565b96505b86516001600091821a1b94507fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008501613e0657506000613e2b565b613e138a8a60018b613e91565b9098509050613e2888856401000026006122b6565b97505b8751600160009190911a1b9450600882901b8317600982901b176740000000000000008614613e7e578989037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016139d3565b6001890197509550613910945050505050565b80516000908190600190821a1b7fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008101613eef578584037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001613b4d565b613f8e6000806000613f028b8b8a612f86565b93509350935093506000613f1b8b85858863ffffffff16565b905089811115613f7d576040517f7480c7840000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08c8b03016004820152602401610513565b909b909a5098505050505050505050565b613f966145c1565b565b600060208284031215613faa57600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114613fda57600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561403357614033613fe1565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561408057614080613fe1565b604052919050565b600067ffffffffffffffff8211156140a2576140a2613fe1565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f8301126140df57600080fd5b81356140f26140ed82614088565b614039565b81815284602083860101111561410757600080fd5b816020850160208301376000918101602001919091529392505050565b600067ffffffffffffffff82111561413e5761413e613fe1565b5060051b60200190565b600082601f83011261415957600080fd5b813560206141696140ed83614124565b82815260059290921b8401810191818101908684111561418857600080fd5b8286015b848110156141a3578035835291830191830161418c565b509695505050505050565b6000806000606084860312156141c357600080fd5b833567ffffffffffffffff808211156141db57600080fd5b6141e7878388016140ce565b945060208601359150808211156141fd57600080fd5b61420987838801614148565b9350604086013591508082111561421f57600080fd5b5061422c86828701614148565b9150509250925092565b60005b83811015614251578181015183820152602001614239565b50506000910152565b60008151808452614272816020860160208601614236565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000613fda602083018461425a565b6000602082840312156142c957600080fd5b813567ffffffffffffffff8111156142e057600080fd5b61053f848285016140ce565b600081518084526020808501945080840160005b8381101561431c57815187529582019590820190600101614300565b509495945050505050565b60408152600061433a604083018561425a565b828103602084015261434c81856142ec565b95945050505050565b73ffffffffffffffffffffffffffffffffffffffff85168152608060208201526000614384608083018661425a565b828103604084015261439681866142ec565b905082810360608401526143aa81856142ec565b979650505050505050565b600060208083850312156143c857600080fd5b825167ffffffffffffffff808211156143e057600080fd5b818501915085601f8301126143f457600080fd5b81516144026140ed82614124565b81815260059190911b8301840190848101908883111561442157600080fd5b8585015b8381101561450e5780518581111561443d5760008081fd5b86016060818c037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018113156144735760008081fd5b61447b614010565b89830151815260408084015160ff811681146144975760008081fd5b828c01529183015191888311156144ae5760008081fd5b82840193508d603f8501126144c557600092508283fd5b8a84015192506144d76140ed84614088565b8381528e828587010111156144ec5760008081fd5b6144fb848d8301848801614236565b9082015285525050918601918601614425565b5098975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60408152600061455d604083018561425a565b90508260208301529392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156102cf576102cf61456c565b808201808211156102cf576102cf61456c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052605160045260246000fdfe013e002a2208b2001080a0102400000302920481840880062e1240044004200204001100c332a00a00d8ac552500df95d8070038ef251e008683ce050031dbd003208596c41f00048a5a16008b6c060d00f39c0626006806f922002870ea21002cb51d1d007ed6ee1c40ce75301000ab79f01400862cf02300f82ccc2b102116660f10a5c7372c10d76cb417003e0bda1b40dce01d2700ec21ff1200121cd20010f7a0481500d0147329002655b3042036bc2d01100b23821a3074ca4013006c16580b00afd55a0e1097af9a02006ab30728009ea40f090008512f2a00a2f61c24002b93430c00e043780800cb7812060096888b190069940c20000c6d8d18002584c41811188b18f218fb19771981198b198b19771977197719771977199519b719e1198b1995198b198b1a0318f2198b198b1a0d1a0d198b18f218f21a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d18f21a241a2e1a2ed6130168250d3957ae34f8026c2bdbd7e21d35bb202e8540a9b3abcbc232ddb60d090d550d900da90e470f2b0f65101510b710e6111511151164119311f5127d13241338138e13a213b713d113dc13f01405148214cd14f3150a15211521156c15b716021602164d164d169816e3172e172e17791860189318ea43e7d24e548ff92fae16c245e1653f705e016bb24fd21dc0ab89d862c3071a1821785780ab522520aaf1921d5a177b745aa7179c67305ed963c709e79bdfbe0d00000000000000000000000000000000000000000000000000000000000000200000000000000000000000003ced0801fc4ca43f80444e5d8e5d0fe643fd22b8000000000000000000000000d9543dc7ac39f540c2b3f5cc92d8542a2d9339c300000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000e26ff0a89c674ee7874a50059054ddd5acd6edb38107e95c2e75cb6dbdd436f89e32206e2bab0932db0450e8c38b68950a44052b1bd8bbefb8e24ca92655ad6ff1abd1896c4996ffe381c0ef9e3df11134168f4e833fef5a41f4801c23e32614009c29ff6018c3e8f08a50ab41edd8c04f1a317f1f74001fee24b733ceae7cd6506da480595485ff70672843e1892d1251f7fbedc14a9b451a1673e2c484ed2c92e88409814f71070b9073596221988eff0ff8aad33202f7db650260c38c450da1003b3d09057c699d9e337214540f6e495e754f252de5259b50ec67669f8fbc70c1a7601780668414f1c72ce3e796ae299907007edcb61c86d68365231b19ea1351f88decc98f689f1361915287551f0109f3ffef167064df7f887798f20d626c72b1de790fe84051a5750a2e83cd067d9648adc117aefc66c24bf0ca682c2ae99e41ee15ec83134e834416cc425f29627299ce571a4fc3c48c675a2bd96a1f2601e9ae6d2cbb3c499d863c2b90599ec3c00ba8c714b85cfa8ef8958738cdc0a4415c45dad34985269efc1633ee18f0c39113e7f07b5e2725b5558cc19ccc390f88212476908f9b71439269a57903b857e7c584e0df86d618551fb40e2eb1633c446479bf4e03331af10639383b8330741330bd8a49cb16e384792fc5ccec6ad09ae5d627d0d8e64a2d48f2ee9bf4af1372819a7abfe676d9458b4b6a1dfd6f395f11603e225c1f8082bf38d2810c341ce034c8482f60ff800bb3a59b713cc19e12ba97ca063e9fb38559686a801c2f5008b468eabf07bb666ad33561de0ccd81597b619d9254bf0105226990f1751c297e0b3fe11bf4a73eb791018842d56627d61ce294d326a455f74039acce6ae6658abfa39da3011d1ae3e48992c80d072c543335fddc950503d76d20c6f0014c27b7b6acfa28eeecb5382d2691f2f3635ab60a4d1a072a0f58c5c6800a41ba493264015f3c419eb9c7d338997d9b8c662bb7d8369b3857b53dd6f399758db63d7a25c8d08311bdbd1263fd6a30325aad4f1b106766025f18ba48df25a8711a7003b02ec1d2aecd8628197ec1f5c7234ae3f3329a4918279ff7b4aeab7275230c03382d5492e3588aedc5631fd035b6fb6e4a8ad7ad1520e9a2ea33c837d52a1885a0a582d123a385c32857a5a3c1ca84375989e85c7a51e742f97420eb6977b1669fbc46eac1a78d1d521cf37f0d35ef6a845d7bc223fb76265a4adb4bcb351db56bb0b7c5c5a4db3e3133775ff11835d9cf186d4cc36ed201bcd8b42aa494cfe4dc6a37449c2c9604f07f7afea6278eb2e70bd6a92e9eae7f20cb351afe21a27e4323a386d3e15dbd8f04911161dbd240bf19de5d47bd8bc09b915dfa51a6499d261104815659da4031333ab858b8b40d2a5b73cb74792dbaf39cc4833acfaab9e7f7d5728d8241ed1bb39a2867dd28cb1a76043429677c1081eb9ef7d1922f08a700d37c77260118ec7e7d9a70b971140d0f31719eaf1a2f66a4137dcd8e57b1635552dbb7751caaa903964303b7313233d809c2e03c2f251fa1ed57d57ed3c38dc1071f03b3a0ab1c36e0f1cae56c95acd8c524e76bafe78199df66c4f26358e6ac6b2e48437e299ebd1c376e2f057e60147f624c58b2f4897de59a85200b817e9d30b4141989f652bdc51c6cdba7a05645ed69289f61a324ee31eab1d7849a1b3eaf4a84cfd1e5acd30eb2cac92047e1459250645c98cc262eec334b753faeb3797894beeb839b9c4955e6d5627a9c39dc9aadd6173fb3ab3159b1ead4f1ddbc929e63b836d0d019776bdab2b5a15e33796efd7992c11ab3556a4fbf106bcb7233b77e1bd94fb173b30b741ee3ac975e1374a4a137510e5e876a257f2de399f35cbec05f9af6e8df954a89657044fee8a57673fe5fd60f7787a9a0ebfa08f94dca94ef4be5e30bdfc07011bffe5ffb4a3ff2cde02706170706c69636174696f6e2f6a736f6e03676465666c6174650462656ea400590879dd5a5b8f243715ee7980884b20080204827040303330d53b3d51d89590d02e4380488448d9c00b8294bbcadd6d4d75b953764d4ff392557e435e23cd7f8894d7e4a7cc4fc939b6ebd237bbaabb7a47895f76b63f5fbe73f1f1f171f5dc8d78f0c00d7fe3d68d7f3374e32f78d67fe1ce8d7feb991bffb607ffce6337fe5d0ffea20fbf73e3df7be6c6bfef99ff25e2c1bf70e33fb875e33ff4acffa3676efc65cff81f1337fe939e07bf73e33ff5e0afdcbaf19f856efce78fddf8ab9ef1bf78e6c67f49dcf86b6eb8f7ab3b37fe6b0ffe1bcffcbff5e0c7c48d9f78c69fdcb9f1d32fdcf8ef6eddf8ef3df89967fec083f7efdcf803cff8730ffe7a4f2a1a5df5766e2f79f0d0839f5c8a196792d094b01b2e154fc7e49a263923a34c4c899a30a219f6b74d1089143aa4aa3573d3f6e57f5cf02705114b5fa44a34a0df1b7235e7920591c853158894c9b622ecc5ffe125ae2b35d3349f0e5946c4880c794ab305fc0388648a802803c253dd8ba7b35c55f2443449f6e047f6e37ff4e225ac8fea9722cf2246860b2018b39b82ada45346dea5f0bfe142b148c4ac4fde2ba49028180a4068c6c08060c99858b32931434de09fd803006d4870d458ff2872a567903316f1110eb42b8a19cbb0536dca210eb4f3e264e8e4c62d349711cfa42ac771630c2b8f11a6585482045597ca5e96cc262f83018addecba3df6b54f6f5cee8f955d6d793934607bc0bf493e4db50e96e52f3a6462be7d7f4da89cb494b94d0b3df89ffe0eeba3fce064d6e73846067058f0828491d72fb4675af5e4f82bb9625144af2edef80388c5b2e8e1c52018d284a6110bc4e8f9f2fff06fcc4607cb00dd0d83b5a6054e7dc552321219fe46231dc4ea26d52217f6329d691c674cca2d3e6de7287af50bf9c53c6559e7d237f0df527ecd6083f47b896bfaf0d8713e2422ba0acc56ef5472d3420ffe0a0a17e559c6c0289a8b0d3b05e36802c135e0f101b835e1f7729d9fe6b2a2cd29bd0960c7057a7f3d7f7e7f447ec0814ff329990929f910367d2ad2206563aaf8358678c5c6e05a9a619f5cfc0f363e09c8a05ff28fe18899d264f0a87b297cfc2f37f21f3c22961338fe0d9c7033c18bcca70ff1381f4f9205483078833d7cd8772e60fc5bf1298313713aeb4c30db420ffeeaba7f975c34719a2ebae6d486df9b557041a7f93fcb44916042a4c168541e2c6704c2f039e123c2ae59b6a882d1b9cb02188db8e290bceec47fcffcf9e8e8bd8c517d28eab3914a32a33cc38c9894cc1e18811190f5680b0ad1fa283b1e4bab1b103a972cee93b746d0abea20755666c79de908cc6e66189f012419ea4dd9258a642482703f647a3a64a7837f068ac6541273ba988f460cbd875338c5874ccd1944f4699e283e4b587de97a465aaddaf72890a532cf76dff2fbde6f3e7fd72805dd0ab642dda9c8932aa741b5320a510cb63d431b8032f47907bf1b959739ea73d62efb20a749a0c4ce1adc4f7fc703adb9154d21a733d8ab023584cebedd0bf45eee94f2520b3df813b456426bbbcd1b7d56dcc4b3c018f73fa4766a42d38e64aab7d0835f6afba8f50ccef222c86b2971c30e0d6d87ad2e5f20b2a0637ff4c9f74e23f9c0749a5771496d212bef3c255f6aa107cfdfda28dd5288af4b531d0def1432994e6ac2b3b53e3039fcbd16d8ea5ae0521fcaf725ff6ba57dab2dd7c23b7bbd0402e5a1365fcfcffff136ff445e4d365fc9ff009bab01ff7ff8f9efb1b9a055b97fccafbb93aba97c1ffd855ff398c93511a1d086c15f93af656ff5eb40ed9660ee8c929cf03e5c108ea1cc798c4a1ab0c1a3d33e7913cffc32c50039b904a5018e3bcbe3c0957e202be84a2b550b3df8eddb2617e1cb351e25c64c6b667f95a0e26dc2c3238ac90ee4371163b1b149713733c7f2c9caddebb45fe94742e991a11f2d523ae55133f9cff7d3cfd1d1535c75a5fe27c5942da9a5d089a6a8abcd1b2f985b4b2de538f3875e6473c1c5b0287a9a09d51cb2d3196a1696b399a9d4d5c54c24789b852413aa72ba0049559e1923408609a55fbcc183baf1de02d60ed7b41dfae2efda88667629da630f1ebae1a3ff16f649ad463b36d36a557bdd50a6b7b5d2496187d3ea8a60ec202b43ccf5b5e29c9cc46c4461679c1a4892186a74da4c83e2977c664dac4f77d7ec35cbaecfcfcc6e044c403a3e4ac4dc2e6347a10215a9956a4ca1a6bf6edfa0e539bbaf7dffe3b0ef962a0e5a072d6f427b1d3146fb6773fb2af135b72ee47f505b841a6f3bab366f1efbf6ae9fc4f1d69367539951ae9e2d409eb73e552a02957f1f440b3ef93f76c9dfc1c9bba7768c7f1c24736ba69fb865fee67599b6191aca0ff598ee245e6ea107bf85b75fb9417c9b8bcfc4dc3eeaeca20b5b3f0407d2052a1d5d449ec4d6591af90aea07fadc977e9efc95a71bbddae450b5bad5367d7816a8e5e7879032f4e0efb7906f9770a1fd7bca0f747b6e673f9e1ed67e879032f4e0efb7906f77fb897b3bbfe3b7459c27e27ee3f3416ecea6851efc23fffdb95118dee386ec2688fa91f9b02b7dacb6d0837ff8341faa8c466a493de55734758f69aa2a6967ac8e2bb8ca82faf009859272b8cd716bf7974368c127ff27ade4ef20e16ba71da8efb39dbfadea423f7fd6dfa72c575794c8a062edb8a55db1052640891057f9cce3fff27ee59b3cadcb0736682c1d7eb7b852035ae958d58298daaa853ce5724e67c1f54540a7fa1bcd56c7e0beefe39f5d8a2938375b3e020d13cc5b8b6cf60ade89c1533fc87966be611ca3f8640cbe9ad6ba9b47d8a2bf3943c9bf8c88ffbed04fecf0ea81733ea8778513256351f5825eee3f506851052bbe96b4b399bb376ca4ad45bb1180225b145f489d6dfa1a6c33f1a5171b597bfd58fae4eaac34ff48e4999a145d97042bbe3323f61da9e62203fd837efbc44f428cbc198fc01611d4f5c7a0e739879804efd7198342416adeb0e72c49fa2eff81f59f9fff7cbaec3ff628dce610606406a68c0bcf58759f256ffb0a794f9df757c979a07d09011bffe9e3a02ca8e23502706170706c69636174696f6e2f63626f7203676465666c6174650000000000000000000000000000000000000000000000000000
|
608060405234801561001057600080fd5b50600436106100be5760003560e01c8063c19423bc11610076578063f0cfdd371161005b578063f0cfdd37146101ec578063fab4087a14610213578063ffc257041461023457600080fd5b8063c19423bc1461018b578063cbb7d173146101d757600080fd5b80638d614591116100a75780638d61459114610135578063a600bd0a1461014a578063b6c7175a1461015d57600080fd5b806301ffc9a7146100c357806331a66b65146100eb575b600080fd5b6100d66100d1366004613f98565b61023c565b60405190151581526020015b60405180910390f35b6100fe6100f93660046141ae565b6102d5565b6040805173ffffffffffffffffffffffffffffffffffffffff948516815292841660208401529216918101919091526060016100e2565b61013d61047c565b6040516100e291906142a4565b61013d6101583660046142b7565b61048b565b6040517fb16774f25e8070712c15ff6f551827d0c112a45d880c2aa8b63b1c2f89a13f7b81526020016100e2565b6101b27f000000000000000000000000d9543dc7ac39f540c2b3f5cc92d8542a2d9339c381565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100e2565b6101ea6101e53660046141ae565b610547565b005b6101b27f0000000000000000000000003ced0801fc4ca43f80444e5d8e5d0fe643fd22b881565b6102266102213660046142b7565b610570565b6040516100e2929190614327565b61013d61058d565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f31a66b650000000000000000000000000000000000000000000000000000000014806102cf57507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b60008060006102e5868686610547565b7f4a48f556905d90b4a58742999556994182322843167010b59bf8149724db51cf3387878760405161031a9493929190614355565b60405180910390a18451865160009182916103bd916020020160400160408051602c83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01681019091527effff0000000000000000000000000000000000000000000000000000000000600190920160e81b919091167f61000080600c6000396000f3000000000000000000000000000000000000000017815290600d820190565b915091506103cc8189896105b0565b60006103d7836105ee565b6040805133815273ffffffffffffffffffffffffffffffffffffffff831660208201529192507fce6e4a4a7b561c65155990775d2faf8a581292f97859ce67e366fd53686b31f1910160405180910390a17f0000000000000000000000003ced0801fc4ca43f80444e5d8e5d0fe643fd22b895507f000000000000000000000000d9543dc7ac39f540c2b3f5cc92d8542a2d9339c39450925050505b93509350939050565b606061048661065c565b905090565b805160208201206060907fb16774f25e8070712c15ff6f551827d0c112a45d880c2aa8b63b1c2f89a13f7b811461051c576040517f26cc0fec0000000000000000000000000000000000000000000000000000000081527fb16774f25e8070712c15ff6f551827d0c112a45d880c2aa8b63b1c2f89a13f7b6004820152602481018290526044015b60405180910390fd5b60008380602001905181019061053291906143b5565b905061053f816002610859565b949350505050565b61056b6040518060800160405280605a81526020016146f4605a9139848484610b86565b505050565b6060806105848361057f61058d565b610f43565b91509150915091565b606060405180610140016040528061010381526020016145f16101039139905090565b80600182510160200281015b808210156105d75781518552602094850194909101906105bc565b505061056b6105e38390565b8484516020016117ab565b6000806000600d9050835160e81c61ffff168101846000f0915073ffffffffffffffffffffffffffffffffffffffff8216610655576040517f08d4abb600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5092915050565b6060613f8e6000602d90508091506000604051806105c001604052808467ffffffffffffffff1667ffffffffffffffff168152602001611811815260200161188b81526020016118f281526020016118fb81526020016119778152602001611981815260200161198b815260200161198b81526020016119778152602001611977815260200161197781526020016119778152602001611977815260200161199581526020016119b781526020016119e1815260200161198b8152602001611995815260200161198b815260200161198b8152602001611a0381526020016118f2815260200161198b815260200161198b8152602001611a0d8152602001611a0d815260200161198b81526020016118f281526020016118f28152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d8152602001611a0d81526020016118f28152602001611a248152602001611a2e8152602001611a2e81525090506060819050602d8151146108475780516040517fc8b56901000000000000000000000000000000000000000000000000000000008152600481019190915260248101849052604401610513565b61085081611a3d565b94505050505090565b6060808060008060ff861667ffffffffffffffff81111561087c5761087c613fe1565b6040519080825280602002602001820160405280156108a5578160200160208202803683370190505b5093508560ff1667ffffffffffffffff8111156108c4576108c4613fe1565b6040519080825280602002602001820160405280156108ed578160200160208202803683370190505b509250865b8051156109625760008061090583611ace565b8951909550919350915082908890869081106109235761092361451b565b602002602001019060ff16908160ff16815250508086858151811061094a5761094a61451b565b602090810291909101015250506001909101906108f2565b5060006005885102602183026001010190508067ffffffffffffffff81111561098d5761098d613fe1565b6040519080825280601f01601f1916602001820160405280156109b7576020820181803683370190505b50955081602087015360005b828110156109f557806021026021880101816020026020018701518153602080830287010151600191820152016109c3565b50506021028401600601905060005b8651811015610b7c576000805b6000806000878581518110610a2857610a2861451b565b60200260200101519050600080610a788b8881518110610a4a57610a4a61451b565b602002602001015160ff168f8a81518110610a6757610a6761451b565b602002602001015160000151611bfc565b925090506005600087610aae7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff85018716611c1e565b01919091028a01805190955062ffffff84811693501690508015610b2357818103610b05576040517f59293c5100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600190970196610b1484611c1e565b87019650505050505050610a11565b8195505050505060188b8681518110610b3e57610b3e61451b565b60200260200101516020015160ff16901b602086901b17821791506000600160056001901b0319905082818351161782525050505050600101610a04565b5050505092915050565b6000610b9184611cf7565b90508082511115610bdb5781516040517ffd9e1af4000000000000000000000000000000000000000000000000000000008152600481019190915260248101829052604401610513565b60208501610be885611d15565b60005b82811015610f3a57600080610c008884611f2b565b915091508551831015610cd2578115610c4f576040517fee8d10810000000000000000000000000000000000000000000000000000000081526004810184905260248101839052604401610513565b858381518110610c6157610c6161451b565b6020026020010151811015610cd2578281878581518110610c8457610c8461451b565b60200260200101516040517ff7dd619f000000000000000000000000000000000000000000000000000000008152600401610513939291909283526020830191909152604082015260600190565b6000610ce089848a51611f50565b905060006018610cf08b87611fbc565b0390506000610cff8b87611fed565b600402820190505b80821015610e84578151601c81901a60020288015162ffffff821691601d1a9060f01c600080610d35888685565b91509150838214610d895760808801516040517fddf5607100000000000000000000000000000000000000000000000000000000815260048101919091526024810183905260448101859052606401610513565b8751821115610ddb57608088015188516040517f2cab6bff0000000000000000000000000000000000000000000000000000000081526004810192909252602482015260448101839052606401610513565b875182900380895260408901511115610e3d57608088015188516040808b015190517f1bc5ab0f000000000000000000000000000000000000000000000000000000008152600481019390935260248301919091526044820152606401610513565b8751810180895260208901511015610e5757875160208901525b6001811115610e6857875160408901525b5050506080850180516001019052505060049190910190610d07565b610e8e8b87612006565b836020015114610ee2578260200151610ea78c88612006565b6040517f4d9c18dc00000000000000000000000000000000000000000000000000000000815260048101929092526024820152604401610513565b82518414610f295782516040517f4689f0b3000000000000000000000000000000000000000000000000000000008152600481019190915260248101859052604401610513565b505060019093019250610beb915050565b50505050505050565b6060806000610f5061201f565b85519091501561178c578451600090602087810191880101825b818310156116e9576001835160001a1b905060018560e001511660000361127b576f07fffffe8000000000000000000000008116156111235760e08501516002161561100b578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f5520a51700000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b6f07fffffe0000000000000000000000008116156110b75761103d836f07fffffe0000000003ff20000000000061218e565b9450925060008061104e878761223f565b9150915081156110b0576040517f53e6feba0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08c8703016004820152602401610513565b50506110d8565b6110d560018401836f07fffffe0000000003ff2000000000006122b6565b92505b604085018051600190810190915260a086018051909101905260e0850180516022177fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffef169052610f6a565b6401000026008116156111745761114360018401836401000026006122b6565b60e0860180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd1690529250610f6a565b6704000000000000008116156111bd5760e0850180516021177fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed16905260019290920191610f6a565b658000000000008116156112515760108560e0015116600003611235578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517fedad0c5800000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b61123f89846122e2565b60e08601805160021790529250610f6a565b8883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001610fd6565b6f07fffffe0000000000000000000000008116156114105760e0850151600216156112fb578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f4e803df600000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b611315836f07fffffe0000000003ff20000000000061218e565b8095508194505050600080613f8e6113338b896101a00151896123ee565b92509250925082156113765760006113558961018001518e898563ffffffff16565b90975090506113658984836124ba565b5060e08801805160041790526113fd565b61138088886125f7565b909350915082156113a557611397886000846124ba565b6113a088612672565b6113fd565b6040517f81bd48db0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08d8803016004820152602401610513565b50505060e0850180516002179052610f6a565b60e08501516004161561150657650100000000008116600003611485576040517f23b5c6ea0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08a8503016004820152602401610513565b60608501805160001a60030190819053603b8111156114d0576040517f6232f2d900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5060e0850180517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9169052600190920191610f6a565b650200000000008116156115d7576000606086015160001a905080600003611580576040517f7f9db5420000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08b8603016004820152602401610513565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd01606086018181538160048201015160001a8260028301015160f01c60010153506115cb86612672565b50600190920191610f6a565b6401000026008116156115f75761114360018401836401000026006122b6565b6703ff00000000000081161561162d57611612858a856126d1565b925061161d85612672565b60e0850180516002179052610f6a565b6510000000000081161561165157611646858a85612823565b600190920191610f6a565b6708000000000000008116156116875761166c858a85612823565b61167585612af6565b601860e0860152600190920191610f6a565b658000000000008116156116bf578883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001611200565b8883037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016112c6565b818314611722576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60e085015160201615611787576040517ff06f54cf0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08a8503016004820152602401610513565b505050505b61179581612d38565b61179e82612e70565b92509250505b9250929050565b6020810680820384015b808510156117d05784518452602094850194909301926117b5565b50801561180b577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600882021c808451168119865116178452505b50505050565b815160009081908390811061186957608085015185516040517feaa16f330000000000000000000000000000000000000000000000000000000081526004810192909252602482015260448101829052606401610513565b846040015181111561187d57604085018190525b506000946001945092505050565b600080836060015183106118e557608084015160608501516040517feb7894540000000000000000000000000000000000000000000000000000000081526004810192909252602482015260448101849052606401610513565b5060009360019350915050565b50600191829150565b60008060008360ff1690506000600885901c60ff1690506000806119238860a0015185611f2b565b915091508281101561196b576040517fff1371080000000000000000000000000000000000000000000000000000000081526004810182905260248101849052604401610513565b50969095509350505050565b5060009160019150565b60101c9160019150565b5060029160019150565b600080601083901c806119a95760016119ab565b805b95600195509350505050565b600080601083901c806119cb5760026119cd565b805b905060028106156119a957806001016119ab565b600080601083901c806119f55760016119f7565b805b95600095509350505050565b5060039160019150565b600080601083901c600181116119a95760026119ab565b5060029160009150565b60046001808316019250929050565b60606000825160020267ffffffffffffffff811115611a5e57611a5e613fe1565b6040519080825280601f01601f191660200182016040528015611a88576020820181803683370190505b50905061ffff80196020850160208651028101600285015b81831015611ac257805183518616908516178152602090920191600201611aa0565b50939695505050505050565b60008060606000805b60ff811015611b4f576000805b8751811015611b1657600080611b06858b8581518110610a6757610a6761451b565b5093909317925050600101611ae4565b506000611b2282611c1e565b905083811115611b36578093508296508195505b87518103611b45575050611b4f565b5050600101611ad7565b5084516040805192909103808352600101602002820190529050600080805b8651811015611bf257600080611b938860ff168a8581518110610a6757610a6761451b565b91509150848216600003611baa5793811793611be8565b888381518110611bbc57611bbc61451b565b6020026020010151868581518110611bd657611bd661451b565b60209081029190910101526001909301925b5050600101611b6e565b5050509193909250565b60008082600052836020536021600020905060018160001a1b91509250929050565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611c505750610100919050565b507f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f7f5555555555555555555555555555555555555555555555555555555555555555600183901c16909103600281901c7f3333333333333333333333333333333333333333333333333333333333333333908116911601600481901c01167f01010101010101010101010101010101010101010101010101010101010101010260f81c90565b60008151600003611d0a57506000919050565b506020015160001a90565b6000611d2082611cf7565b90508015611ee95781516001600283020190811115611d6d57826040517f17f4bc5e00000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b82516020828501810191850101602160027fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860102860181019086015b808210611eae57815160f01c8481016004810185811115611df857896040517e39ba5600000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b8151600081901a90600181901a90600281901a9060031a80821180611e1c57508281115b15611e57578d876040517feaf45f4f00000000000000000000000000000000000000000000000000000000815260040161051392919061454a565b505050600481028201878114611e9b578b6040517ffbb8027a00000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b8397506002870396505050505050611daa565b838314610f3a57866040517fde67b29a00000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b600182511115611f2757816040517fd013da5d00000000000000000000000000000000000000000000000000000000815260040161051391906142a4565b5050565b6000806000611f3a8585611fbc565b51600281901a9660039190911a95509350505050565b611f896040518060c001604052806000815260200160008152602001600081526020016000815260200160008152602001606081525090565b506040805160c081018252838152602081018490529081019290925260608201526000608082015260a081019190915290565b600080611fc884611cf7565b60020260010190506000611fdc8585612ee5565b949091019093016020019392505050565b600080611ffa8484611fbc565b5160001a949350505050565b6000806120138484611fbc565b5160011a949350505050565b612098604051806101e001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b6000604051806101e0016040528060008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001601060081781526020016000815260200160008152602001600081526020016000815260200161210d6135bc60101b6133101790565b8152602001612137613cf360401b613b8260301b613a2660201b61391860101b61387b1717171790565b8152600060209182018190526040805183815280840182528452918301819052908201819052606082018190526080820181905260a08201819052610100820181905261012082018190526101c082015292915050565b8151600090819060015b8419600183831a1b16156020821016156121b457600101612198565b9485019460208190036008810292831c90921b9161223657604080516020810184905201604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527fe47fe8b7000000000000000000000000000000000000000000000000000000008252610513916004016142a4565b50939492505050565b60008061224c84846125f7565b9092509050816117a457506101008301805160408051948552602080862092865285018152909401517fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000909416601085901b62ff000016179092179091529160ff90911660010190565b60005b6000826001865160001a1b161183851016156122da576001840193506122b9565b509192915050565b805160009060f01c612f2a811461234b576040517f3e47169c0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0858503016004820152602401610513565b835160029390930192602a90602f90860160200160005b806123a8575b81871084885160001a1415161561238457600187019650612368565b6001870196508187101583885160001a1417156123a357506001958601955b612362565b50808611156123e3576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b509395945050505050565b600183810180516000928392613f8e92602160ff909116028801600681019201845b818310156124a6576001830151602190930180519093600090819060ff16818061243a838f611bfc565b9150915060008761244f600185038916611c1e565b016005028b015195505062ffffff90811693508416830391506124919050575060019850601b81901a9750601c1a8a901c61ffff169550610473945050505050565b61249a83611c1e565b84019350505050612410565b506000998a99508998509650505050505050565b6124c383612f3c565b60e08301805160207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff79190911681179091528301516021600091821a850101805190911a600101815350825180516060850151600090811a86016061018051929361ffff85169360088504909103601c0192600191901a018153600060038201537fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe30180517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00001690911790528451602090920183821b176018820185901b179182905260e08190036125f0578451604080518088526020601084901b81178252810190915281517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000161790525b5050505050565b61010082015161012083015160008381526020808220919384939290911c91600160ff84161b8082161561265d5761ffff83165b801561265b578360201c850361264e576001965061ffff8460101c16955061265b565b51925061ffff831661262b565b505b17610120909601959095525090939092509050565b6000606082015160001a905080600003611f275760208201805160001a600101908181535080603f0361056b576040517fa25cba3100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000613f8e60008060006126eb8861018001518888612f86565b8981038a206101408d015194985092965090945092507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000016906001600083811a82901b92909190831615612791576101608c015160101c5b801561278f5780517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00008116860361277e57600193505061278f565b505160019091019061ffff16612743565b505b6101608c015161ffff166127b76001846127ab57826127af565b8383035b8f91906124ba565b508161281357604080518082019091526101608d015160101c8517815260006127e58d8a8a63ffffffff8e16565b6020830152506101608d018051600161ffff9091160160109290921b9190911790526101408c018051841790525b50929a9950505050505050505050565b606083015160001a8015612889576040517f6fb11cdc0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0848403016004820152602401610513565b5061289383612f3c565b60e083018051603060089182161790915260a0840151602085015160ff8083169360f89290921c9290911c168103600081900361295c5760088660e0015116600003612931576040517fab1d3ea70000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b90820160f881901b60208701526101c08601519091906129519084613249565b6101c0870152612a25565b6001811115612a2557808310156129c5576040517f78ef27820000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b80831115612a25576040517f43168e680000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b8082036001016020601083028101905b81811015612ae15760a08901516020848b01015190821c61ffff169060001a60015b818111612ad05760208306601c03612a7057915160f01c915b82516101c08d015160019190911a90612a899082613291565b6101c08e0152612aba8284148015612aa15750886001145b612aac576001612aae565b8a5b6101c08f0151906132d8565b6101c08e01525060049290920191600101612a57565b505060019093019250601001612a35565b5050505060081b60a090940193909352505050565b60c0810151602082015160f082811c9160001a60010190829003612b46576040517fa806284100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600080856101c001519050855161ffff815160101c165b8015612b7457805190915060101c61ffff16612b5d565b50604051602188018051919450601c830192916004916024870191600090811a805b8a831015612c5c5760048202860195506004878903045b80821115612bcb57965161ffff16601c810198509690036007612bad565b506004810297889003805186529794909401938103865b6007821115612c27575160101c61ffff1680518652601c909501947ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff990910190612be2565b8115612c42575160101c61ffff168051865260048202909501945b505050600191820180519092919091019060001a80612b96565b50505050818652600486019350846001600484040360181b1763ffffffff19855116178452601f19601f820116604052505050506001846001901b612ca1919061459b565b851682851b60f0612cb38760106145ae565b901b171760c087015260e0860180517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdf16905260408051602080825280820183529088526000908801819052908701819052606087018190526080870181905260a08701819052610100870181905261012087018190526101c0870152505050505050565b60c08101518151516060919060f082901c9060208114612d84576040517f858f2dcf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b604051935060208401601083046000818353506001600885048301810192839101600080805b88811015612de35789811c61ffff81165163ffff0000601092831b16811760e01b8786015284019360f08390031b929092179101612daa565b50825117909152878203017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08181018952908801601f011660405260005b82811015612e64576002810288016003015161ffff90811683018051602060f082901c019260e09190911c1690612e598382846117ab565b505050600101612e21565b50505050505050919050565b6101608101516040805161ffff8316808252602080820283019081019093529092909160109190911c90835b80821115612edc5760208301518252915161ffff16917fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090910190612e9c565b50505050919050565b6000612ef083611cf7565b8210612f2c5782826040517f30489add00000000000000000000000000000000000000000000000000000000815260040161051392919061454a565b50600202016003015161ffff1690565b60208101805160001a6001810182015160001a61056b578251805160a085018051600861ffff939093169290920460200390920160106001601e84901a860301021b179052505050565b8051613f8e9060009081908190600181831a1b6703ff0000000000008116156131a857600182811a1b7ffffffffffffffffffffffffffffffffffeffffffffffffffffff000000000000828217016130625760028801806c7e0000007e03ff0000000000005b806001835160001a1b161561300657600182019150612fec565b508a5161ffff8d16908c016020018083111561304e576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b509850909650945084935061324092505050565b876001810160006703ff0000000000006c200000002000000000000000005b816001855160001a1b161561309b57600184019350613081565b806001855160001a1b16156130cc57600184019392505b816001855160001a1b16156130cc576001840193506130b2565b505080158015906130eb5750806003018211806130eb57508060010182145b15613148576040517f013b2aaa0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08d8303016004820152602401610513565b8b5161ffff60108f901c16908d0160200180841115613193576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50995091975095508594506132409350505050565b875188016020018088106131e8576040517f7d565df600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517fb0e4e5b30000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08a8a03016004820152602401610513565b93509350935093565b600061325583836132d8565b9250507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff821660ff600884811c919091168301901b1792915050565b600060ff8316828110156132d1576040517f04671d0000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050900390565b600060ff808416830190600885901c16601085901c808311156132f85750815b601081901b600883901b841717935050505092915050565b60008282036040811115613376576040517fff2f59490000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b806000036133d6576040517fc75cd5090000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b60028106600103613439576040517fd76d9b570000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff830160005b8582106135b2578151600090811a906001821b906703ff0000000000008216156134ac57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd0820161357c565b6c7e0000000000000000000000008216156134ea57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa9820161357c565b687e000000000000000082161561352457507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc9820161357c565b6040517f69f1e3e60000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08b8703016004820152602401610513565b831b959095179450507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9091019060040161345f565b5050509392505050565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffd8101516000908190603090829080821a87870360038111801561361157506001821b6c200000002000000000000000001615155b1561363357600488039550600a858460011a0302858460021a030193506136df565b8260011a915060028111801561365a57506001821b6c200000002000000000000000001615155b1561367257600388039550848360021a0393506136df565b801561368757600188039550600093506136df565b6040517ffa65827e0000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08b8b03016004820152602401610513565b5050505b8583101580156136f35750604d81105b1561373857825160001a829003600a82900a0293909301927fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201916001016136e3565b8583106135b257825160001a82900360018111156137ab578784037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f8f2b5ffd00000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b600a82900a81028581018611156137e6578885037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001613776565b9490940193507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909201915b8583106135b257825160001a60308114613850578784037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001613776565b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90920191613812565b80516000908190600190821a1b7ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008101613907576040517ff8216c550000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0868603016004820152602401610513565b83600092509250505b935093915050565b815181516000918291600190831a1b9085016020017ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008201613a185761396760018601826401000026006122b6565b94506000613979888861ffff89613e91565b909650905061398e86836401000026006122b6565b8051909650600160009190911a1b92506740000000000000008314613a08578686037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f722cd24a00000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b6001860194509250613910915050565b846000935093505050613910565b815181516000918291600190831a1b9085016020017ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008201613b2757613a7560018601826401000026006122b6565b94506000613a86888860ff89613e91565b909650905080613a9c87846401000026006122b6565b96506000613aad8a8a60ff8b613e91565b909850600881901b92909217919050613acc88856401000026006122b6565b8051909850600160009190911a1b94506740000000000000008514613b15578888037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016139d3565b50600187019550935061391092505050565b8585037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015b6040517f24027dc400000000000000000000000000000000000000000000000000000000815260040161051391815260200190565b815181516000918291600190831a1b9085016020017ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008201613a1857613bd160018601826401000026006122b6565b80519095506001600091821a1b92507fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008301613c0f57506000613c34565b613c1c8888600189613e91565b9096509050613c3186836401000026006122b6565b95505b85516001600091821a1b93507fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008401613c6f57506000613c94565b613c7c898960018a613e91565b9097509050613c9187846401000026006122b6565b96505b8651600160009190911a81901b945081901b82176740000000000000008514613ce1578888037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016139d3565b60018801965094506139109350505050565b815181516000918291600190831a1b9085016020017ffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000008201613b2757613d4260018601826401000026006122b6565b94506000613d53888860ff89613e91565b9096509050613d6886836401000026006122b6565b80519096506001600091821a1b93507fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008401613da657506000613dcb565b613db3898960018a613e91565b9097509050613dc887846401000026006122b6565b96505b86516001600091821a1b94507fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008501613e0657506000613e2b565b613e138a8a60018b613e91565b9098509050613e2888856401000026006122b6565b97505b8751600160009190911a1b9450600882901b8317600982901b176740000000000000008614613e7e578989037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0016139d3565b6001890197509550613910945050505050565b80516000908190600190821a1b7fffffffffffffffffffffffffffffffffffffffffffffffffc0000000000000008101613eef578584037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001613b4d565b613f8e6000806000613f028b8b8a612f86565b93509350935093506000613f1b8b85858863ffffffff16565b905089811115613f7d576040517f7480c7840000000000000000000000000000000000000000000000000000000081527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08c8b03016004820152602401610513565b909b909a5098505050505050505050565b613f966145c1565b565b600060208284031215613faa57600080fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114613fda57600080fd5b9392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561403357614033613fe1565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561408057614080613fe1565b604052919050565b600067ffffffffffffffff8211156140a2576140a2613fe1565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b600082601f8301126140df57600080fd5b81356140f26140ed82614088565b614039565b81815284602083860101111561410757600080fd5b816020850160208301376000918101602001919091529392505050565b600067ffffffffffffffff82111561413e5761413e613fe1565b5060051b60200190565b600082601f83011261415957600080fd5b813560206141696140ed83614124565b82815260059290921b8401810191818101908684111561418857600080fd5b8286015b848110156141a3578035835291830191830161418c565b509695505050505050565b6000806000606084860312156141c357600080fd5b833567ffffffffffffffff808211156141db57600080fd5b6141e7878388016140ce565b945060208601359150808211156141fd57600080fd5b61420987838801614148565b9350604086013591508082111561421f57600080fd5b5061422c86828701614148565b9150509250925092565b60005b83811015614251578181015183820152602001614239565b50506000910152565b60008151808452614272816020860160208601614236565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b602081526000613fda602083018461425a565b6000602082840312156142c957600080fd5b813567ffffffffffffffff8111156142e057600080fd5b61053f848285016140ce565b600081518084526020808501945080840160005b8381101561431c57815187529582019590820190600101614300565b509495945050505050565b60408152600061433a604083018561425a565b828103602084015261434c81856142ec565b95945050505050565b73ffffffffffffffffffffffffffffffffffffffff85168152608060208201526000614384608083018661425a565b828103604084015261439681866142ec565b905082810360608401526143aa81856142ec565b979650505050505050565b600060208083850312156143c857600080fd5b825167ffffffffffffffff808211156143e057600080fd5b818501915085601f8301126143f457600080fd5b81516144026140ed82614124565b81815260059190911b8301840190848101908883111561442157600080fd5b8585015b8381101561450e5780518581111561443d5760008081fd5b86016060818c037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0018113156144735760008081fd5b61447b614010565b89830151815260408084015160ff811681146144975760008081fd5b828c01529183015191888311156144ae5760008081fd5b82840193508d603f8501126144c557600092508283fd5b8a84015192506144d76140ed84614088565b8381528e828587010111156144ec5760008081fd5b6144fb848d8301848801614236565b9082015285525050918601918601614425565b5098975050505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60408152600061455d604083018561425a565b90508260208301529392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156102cf576102cf61456c565b808201808211156102cf576102cf61456c565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052605160045260246000fdfe013e002a2208b2001080a0102400000302920481840880062e1240044004200204001100c332a00a00d8ac552500df95d8070038ef251e008683ce050031dbd003208596c41f00048a5a16008b6c060d00f39c0626006806f922002870ea21002cb51d1d007ed6ee1c40ce75301000ab79f01400862cf02300f82ccc2b102116660f10a5c7372c10d76cb417003e0bda1b40dce01d2700ec21ff1200121cd20010f7a0481500d0147329002655b3042036bc2d01100b23821a3074ca4013006c16580b00afd55a0e1097af9a02006ab30728009ea40f090008512f2a00a2f61c24002b93430c00e043780800cb7812060096888b190069940c20000c6d8d18002584c41811188b18f218fb19771981198b198b19771977197719771977199519b719e1198b1995198b198b1a0318f2198b198b1a0d1a0d198b18f218f21a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d18f21a241a2e1a2e
|
{{
"language": "Solidity",
"sources": {
"lib/rain.flow/lib/rain.interpreter/src/concrete/RainterpreterExpressionDeployerNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity =0.8.19;\n\nimport \"openzeppelin-contracts/contracts/utils/introspection/ERC165.sol\";\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {LibStackPointer} from \"rain.solmem/lib/LibStackPointer.sol\";\nimport {LibDataContract, DataContractMemoryContainer} from \"rain.datacontract/lib/LibDataContract.sol\";\nimport \"rain.erc1820/lib/LibIERC1820.sol\";\n\nimport \"../interface/unstable/IExpressionDeployerV2.sol\";\nimport \"../interface/unstable/IDebugExpressionDeployerV2.sol\";\nimport \"../interface/unstable/IDebugInterpreterV2.sol\";\nimport \"../interface/unstable/IParserV1.sol\";\n\nimport {LibIntegrityCheckNP} from \"../lib/integrity/LibIntegrityCheckNP.sol\";\nimport \"../lib/state/LibInterpreterStateDataContractNP.sol\";\nimport \"../lib/op/LibAllStandardOpsNP.sol\";\nimport {LibParse, LibParseMeta, AuthoringMeta} from \"../lib/parse/LibParse.sol\";\n\nimport {RainterpreterNP, OPCODE_FUNCTION_POINTERS, INTERPRETER_BYTECODE_HASH} from \"./RainterpreterNP.sol\";\n\n/// @dev Thrown when the pointers known to the expression deployer DO NOT match\n/// the interpreter it is constructed for. This WILL cause undefined expression\n/// behaviour so MUST REVERT.\n/// @param actualPointers The actual function pointers found at the interpreter\n/// address upon construction.\nerror UnexpectedPointers(bytes actualPointers);\n\n/// Thrown when the `RainterpreterExpressionDeployer` is constructed with unknown\n/// interpreter bytecode.\n/// @param expectedBytecodeHash The bytecode hash that was expected at the\n/// interpreter address upon construction.\n/// @param actualBytecodeHash The bytecode hash that was found at the interpreter\n/// address upon construction.\nerror UnexpectedInterpreterBytecodeHash(bytes32 expectedBytecodeHash, bytes32 actualBytecodeHash);\n\n/// Thrown when the `Rainterpreter` is constructed with unknown store bytecode.\n/// @param expectedBytecodeHash The bytecode hash that was expected at the store\n/// address upon construction.\n/// @param actualBytecodeHash The bytecode hash that was found at the store\n/// address upon construction.\nerror UnexpectedStoreBytecodeHash(bytes32 expectedBytecodeHash, bytes32 actualBytecodeHash);\n\n/// Thrown when the `Rainterpreter` is constructed with unknown meta.\n/// @param expectedConstructionMetaHash The meta hash that was expected upon\n/// construction.\n/// @param actualConstructionMetaHash The meta hash that was found upon\n/// construction.\nerror UnexpectedConstructionMetaHash(bytes32 expectedConstructionMetaHash, bytes32 actualConstructionMetaHash);\n\n/// @dev The function pointers for the integrity check fns.\nbytes constant INTEGRITY_FUNCTION_POINTERS =\n hex\"1811188b18f218fb19771981198b198b19771977197719771977199519b719e1198b1995198b198b1a0318f2198b198b1a0d1a0d198b18f218f21a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d18f21a241a2e1a2e\";\n\n/// @dev Hash of the known store bytecode.\nbytes32 constant STORE_BYTECODE_HASH = bytes32(0xd6130168250d3957ae34f8026c2bdbd7e21d35bb202e8540a9b3abcbc232ddb6);\n\n/// @dev Hash of the known authoring meta.\nbytes32 constant AUTHORING_META_HASH = bytes32(0xb16774f25e8070712c15ff6f551827d0c112a45d880c2aa8b63b1c2f89a13f7b);\n\n/// @dev Hash of the known construction meta.\nbytes32 constant CONSTRUCTION_META_HASH = bytes32(0x43e7d24e548ff92fae16c245e1653f705e016bb24fd21dc0ab89d862c3071a18);\n\nbytes constant PARSE_META =\n hex\"013e002a2208b2001080a0102400000302920481840880062e1240044004200204001100c332a00a00d8ac552500df95d8070038ef251e008683ce050031dbd003208596c41f00048a5a16008b6c060d00f39c0626006806f922002870ea21002cb51d1d007ed6ee1c40ce75301000ab79f01400862cf02300f82ccc2b102116660f10a5c7372c10d76cb417003e0bda1b40dce01d2700ec21ff1200121cd20010f7a0481500d0147329002655b3042036bc2d01100b23821a3074ca4013006c16580b00afd55a0e1097af9a02006ab30728009ea40f090008512f2a00a2f61c24002b93430c00e043780800cb7812060096888b190069940c20000c6d8d18002584c4\";\n\n/// All config required to construct a `Rainterpreter`.\n/// @param interpreter The `IInterpreterV1` to use for evaluation. MUST match\n/// known bytecode.\n/// @param store The `IInterpreterStoreV1`. MUST match known bytecode.\n/// @param meta Contract meta for tooling.\nstruct RainterpreterExpressionDeployerConstructionConfig {\n address interpreter;\n address store;\n bytes meta;\n}\n\n/// @title RainterpreterExpressionDeployer\n/// @notice !!!EXPERIMENTAL!!! This is the deployer for the RainterpreterNP\n/// interpreter. Notably includes onchain parsing/compiling of expressions from\n/// Rainlang strings.\ncontract RainterpreterExpressionDeployerNP is IExpressionDeployerV2, IDebugExpressionDeployerV2, IParserV1, ERC165 {\n using LibPointer for Pointer;\n using LibStackPointer for Pointer;\n using LibUint256Array for uint256[];\n\n /// The config of the deployed expression including uncompiled sources. Will\n /// only be emitted after the config passes the integrity check.\n /// @param sender The caller of `deployExpression`.\n /// @param bytecode As per `IExpressionDeployerV2`.\n /// @param constants As per `IExpressionDeployerV2`.\n /// @param minOutputs As per `IExpressionDeployerV2`.\n event NewExpression(address sender, bytes bytecode, uint256[] constants, uint256[] minOutputs);\n\n /// The address of the deployed expression. Will only be emitted once the\n /// expression can be loaded and deserialized into an evaluable interpreter\n /// state.\n /// @param sender The caller of `deployExpression`.\n /// @param expression The address of the deployed expression.\n event ExpressionAddress(address sender, address expression);\n\n /// The interpreter with known bytecode that this deployer is constructed\n /// for.\n IInterpreterV1 public immutable iInterpreter;\n /// The store with known bytecode that this deployer is constructed for.\n IInterpreterStoreV1 public immutable iStore;\n\n constructor(RainterpreterExpressionDeployerConstructionConfig memory config) {\n // Set the immutables.\n IInterpreterV1 interpreter = IInterpreterV1(config.interpreter);\n IInterpreterStoreV1 store = IInterpreterStoreV1(config.store);\n iInterpreter = interpreter;\n iStore = store;\n\n /// This IS a security check. This prevents someone making an exact\n /// bytecode copy of the interpreter and shipping different meta for\n /// the copy to lie about what each op does in the interpreter.\n bytes32 constructionMetaHash = keccak256(config.meta);\n if (constructionMetaHash != CONSTRUCTION_META_HASH) {\n revert UnexpectedConstructionMetaHash(CONSTRUCTION_META_HASH, constructionMetaHash);\n }\n\n // Guard against serializing incorrect function pointers, which would\n // cause undefined runtime behaviour for corrupted opcodes.\n bytes memory functionPointers = interpreter.functionPointers();\n if (keccak256(functionPointers) != keccak256(OPCODE_FUNCTION_POINTERS)) {\n revert UnexpectedPointers(functionPointers);\n }\n // Guard against an interpreter with unknown bytecode.\n bytes32 interpreterHash;\n assembly (\"memory-safe\") {\n interpreterHash := extcodehash(interpreter)\n }\n if (interpreterHash != INTERPRETER_BYTECODE_HASH) {\n /// THIS IS NOT A SECURITY CHECK. IT IS AN INTEGRITY CHECK TO PREVENT\n /// HONEST MISTAKES.\n revert UnexpectedInterpreterBytecodeHash(INTERPRETER_BYTECODE_HASH, interpreterHash);\n }\n\n // Guard against an store with unknown bytecode.\n bytes32 storeHash;\n assembly (\"memory-safe\") {\n storeHash := extcodehash(store)\n }\n if (storeHash != STORE_BYTECODE_HASH) {\n /// THIS IS NOT A SECURITY CHECK. IT IS AN INTEGRITY CHECK TO PREVENT\n /// HONEST MISTAKES.\n revert UnexpectedStoreBytecodeHash(STORE_BYTECODE_HASH, storeHash);\n }\n\n emit DISpair(msg.sender, address(this), address(interpreter), address(store), config.meta);\n\n // Register the interface for the deployer.\n // We have to check that the 1820 registry has bytecode at the address\n // before we can register the interface. We can't assume that the chain\n // we are deploying to has 1820 deployed.\n if (address(IERC1820_REGISTRY).code.length > 0) {\n IERC1820_REGISTRY.setInterfaceImplementer(\n address(this), IERC1820_REGISTRY.interfaceHash(IERC1820_NAME_IEXPRESSION_DEPLOYER_V2), address(this)\n );\n }\n }\n\n // @inheritdoc IERC165\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IExpressionDeployerV2).interfaceId || interfaceId == type(IERC165).interfaceId;\n }\n\n /// @inheritdoc IParserV1\n function authoringMetaHash() external pure virtual override returns (bytes32) {\n return AUTHORING_META_HASH;\n }\n\n /// @inheritdoc IParserV1\n function buildParseMeta(bytes memory authoringMeta) external pure virtual override returns (bytes memory) {\n bytes32 inputAuthoringMetaHash = keccak256(authoringMeta);\n if (inputAuthoringMetaHash != AUTHORING_META_HASH) {\n revert AuthoringMetaHashMismatch(AUTHORING_META_HASH, inputAuthoringMetaHash);\n }\n AuthoringMeta[] memory words = abi.decode(authoringMeta, (AuthoringMeta[]));\n return LibParseMeta.buildParseMeta(words, 2);\n }\n\n /// @inheritdoc IParserV1\n function parseMeta() public pure virtual override returns (bytes memory) {\n return PARSE_META;\n }\n\n /// @inheritdoc IParserV1\n function parse(bytes memory data) external pure virtual override returns (bytes memory, uint256[] memory) {\n // The return is used by returning it, so this is a false positive.\n //slither-disable-next-line unused-return\n return LibParse.parse(data, parseMeta());\n }\n\n /// @inheritdoc IExpressionDeployerV2\n function deployExpression(bytes memory bytecode, uint256[] memory constants, uint256[] memory minOutputs)\n external\n returns (IInterpreterV1, IInterpreterStoreV1, address)\n {\n integrityCheck(bytecode, constants, minOutputs);\n\n emit NewExpression(msg.sender, bytecode, constants, minOutputs);\n\n (DataContractMemoryContainer container, Pointer pointer) =\n LibDataContract.newContainer(LibInterpreterStateDataContractNP.serializeSizeNP(bytecode, constants));\n\n // Serialize the state config into bytes that can be deserialized later\n // by the interpreter.\n LibInterpreterStateDataContractNP.unsafeSerializeNP(pointer, bytecode, constants);\n\n // Deploy the serialized expression onchain.\n address expression = LibDataContract.write(container);\n\n // Emit and return the address of the deployed expression.\n emit ExpressionAddress(msg.sender, expression);\n\n return (iInterpreter, iStore, expression);\n }\n\n /// @inheritdoc IDebugExpressionDeployerV2\n function integrityCheck(bytes memory bytecode, uint256[] memory constants, uint256[] memory minOutputs)\n public\n view\n {\n LibIntegrityCheckNP.integrityCheck(INTEGRITY_FUNCTION_POINTERS, bytecode, constants, minOutputs);\n }\n\n /// Defines all the function pointers to integrity checks. This is the\n /// expression deployer's equivalent of the opcode function pointers and\n /// follows a near identical dispatch process. These are never compiled into\n /// source and are instead indexed into directly by the integrity check. The\n /// indexing into integrity pointers (which has an out of bounds check) is a\n /// proxy for enforcing that all opcode pointers exist at runtime, so the\n /// length of the integrity pointers MUST match the length of opcode function\n /// pointers. This function is `virtual` so that it can be overridden\n /// pairwise with overrides to `functionPointers` on `Rainterpreter`.\n /// @return The list of integrity function pointers.\n function integrityFunctionPointers() external view virtual returns (bytes memory) {\n return LibAllStandardOpsNP.integrityFunctionPointers();\n }\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibPointer.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// A pointer to a location in memory. This is a `uint256` to save gas on low\n/// level operations on the evm stack. These same low level operations typically\n/// WILL NOT check for overflow or underflow, so all pointer logic MUST ensure\n/// that reads, writes and movements are not out of bounds.\ntype Pointer is uint256;\n\n/// @title LibPointer\n/// Ergonomic wrappers around common pointer movements, reading and writing. As\n/// wrappers on such low level operations often introduce too much jump gas\n/// overhead, these functions MAY find themselves used in reference\n/// implementations that more optimised code can be fuzzed against. MAY also be\n/// situationally useful on cooler performance paths.\nlibrary LibPointer {\n /// Cast a `Pointer` to `bytes` without modification or any safety checks.\n /// The caller MUST ensure the pointer is to a valid region of memory for\n /// some `bytes`.\n /// @param pointer The pointer to cast to `bytes`.\n /// @return data The cast `bytes`.\n function unsafeAsBytes(Pointer pointer) internal pure returns (bytes memory data) {\n assembly (\"memory-safe\") {\n data := pointer\n }\n }\n\n /// Increase some pointer by a number of bytes.\n ///\n /// This is UNSAFE because it can silently overflow or point beyond some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// Note that moving a pointer by some bytes offset is likely to unalign it\n /// with the 32 byte increments of the Solidity allocator.\n ///\n /// @param pointer The pointer to increase by `length`.\n /// @param length The number of bytes to increase the pointer by.\n /// @return The increased pointer.\n function unsafeAddBytes(Pointer pointer, uint256 length) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := add(pointer, length)\n }\n return pointer;\n }\n\n /// Increase some pointer by a single 32 byte word.\n ///\n /// This is UNSAFE because it can silently overflow or point beyond some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// If the original pointer is aligned to the Solidity allocator it will be\n /// aligned after the movement.\n ///\n /// @param pointer The pointer to increase by a single word.\n /// @return The increased pointer.\n function unsafeAddWord(Pointer pointer) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := add(pointer, 0x20)\n }\n return pointer;\n }\n\n /// Increase some pointer by multiple 32 byte words.\n ///\n /// This is UNSAFE because it can silently overflow or point beyond some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// If the original pointer is aligned to the Solidity allocator it will be\n /// aligned after the movement.\n ///\n /// @param pointer The pointer to increase.\n /// @param words The number of words to increase the pointer by.\n /// @return The increased pointer.\n function unsafeAddWords(Pointer pointer, uint256 words) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := add(pointer, mul(0x20, words))\n }\n return pointer;\n }\n\n /// Decrease some pointer by a single 32 byte word.\n ///\n /// This is UNSAFE because it can silently underflow or point below some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// If the original pointer is aligned to the Solidity allocator it will be\n /// aligned after the movement.\n ///\n /// @param pointer The pointer to decrease by a single word.\n /// @return The decreased pointer.\n function unsafeSubWord(Pointer pointer) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := sub(pointer, 0x20)\n }\n return pointer;\n }\n\n /// Decrease some pointer by multiple 32 byte words.\n ///\n /// This is UNSAFE because it can silently underflow or point below some\n /// data structure. The caller MUST ensure that this is a safe operation.\n ///\n /// If the original pointer is aligned to the Solidity allocator it will be\n /// aligned after the movement.\n ///\n /// @param pointer The pointer to decrease.\n /// @param words The number of words to decrease the pointer by.\n /// @return The decreased pointer.\n function unsafeSubWords(Pointer pointer, uint256 words) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n pointer := sub(pointer, mul(0x20, words))\n }\n return pointer;\n }\n\n /// Read the word at the pointer.\n ///\n /// This is UNSAFE because it can read outside any particular data stucture\n /// or even beyond allocated memory. The caller MUST ensure that this is a\n /// safe operation.\n ///\n /// @param pointer Pointer to read the word at.\n /// @return word The word read from the pointer.\n function unsafeReadWord(Pointer pointer) internal pure returns (uint256 word) {\n assembly (\"memory-safe\") {\n word := mload(pointer)\n }\n }\n\n /// Write a word at the pointer.\n ///\n /// This is UNSAFE because it can write outside any particular data stucture\n /// or even beyond allocated memory. The caller MUST ensure that this is a\n /// safe operation.\n ///\n /// @param pointer Pointer to write the word at.\n /// @param word The word to write.\n function unsafeWriteWord(Pointer pointer, uint256 word) internal pure {\n assembly (\"memory-safe\") {\n mstore(pointer, word)\n }\n }\n\n /// Get the pointer to the end of all allocated memory.\n /// As per Solidity docs, there is no guarantee that the region of memory\n /// beyond this pointer is zeroed out, as assembly MAY write beyond allocated\n /// memory for temporary use if the scratch space is insufficient.\n /// @return pointer The pointer to the end of all allocated memory.\n function allocatedMemoryPointer() internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := mload(0x40)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibStackPointer.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibUint256Array.sol\";\nimport \"./LibMemory.sol\";\nimport \"./LibMemCpy.sol\";\n\n/// Throws if a stack pointer is not aligned to 32 bytes.\nerror UnalignedStackPointer(Pointer pointer);\n\n/// @title LibStackPointer\n/// @notice A stack `Pointer` is still just a pointer to some memory, but we are\n/// going to treat it like it is pointing to a stack data structure. That means\n/// it can move \"up\" and \"down\" (increment and decrement) by `uint256` (32 bytes)\n/// increments. Structurally a stack is a `uint256[]` but we can save a lot of\n/// gas vs. default Solidity handling of array indexes by using assembly to\n/// bypass runtime bounds checks on every read and write. Of course, this means\n/// the caller is responsible for ensuring the stack reads and write are not out\n/// of bounds.\n///\n/// The pointer to the bottom of a stack points at the 0th item, NOT the length\n/// of the implied `uint256[]` and the top of a stack points AFTER the last item.\n/// e.g. consider a `uint256[]` in memory with values `3 A B C` and assume this\n/// starts at position `0` in memory, i.e. `0` points to value `3` for the\n/// array length. In this case the stack bottom would be `Pointer.wrap(0x20)`\n/// (32 bytes above 0, past the length) and the stack top would be\n/// `StackPointer.wrap(0x80)` (96 bytes above the stack bottom).\n///\n/// Most of the functions in this library are equivalent to each other via\n/// composition, i.e. everything could be achieved with just `up`, `down`,\n/// `pop`, `push`, `peek`. The reason there is so much overloaded/duplicated\n/// logic is that the Solidity compiler seems to fail at inlining equivalent\n/// logic quite a lot. Perhaps once the IR compilation of Solidity is better\n/// supported by tooling etc. we could remove a lot of this duplication as the\n/// compiler itself would handle the optimisations.\nlibrary LibStackPointer {\n using LibStackPointer for Pointer;\n using LibStackPointer for uint256[];\n using LibStackPointer for bytes;\n using LibUint256Array for uint256[];\n using LibMemory for uint256;\n\n /// Read the word immediately below the given stack pointer.\n ///\n /// Treats the given pointer as a pointer to the top of the stack, so `peek`\n /// reads the word below the pointer.\n ///\n /// https://en.wikipedia.org/wiki/Peek_(data_type_operation)\n ///\n /// The caller MUST ensure this read is not out of bounds, e.g. a `peek` to\n /// `0` will underflow (and exhaust gas attempting to read).\n ///\n /// @param pointer Pointer to the top of the stack to read below.\n /// @return word The word that was read.\n function unsafePeek(Pointer pointer) internal pure returns (uint256 word) {\n assembly (\"memory-safe\") {\n word := mload(sub(pointer, 0x20))\n }\n }\n\n /// Peeks 2 words from the top of the stack.\n ///\n /// Same as `unsafePeek` but returns 2 words instead of 1.\n ///\n /// @param pointer The stack top to peek below.\n /// @return lower The lower of the two words read.\n /// @return upper The upper of the two words read.\n function unsafePeek2(Pointer pointer) internal pure returns (uint256 lower, uint256 upper) {\n assembly (\"memory-safe\") {\n lower := mload(sub(pointer, 0x40))\n upper := mload(sub(pointer, 0x20))\n }\n }\n\n /// Pops the word from the top of the stack.\n ///\n /// Treats the given pointer as a pointer to the top of the stack, so `pop`\n /// reads the word below the pointer. The popped pointer is returned\n /// alongside the read word.\n ///\n /// https://en.wikipedia.org/wiki/Stack_(abstract_data_type)\n ///\n /// The caller MUST ensure the pop will not result in an out of bounds read.\n ///\n /// @param pointer Pointer to the top of the stack to read below.\n /// @return pointerAfter Pointer after the pop.\n /// @return word The word that was read.\n function unsafePop(Pointer pointer) internal pure returns (Pointer pointerAfter, uint256 word) {\n assembly (\"memory-safe\") {\n pointerAfter := sub(pointer, 0x20)\n word := mload(pointerAfter)\n }\n }\n\n /// Pushes a word to the top of the stack.\n ///\n /// Treats the given pointer as a pointer to the top of the stack, so `push`\n /// writes a word at the pointer. The pushed pointer is returned.\n ///\n /// https://en.wikipedia.org/wiki/Stack_(abstract_data_type)\n ///\n /// The caller MUST ensure the push will not result in an out of bounds\n /// write.\n ///\n /// @param pointer The stack pointer to write at.\n /// @param word The value to write.\n /// @return The stack pointer above where `word` was written to.\n function unsafePush(Pointer pointer, uint256 word) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n mstore(pointer, word)\n pointer := add(pointer, 0x20)\n }\n return pointer;\n }\n\n /// Returns `length` values from the stack as an array without allocating\n /// new memory. As arrays always start with their length, this requires\n /// writing the length value to the stack below the array values. The value\n /// that is overwritten in the process is also returned so that data is not\n /// lost. For example, imagine a stack `[ A B C D ]` and we list 2 values.\n /// This will write the stack to look like `[ A 2 C D ]` and return both `B`\n /// and a pointer to `2` represented as a `uint256[]`.\n /// The returned array is ONLY valid for as long as the stack DOES NOT move\n /// back into its memory. As soon as the stack moves up again and writes into\n /// the array it will be corrupt. The caller MUST ensure that it does not\n /// read from the returned array after it has been corrupted by subsequent\n /// stack writes.\n /// @param pointer The stack pointer to read the values below into an\n /// array.\n /// @param length The number of values to include in the returned array.\n /// @return head The value that was overwritten with the length.\n /// @return tail The array constructed from the stack memory.\n function unsafeList(Pointer pointer, uint256 length) internal pure returns (uint256 head, uint256[] memory tail) {\n assembly (\"memory-safe\") {\n tail := sub(pointer, add(0x20, mul(length, 0x20)))\n head := mload(tail)\n mstore(tail, length)\n }\n }\n\n /// Convert two stack pointer values to a single stack index. A stack index\n /// is the distance in 32 byte increments between two stack pointers. The\n /// calculations require the two stack pointers are aligned. If the pointers\n /// are not aligned, the function will revert.\n ///\n /// @param lower The lower of the two values.\n /// @param upper The higher of the two values.\n /// @return The stack index as 32 byte words distance between the top and\n /// bottom. Negative if `lower` is above `upper`.\n function toIndexSigned(Pointer lower, Pointer upper) internal pure returns (int256) {\n unchecked {\n if (Pointer.unwrap(lower) % 0x20 != 0) {\n revert UnalignedStackPointer(lower);\n }\n if (Pointer.unwrap(upper) % 0x20 != 0) {\n revert UnalignedStackPointer(upper);\n }\n // Dividing by 0x20 before casting to a signed int avoids the case\n // where the difference between the two pointers is greater than\n // `type(int256).max` and would overflow the signed int.\n return int256(Pointer.unwrap(upper) / 0x20) - int256(Pointer.unwrap(lower) / 0x20);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.datacontract/src/lib/LibDataContract.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.solmem/lib/LibPointer.sol\";\n\n/// Thrown if writing the data by creating the contract fails somehow.\nerror WriteError();\n\n/// Thrown if reading a zero length address.\nerror ReadError();\n\n/// @dev SSTORE2 Verbatim reference\n/// https://github.com/0xsequence/sstore2/blob/master/contracts/utils/Bytecode.sol#L15\n///\n/// 0x00 0x63 0x63XXXXXX PUSH4 _code.length size\n/// 0x01 0x80 0x80 DUP1 size size\n/// 0x02 0x60 0x600e PUSH1 14 14 size size\n/// 0x03 0x60 0x6000 PUSH1 00 0 14 size size\n/// 0x04 0x39 0x39 CODECOPY size\n/// 0x05 0x60 0x6000 PUSH1 00 0 size\n/// 0x06 0xf3 0xf3 RETURN\n/// <CODE>\n///\n/// However note that 00 is also prepended (although docs say append) so there's\n/// an additional byte that isn't described above.\n/// https://github.com/0xsequence/sstore2/blob/master/contracts/SSTORE2.sol#L25\n///\n/// Note also typo 0x63XXXXXX which indicates 3 bytes but instead 4 are used as\n/// 0x64XXXXXXXX.\n///\n/// Note also that we don't need 4 bytes to represent the size of a contract as\n/// 24kb is the max PUSH2 (0x61) can be used instead of PUSH4 for code length.\n/// This also changes the 0x600e to 0x600c as we've reduced prefix size by 2\n/// relative to reference implementation.\n/// https://github.com/0xsequence/sstore2/pull/5/files\nuint256 constant BASE_PREFIX = 0x61_0000_80_600C_6000_39_6000_F3_00_00000000000000000000000000000000000000;\n\n/// @dev Length of the prefix that converts in memory data to a deployable\n/// contract.\nuint256 constant PREFIX_BYTES_LENGTH = 13;\n\n/// A container is a region of memory that is directly deployable with `create`,\n/// without length prefixes or other Solidity type trappings. Where the length is\n/// needed, such as in `write` it can be read as bytes `[1,2]` from the prefix.\n/// This is just a pointer but given a new type to help avoid mistakes.\ntype DataContractMemoryContainer is uint256;\n\n/// @title DataContract\n///\n/// DataContract is a simplified reimplementation of\n/// https://github.com/0xsequence/sstore2\n///\n/// - Doesn't force additonal internal allocations with ABI encoding calls\n/// - Optimised for the case where the data to read/write and contract are 1:1\n/// - Assembly optimisations for less gas usage\n/// - Not shipped with other unrelated code to reduce dependency bloat\n/// - Fuzzed with foundry\n///\n/// It is a little more low level in that it doesn't work on `bytes` from\n/// Solidity but instead requires the caller to copy memory directy by pointer.\n/// https://github.com/rainprotocol/sol.lib.bytes can help with that.\nlibrary LibDataContract {\n /// Prepares a container ready to write exactly `length_` bytes at the\n /// returned `pointer_`. The caller MUST write exactly the number of bytes\n /// that it asks for at the pointer otherwise memory WILL be corrupted.\n /// @param length_ Caller specifies the number of bytes to allocate for the\n /// data it wants to write. The actual size of the container in memory will\n /// be larger than this due to the contract creation prefix and the padding\n /// potentially required to align the memory allocation.\n /// @return container_ The pointer to the start of the container that can be\n /// deployed as an onchain contract. Caller can pass this back to `write` to\n /// have the data contract deployed\n /// (after it copies its data to the pointer).\n /// @return pointer_ The caller can copy its data at the pointer without any\n /// additional allocations or Solidity type wrangling.\n function newContainer(uint256 length_)\n internal\n pure\n returns (DataContractMemoryContainer container_, Pointer pointer_)\n {\n unchecked {\n uint256 prefixBytesLength_ = PREFIX_BYTES_LENGTH;\n uint256 basePrefix_ = BASE_PREFIX;\n assembly (\"memory-safe\") {\n // allocate output byte array - this could also be done without assembly\n // by using container_ = new bytes(size)\n container_ := mload(0x40)\n // new \"memory end\" including padding\n mstore(0x40, add(container_, and(add(add(length_, prefixBytesLength_), 0x1f), not(0x1f))))\n // pointer is where the caller will write data to\n pointer_ := add(container_, prefixBytesLength_)\n\n // copy length into the 2 bytes gap in the base prefix\n let prefix_ :=\n or(\n basePrefix_,\n shl(\n // length sits 29 bytes from the right\n 232,\n and(\n // mask the length to 2 bytes\n 0xFFFF,\n add(length_, 1)\n )\n )\n )\n mstore(container_, prefix_)\n }\n }\n }\n\n /// Given a container prepared by `newContainer` and populated with bytes by\n /// the caller, deploy to a new onchain contract and return the contract\n /// address.\n /// @param container_ The container full of data to deploy as an onchain data\n /// contract.\n /// @return The newly deployed contract containing the data in the container.\n function write(DataContractMemoryContainer container_) internal returns (address) {\n address pointer_;\n uint256 prefixLength_ = PREFIX_BYTES_LENGTH;\n assembly (\"memory-safe\") {\n pointer_ :=\n create(\n 0,\n container_,\n add(\n prefixLength_,\n // Read length out of prefix.\n and(0xFFFF, shr(232, mload(container_)))\n )\n )\n }\n // Zero address means create failed.\n if (pointer_ == address(0)) revert WriteError();\n return pointer_;\n }\n\n /// Reads data back from a previously deployed container.\n /// Almost verbatim Solidity docs.\n /// https://docs.soliditylang.org/en/v0.8.17/assembly.html#example\n /// Notable difference is that we skip the first byte when we read as it is\n /// a `0x00` prefix injected by containers on deploy.\n /// @param pointer_ The address of the data contract to read from. MUST have\n /// a leading byte that can be safely ignored.\n /// @return data_ The data read from the data contract. First byte is skipped\n /// and contract is read completely to the end.\n function read(address pointer_) internal view returns (bytes memory data_) {\n uint256 size_;\n assembly (\"memory-safe\") {\n // Retrieve the size of the code, this needs assembly.\n size_ := extcodesize(pointer_)\n }\n if (size_ == 0) revert ReadError();\n assembly (\"memory-safe\") {\n // Skip the first byte.\n size_ := sub(size_, 1)\n // Allocate output byte array - this could also be done without\n // assembly by using data_ = new bytes(size)\n data_ := mload(0x40)\n // New \"memory end\" including padding.\n // Compiler will optimise away the double constant addition.\n mstore(0x40, add(data_, and(add(add(size_, 0x20), 0x1f), not(0x1f))))\n // Store length in memory.\n mstore(data_, size_)\n // actually retrieve the code, this needs assembly\n // skip the first byte\n extcodecopy(pointer_, add(data_, 0x20), 1, size_)\n }\n }\n\n /// Hybrid of address-only read, SSTORE2 read and Solidity docs.\n /// Unlike SSTORE2, reading past the end of the data contract WILL REVERT.\n /// @param pointer_ As per `read`.\n /// @param start_ Starting offset for reads from the data contract.\n /// @param length_ Number of bytes to read.\n function readSlice(address pointer_, uint16 start_, uint16 length_) internal view returns (bytes memory data_) {\n uint256 size_;\n // uint256 offset and end avoids overflow issues from uint16.\n uint256 offset_;\n uint256 end_;\n assembly (\"memory-safe\") {\n // Skip the first byte.\n offset_ := add(start_, 1)\n end_ := add(offset_, length_)\n // Retrieve the size of the code, this needs assembly.\n size_ := extcodesize(pointer_)\n }\n if (size_ < end_) revert ReadError();\n assembly (\"memory-safe\") {\n // Allocate output byte array - this could also be done without\n // assembly by using data_ = new bytes(size)\n data_ := mload(0x40)\n // New \"memory end\" including padding.\n // Compiler will optimise away the double constant addition.\n mstore(0x40, add(data_, and(add(add(length_, 0x20), 0x1f), not(0x1f))))\n // Store length in memory.\n mstore(data_, length_)\n // actually retrieve the code, this needs assembly\n extcodecopy(pointer_, add(data_, 0x20), offset_, length_)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.erc1820/src/lib/LibIERC1820.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../interface/IERC1820Registry.sol\";\n\n/// @dev https://eips.ethereum.org/EIPS/eip-1820#single-use-registry-deployment-account\nIERC1820Registry constant IERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/unstable/IExpressionDeployerV2.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../IInterpreterV1.sol\";\n\nstring constant IERC1820_NAME_IEXPRESSION_DEPLOYER_V2 = \"IExpressionDeployerV2\";\n\n/// @title IExpressionDeployerV1\n/// @notice Companion to `IInterpreterV1` responsible for onchain static code\n/// analysis and deploying expressions. Each `IExpressionDeployerV1` is tightly\n/// coupled at the bytecode level to some interpreter that it knows how to\n/// analyse and deploy expressions for. The expression deployer can perform an\n/// integrity check \"dry run\" of candidate source code for the intepreter. The\n/// critical analysis/transformation includes:\n///\n/// - Enforcement of no out of bounds memory reads/writes\n/// - Calculation of memory required to eval the stack with a single allocation\n/// - Replacing index based opcodes with absolute interpreter function pointers\n/// - Enforcement that all opcodes and operands used exist and are valid\n///\n/// This analysis is highly sensitive to the specific implementation and position\n/// of all opcodes and function pointers as compiled into the interpreter. This\n/// is what makes the coupling between an interpreter and expression deployer\n/// so tight. Ideally all responsibilities would be handled by a single contract\n/// but this introduces code size issues quickly by roughly doubling the compiled\n/// logic of each opcode (half for the integrity check and half for evaluation).\n///\n/// Interpreters MUST assume that expression deployers are malicious and fail\n/// gracefully if the integrity check is corrupt/bypassed and/or function\n/// pointers are incorrect, etc. i.e. the interpreter MUST always return a stack\n/// from `eval` in a read only way or error. I.e. it is the expression deployer's\n/// responsibility to do everything it can to prevent undefined behaviour in the\n/// interpreter, and the interpreter's responsibility to handle the expression\n/// deployer completely failing to do so.\ninterface IExpressionDeployerV2 {\n /// This is the literal InterpreterOpMeta bytes to be used offchain to make\n /// sense of the opcodes in this interpreter deployment, as a human. For\n /// formats like json that make heavy use of boilerplate, repetition and\n /// whitespace, some kind of compression is recommended.\n /// @param sender The `msg.sender` providing the op meta.\n /// @param opMeta The raw binary data of the op meta. Maybe compressed data\n /// etc. and is intended for offchain consumption.\n event DISpair(address sender, address deployer, address interpreter, address store, bytes opMeta);\n\n /// Expressions are expected to be deployed onchain as immutable contract\n /// code with a first class address like any other contract or account.\n /// Technically this is optional in the sense that all the tools required to\n /// eval some expression and define all its opcodes are available as\n /// libraries.\n ///\n /// In practise there are enough advantages to deploying the sources directly\n /// onchain as contract data and loading them from the interpreter at eval:\n ///\n /// - Loading and storing binary data is gas efficient as immutable contract\n /// data\n /// - Expressions need to be immutable between their deploy time integrity\n /// check and runtime evaluation\n /// - Passing the address of an expression through calldata to an interpreter\n /// is cheaper than passing an entire expression through calldata\n /// - Conceptually a very simple approach, even if implementations like\n /// SSTORE2 are subtle under the hood\n ///\n /// The expression deployer MUST perform an integrity check of the source\n /// code before it puts the expression onchain at a known address. The\n /// integrity check MUST at a minimum (it is free to do additional static\n /// analysis) calculate the memory required to be allocated for the stack in\n /// total, and that no out of bounds memory reads/writes occur within this\n /// stack. A simple example of an invalid source would be one that pushes one\n /// value to the stack then attempts to pops two values, clearly we cannot\n /// remove more values than we added. The `IExpressionDeployerV1` MUST revert\n /// in the case of any integrity failure, all integrity checks MUST pass in\n /// order for the deployment to complete.\n ///\n /// Once the integrity check is complete the `IExpressionDeployerV1` MUST do\n /// any additional processing required by its paired interpreter.\n /// For example, the `IExpressionDeployerV1` MAY NEED to replace the indexed\n /// opcodes in the `ExpressionConfig` sources with real function pointers\n /// from the corresponding interpreter.\n ///\n /// @param bytecode Bytecode verbatim. Exactly how the bytecode is structured\n /// is up to the deployer and interpreter. The deployer MUST NOT modify the\n /// bytecode in any way. The interpreter MUST NOT assume anything about the\n /// bytecode other than that it is valid according to the interpreter's\n /// integrity checks. It is assumed that the bytecode will be produced from\n /// a human friendly string via. `IParserV1.parse` but this is not required\n /// if the caller has some other means to prooduce valid bytecode.\n /// @param constants Constants verbatim. Constants are provided alongside\n /// sources rather than inline as it allows us to avoid variable length\n /// opcodes and can be more memory efficient if the same constant is\n /// referenced several times from the sources.\n /// @param minOutputs The first N sources on the state config are entrypoints\n /// to the expression where N is the length of the `minOutputs` array. Each\n /// item in the `minOutputs` array specifies the number of outputs that MUST\n /// be present on the final stack for an evaluation of each entrypoint. The\n /// minimum output for some entrypoint MAY be zero if the expectation is that\n /// the expression only applies checks and error logic. Non-entrypoint\n /// sources MUST NOT have a minimum outputs length specified.\n /// @return interpreter The interpreter the deployer believes it is qualified\n /// to perform integrity checks on behalf of.\n /// @return store The interpreter store the deployer believes is compatible\n /// with the interpreter.\n /// @return expression The address of the deployed onchain expression. MUST\n /// be valid according to all integrity checks the deployer is aware of.\n function deployExpression(bytes memory bytecode, uint256[] memory constants, uint256[] memory minOutputs)\n external\n returns (IInterpreterV1 interpreter, IInterpreterStoreV1 store, address expression);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/unstable/IDebugExpressionDeployerV2.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../IInterpreterV1.sol\";\n\ninterface IDebugExpressionDeployerV2 {\n /// Drives an integrity check of the provided bytecode and constants.\n /// Unlike `IDebugExpressionDeployerV1` this version ONLY checks the\n /// integrity of bytecode as produced by `IParserV1.parse`. There is an eval\n /// debug method on `IDebugInterpreterV2` that can be used to check the\n /// runtime outputs of bytecode that passes the integrity check.\n /// Integrity check MUST revert with a descriptive error if the bytecode\n /// fails the integrity check.\n /// @param bytecode The bytecode to check.\n /// @param constants The constants to check.\n /// @param minOutputs The minimum number of outputs expected from each of\n /// the sources. Only applies to sources that are entrypoints. Internal\n /// sources have their integrity checked implicitly by the use of opcodes\n /// such as `call` that have min/max outputs in their operand.\n function integrityCheck(bytes memory bytecode, uint256[] memory constants, uint256[] memory minOutputs)\n external\n view;\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/unstable/IDebugInterpreterV2.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../IInterpreterV1.sol\";\n\ninterface IDebugInterpreterV2 {\n /// A more explicit/open version of `eval` that is designed for offchain\n /// debugging. It MUST function identically to `eval` so implementations\n /// MAY call it directly internally for `eval` to ensure consistency at the\n /// expense of a small amount of gas.\n /// The affordances made for debugging are:\n /// - A fully qualified namespace is passed in. This allows for storage reads\n /// from the perspective of an arbitrary caller during `eval`. Note that it\n /// does not allow for arbitrary writes, which are still gated by the store\n /// contract itself, so this is safe to expose.\n /// - The bytecode is passed in directly. This allows for debugging of\n /// bytecode that has not been deployed to the chain yet.\n /// - The components of the encoded dispatch other than the onchain\n /// expression address are passed separately. This remove the need to\n /// provide an address at all.\n /// - Inputs to the entrypoint stack are passed in directly. This allows for\n /// debugging/simulating logic that could normally only be accessed via.\n /// some internal dispatch with a mid-flight state creating inputs for the\n /// internal call.\n function offchainDebugEval(\n IInterpreterStoreV1 store,\n FullyQualifiedNamespace namespace,\n bytes calldata expressionData,\n SourceIndex sourceIndex,\n uint256 maxOutputs,\n uint256[][] calldata context,\n uint256[] calldata inputs\n ) external view returns (uint256[] calldata finalStack, uint256[] calldata writes);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/unstable/IParserV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../IInterpreterV1.sol\";\n\n/// @dev The `IParserV1` MUST revert if the authoring meta provided to a build\n/// does not match the authoring meta hash.\nerror AuthoringMetaHashMismatch(bytes32 expected, bytes32 actual);\n\ninterface IParserV1 {\n /// Returns the bytes of the authoring meta hash. Authoring meta is the data\n /// used by the authoring tool to give authors a better experience when\n /// writing Rainlang strings. The authoring meta is also used to generate the\n /// parse meta. As the authoring meta can be quite large, including\n /// potentially hundreds of long string descriptions of individual words,\n /// only the hash is required to be reported by the parser. This hash MUST\n /// NOT be modified after deployment. There MUST be a one-to-one mapping\n /// between authoring meta and parse meta that can be verified externally in\n /// a deterministic way.\n /// @return metaHash The authoring meta hash.\n function authoringMetaHash() external pure returns (bytes32 metaHash);\n\n /// Builds the parse meta from authoring meta. MUST be deterministic and\n /// MUST NOT have side effects. The only input is the authoring meta.\n /// The hash of the provided authoring meta MUST match the authoring meta\n /// hash returned by `authoringMetaHash` and MUST determine the parse meta\n /// returned by `parseMeta`. Implementations are free to define their own\n /// data structures for authoring meta, which is why this function takes\n /// `bytes`. This function is likely very gas intensive, so it is STRONGLY\n /// RECOMMENDED to use a tool to generate the authoring meta offchain then\n /// call this and cross reference it against the return value of `parseMeta`,\n /// but then always use `parseMeta` directly onchain.\n /// @param authoringMeta The authoring meta bytes.\n /// @return parseMetaBytes The built parse meta bytes.\n function buildParseMeta(bytes memory authoringMeta) external pure returns (bytes memory parseMetaBytes);\n\n /// Returns the bytes of the parse meta. Parse meta is the data used by the\n /// parser to convert a Rainlang string into an evaluable expression.\n /// These bytes MUST NOT be modified after deployment. The function is\n /// marked `external` so that it can be externally verified against the\n /// authoring meta, but is likely to be `public` in practice so that it can\n /// also be used internally by `parse`. The bytes returned MUST be identical\n /// to the bytes returned by `buildParseMeta` when provided with the correct\n /// authoring meta as defined by `authoringMetaHash`.\n /// @return parseMetaBytes The parse meta bytes.\n function parseMeta() external pure returns (bytes memory parseMetaBytes);\n\n /// Parses a Rainlang string into an evaluable expression. MUST be\n /// deterministic and MUST NOT have side effects. The only inputs are the\n /// Rainlang string and the parse meta. MAY revert if the Rainlang string\n /// is invalid. This function takes `bytes` instead of `string` to allow\n /// for definitions of \"string\" other than UTF-8.\n /// @param data The Rainlang bytes to parse.\n /// @return bytecode The expressions that can be evaluated.\n /// @return constants The constants that can be referenced by sources.\n function parse(bytes memory data) external pure returns (bytes memory bytecode, uint256[] memory constants);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/integrity/LibIntegrityCheckNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.19;\n\nimport \"../../interface/IInterpreterV1.sol\";\nimport \"../../lib/bytecode/LibBytecode.sol\";\n\n/// @dev There are more entrypoints defined by the minimum stack outputs than\n/// there are provided sources. This means the calling contract WILL attempt to\n/// eval a dangling reference to a non-existent source at some point, so this\n/// MUST REVERT.\nerror EntrypointMissing(uint256 expectedEntrypoints, uint256 actualEntrypoints);\n\n/// Thrown when some entrypoint has non-zero inputs. This is not allowed as\n/// only internal dispatches can have source level inputs.\nerror EntrypointNonZeroInput(uint256 entrypointIndex, uint256 inputsLength);\n\n/// Thrown when some entrypoint has less outputs than the minimum required.\nerror EntrypointMinOutputs(uint256 entrypointIndex, uint256 outputsLength, uint256 minOutputs);\n\n/// The bytecode and integrity function disagree on number of inputs.\nerror BadOpInputsLength(uint256 opIndex, uint256 calculatedInputs, uint256 bytecodeInputs);\n\n/// The stack underflowed during integrity check.\nerror StackUnderflow(uint256 opIndex, uint256 stackIndex, uint256 calculatedInputs);\n\n/// The stack underflowed the highwater during integrity check.\nerror StackUnderflowHighwater(uint256 opIndex, uint256 stackIndex, uint256 stackHighwater);\n\n/// The bytecode stack allocation does not match the allocation calculated by\n/// the integrity check.\nerror StackAllocationMismatch(uint256 stackMaxIndex, uint256 bytecodeAllocation);\n\n/// The final stack index does not match the bytecode outputs.\nerror StackOutputsMismatch(uint256 stackIndex, uint256 bytecodeOutputs);\n\nstruct IntegrityCheckStateNP {\n uint256 stackIndex;\n uint256 stackMaxIndex;\n uint256 readHighwater;\n uint256 constantsLength;\n uint256 opIndex;\n bytes bytecode;\n}\n\nlibrary LibIntegrityCheckNP {\n using LibIntegrityCheckNP for IntegrityCheckStateNP;\n\n function newState(bytes memory bytecode, uint256 stackIndex, uint256 constantsLength)\n internal\n pure\n returns (IntegrityCheckStateNP memory)\n {\n return IntegrityCheckStateNP(\n // stackIndex\n stackIndex,\n // stackMaxIndex\n stackIndex,\n // highwater (source inputs are always immutable)\n stackIndex,\n // constantsLength\n constantsLength,\n // opIndex\n 0,\n // bytecode\n bytecode\n );\n }\n\n // The cyclomatic complexity here comes from all the `if` checks for each\n // integrity check. While the scanner isn't wrong, if we broke the checks\n // out into functions it would be a mostly superficial reduction in\n // complexity, and would make the code harder to read, as well as cost gas.\n //slither-disable-next-line cyclomatic-complexity\n function integrityCheck(\n bytes memory fPointers,\n bytes memory bytecode,\n uint256[] memory constants,\n uint256[] memory minOutputs\n ) internal view {\n unchecked {\n uint256 sourceCount = LibBytecode.sourceCount(bytecode);\n\n // Ensure that we are not missing any entrypoints expected by the calling\n // contract.\n if (minOutputs.length > sourceCount) {\n revert EntrypointMissing(minOutputs.length, sourceCount);\n }\n\n uint256 fPointersStart;\n assembly {\n fPointersStart := add(fPointers, 0x20)\n }\n\n // Ensure that the bytecode has no out of bounds pointers BEFORE we\n // start attempting to iterate over opcodes. This ensures the\n // integrity of the source count, relative offset pointers,\n // ops count per source, and that there is no garbage bytes at the\n // end or between these things. Basically everything structural about\n // the bytecode is confirmed here.\n LibBytecode.checkNoOOBPointers(bytecode);\n\n // Run the integrity check over each source. This needs to ensure\n // the integrity of each source's inputs, outputs, and stack\n // allocation, as well as the integrity of the bytecode itself on\n // a per-opcode basis, according to each opcode's implementation.\n for (uint256 i = 0; i < sourceCount; i++) {\n (uint256 inputsLength, uint256 outputsLength) = LibBytecode.sourceInputsOutputsLength(bytecode, i);\n\n // This is an entrypoint so has additional restrictions.\n if (i < minOutputs.length) {\n if (inputsLength != 0) {\n revert EntrypointNonZeroInput(i, inputsLength);\n }\n\n if (outputsLength < minOutputs[i]) {\n revert EntrypointMinOutputs(i, outputsLength, minOutputs[i]);\n }\n }\n\n IntegrityCheckStateNP memory state =\n LibIntegrityCheckNP.newState(bytecode, inputsLength, constants.length);\n\n // Have low 4 bytes of cursor overlap the first op, skipping the\n // prefix.\n uint256 cursor = Pointer.unwrap(LibBytecode.sourcePointer(bytecode, i)) - 0x18;\n uint256 end = cursor + LibBytecode.sourceOpsCount(bytecode, i) * 4;\n\n while (cursor < end) {\n Operand operand;\n uint256 bytecodeOpInputs;\n function(IntegrityCheckStateNP memory, Operand)\n view\n returns (uint256, uint256) f;\n assembly (\"memory-safe\") {\n let word := mload(cursor)\n f := shr(0xf0, mload(add(fPointersStart, mul(byte(28, word), 2))))\n // 3 bytes mask.\n operand := and(word, 0xFFFFFF)\n bytecodeOpInputs := byte(29, word)\n }\n (uint256 calcOpInputs, uint256 calcOpOutputs) = f(state, operand);\n if (calcOpInputs != bytecodeOpInputs) {\n revert BadOpInputsLength(state.opIndex, calcOpInputs, bytecodeOpInputs);\n }\n\n if (calcOpInputs > state.stackIndex) {\n revert StackUnderflow(state.opIndex, state.stackIndex, calcOpInputs);\n }\n state.stackIndex -= calcOpInputs;\n\n // The stack index can't move below the highwater.\n if (state.stackIndex < state.readHighwater) {\n revert StackUnderflowHighwater(state.opIndex, state.stackIndex, state.readHighwater);\n }\n\n // Let's assume that sane opcode implementations don't\n // overflow uint256 due to their outputs.\n state.stackIndex += calcOpOutputs;\n\n // Ensure the max stack index is updated if needed.\n if (state.stackIndex > state.stackMaxIndex) {\n state.stackMaxIndex = state.stackIndex;\n }\n\n // If there are multiple outputs the highwater MUST move.\n if (calcOpOutputs > 1) {\n state.readHighwater = state.stackIndex;\n }\n\n state.opIndex++;\n cursor += 4;\n }\n\n // The final stack max index MUST match the bytecode allocation.\n if (state.stackMaxIndex != LibBytecode.sourceStackAllocation(bytecode, i)) {\n revert StackAllocationMismatch(state.stackMaxIndex, LibBytecode.sourceStackAllocation(bytecode, i));\n }\n\n // The final stack index MUST match the bytecode source outputs.\n if (state.stackIndex != outputsLength) {\n revert StackOutputsMismatch(state.stackIndex, outputsLength);\n }\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/state/LibInterpreterStateDataContractNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.solmem/lib/LibPointer.sol\";\nimport \"rain.solmem/lib/LibMemCpy.sol\";\nimport \"rain.solmem/lib/LibBytes.sol\";\n\nimport \"../ns/LibNamespace.sol\";\nimport \"./LibInterpreterStateNP.sol\";\n\nlibrary LibInterpreterStateDataContractNP {\n using LibBytes for bytes;\n\n function serializeSizeNP(bytes memory bytecode, uint256[] memory constants) internal pure returns (uint256 size) {\n unchecked {\n size = bytecode.length + constants.length * 0x20 + 0x40;\n }\n }\n\n function unsafeSerializeNP(Pointer cursor, bytes memory bytecode, uint256[] memory constants) internal pure {\n unchecked {\n // Copy constants into place with length.\n assembly (\"memory-safe\") {\n for {\n let constantsCursor := constants\n let constantsEnd := add(constantsCursor, mul(0x20, add(mload(constants), 1)))\n } lt(constantsCursor, constantsEnd) {\n constantsCursor := add(constantsCursor, 0x20)\n cursor := add(cursor, 0x20)\n } { mstore(cursor, mload(constantsCursor)) }\n }\n // Copy the bytecode into place with length.\n LibMemCpy.unsafeCopyBytesTo(bytecode.startPointer(), cursor, bytecode.length + 0x20);\n }\n }\n\n function unsafeDeserializeNP(\n bytes memory serialized,\n uint256 sourceIndex,\n FullyQualifiedNamespace namespace,\n IInterpreterStoreV1 store,\n uint256[][] memory context,\n bytes memory fs\n ) internal pure returns (InterpreterStateNP memory) {\n unchecked {\n Pointer cursor;\n assembly (\"memory-safe\") {\n cursor := add(serialized, 0x20)\n }\n\n // Reference the constants array as-is and move cursor past it.\n uint256[] memory constants;\n assembly (\"memory-safe\") {\n constants := cursor\n cursor := add(cursor, mul(0x20, add(mload(cursor), 1)))\n }\n\n // Reference the bytecode array as-is.\n bytes memory bytecode;\n assembly (\"memory-safe\") {\n bytecode := cursor\n }\n\n // Build all the stacks.\n Pointer[] memory stackBottoms;\n assembly (\"memory-safe\") {\n cursor := add(cursor, 0x20)\n let stacksLength := byte(0, mload(cursor))\n cursor := add(cursor, 1)\n let sourcesStart := add(cursor, mul(stacksLength, 2))\n\n // Allocate the memory for stackBottoms.\n // We don't need to zero this because we're about to write to it.\n stackBottoms := mload(0x40)\n mstore(stackBottoms, stacksLength)\n mstore(0x40, add(stackBottoms, mul(add(stacksLength, 1), 0x20)))\n\n // Allocate each stack and point to it.\n let stacksCursor := add(stackBottoms, 0x20)\n for { let i := 0 } lt(i, stacksLength) {\n i := add(i, 1)\n // Move over the 2 byte source pointer.\n cursor := add(cursor, 2)\n // Move the stacks cursor forward.\n stacksCursor := add(stacksCursor, 0x20)\n } {\n // The stack size is in the prefix of the source data, which\n // is behind a relative pointer in the bytecode prefix.\n let sourcePointer := add(sourcesStart, shr(0xf0, mload(cursor)))\n // Stack size is the second byte of the source prefix.\n let stackSize := byte(1, mload(sourcePointer))\n\n // Allocate the stack.\n // We don't need to zero the stack because the interpreter\n // assumes values above the stack top are dirty anyway.\n let stack := mload(0x40)\n mstore(stack, stackSize)\n let stackBottom := add(stack, mul(add(stackSize, 1), 0x20))\n mstore(0x40, stackBottom)\n\n // Point to the stack bottom\n mstore(stacksCursor, stackBottom)\n }\n }\n\n return InterpreterStateNP(\n stackBottoms, constants, sourceIndex, MemoryKV.wrap(0), namespace, store, context, bytecode, fs\n );\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/LibAllStandardOpsNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.19;\n\nimport {LibConvert} from \"rain.lib.typecast/LibConvert.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../interface/IInterpreterV1.sol\";\nimport {LibIntegrityCheckNP, IntegrityCheckStateNP} from \"../integrity/LibIntegrityCheckNP.sol\";\nimport {LibInterpreterStateNP, InterpreterStateNP} from \"../state/LibInterpreterStateNP.sol\";\nimport {AuthoringMeta} from \"../parse/LibParseMeta.sol\";\nimport {\n OPERAND_PARSER_OFFSET_DISALLOWED,\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT,\n OPERAND_PARSER_OFFSET_M1_M1,\n OPERAND_PARSER_OFFSET_8_M1_M1\n} from \"../parse/LibParseOperand.sol\";\nimport {LibUint256Array} from \"rain.solmem/lib/LibUint256Array.sol\";\nimport {LibOpStackNP} from \"./00/LibOpStackNP.sol\";\nimport {LibOpConstantNP} from \"./00/LibOpConstantNP.sol\";\n\nimport {LibOpCtPopNP} from \"./bitwise/LibOpCtPopNP.sol\";\n\nimport {LibOpCallNP} from \"./call/LibOpCallNP.sol\";\n\nimport {LibOpContextNP} from \"./context/LibOpContextNP.sol\";\n\nimport {LibOpHashNP} from \"./crypto/LibOpHashNP.sol\";\n\nimport {LibOpERC721BalanceOfNP} from \"./erc721/LibOpERC721BalanceOfNP.sol\";\nimport {LibOpERC721OwnerOfNP} from \"./erc721/LibOpERC721OwnerOfNP.sol\";\n\nimport {LibOpBlockNumberNP} from \"./evm/LibOpBlockNumberNP.sol\";\nimport {LibOpChainIdNP} from \"./evm/LibOpChainIdNP.sol\";\nimport {LibOpMaxUint256NP} from \"./evm/LibOpMaxUint256NP.sol\";\nimport {LibOpTimestampNP} from \"./evm/LibOpTimestampNP.sol\";\n\nimport {LibOpAnyNP} from \"./logic/LibOpAnyNP.sol\";\nimport {LibOpConditionsNP} from \"./logic/LibOpConditionsNP.sol\";\nimport {EnsureFailed, LibOpEnsureNP} from \"./logic/LibOpEnsureNP.sol\";\nimport {LibOpEqualToNP} from \"./logic/LibOpEqualToNP.sol\";\nimport {LibOpEveryNP} from \"./logic/LibOpEveryNP.sol\";\nimport {LibOpGreaterThanNP} from \"./logic/LibOpGreaterThanNP.sol\";\nimport {LibOpGreaterThanOrEqualToNP} from \"./logic/LibOpGreaterThanOrEqualToNP.sol\";\nimport {LibOpIfNP} from \"./logic/LibOpIfNP.sol\";\nimport {LibOpIsZeroNP} from \"./logic/LibOpIsZeroNP.sol\";\nimport {LibOpLessThanNP} from \"./logic/LibOpLessThanNP.sol\";\nimport {LibOpLessThanOrEqualToNP} from \"./logic/LibOpLessThanOrEqualToNP.sol\";\n\nimport {LibOpDecimal18MulNP} from \"./math/decimal18/LibOpDecimal18MulNP.sol\";\nimport {LibOpDecimal18DivNP} from \"./math/decimal18/LibOpDecimal18DivNP.sol\";\nimport {LibOpDecimal18Scale18DynamicNP} from \"./math/decimal18/LibOpDecimal18Scale18DynamicNP.sol\";\nimport {LibOpDecimal18Scale18NP} from \"./math/decimal18/LibOpDecimal18Scale18NP.sol\";\nimport {LibOpDecimal18ScaleNNP} from \"./math/decimal18/LibOpDecimal18ScaleNNP.sol\";\n\nimport {LibOpIntAddNP} from \"./math/int/LibOpIntAddNP.sol\";\nimport {LibOpIntDivNP} from \"./math/int/LibOpIntDivNP.sol\";\nimport {LibOpIntExpNP} from \"./math/int/LibOpIntExpNP.sol\";\nimport {LibOpIntMaxNP} from \"./math/int/LibOpIntMaxNP.sol\";\nimport {LibOpIntMinNP} from \"./math/int/LibOpIntMinNP.sol\";\nimport {LibOpIntModNP} from \"./math/int/LibOpIntModNP.sol\";\nimport {LibOpIntMulNP} from \"./math/int/LibOpIntMulNP.sol\";\nimport {LibOpIntSubNP} from \"./math/int/LibOpIntSubNP.sol\";\n\nimport {LibOpGetNP} from \"./store/LibOpGetNP.sol\";\nimport {LibOpSetNP} from \"./store/LibOpSetNP.sol\";\n\nimport {LibOpUniswapV2AmountIn} from \"./uniswap/LibOpUniswapV2AmountIn.sol\";\nimport {LibOpUniswapV2AmountOut} from \"./uniswap/LibOpUniswapV2AmountOut.sol\";\n\n/// Thrown when a dynamic length array is NOT 1 more than a fixed length array.\n/// Should never happen outside a major breaking change to memory layouts.\nerror BadDynamicLength(uint256 dynamicLength, uint256 standardOpsLength);\n\n/// @dev Number of ops currently provided by `AllStandardOpsNP`.\nuint256 constant ALL_STANDARD_OPS_LENGTH = 45;\n\n/// @title LibAllStandardOpsNP\n/// @notice Every opcode available from the core repository laid out as a single\n/// array to easily build function pointers for `IInterpreterV1`.\nlibrary LibAllStandardOpsNP {\n function authoringMeta() internal pure returns (bytes memory) {\n AuthoringMeta memory lengthPlaceholder;\n AuthoringMeta[ALL_STANDARD_OPS_LENGTH + 1] memory wordsFixed = [\n lengthPlaceholder,\n // Stack and constant MUST be in this order for parsing to work.\n AuthoringMeta(\"stack\", OPERAND_PARSER_OFFSET_SINGLE_FULL, \"Copies an existing value from the stack.\"),\n AuthoringMeta(\"constant\", OPERAND_PARSER_OFFSET_SINGLE_FULL, \"Copies a constant value onto the stack.\"),\n // These are all ordered according to how they appear in the file system.\n AuthoringMeta(\n \"bitwise-count-ones\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Counts the number of binary bits set to 1 in the input.\"\n ),\n AuthoringMeta(\n \"call\",\n OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT,\n \"Calls a source by index in the same Rain bytecode. The inputs to call are copied to the top of the called stack and the outputs specified in the operand are copied back to the calling stack. The first operand is the source index and the second is the number of outputs.\"\n ),\n AuthoringMeta(\n \"context\",\n OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT,\n \"Copies a value from the context. The first operand is the context column and second is the context row.\"\n ),\n AuthoringMeta(\n \"hash\", OPERAND_PARSER_OFFSET_DISALLOWED, \"Hashes all inputs into a single 32 byte value using keccak256.\"\n ),\n AuthoringMeta(\n \"erc721-balance-of\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Gets the balance of an erc721 token for an account. The first input is the token address and the second is the account address.\"\n ),\n AuthoringMeta(\n \"erc721-owner-of\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Gets the owner of an erc721 token. The first input is the token address and the second is the token id.\"\n ),\n AuthoringMeta(\"block-number\", OPERAND_PARSER_OFFSET_DISALLOWED, \"The current block number.\"),\n AuthoringMeta(\"chain-id\", OPERAND_PARSER_OFFSET_DISALLOWED, \"The current chain id.\"),\n AuthoringMeta(\n \"max-int-value\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"The maximum possible non-negative integer value. 2^256 - 1.\"\n ),\n AuthoringMeta(\n \"max-decimal18-value\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"The maximum possible 18 decimal fixed point value. roughly 1.15e77.\"\n ),\n AuthoringMeta(\"block-timestamp\", OPERAND_PARSER_OFFSET_DISALLOWED, \"The current block timestamp.\"),\n AuthoringMeta(\n \"any\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"The first non-zero value out of all inputs, or 0 if every input is 0.\"\n ),\n AuthoringMeta(\n \"conditions\",\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n \"Treats inputs as pairwise condition/value pairs. The first nonzero condition's value is used. If no conditions are nonzero, the expression reverts. The operand can be used as an error code to differentiate between multiple conditions in the same expression.\"\n ),\n AuthoringMeta(\n \"ensure\",\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n \"Reverts if any input is 0. All inputs are eagerly evaluated there are no outputs. The operand can be used as an error code to differentiate between multiple conditions in the same expression.\"\n ),\n AuthoringMeta(\"equal-to\", OPERAND_PARSER_OFFSET_DISALLOWED, \"1 if all inputs are equal, 0 otherwise.\"),\n AuthoringMeta(\n \"every\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"The last nonzero value out of all inputs, or 0 if any input is 0.\"\n ),\n AuthoringMeta(\n \"greater-than\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"1 if the first input is greater than the second input, 0 otherwise.\"\n ),\n AuthoringMeta(\n \"greater-than-or-equal-to\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"1 if the first input is greater than or equal to the second input, 0 otherwise.\"\n ),\n AuthoringMeta(\n \"if\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"If the first input is nonzero, the second input is used. Otherwise, the third input is used. If is eagerly evaluated.\"\n ),\n AuthoringMeta(\"is-zero\", OPERAND_PARSER_OFFSET_DISALLOWED, \"1 if the input is 0, 0 otherwise.\"),\n AuthoringMeta(\n \"less-than\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"1 if the first input is less than the second input, 0 otherwise.\"\n ),\n AuthoringMeta(\n \"less-than-or-equal-to\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"1 if the first input is less than or equal to the second input, 0 otherwise.\"\n ),\n AuthoringMeta(\n \"decimal18-div\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Divides the first input by all other inputs as fixed point 18 decimal numbers (i.e. 'one' is 1e18). Errors if any divisor is zero.\"\n ),\n AuthoringMeta(\n \"decimal18-mul\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Multiplies all inputs together as fixed point 18 decimal numbers (i.e. 'one' is 1e18). Errors if the multiplication exceeds the maximum value (roughly 1.15e77).\"\n ),\n AuthoringMeta(\n \"decimal18-scale18-dynamic\",\n OPERAND_PARSER_OFFSET_M1_M1,\n \"Scales a value from some fixed point decimal scale to 18 decimal fixed point. The first input is the scale to scale from and the second is the value to scale. The two optional operands control rounding and saturation respectively as per `decimal18-scale18`.\"\n ),\n AuthoringMeta(\n \"decimal18-scale18\",\n OPERAND_PARSER_OFFSET_8_M1_M1,\n \"Scales an input value from some fixed point decimal scale to 18 decimal fixed point. The first operand is the scale to scale from. The second (optional) operand controls rounding where 0 (default) rounds down and 1 rounds up. The third (optional) operand controls saturation where 0 (default) errors on overflow and 1 saturates at max-decimal-value.\"\n ),\n AuthoringMeta(\n \"decimal18-scale-n\",\n OPERAND_PARSER_OFFSET_8_M1_M1,\n \"Scales an input value from 18 decimal fixed point to some other fixed point scale N. The first operand is the scale to scale to. The second (optional) operand controls rounding where 0 (default) rounds down and 1 rounds up. The third (optional) operand controls saturation where 0 (default) errors on overflow and 1 saturates at max-decimal-value.\"\n ),\n // int and decimal18 add have identical implementations and point to\n // the same function pointer. This is intentional.\n AuthoringMeta(\n \"int-add\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Adds all inputs together as non-negative integers. Errors if the addition exceeds the maximum value (roughly 1.15e77).\"\n ),\n AuthoringMeta(\n \"decimal18-add\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Adds all inputs together as fixed point 18 decimal numbers (i.e. 'one' is 1e18). Errors if the addition exceeds the maximum value (roughly 1.15e77).\"\n ),\n AuthoringMeta(\n \"int-div\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Divides the first input by all other inputs as non-negative integers. Errors if any divisor is zero.\"\n ),\n AuthoringMeta(\n \"int-exp\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Raises the first input to the power of all other inputs as non-negative integers. Errors if the exponentiation would exceed the maximum value (roughly 1.15e77).\"\n ),\n // int and decimal18 max have identical implementations and point to\n // the same function pointer. This is intentional.\n AuthoringMeta(\n \"int-max\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Finds the maximum value from all inputs as non-negative integers.\"\n ),\n AuthoringMeta(\n \"decimal18-max\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Finds the maximum value from all inputs as fixed point 18 decimal numbers (i.e. 'one' is 1e18).\"\n ),\n // int and decimal18 min have identical implementations and point to\n // the same function pointer. This is intentional.\n AuthoringMeta(\n \"int-min\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Finds the minimum value from all inputs as non-negative integers.\"\n ),\n AuthoringMeta(\n \"decimal18-min\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Finds the minimum value from all inputs as fixed point 18 decimal numbers (i.e. 'one' is 1e18).\"\n ),\n AuthoringMeta(\n \"int-mod\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Modulos the first input by all other inputs as non-negative integers. Errors if any divisor is zero.\"\n ),\n AuthoringMeta(\n \"int-mul\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Multiplies all inputs together as non-negative integers. Errors if the multiplication exceeds the maximum value (roughly 1.15e77).\"\n ),\n // int and decimal18 sub have identical implementations and point to\n // the same function pointer. This is intentional.\n AuthoringMeta(\n \"int-sub\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Subtracts all inputs from the first input as non-negative integers. Errors if the subtraction would result in a negative value.\"\n ),\n AuthoringMeta(\n \"decimal18-sub\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Subtracts all inputs from the first input as fixed point 18 decimal numbers (i.e. 'one' is 1e18). Errors if the subtraction would result in a negative value.\"\n ),\n AuthoringMeta(\n \"get\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Gets a value from storage. The first operand is the key to lookup.\"\n ),\n AuthoringMeta(\n \"set\",\n OPERAND_PARSER_OFFSET_DISALLOWED,\n \"Sets a value in storage. The first operand is the key to set and the second operand is the value to set.\"\n ),\n AuthoringMeta(\n \"uniswap-v2-amount-in\",\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n \"Computes the minimum amount of input tokens required to get a given amount of output tokens from a UniswapV2 pair. Input/output token directions are from the perspective of the Uniswap contract. The first input is the factory address, the second is the amount of output tokens, the third is the input token address, and the fourth is the output token address. If the operand is 1 the last time the prices changed will be returned as well.\"\n ),\n AuthoringMeta(\n \"uniswap-v2-amount-out\",\n OPERAND_PARSER_OFFSET_SINGLE_FULL,\n \"Computes the maximum amount of output tokens received from a given amount of input tokens from a UniswapV2 pair. Input/output token directions are from the perspective of the Uniswap contract. The first input is the factory address, the second is the amount of input tokens, the third is the input token address, and the fourth is the output token address. If the operand is 1 the last time the prices changed will be returned as well.\"\n )\n ];\n AuthoringMeta[] memory wordsDynamic;\n uint256 length = ALL_STANDARD_OPS_LENGTH;\n assembly (\"memory-safe\") {\n wordsDynamic := wordsFixed\n mstore(wordsDynamic, length)\n }\n return abi.encode(wordsDynamic);\n }\n\n function integrityFunctionPointers() internal pure returns (bytes memory) {\n unchecked {\n function(IntegrityCheckStateNP memory, Operand)\n view\n returns (uint256, uint256) lengthPointer;\n uint256 length = ALL_STANDARD_OPS_LENGTH;\n assembly (\"memory-safe\") {\n lengthPointer := length\n }\n function(IntegrityCheckStateNP memory, Operand)\n view\n returns (uint256, uint256)[ALL_STANDARD_OPS_LENGTH + 1] memory pointersFixed = [\n lengthPointer,\n // Stack then constant are the first two ops to match the\n // field ordering in the interpreter state NOT the lexical\n // ordering of the file system.\n LibOpStackNP.integrity,\n LibOpConstantNP.integrity,\n // Everything else is alphabetical, including folders.\n LibOpCtPopNP.integrity,\n LibOpCallNP.integrity,\n LibOpContextNP.integrity,\n LibOpHashNP.integrity,\n LibOpERC721BalanceOfNP.integrity,\n LibOpERC721OwnerOfNP.integrity,\n LibOpBlockNumberNP.integrity,\n LibOpChainIdNP.integrity,\n // int and decimal18 max have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpMaxUint256NP.integrity,\n // decimal18 max.\n LibOpMaxUint256NP.integrity,\n LibOpTimestampNP.integrity,\n LibOpAnyNP.integrity,\n LibOpConditionsNP.integrity,\n LibOpEnsureNP.integrity,\n LibOpEqualToNP.integrity,\n LibOpEveryNP.integrity,\n LibOpGreaterThanNP.integrity,\n LibOpGreaterThanOrEqualToNP.integrity,\n LibOpIfNP.integrity,\n LibOpIsZeroNP.integrity,\n LibOpLessThanNP.integrity,\n LibOpLessThanOrEqualToNP.integrity,\n LibOpDecimal18DivNP.integrity,\n LibOpDecimal18MulNP.integrity,\n LibOpDecimal18Scale18DynamicNP.integrity,\n LibOpDecimal18Scale18NP.integrity,\n LibOpDecimal18ScaleNNP.integrity,\n // int and decimal18 add have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntAddNP.integrity,\n // decimal18 add.\n LibOpIntAddNP.integrity,\n LibOpIntDivNP.integrity,\n LibOpIntExpNP.integrity,\n // int and decimal18 max have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntMaxNP.integrity,\n // decimal18 max.\n LibOpIntMaxNP.integrity,\n // int and decimal18 min have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntMinNP.integrity,\n // decimal18 min.\n LibOpIntMinNP.integrity,\n LibOpIntModNP.integrity,\n LibOpIntMulNP.integrity,\n // int and decimal18 sub have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntSubNP.integrity,\n // decimal18 sub.\n LibOpIntSubNP.integrity,\n LibOpGetNP.integrity,\n LibOpSetNP.integrity,\n LibOpUniswapV2AmountIn.integrity,\n LibOpUniswapV2AmountOut.integrity\n ];\n uint256[] memory pointersDynamic;\n assembly (\"memory-safe\") {\n pointersDynamic := pointersFixed\n }\n // Sanity check that the dynamic length is correct. Should be an\n // unreachable error.\n if (pointersDynamic.length != ALL_STANDARD_OPS_LENGTH) {\n revert BadDynamicLength(pointersDynamic.length, length);\n }\n return LibConvert.unsafeTo16BitBytes(pointersDynamic);\n }\n }\n\n /// All function pointers for the standard opcodes. Intended to be used to\n /// build a `IInterpreterV1` instance, specifically the `functionPointers`\n /// method can just be a thin wrapper around this function.\n function opcodeFunctionPointers() internal pure returns (bytes memory) {\n unchecked {\n function(InterpreterStateNP memory, Operand, Pointer)\n view\n returns (Pointer) lengthPointer;\n uint256 length = ALL_STANDARD_OPS_LENGTH;\n assembly (\"memory-safe\") {\n lengthPointer := length\n }\n function(InterpreterStateNP memory, Operand, Pointer)\n view\n returns (Pointer)[ALL_STANDARD_OPS_LENGTH + 1] memory pointersFixed = [\n lengthPointer,\n // Stack then constant are the first two ops to match the\n // field ordering in the interpreter state NOT the lexical\n // ordering of the file system.\n LibOpStackNP.run,\n LibOpConstantNP.run,\n // Everything else is alphabetical, including folders.\n LibOpCtPopNP.run,\n LibOpCallNP.run,\n LibOpContextNP.run,\n LibOpHashNP.run,\n LibOpERC721BalanceOfNP.run,\n LibOpERC721OwnerOfNP.run,\n LibOpBlockNumberNP.run,\n LibOpChainIdNP.run,\n // int and decimal18 max have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpMaxUint256NP.run,\n // decimal18 max.\n LibOpMaxUint256NP.run,\n LibOpTimestampNP.run,\n LibOpAnyNP.run,\n LibOpConditionsNP.run,\n LibOpEnsureNP.run,\n LibOpEqualToNP.run,\n LibOpEveryNP.run,\n LibOpGreaterThanNP.run,\n LibOpGreaterThanOrEqualToNP.run,\n LibOpIfNP.run,\n LibOpIsZeroNP.run,\n LibOpLessThanNP.run,\n LibOpLessThanOrEqualToNP.run,\n LibOpDecimal18DivNP.run,\n LibOpDecimal18MulNP.run,\n LibOpDecimal18Scale18DynamicNP.run,\n LibOpDecimal18Scale18NP.run,\n LibOpDecimal18ScaleNNP.run,\n // int and decimal18 add have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntAddNP.run,\n // decimal18 add.\n LibOpIntAddNP.run,\n LibOpIntDivNP.run,\n LibOpIntExpNP.run,\n // int and decimal18 max have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntMaxNP.run,\n // decimal18 max.\n LibOpIntMaxNP.run,\n // int and decimal18 min have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntMinNP.run,\n // decimal18 min.\n LibOpIntMinNP.run,\n LibOpIntModNP.run,\n LibOpIntMulNP.run,\n // int and decimal18 sub have identical implementations and\n // point to the same function pointer. This is intentional.\n LibOpIntSubNP.run,\n // decimal18 sub.\n LibOpIntSubNP.run,\n LibOpGetNP.run,\n LibOpSetNP.run,\n LibOpUniswapV2AmountIn.run,\n LibOpUniswapV2AmountOut.run\n ];\n uint256[] memory pointersDynamic;\n assembly (\"memory-safe\") {\n pointersDynamic := pointersFixed\n }\n // Sanity check that the dynamic length is correct. Should be an\n // unreachable error.\n if (pointersDynamic.length != ALL_STANDARD_OPS_LENGTH) {\n revert BadDynamicLength(pointersDynamic.length, length);\n }\n return LibConvert.unsafeTo16BitBytes(pointersDynamic);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParse.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.solmem/lib/LibPointer.sol\";\nimport \"rain.solmem/lib/LibMemCpy.sol\";\n\nimport \"../bitwise/LibCtPop.sol\";\nimport \"./LibParseMeta.sol\";\nimport \"./LibParseCMask.sol\";\nimport \"./LibParseLiteral.sol\";\nimport \"./LibParseOperand.sol\";\nimport \"../../interface/IInterpreterV1.sol\";\nimport \"./LibParseStackName.sol\";\n\n/// The expression does not finish with a semicolon (EOF).\nerror MissingFinalSemi(uint256 offset);\n\n/// Enountered an unexpected character on the LHS.\nerror UnexpectedLHSChar(uint256 offset);\n\n/// Encountered an unexpected character on the RHS.\nerror UnexpectedRHSChar(uint256 offset);\n\n/// More specific version of UnexpectedRHSChar where we specifically expected\n/// a left paren but got some other char.\nerror ExpectedLeftParen(uint256 offset);\n\n/// Encountered a right paren without a matching left paren.\nerror UnexpectedRightParen(uint256 offset);\n\n/// Encountered an unclosed left paren.\nerror UnclosedLeftParen(uint256 offset);\n\n/// Encountered a comment outside the interstitial space between lines.\nerror UnexpectedComment(uint256 offset);\n\n/// Encountered a comment start sequence that is malformed.\nerror MalformedCommentStart(uint256 offset);\n\n/// @dev Thrown when a stack name is duplicated. Shadowing in all forms is\n/// disallowed in Rainlang.\nerror DuplicateLHSItem(uint256 errorOffset);\n\n/// Encountered too many LHS items.\nerror ExcessLHSItems(uint256 offset);\n\n/// Encountered inputs where they can't be handled.\nerror NotAcceptingInputs(uint256 offset);\n\n/// Encountered too many RHS items.\nerror ExcessRHSItems(uint256 offset);\n\n/// Encountered a word that is longer than 32 bytes.\nerror WordSize(string word);\n\n/// Parsed a word that is not in the meta.\nerror UnknownWord(uint256 offset);\n\n/// The parser exceeded the maximum number of sources that it can build.\nerror MaxSources();\n\n/// The parser encountered a dangling source. This is a bug in the parser.\nerror DanglingSource();\n\n/// The parser moved past the end of the data.\nerror ParserOutOfBounds();\n\n/// The parser encountered a stack deeper than it can process in the memory\n/// region allocated for stack names.\nerror StackOverflow();\n\n/// The parser encountered a stack underflow.\nerror StackUnderflow();\n\n/// The parser encountered a paren group deeper than it can process in the\n/// memory region allocated for paren tracking.\nerror ParenOverflow();\n\nuint256 constant NOT_LOW_16_BIT_MASK = ~uint256(0xFFFF);\nuint256 constant ACTIVE_SOURCE_MASK = NOT_LOW_16_BIT_MASK;\n\nuint256 constant FSM_RHS_MASK = 1;\nuint256 constant FSM_YANG_MASK = 1 << 1;\nuint256 constant FSM_WORD_END_MASK = 1 << 2;\nuint256 constant FSM_ACCEPTING_INPUTS_MASK = 1 << 3;\n\n/// @dev The space between lines where comments and whitespace is allowed.\n/// The first LHS item breaks us out of the interstitial.\nuint256 constant FSM_INTERSTITIAL_MASK = 1 << 4;\n\n/// @dev If a source is active we cannot finish parsing without a semi to trigger\n/// finalisation.\nuint256 constant FSM_ACTIVE_SOURCE_MASK = 1 << 5;\n\n/// @dev fsm default state is:\n/// - LHS\n/// - yin\n/// - not word end\n/// - accepting inputs\n/// - interstitial\nuint256 constant FSM_DEFAULT = FSM_ACCEPTING_INPUTS_MASK | FSM_INTERSTITIAL_MASK;\n\nuint256 constant EMPTY_ACTIVE_SOURCE = 0x20;\n\n/// @dev The opcode that will be used in the source to represent a stack copy\n/// implied by named LHS stack items.\n/// @dev @todo support the meta defining the opcode.\nuint256 constant OPCODE_STACK = 0;\n\n/// @dev The opcode that will be used in the source to read a constant.\n/// @dev @todo support the meta defining the opcode.\nuint256 constant OPCODE_CONSTANT = 1;\n\ntype StackTracker is uint256;\n\n/// The parser is stateful. This struct keeps track of the entire state.\n/// @param activeSourcePtr The pointer to the current source being built.\n/// The active source being pointed to is:\n/// - low 16 bits: bitwise offset into the source for the next word to be\n/// written. Starts at 0x20. Once a source is no longer the active source, i.e.\n/// it is full and a member of the LL tail, the offset is replaced with a\n/// pointer to the next source (towards the head) to build a doubly linked\n/// list.\n/// - mid 16 bits: pointer to the previous active source (towards the tail). This\n/// is a linked list of sources that are built RTL and then reversed to LTR to\n/// eval.\n/// - high bits: 4 byte opcodes and operand pairs.\n/// @param sourcesBuilder A builder for the sources array. This is a 256 bit\n/// integer where each 16 bits is a literal memory pointer to a source.\n/// @param fsm The finite state machine representation of the parser.\n/// - bit 0: LHS/RHS => 0 = LHS, 1 = RHS\n/// - bit 1: yang/yin => 0 = yin, 1 = yang\n/// - bit 2: word end => 0 = not end, 1 = end\n/// - bit 3: accepting inputs => 0 = not accepting, 1 = accepting\n/// - bit 4: interstitial => 0 = not interstitial, 1 = interstitial\n/// @param topLevel0 Memory region for stack word counters. The first byte is a\n/// counter/offset into the region, which increments for every top level item\n/// parsed on the RHS. The remaining 31 bytes are the word counters for each\n/// stack item, which are incremented for every op pushed to the source. This is\n/// reset to 0 for every new source.\n/// @param topLevel1 31 additional bytes of stack words, allowing for 62 top\n/// level stack items total per source. The final byte is used to count the\n/// stack height according to the LHS for the current source. This is reset to 0\n/// for every new source.\n/// @param parenTracker0 Memory region for tracking pointers to words in the\n/// source, and counters for the number of words in each paren group. The first\n/// byte is a counter/offset into the region. The second byte is a phantom\n/// counter for the root level, the remaining 30 bytes are the paren group words.\n/// @param parenTracker1 32 additional bytes of paren group words.\n/// @param lineTracker A 32 byte memory region for tracking the current line.\n/// Will be partially reset for each line when `balanceLine` is called. Fully\n/// reset when a new source is started.\n/// Bytes from low to high:\n/// - byte 0: Lowest byte is the number of LHS items parsed. This is the low\n/// byte so that a simple ++ is a valid operation on the line tracker while\n/// parsing the LHS. This is reset to 0 for each new line.\n/// - byte 1: A snapshot of the first high byte of `topLevel0`, i.e. the offset\n/// of top level items as at the beginning of the line. This is reset to the high\n/// byte of `topLevel0` on each new line.\n/// - bytes 2+: A sequence of 2 byte pointers to before the start of each top\n/// level item, which is implictly after the end of the previous top level item.\n/// Allows us to quickly find the start of the RHS source for each top level\n/// item.\n/// @param stackNames A linked list of stack names. As the parser encounters\n/// named stack items it pushes them onto this linked list. The linked list is\n/// in FILO order, so the first item on the stack is the last item in the list.\n/// This makes it more efficient to reference more recent stack names on the RHS.\n/// @param literalBloom A bloom filter of all the literals that have been\n/// encountered so far. This is used to quickly dedupe literals.\n/// @param constantsBuilder A builder for the constants array.\n/// @param literalParsers A 256 bit integer where each 16 bits is a function\n/// pointer to a literal parser.\nstruct ParseState {\n /// @dev START things that are referenced directly in assembly by hardcoded\n /// offsets. E.g.\n /// - `pushOpToSource`\n /// - `snapshotSourceHeadToLineTracker`\n /// - `newSource`\n uint256 activeSourcePtr;\n uint256 topLevel0;\n uint256 topLevel1;\n uint256 parenTracker0;\n uint256 parenTracker1;\n uint256 lineTracker;\n /// @dev END things that are referenced directly in assembly by hardcoded\n /// offsets.\n uint256 sourcesBuilder;\n uint256 fsm;\n uint256 stackNames;\n uint256 stackNameBloom;\n uint256 literalBloom;\n uint256 constantsBuilder;\n uint256 literalParsers;\n uint256 operandParsers;\n StackTracker stackTracker;\n}\n\nlibrary LibStackTracker {\n using LibStackTracker for StackTracker;\n\n /// Pushing inputs requires special handling as the inputs need to be tallied\n /// separately and in addition to the regular stack pushes.\n function pushInputs(StackTracker tracker, uint256 n) internal pure returns (StackTracker) {\n unchecked {\n tracker = tracker.push(n);\n uint256 inputs = (StackTracker.unwrap(tracker) >> 8) & 0xFF;\n inputs += n;\n return StackTracker.wrap((StackTracker.unwrap(tracker) & ~uint256(0xFF00)) | (inputs << 8));\n }\n }\n\n function push(StackTracker tracker, uint256 n) internal pure returns (StackTracker) {\n unchecked {\n uint256 current = StackTracker.unwrap(tracker) & 0xFF;\n uint256 inputs = (StackTracker.unwrap(tracker) >> 8) & 0xFF;\n uint256 max = StackTracker.unwrap(tracker) >> 0x10;\n current += n;\n if (current > max) {\n max = current;\n }\n return StackTracker.wrap(current | (inputs << 8) | (max << 0x10));\n }\n }\n\n function pop(StackTracker tracker, uint256 n) internal pure returns (StackTracker) {\n unchecked {\n uint256 current = StackTracker.unwrap(tracker) & 0xFF;\n if (current < n) {\n revert StackUnderflow();\n }\n return StackTracker.wrap(StackTracker.unwrap(tracker) - n);\n }\n }\n}\n\nlibrary LibParseState {\n using LibParseState for ParseState;\n using LibStackTracker for StackTracker;\n\n function resetSource(ParseState memory state) internal pure {\n uint256 activeSourcePtr;\n uint256 emptyActiveSource = EMPTY_ACTIVE_SOURCE;\n assembly (\"memory-safe\") {\n activeSourcePtr := mload(0x40)\n mstore(activeSourcePtr, emptyActiveSource)\n mstore(0x40, add(activeSourcePtr, 0x20))\n }\n state.activeSourcePtr = activeSourcePtr;\n state.topLevel0 = 0;\n state.topLevel1 = 0;\n state.parenTracker0 = 0;\n state.parenTracker1 = 0;\n state.lineTracker = 0;\n state.stackNames = 0;\n state.stackNameBloom = 0;\n state.stackTracker = StackTracker.wrap(0);\n }\n\n function newState() internal pure returns (ParseState memory) {\n ParseState memory state = ParseState(\n // activeSource\n // (will be built in `newActiveSource`)\n 0,\n // topLevel0\n 0,\n // topLevel1\n 0,\n // parenTracker0\n 0,\n // parenTracker1\n 0,\n // lineTracker\n // (will be built in `newActiveSource`)\n 0,\n // sourcesBuilder\n 0,\n // fsm\n FSM_DEFAULT,\n // stackNames\n 0,\n // stackNameBloom\n 0,\n // literalBloom\n 0,\n // constantsBuilder\n 0,\n // literalParsers\n LibParseLiteral.buildLiteralParsers(),\n // operandParsers\n LibParseOperand.buildOperandParsers(),\n // stackTracker\n StackTracker.wrap(0)\n );\n state.resetSource();\n return state;\n }\n\n // Find the pointer to the first opcode in the source LL. Put it in the line\n // tracker at the appropriate offset.\n function snapshotSourceHeadToLineTracker(ParseState memory state) internal pure {\n assembly (\"memory-safe\") {\n let topLevel0Pointer := add(state, 0x20)\n let totalRHSTopLevel := byte(0, mload(topLevel0Pointer))\n // Only do stuff if the current word counter is zero.\n if iszero(byte(0, mload(add(topLevel0Pointer, add(totalRHSTopLevel, 1))))) {\n let sourceHead := mload(state)\n let byteOffset := div(and(mload(sourceHead), 0xFFFF), 8)\n sourceHead := add(sourceHead, sub(0x20, byteOffset))\n\n let lineTracker := mload(add(state, 0xa0))\n let lineRHSTopLevel := sub(totalRHSTopLevel, byte(30, lineTracker))\n let offset := mul(0x10, add(lineRHSTopLevel, 1))\n lineTracker := or(lineTracker, shl(offset, sourceHead))\n mstore(add(state, 0xa0), lineTracker)\n }\n }\n }\n\n function endLine(ParseState memory state, bytes memory data, uint256 cursor) internal pure {\n unchecked {\n {\n uint256 parenOffset;\n assembly (\"memory-safe\") {\n parenOffset := byte(0, mload(add(state, 0x60)))\n }\n if (parenOffset > 0) {\n revert UnclosedLeftParen(LibParse.parseErrorOffset(data, cursor));\n }\n }\n\n // This will snapshot the current head of the source, which will be\n // the start of where we want to read for the final line RHS item,\n // if it exists.\n state.snapshotSourceHeadToLineTracker();\n\n // Preserve the accepting inputs flag but set\n // everything else back to defaults. Also set that\n // there is an active source.\n state.fsm = (FSM_DEFAULT & ~FSM_ACCEPTING_INPUTS_MASK) | (state.fsm & FSM_ACCEPTING_INPUTS_MASK)\n | FSM_ACTIVE_SOURCE_MASK;\n\n uint256 lineLHSItems = state.lineTracker & 0xFF;\n // Total number of RHS at top level is the top byte of topLevel0.\n uint256 totalRHSTopLevel = state.topLevel0 >> 0xf8;\n // Snapshot for RHS from start of line is second low byte of\n // lineTracker.\n uint256 lineRHSTopLevel = totalRHSTopLevel - ((state.lineTracker >> 8) & 0xFF);\n\n // If:\n // - we are accepting inputs\n // - the RHS on this line is empty\n // Then we treat the LHS items as inputs to the source. This means that\n // we need to move the RHS offset to the end of the LHS items. There MAY\n // be 0 LHS items, e.g. if the entire source is empty. This can only\n // happen at the start of the source, as any RHS item immediately flips\n // the FSM to not accepting inputs.\n if (lineRHSTopLevel == 0) {\n if (state.fsm & FSM_ACCEPTING_INPUTS_MASK == 0) {\n revert NotAcceptingInputs(LibParse.parseErrorOffset(data, cursor));\n } else {\n // As there are no RHS opcodes yet we can simply set topLevel0 directly.\n // This is the only case where we defer to the LHS to tell\n // us how many top level items there are.\n totalRHSTopLevel += lineLHSItems;\n state.topLevel0 = totalRHSTopLevel << 0xf8;\n\n // Push the inputs onto the stack tracker.\n state.stackTracker = state.stackTracker.pushInputs(lineLHSItems);\n }\n }\n // If:\n // - there are multiple RHS items on this line\n // Then there must be the same number of LHS items. Multi or zero output\n // RHS top level items are NOT supported unless they are the only RHS\n // item on that line.\n else if (lineRHSTopLevel > 1) {\n if (lineLHSItems < lineRHSTopLevel) {\n revert ExcessRHSItems(LibParse.parseErrorOffset(data, cursor));\n } else if (lineLHSItems > lineRHSTopLevel) {\n revert ExcessLHSItems(LibParse.parseErrorOffset(data, cursor));\n }\n }\n\n // Follow pointers to the start of the RHS item.\n uint256 topLevelOffset = 1 + totalRHSTopLevel - lineRHSTopLevel;\n uint256 end = (0x10 * lineRHSTopLevel) + 0x20;\n for (uint256 offset = 0x20; offset < end; offset += 0x10) {\n uint256 itemSourceHead = (state.lineTracker >> offset) & 0xFFFF;\n uint256 opsDepth;\n assembly (\"memory-safe\") {\n opsDepth := byte(0, mload(add(state, add(0x20, topLevelOffset))))\n }\n for (uint256 i = 1; i <= opsDepth; i++) {\n {\n // We've hit the end of a LL item so have to jump towards the\n // tail to keep going.\n if (itemSourceHead % 0x20 == 0x1c) {\n assembly (\"memory-safe\") {\n itemSourceHead := shr(0xf0, mload(itemSourceHead))\n }\n }\n uint256 opInputs;\n assembly (\"memory-safe\") {\n opInputs := byte(1, mload(itemSourceHead))\n }\n state.stackTracker = state.stackTracker.pop(opInputs);\n // Nested multi or zero output RHS items are NOT\n // supported. If the top level RHS item is the ONLY RHS\n // item on the line then it MAY have multiple or zero\n // outputs. In this case we defer to the LHS to tell us\n // how many outputs there are. If the LHS is wrong then\n // later integrity checks will need to flag it.\n state.stackTracker =\n state.stackTracker.push(i == opsDepth && lineRHSTopLevel == 1 ? lineLHSItems : 1);\n }\n itemSourceHead += 4;\n }\n topLevelOffset++;\n }\n\n state.lineTracker = totalRHSTopLevel << 8;\n }\n }\n\n /// We potentially just closed out some group of arbitrarily nested parens\n /// OR a lone literal value at the top level. IF we are at the top level we\n /// move the immutable stack highwater mark forward 1 item, which moves the\n /// RHS offset forward 1 byte to start a new word counter.\n function highwater(ParseState memory state) internal pure {\n uint256 parenOffset;\n assembly (\"memory-safe\") {\n parenOffset := byte(0, mload(add(state, 0x60)))\n }\n if (parenOffset == 0) {\n uint256 newStackRHSOffset;\n assembly (\"memory-safe\") {\n let stackRHSOffsetPtr := add(state, 0x20)\n newStackRHSOffset := add(byte(0, mload(stackRHSOffsetPtr)), 1)\n mstore8(stackRHSOffsetPtr, newStackRHSOffset)\n }\n if (newStackRHSOffset == 0x3f) {\n revert StackOverflow();\n }\n }\n }\n\n function pushLiteral(ParseState memory state, bytes memory data, uint256 cursor) internal pure returns (uint256) {\n unchecked {\n (\n function(bytes memory, uint256, uint256) pure returns (uint256) parser,\n uint256 innerStart,\n uint256 innerEnd,\n uint256 outerEnd\n ) = LibParseLiteral.boundLiteral(state.literalParsers, data, cursor);\n uint256 fingerprint;\n uint256 fingerprintBloom;\n assembly (\"memory-safe\") {\n fingerprint := and(keccak256(cursor, sub(outerEnd, cursor)), not(0xFFFF))\n //slither-disable-next-line incorrect-shift\n fingerprintBloom := shl(byte(0, fingerprint), 1)\n }\n\n // Whether the literal is a duplicate.\n bool exists = false;\n\n // The index of the literal in the linked list of literals. This is\n // starting from the top of the linked list, so the final index is\n // the height of the linked list minus this value.\n uint256 t = 1;\n\n // If the literal is in the bloom filter, then it MAY be a duplicate.\n // Try to find the literal in the linked list of literals using the\n // full fingerprint for better collision resistance than the bloom.\n //\n // If the literal is NOT in the bloom filter, then it is definitely\n // NOT a duplicate, so avoid traversing the linked list.\n //\n // Worst case is a false positive in the bloom filter, which means\n // we traverse the linked list and find no match. This is O(1) for\n // the bloom filter and O(n) for the linked list traversal, then\n // O(m) for the per-char literal parsing. The bloom filter is\n // 256 bits, so the chance of there being at least one false positive\n // over 10 literals is ~15% due to the birthday paradox.\n if (state.literalBloom & fingerprintBloom != 0) {\n uint256 tailPtr = state.constantsBuilder >> 0x10;\n while (tailPtr != 0) {\n uint256 tailKey;\n assembly (\"memory-safe\") {\n tailKey := mload(tailPtr)\n }\n // If the fingerprint matches, then the literal IS a duplicate,\n // with 240 bits of collision resistance. The value sits alongside\n // the key in memory.\n if (fingerprint == (tailKey & ~uint256(0xFFFF))) {\n exists = true;\n break;\n }\n\n assembly (\"memory-safe\") {\n // Tail pointer is the low 16 bits of the key.\n tailPtr := and(mload(tailPtr), 0xFFFF)\n }\n t++;\n }\n }\n\n // Push the literal opcode to the source.\n // The index is either the height of the constants, if the literal\n // is NOT a duplicate, or the height minus the index of the\n // duplicate. This is because the final constants array is built\n // 0 indexed from the bottom of the linked list to the top.\n {\n uint256 constantsHeight = state.constantsBuilder & 0xFFFF;\n state.pushOpToSource(OPCODE_CONSTANT, Operand.wrap(exists ? constantsHeight - t : constantsHeight));\n }\n\n // If the literal is not a duplicate, then we need to add it to the\n // linked list of literals so that `t` can point to it, and we can\n // build the constants array from the values in the linked list\n // later.\n if (!exists) {\n uint256 ptr;\n assembly (\"memory-safe\") {\n // Allocate two words.\n ptr := mload(0x40)\n mstore(0x40, add(ptr, 0x40))\n }\n // First word is the key.\n {\n // tail key is the fingerprint with the low 16 bits set to\n // the pointer to the next item in the linked list. If there\n // is no next item then the pointer is 0.\n uint256 tailKey = state.constantsBuilder >> 0x10 | fingerprint;\n assembly (\"memory-safe\") {\n mstore(ptr, tailKey)\n }\n }\n // Second word is the value.\n {\n uint256 tailValue = parser(data, innerStart, innerEnd);\n\n assembly (\"memory-safe\") {\n // Second word is the value\n mstore(add(ptr, 0x20), tailValue)\n }\n }\n\n state.constantsBuilder = ((state.constantsBuilder & 0xFFFF) + 1) | (ptr << 0x10);\n state.literalBloom |= fingerprintBloom;\n }\n\n return outerEnd;\n }\n }\n\n function pushOpToSource(ParseState memory state, uint256 opcode, Operand operand) internal pure {\n unchecked {\n // This might be a top level item so try to snapshot its pointer to\n // the line tracker before writing the stack counter.\n state.snapshotSourceHeadToLineTracker();\n\n // As soon as we push an op to source we can no longer accept inputs.\n state.fsm &= ~FSM_ACCEPTING_INPUTS_MASK;\n // We also have an active source;\n state.fsm |= FSM_ACTIVE_SOURCE_MASK;\n\n // Increment the top level stack counter for the current top level\n // word. MAY be setting 0 to 1 if this is the top level.\n assembly (\"memory-safe\") {\n // Hardcoded offset into the state struct.\n let counterOffset := add(state, 0x20)\n let counterPointer := add(counterOffset, add(byte(0, mload(counterOffset)), 1))\n // Increment the counter.\n mstore8(counterPointer, add(byte(0, mload(counterPointer)), 1))\n }\n\n uint256 activeSource;\n uint256 offset;\n assembly (\"memory-safe\") {\n let activeSourcePointer := mload(state)\n activeSource := mload(activeSourcePointer)\n // The low 16 bits of the active source is the current offset.\n offset := and(activeSource, 0xFFFF)\n\n // The offset is in bits so for a byte pointer we need to divide\n // by 8, then add 4 to move to the operand low byte.\n let inputsBytePointer := sub(add(activeSourcePointer, 0x20), add(div(offset, 8), 4))\n\n // Increment the paren input counter. The input counter is for the paren\n // group that is currently being built. This means the counter is for\n // the paren group that is one level above the current paren offset.\n // Assumes that every word has exactly 1 output, therefore the input\n // counter always increases by 1.\n // Hardcoded offset into the state struct.\n let inputCounterPos := add(state, 0x60)\n inputCounterPos :=\n add(\n add(\n inputCounterPos,\n // the offset\n byte(0, mload(inputCounterPos))\n ),\n // +2 for the reserved bytes -1 to move back to the counter\n // for the previous paren group.\n 1\n )\n // Increment the parent counter.\n mstore8(inputCounterPos, add(byte(0, mload(inputCounterPos)), 1))\n // Zero out the current counter.\n mstore8(add(inputCounterPos, 3), 0)\n\n // Write the operand low byte pointer into the paren tracker.\n // Move 3 bytes after the input counter pos, then shift down 32\n // bytes to accomodate the full mload.\n let parenTrackerPointer := sub(inputCounterPos, 29)\n mstore(parenTrackerPointer, or(and(mload(parenTrackerPointer), not(0xFFFF)), inputsBytePointer))\n }\n\n // We write sources RTL so they can run LTR.\n activeSource =\n // increment offset. We have 16 bits allocated to the offset and stop\n // processing at 0x100 so this never overflows into the actual source\n // data.\n activeSource + 0x20\n // include the operand. The operand is assumed to be 16 bits, so we shift\n // it into the correct position.\n | Operand.unwrap(operand) << offset\n // include new op. The opcode is assumed to be 8 bits, so we shift it\n // into the correct position, beyond the operand.\n | opcode << (offset + 0x18);\n assembly (\"memory-safe\") {\n mstore(mload(state), activeSource)\n }\n\n // We have filled the current source slot. Need to create a new active\n // source and fulfill the doubly linked list.\n if (offset == 0xe0) {\n // Pointer to a newly allocated active source.\n uint256 newTailPtr;\n // Pointer to the old head of the LL tail.\n uint256 oldTailPtr;\n uint256 emptyActiveSource = EMPTY_ACTIVE_SOURCE;\n assembly (\"memory-safe\") {\n oldTailPtr := mload(state)\n\n // Build the new tail head.\n newTailPtr := mload(0x40)\n mstore(state, newTailPtr)\n mstore(newTailPtr, or(emptyActiveSource, shl(0x10, oldTailPtr)))\n mstore(0x40, add(newTailPtr, 0x20))\n\n // The old tail head must now point back to the new tail head.\n mstore(oldTailPtr, or(and(mload(oldTailPtr), not(0xFFFF)), newTailPtr))\n }\n }\n }\n }\n\n function endSource(ParseState memory state) internal pure {\n uint256 sourcesBuilder = state.sourcesBuilder;\n uint256 offset = sourcesBuilder >> 0xf0;\n\n // End is the number of top level words in the source, which is the\n // byte offset index + 1.\n uint256 end;\n assembly (\"memory-safe\") {\n end := add(byte(0, mload(add(state, 0x20))), 1)\n }\n\n if (offset == 0xf0) {\n revert MaxSources();\n }\n // Follow the word counters to build the source with the correct\n // combination of LTR and RTL words. The stack needs to be built\n // LTR at the top level, so that as the evaluation proceeds LTR it\n // can reference previous items in subsequent items. However, the\n // stack is built RTL within each item, so that nested parens are\n // evaluated correctly similar to reverse polish notation.\n else {\n uint256 source;\n StackTracker stackTracker = state.stackTracker;\n assembly (\"memory-safe\") {\n // find the end of the LL tail.\n let cursor := mload(state)\n\n let tailPointer := and(shr(0x10, mload(cursor)), 0xFFFF)\n for {} iszero(iszero(tailPointer)) {} {\n cursor := tailPointer\n tailPointer := and(shr(0x10, mload(cursor)), 0xFFFF)\n }\n\n // Move cursor to the end of the end of the LL tail item.\n // This is 4 bytes from the end of the EVM word, to compensate\n // for the offset and pointer positions.\n tailPointer := cursor\n cursor := add(cursor, 0x1C)\n // leave space for the source prefix in the bytecode output.\n let length := 4\n source := mload(0x40)\n // Move over the source 32 byte length and the 4 byte prefix.\n let writeCursor := add(source, 0x20)\n writeCursor := add(writeCursor, 4)\n\n let counterCursor := add(state, 0x21)\n for {\n let i := 0\n let wordsTotal := byte(0, mload(counterCursor))\n let wordsRemaining := wordsTotal\n } lt(i, end) {\n i := add(i, 1)\n counterCursor := add(counterCursor, 1)\n wordsTotal := byte(0, mload(counterCursor))\n wordsRemaining := wordsTotal\n } {\n length := add(length, mul(wordsTotal, 4))\n {\n // 4 bytes per source word.\n let tailItemWordsRemaining := div(sub(cursor, tailPointer), 4)\n // loop to the tail item that contains the start of the words\n // that we need to copy.\n for {} gt(wordsRemaining, tailItemWordsRemaining) {} {\n wordsRemaining := sub(wordsRemaining, tailItemWordsRemaining)\n tailPointer := and(mload(tailPointer), 0xFFFF)\n tailItemWordsRemaining := 7\n cursor := add(tailPointer, 0x1C)\n }\n }\n\n // Now the words remaining is lte the words remaining in the\n // tail item. Move the cursor back to the start of the words\n // and copy the passed over bytes to the write cursor.\n {\n let forwardTailPointer := tailPointer\n let size := mul(wordsRemaining, 4)\n cursor := sub(cursor, size)\n mstore(writeCursor, mload(cursor))\n writeCursor := add(writeCursor, size)\n\n // Redefine wordsRemaining to be the number of words\n // left to copy.\n wordsRemaining := sub(wordsTotal, wordsRemaining)\n // Move over whole tail items.\n for {} gt(wordsRemaining, 7) {} {\n wordsRemaining := sub(wordsRemaining, 7)\n // Follow the forward tail pointer.\n forwardTailPointer := and(shr(0x10, mload(forwardTailPointer)), 0xFFFF)\n mstore(writeCursor, mload(forwardTailPointer))\n writeCursor := add(writeCursor, 0x1c)\n }\n // Move over the remaining words in the tail item.\n if gt(wordsRemaining, 0) {\n forwardTailPointer := and(shr(0x10, mload(forwardTailPointer)), 0xFFFF)\n mstore(writeCursor, mload(forwardTailPointer))\n writeCursor := add(writeCursor, mul(wordsRemaining, 4))\n }\n }\n }\n // Store the bytes length in the source.\n mstore(source, length)\n // Store the opcodes length and stack tracker in the source\n // prefix.\n let prefixWritePointer := add(source, 4)\n mstore(\n prefixWritePointer,\n or(\n and(mload(prefixWritePointer), not(0xFFFFFFFF)),\n or(shl(0x18, sub(div(length, 4), 1)), stackTracker)\n )\n )\n\n // Round up to the nearest 32 bytes to realign memory.\n mstore(0x40, and(add(writeCursor, 0x1f), not(0x1f)))\n }\n\n //slither-disable-next-line incorrect-shift\n state.sourcesBuilder =\n ((offset + 0x10) << 0xf0) | (source << offset) | (sourcesBuilder & ((1 << offset) - 1));\n\n // Reset source as we're done with this one.\n state.fsm &= ~FSM_ACTIVE_SOURCE_MASK;\n state.resetSource();\n }\n }\n\n function buildBytecode(ParseState memory state) internal pure returns (bytes memory bytecode) {\n unchecked {\n uint256 sourcesBuilder = state.sourcesBuilder;\n uint256 offsetEnd = (sourcesBuilder >> 0xf0);\n\n // Somehow the parser state for the active source was not reset\n // correctly, or the finalised offset is dangling. This implies that\n // we are building the overall sources array while still trying to\n // build one of the individual sources. This is a bug in the parser.\n uint256 activeSource;\n assembly (\"memory-safe\") {\n activeSource := mload(mload(state))\n }\n if (activeSource != EMPTY_ACTIVE_SOURCE) {\n revert DanglingSource();\n }\n\n uint256 cursor;\n uint256 sourcesCount;\n uint256 sourcesStart;\n assembly (\"memory-safe\") {\n cursor := mload(0x40)\n bytecode := cursor\n // Move past the bytecode length, we will write this at the end.\n cursor := add(cursor, 0x20)\n\n // First byte is the number of sources.\n sourcesCount := div(offsetEnd, 0x10)\n mstore8(cursor, sourcesCount)\n cursor := add(cursor, 1)\n\n let pointersCursor := cursor\n\n // Skip past the pointer space. We'll back fill it.\n // Divide offsetEnd to convert from a bit to a byte shift.\n cursor := add(cursor, div(offsetEnd, 8))\n sourcesStart := cursor\n\n // Write total bytes length into bytecode. We do ths and handle\n // the allocation in this same assembly block for memory safety\n // for the compiler optimiser.\n let sourcesLength := 0\n let sourcePointers := 0\n for { let offset := 0 } lt(offset, offsetEnd) { offset := add(offset, 0x10) } {\n let currentSourcePointer := and(shr(offset, sourcesBuilder), 0xFFFF)\n // add 4 byte prefix to the length of the sources, all as\n // bytes.\n sourcePointers := or(sourcePointers, shl(sub(0xf0, offset), sourcesLength))\n let currentSourceLength := mload(currentSourcePointer)\n\n // Put the reference source pointer and length into the\n // prefix so that we can use them to copy the actual data\n // into the bytecode.\n let tmpPrefix := shl(0xe0, or(shl(0x10, currentSourcePointer), currentSourceLength))\n mstore(add(sourcesStart, sourcesLength), tmpPrefix)\n sourcesLength := add(sourcesLength, currentSourceLength)\n }\n mstore(pointersCursor, or(mload(pointersCursor), sourcePointers))\n mstore(bytecode, add(sourcesLength, sub(sub(sourcesStart, 0x20), bytecode)))\n\n // Round up to the nearest 32 bytes past cursor to realign and\n // allocate memory.\n mstore(0x40, and(add(add(add(0x20, mload(bytecode)), bytecode), 0x1f), not(0x1f)))\n }\n\n // Loop over the sources and write them into the bytecode. Perhaps\n // there is a more efficient way to do this in the future that won't\n // cause each source to be written twice in memory.\n for (uint256 i = 0; i < sourcesCount; i++) {\n Pointer sourcePointer;\n uint256 length;\n Pointer targetPointer;\n assembly (\"memory-safe\") {\n let relativePointer := and(mload(add(bytecode, add(3, mul(i, 2)))), 0xFFFF)\n targetPointer := add(sourcesStart, relativePointer)\n let tmpPrefix := mload(targetPointer)\n sourcePointer := add(0x20, shr(0xf0, tmpPrefix))\n length := and(shr(0xe0, tmpPrefix), 0xFFFF)\n }\n LibMemCpy.unsafeCopyBytesTo(sourcePointer, targetPointer, length);\n }\n }\n }\n\n function buildConstants(ParseState memory state) internal pure returns (uint256[] memory constants) {\n uint256 constantsHeight = state.constantsBuilder & 0xFFFF;\n uint256 tailPtr = state.constantsBuilder >> 0x10;\n\n assembly (\"memory-safe\") {\n let cursor := mload(0x40)\n constants := cursor\n mstore(cursor, constantsHeight)\n let end := cursor\n // Move the cursor to the end of the array. Write in reverse order\n // of the linked list traversal so that the constants are built\n // according to the stable indexes in the source from the linked\n // list base.\n cursor := add(cursor, mul(constantsHeight, 0x20))\n // Allocate one word past the cursor. This will be just after the\n // length if the constants array is empty. Otherwise it will be\n // just after the last constant.\n mstore(0x40, add(cursor, 0x20))\n // It MUST be equivalent to say that the cursor is above the end,\n // and that we are following tail pointers until they point to 0,\n // and that the cursor is moving as far as the constants height.\n // This is ensured by the fact that the constants height is only\n // incremented when a new constant is added to the linked list.\n for {} gt(cursor, end) {\n // Next item in the linked list.\n cursor := sub(cursor, 0x20)\n // tail pointer in tail keys is the low 16 bits under the\n // fingerprint, which is different from the tail pointer in\n // the constants builder, where it sits above the constants\n // height.\n tailPtr := and(mload(tailPtr), 0xFFFF)\n } {\n // Store the values not the keys.\n mstore(cursor, mload(add(tailPtr, 0x20)))\n }\n }\n }\n}\n\nlibrary LibParse {\n using LibPointer for Pointer;\n using LibParseState for ParseState;\n using LibParseStackName for ParseState;\n\n function parseErrorOffset(bytes memory data, uint256 cursor) internal pure returns (uint256 offset) {\n assembly (\"memory-safe\") {\n offset := sub(cursor, add(data, 0x20))\n }\n }\n\n function parseWord(uint256 cursor, uint256 mask) internal pure returns (uint256, bytes32) {\n bytes32 word;\n uint256 i = 1;\n assembly (\"memory-safe\") {\n // word is head + tail\n word := mload(cursor)\n // loop over the tail\n //slither-disable-next-line incorrect-shift\n for {} and(lt(i, 0x20), iszero(and(shl(byte(i, word), 1), not(mask)))) { i := add(i, 1) } {}\n let scrub := mul(sub(0x20, i), 8)\n word := shl(scrub, shr(scrub, word))\n cursor := add(cursor, i)\n }\n if (i == 0x20) {\n revert WordSize(string(abi.encodePacked(word)));\n }\n return (cursor, word);\n }\n\n /// Skip an unlimited number of chars until we find one that is not in the\n /// mask.\n function skipMask(uint256 cursor, uint256 end, uint256 mask) internal pure returns (uint256) {\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n for {} and(lt(cursor, end), gt(and(shl(byte(0, mload(cursor)), 1), mask), 0)) { cursor := add(cursor, 1) } {}\n }\n return cursor;\n }\n\n /// The cursor currently points at the head of a comment. We need to skip\n /// over all data until we find the end of the comment. This MAY REVERT if\n /// the comment is malformed, e.g. if the comment doesn't start with `/*`.\n /// @param data The source data.\n /// @param cursor The current cursor position.\n /// @return The new cursor position.\n function skipComment(bytes memory data, uint256 cursor) internal pure returns (uint256) {\n // First check the comment opening sequence is not malformed.\n uint256 startSequence;\n assembly (\"memory-safe\") {\n startSequence := shr(0xf0, mload(cursor))\n }\n if (startSequence != COMMENT_START_SEQUENCE) {\n revert MalformedCommentStart(parseErrorOffset(data, cursor));\n }\n uint256 commentEndSequenceStart = COMMENT_END_SEQUENCE >> 8;\n uint256 commentEndSequenceEnd = COMMENT_END_SEQUENCE & 0xFF;\n uint256 max;\n assembly (\"memory-safe\") {\n // Move past the start sequence.\n cursor := add(cursor, 2)\n max := add(data, add(mload(data), 0x20))\n\n // Loop until we find the end sequence.\n let done := 0\n for {} iszero(done) {} {\n for {} and(iszero(eq(byte(0, mload(cursor)), commentEndSequenceStart)), lt(cursor, max)) {} {\n cursor := add(cursor, 1)\n }\n // We have found the start of the end sequence. Now check the\n // end sequence is correct.\n cursor := add(cursor, 1)\n // Only exit the loop if the end sequence is correct. We don't\n // move the cursor forward unless we haven exact match on the\n // end byte. E.g. consider the sequence `/** comment **/`.\n if or(eq(byte(0, mload(cursor)), commentEndSequenceEnd), iszero(lt(cursor, max))) {\n done := 1\n cursor := add(cursor, 1)\n }\n }\n }\n // If the cursor is past the max we either never even started an end\n // sequence, or we started parsing an end sequence but couldn't complete\n // it. Either way, the comment is malformed, and the parser is OOB.\n if (cursor > max) {\n revert ParserOutOfBounds();\n }\n return cursor;\n }\n\n //slither-disable-next-line cyclomatic-complexity\n function parse(bytes memory data, bytes memory meta)\n internal\n pure\n returns (bytes memory bytecode, uint256[] memory)\n {\n unchecked {\n ParseState memory state = LibParseState.newState();\n if (data.length > 0) {\n bytes32 word;\n uint256 cursor;\n uint256 end;\n uint256 char;\n assembly (\"memory-safe\") {\n cursor := add(data, 0x20)\n end := add(cursor, mload(data))\n }\n while (cursor < end) {\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n\n // LHS\n if (state.fsm & FSM_RHS_MASK == 0) {\n if (char & CMASK_LHS_STACK_HEAD > 0) {\n // if yang we can't start new stack item\n if (state.fsm & FSM_YANG_MASK > 0) {\n revert UnexpectedLHSChar(parseErrorOffset(data, cursor));\n }\n\n // Named stack item.\n if (char & CMASK_IDENTIFIER_HEAD > 0) {\n (cursor, word) = parseWord(cursor, CMASK_LHS_STACK_TAIL);\n (bool exists, uint256 index) = state.pushStackName(word);\n (index);\n // If the stack name already exists, then we\n // revert as shadowing is not allowed.\n if (exists) {\n revert DuplicateLHSItem(parseErrorOffset(data, cursor));\n }\n }\n // Anon stack item.\n else {\n cursor = skipMask(cursor + 1, end, CMASK_LHS_STACK_TAIL);\n }\n // Bump the index regardless of whether the stack\n // item is named or not.\n state.topLevel1++;\n state.lineTracker++;\n\n // Set yang as we are now building a stack item.\n // We are also no longer interstitial\n state.fsm = (state.fsm | FSM_YANG_MASK | FSM_ACTIVE_SOURCE_MASK) & ~FSM_INTERSTITIAL_MASK;\n } else if (char & CMASK_WHITESPACE != 0) {\n cursor = skipMask(cursor + 1, end, CMASK_WHITESPACE);\n // Set ying as we now open to possibilities.\n state.fsm &= ~FSM_YANG_MASK;\n } else if (char & CMASK_LHS_RHS_DELIMITER != 0) {\n // Set RHS and yin. Move out of the interstitial if\n // we haven't already.\n state.fsm = (state.fsm | FSM_RHS_MASK | FSM_ACTIVE_SOURCE_MASK)\n & ~(FSM_YANG_MASK | FSM_INTERSTITIAL_MASK);\n cursor++;\n } else if (char & CMASK_COMMENT_HEAD != 0) {\n if (state.fsm & FSM_INTERSTITIAL_MASK == 0) {\n revert UnexpectedComment(parseErrorOffset(data, cursor));\n }\n cursor = skipComment(data, cursor);\n // Set yang for comments to force a little breathing\n // room between comments and the next item.\n state.fsm |= FSM_YANG_MASK;\n } else {\n revert UnexpectedLHSChar(parseErrorOffset(data, cursor));\n }\n }\n // RHS\n else {\n if (char & CMASK_RHS_WORD_HEAD > 0) {\n // If yang we can't start a new word.\n if (state.fsm & FSM_YANG_MASK > 0) {\n revert UnexpectedRHSChar(parseErrorOffset(data, cursor));\n }\n\n (cursor, word) = parseWord(cursor, CMASK_RHS_WORD_TAIL);\n\n // First check if this word is in meta.\n (\n bool exists,\n uint256 opcodeIndex,\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParser\n ) = LibParseMeta.lookupWord(meta, state.operandParsers, word);\n if (exists) {\n Operand operand;\n (cursor, operand) = operandParser(state.literalParsers, data, cursor);\n state.pushOpToSource(opcodeIndex, operand);\n // This is a real word so we expect to see parens\n // after it.\n state.fsm |= FSM_WORD_END_MASK;\n }\n // Fallback to LHS items.\n else {\n (exists, opcodeIndex) = LibParseStackName.stackNameIndex(state, word);\n if (exists) {\n state.pushOpToSource(OPCODE_STACK, Operand.wrap(opcodeIndex));\n // Need to process highwater here because we\n // don't have any parens to open or close.\n state.highwater();\n } else {\n revert UnknownWord(parseErrorOffset(data, cursor));\n }\n }\n\n state.fsm |= FSM_YANG_MASK;\n }\n // If this is the end of a word we MUST start a paren.\n else if (state.fsm & FSM_WORD_END_MASK > 0) {\n if (char & CMASK_LEFT_PAREN == 0) {\n revert ExpectedLeftParen(parseErrorOffset(data, cursor));\n }\n // Increase the paren depth by 1.\n // i.e. move the byte offset by 3\n // There MAY be garbage at this new offset due to\n // a previous paren group being deallocated. The\n // deallocation process writes the input counter\n // to zero but leaves a garbage word in place, with\n // the expectation that it will be overwritten by\n // the next paren group.\n uint256 newParenOffset;\n assembly (\"memory-safe\") {\n newParenOffset := add(byte(0, mload(add(state, 0x60))), 3)\n mstore8(add(state, 0x60), newParenOffset)\n }\n // first 2 bytes are reserved, then remaining 62\n // bytes are for paren groups, so the offset MUST NOT\n // imply writing to the 63rd byte.\n if (newParenOffset > 59) {\n revert ParenOverflow();\n }\n cursor++;\n\n // We've moved past the paren, so we are no longer at\n // the end of a word and are yin.\n state.fsm &= ~(FSM_WORD_END_MASK | FSM_YANG_MASK);\n } else if (char & CMASK_RIGHT_PAREN > 0) {\n uint256 parenOffset;\n assembly (\"memory-safe\") {\n parenOffset := byte(0, mload(add(state, 0x60)))\n }\n if (parenOffset == 0) {\n revert UnexpectedRightParen(parseErrorOffset(data, cursor));\n }\n // Decrease the paren depth by 1.\n // i.e. move the byte offset by -3.\n // This effectively deallocates the paren group, so\n // write the input counter out to the operand pointed\n // to by the pointer we deallocated.\n assembly (\"memory-safe\") {\n // State field offset.\n let stateOffset := add(state, 0x60)\n parenOffset := sub(parenOffset, 3)\n mstore8(stateOffset, parenOffset)\n mstore8(\n // Add 2 for the reserved bytes to the offset\n // then read top 16 bits from the pointer.\n // Add 1 to sandwitch the inputs byte between\n // the opcode index byte and the operand low\n // bytes.\n add(1, shr(0xf0, mload(add(add(stateOffset, 2), parenOffset)))),\n // Store the input counter, which is 2 bytes\n // after the operand write pointer.\n byte(0, mload(add(add(stateOffset, 4), parenOffset)))\n )\n }\n state.highwater();\n cursor++;\n } else if (char & CMASK_WHITESPACE > 0) {\n cursor = skipMask(cursor + 1, end, CMASK_WHITESPACE);\n // Set yin as we now open to possibilities.\n state.fsm &= ~FSM_YANG_MASK;\n }\n // Handle all literals.\n else if (char & CMASK_LITERAL_HEAD > 0) {\n cursor = state.pushLiteral(data, cursor);\n state.highwater();\n // We are yang now. Need the next char to release to\n // yin.\n state.fsm |= FSM_YANG_MASK;\n } else if (char & CMASK_EOL > 0) {\n state.endLine(data, cursor);\n cursor++;\n }\n // End of source.\n else if (char & CMASK_EOS > 0) {\n state.endLine(data, cursor);\n state.endSource();\n cursor++;\n\n state.fsm = FSM_DEFAULT;\n }\n // Comments aren't allowed in the RHS but we can give a\n // nicer error message than the default.\n else if (char & CMASK_COMMENT_HEAD != 0) {\n revert UnexpectedComment(parseErrorOffset(data, cursor));\n } else {\n revert UnexpectedRHSChar(parseErrorOffset(data, cursor));\n }\n }\n }\n if (cursor != end) {\n revert ParserOutOfBounds();\n }\n if (state.fsm & FSM_ACTIVE_SOURCE_MASK != 0) {\n revert MissingFinalSemi(parseErrorOffset(data, cursor));\n }\n }\n return (state.buildBytecode(), state.buildConstants());\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/concrete/RainterpreterNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity =0.8.19;\n\nimport \"openzeppelin-contracts/contracts/utils/introspection/ERC165.sol\";\n\nimport \"rain.lib.typecast/LibCast.sol\";\nimport {LibDataContract} from \"rain.datacontract/lib/LibDataContract.sol\";\n\nimport \"../interface/unstable/IDebugInterpreterV2.sol\";\n\nimport {LibEvalNP} from \"../lib/eval/LibEvalNP.sol\";\nimport \"../lib/ns/LibNamespace.sol\";\nimport {LibInterpreterStateDataContractNP} from \"../lib/state/LibInterpreterStateDataContractNP.sol\";\nimport \"../lib/caller/LibEncodedDispatch.sol\";\n\nimport {InterpreterStateNP} from \"../lib/state/LibInterpreterStateNP.sol\";\nimport {LibAllStandardOpsNP} from \"../lib/op/LibAllStandardOpsNP.sol\";\nimport {LibPointer, Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {LibStackPointer} from \"rain.solmem/lib/LibStackPointer.sol\";\nimport {LibUint256Array} from \"rain.solmem/lib/LibUint256Array.sol\";\nimport {LibMemoryKV, MemoryKV} from \"rain.lib.memkv/lib/LibMemoryKV.sol\";\n\n/// Thrown when the stack length is negative during eval.\nerror NegativeStackLength(int256 length);\n\n/// Thrown when the source index is invalid during eval. This is a runtime check\n/// for the exposed external eval entrypoint. Internally recursive evals are\n/// expected to preflight check the source index.\nerror InvalidSourceIndex(SourceIndex sourceIndex);\n\n/// @dev Hash of the known interpreter bytecode.\nbytes32 constant INTERPRETER_BYTECODE_HASH = bytes32(0x21785780ab522520aaf1921d5a177b745aa7179c67305ed963c709e79bdfbe0d);\n\n/// @dev The function pointers known to the interpreter for dynamic dispatch.\n/// By setting these as a constant they can be inlined into the interpreter\n/// and loaded at eval time for very low gas (~100) due to the compiler\n/// optimising it to a single `codecopy` to build the in memory bytes array.\nbytes constant OPCODE_FUNCTION_POINTERS =\n hex\"0d090d550d900da90e470f2b0f65101510b710e6111511151164119311f5127d13241338138e13a213b713d113dc13f01405148214cd14f3150a15211521156c15b716021602164d164d169816e3172e172e17791860189318ea\";\n\n/// @title RainterpreterNP\n/// @notice !!EXPERIMENTAL!! implementation of a Rainlang interpreter that is\n/// compatible with native onchain Rainlang parsing. Initially copied verbatim\n/// from the JS compatible Rainterpreter. This interpreter is deliberately\n/// separate from the JS Rainterpreter to allow for experimentation with the\n/// onchain interpreter without affecting the JS interpreter, up to and including\n/// a complely different execution model and opcodes.\ncontract RainterpreterNP is IInterpreterV1, IDebugInterpreterV2, ERC165 {\n using LibEvalNP for InterpreterStateNP;\n using LibNamespace for StateNamespace;\n using LibInterpreterStateDataContractNP for bytes;\n\n /// There are MANY ways that eval can be forced into undefined/corrupt\n /// behaviour by passing in invalid data. This is a deliberate design\n /// decision to allow for the interpreter to be as gas efficient as\n /// possible. The interpreter is provably read only, it contains no state\n /// changing evm opcodes reachable on any logic path. This means that\n /// the caller can only harm themselves by passing in invalid data and\n /// either reverting, exhausting gas or getting back some garbage data.\n /// The caller can trivially protect themselves from these OOB issues by\n /// ensuring the integrity check has successfully run over the bytecode\n /// before calling eval. Any smart contract caller can do this by using a\n /// trusted and appropriate deployer contract to deploy the bytecode, which\n /// will automatically run the integrity check during deployment, then\n /// keeping a registry of trusted expression addresses for itself in storage.\n ///\n /// This appears first in the contract in the hope that the compiler will\n /// put it in the most efficient internal dispatch location to save a few\n /// gas per eval call.\n ///\n /// @inheritdoc IInterpreterV1\n function eval(\n IInterpreterStoreV1 store,\n StateNamespace namespace,\n EncodedDispatch dispatch,\n uint256[][] memory context\n ) external view returns (uint256[] memory, uint256[] memory) {\n // Decode the dispatch.\n (address expression, SourceIndex sourceIndex16, uint256 maxOutputs) = LibEncodedDispatch.decode(dispatch);\n bytes memory expressionData = LibDataContract.read(expression);\n\n // Need to clean source index as it is a uint16.\n uint256 sourceIndex;\n assembly (\"memory-safe\") {\n sourceIndex := and(sourceIndex16, 0xFFFF)\n }\n\n InterpreterStateNP memory state = expressionData.unsafeDeserializeNP(\n sourceIndex, namespace.qualifyNamespace(msg.sender), store, context, OPCODE_FUNCTION_POINTERS\n );\n // We use the return by returning it. Slither false positive.\n //slither-disable-next-line unused-return\n return state.evalNP(new uint256[](0), maxOutputs);\n }\n\n // @inheritdoc ERC165\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IInterpreterV1).interfaceId || interfaceId == type(IDebugInterpreterV2).interfaceId\n || super.supportsInterface(interfaceId);\n }\n\n /// @inheritdoc IDebugInterpreterV2\n function offchainDebugEval(\n IInterpreterStoreV1 store,\n FullyQualifiedNamespace namespace,\n bytes memory expressionData,\n SourceIndex sourceIndex16,\n uint256 maxOutputs,\n uint256[][] memory context,\n uint256[] memory inputs\n ) external view returns (uint256[] memory, uint256[] memory) {\n // Need to clean source index as it is a uint16.\n uint256 sourceIndex;\n assembly (\"memory-safe\") {\n sourceIndex := and(sourceIndex16, 0xFFFF)\n }\n InterpreterStateNP memory state =\n expressionData.unsafeDeserializeNP(sourceIndex, namespace, store, context, OPCODE_FUNCTION_POINTERS);\n // We use the return by returning it. Slither false positive.\n //slither-disable-next-line unused-return\n return state.evalNP(inputs, maxOutputs);\n }\n\n /// @inheritdoc IInterpreterV1\n function functionPointers() external view virtual returns (bytes memory) {\n return LibAllStandardOpsNP.opcodeFunctionPointers();\n }\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibUint256Array.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibMemCpy.sol\";\n\n/// Thrown if a truncated length is longer than the array being truncated. It is\n/// not possible to truncate something and increase its length as the memory\n/// region after the array MAY be allocated for something else already.\nerror OutOfBoundsTruncate(uint256 arrayLength, uint256 truncatedLength);\n\n/// @title Uint256Array\n/// @notice Things we want to do carefully and efficiently with uint256 arrays\n/// that Solidity doesn't give us native tools for.\nlibrary LibUint256Array {\n using LibUint256Array for uint256[];\n\n /// Pointer to the start (length prefix) of a `uint256[]`.\n /// @param array The array to get the start pointer of.\n /// @return pointer The pointer to the start of `array`.\n function startPointer(uint256[] memory array) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := array\n }\n }\n\n /// Pointer to the data of a `uint256[]` NOT the length prefix.\n /// @param array The array to get the data pointer of.\n /// @return pointer The pointer to the data of `array`.\n function dataPointer(uint256[] memory array) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(array, 0x20)\n }\n }\n\n /// Pointer to the end of the allocated memory of an array.\n /// @param array The array to get the end pointer of.\n /// @return pointer The pointer to the end of `array`.\n function endPointer(uint256[] memory array) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(array, add(0x20, mul(0x20, mload(array))))\n }\n }\n\n /// Cast a `Pointer` to `uint256[]` without modification or safety checks.\n /// The caller MUST ensure the pointer is to a valid region of memory for\n /// some `uint256[]`.\n /// @param pointer The pointer to cast to `uint256[]`.\n /// @return array The cast `uint256[]`.\n function unsafeAsUint256Array(Pointer pointer) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := pointer\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a A single integer to build an array around.\n /// @return array The newly allocated array including `a` as a single item.\n function arrayFrom(uint256 a) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 1)\n mstore(add(array, 0x20), a)\n mstore(0x40, add(array, 0x40))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @return array The newly allocated array including `a` and `b` as the only\n /// items.\n function arrayFrom(uint256 a, uint256 b) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 2)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(0x40, add(array, 0x60))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @param c The third integer to build an array around.\n /// @return array The newly allocated array including `a`, `b` and `c` as the\n /// only items.\n function arrayFrom(uint256 a, uint256 b, uint256 c) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 3)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(add(array, 0x60), c)\n mstore(0x40, add(array, 0x80))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @param c The third integer to build an array around.\n /// @param d The fourth integer to build an array around.\n /// @return array The newly allocated array including `a`, `b`, `c` and `d` as the\n /// only items.\n function arrayFrom(uint256 a, uint256 b, uint256 c, uint256 d) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 4)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(add(array, 0x60), c)\n mstore(add(array, 0x80), d)\n mstore(0x40, add(array, 0xA0))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @param c The third integer to build an array around.\n /// @param d The fourth integer to build an array around.\n /// @param e The fifth integer to build an array around.\n /// @return array The newly allocated array including `a`, `b`, `c`, `d` and\n /// `e` as the only items.\n function arrayFrom(uint256 a, uint256 b, uint256 c, uint256 d, uint256 e)\n internal\n pure\n returns (uint256[] memory array)\n {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 5)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(add(array, 0x60), c)\n mstore(add(array, 0x80), d)\n mstore(add(array, 0xA0), e)\n mstore(0x40, add(array, 0xC0))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first integer to build an array around.\n /// @param b The second integer to build an array around.\n /// @param c The third integer to build an array around.\n /// @param d The fourth integer to build an array around.\n /// @param e The fifth integer to build an array around.\n /// @param f The sixth integer to build an array around.\n /// @return array The newly allocated array including `a`, `b`, `c`, `d`, `e`\n /// and `f` as the only items.\n function arrayFrom(uint256 a, uint256 b, uint256 c, uint256 d, uint256 e, uint256 f)\n internal\n pure\n returns (uint256[] memory array)\n {\n assembly (\"memory-safe\") {\n array := mload(0x40)\n mstore(array, 6)\n mstore(add(array, 0x20), a)\n mstore(add(array, 0x40), b)\n mstore(add(array, 0x60), c)\n mstore(add(array, 0x80), d)\n mstore(add(array, 0xA0), e)\n mstore(add(array, 0xC0), f)\n mstore(0x40, add(array, 0xE0))\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The head of the new array.\n /// @param tail The tail of the new array.\n /// @return array The new array.\n function arrayFrom(uint256 a, uint256[] memory tail) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n let length := add(mload(tail), 1)\n let outputCursor := mload(0x40)\n array := outputCursor\n let outputEnd := add(outputCursor, add(0x20, mul(length, 0x20)))\n mstore(0x40, outputEnd)\n\n mstore(outputCursor, length)\n mstore(add(outputCursor, 0x20), a)\n\n for {\n outputCursor := add(outputCursor, 0x40)\n let inputCursor := add(tail, 0x20)\n } lt(outputCursor, outputEnd) {\n outputCursor := add(outputCursor, 0x20)\n inputCursor := add(inputCursor, 0x20)\n } { mstore(outputCursor, mload(inputCursor)) }\n }\n }\n\n /// Building arrays from literal components is a common task that introduces\n /// boilerplate that is either inefficient or error prone.\n /// @param a The first item of the new array.\n /// @param b The second item of the new array.\n /// @param tail The tail of the new array.\n /// @return array The new array.\n function arrayFrom(uint256 a, uint256 b, uint256[] memory tail) internal pure returns (uint256[] memory array) {\n assembly (\"memory-safe\") {\n let length := add(mload(tail), 2)\n let outputCursor := mload(0x40)\n array := outputCursor\n let outputEnd := add(outputCursor, add(0x20, mul(length, 0x20)))\n mstore(0x40, outputEnd)\n\n mstore(outputCursor, length)\n mstore(add(outputCursor, 0x20), a)\n mstore(add(outputCursor, 0x40), b)\n\n for {\n outputCursor := add(outputCursor, 0x60)\n let inputCursor := add(tail, 0x20)\n } lt(outputCursor, outputEnd) {\n outputCursor := add(outputCursor, 0x20)\n inputCursor := add(inputCursor, 0x20)\n } { mstore(outputCursor, mload(inputCursor)) }\n }\n }\n\n /// Solidity provides no way to change the length of in-memory arrays but\n /// it also does not deallocate memory ever. It is always safe to shrink an\n /// array that has already been allocated, with the caveat that the\n /// truncated items will effectively become inaccessible regions of memory.\n /// That is to say, we deliberately \"leak\" the truncated items, but that is\n /// no worse than Solidity's native behaviour of leaking everything always.\n /// The array is MUTATED in place so there is no return value and there is\n /// no new allocation or copying of data either.\n /// @param array The array to truncate.\n /// @param newLength The new length of the array after truncation.\n function truncate(uint256[] memory array, uint256 newLength) internal pure {\n if (newLength > array.length) {\n revert OutOfBoundsTruncate(array.length, newLength);\n }\n assembly (\"memory-safe\") {\n mstore(array, newLength)\n }\n }\n\n /// Extends `base_` with `extend_` by allocating only an additional\n /// `extend_.length` words onto `base_` and copying only `extend_` if\n /// possible. If `base_` is large this MAY be significantly more efficient\n /// than allocating `base_.length + extend_.length` for an entirely new array\n /// and copying both `base_` and `extend_` into the new array one item at a\n /// time in Solidity.\n ///\n /// The efficient version of extension is only possible if the free memory\n /// pointer sits at the end of the base array at the moment of extension. If\n /// there is allocated memory after the end of base then extension will\n /// require copying both the base and extend arays to a new region of memory.\n /// The caller is responsible for optimising code paths to avoid additional\n /// allocations.\n ///\n /// This function is UNSAFE because the base array IS MUTATED DIRECTLY by\n /// some code paths AND THE FINAL RETURN ARRAY MAY POINT TO THE SAME REGION\n /// OF MEMORY. It is NOT POSSIBLE to reliably see this behaviour from the\n /// caller in all cases as the Solidity compiler optimisations may switch the\n /// caller between the allocating and non-allocating logic due to subtle\n /// optimisation reasons. To use this function safely THE CALLER MUST NOT USE\n /// THE BASE ARRAY AND MUST USE THE RETURNED ARRAY ONLY. It is safe to use\n /// the extend array after calling this function as it is never mutated, it\n /// is only copied from.\n ///\n /// @param b The base integer array that will be extended by `e`.\n /// @param e The extend integer array that extends `b`.\n /// @return extended The extended array of `b` extended by `e`.\n function unsafeExtend(uint256[] memory b, uint256[] memory e) internal pure returns (uint256[] memory extended) {\n assembly (\"memory-safe\") {\n // Slither doesn't recognise assembly function names as mixed case\n // even if they are.\n // https://github.com/crytic/slither/issues/1815\n //slither-disable-next-line naming-convention\n function extendInline(base, extend) -> baseAfter {\n let outputCursor := mload(0x40)\n let baseLength := mload(base)\n let baseEnd := add(base, add(0x20, mul(baseLength, 0x20)))\n\n // If base is NOT the last thing in allocated memory, allocate,\n // copy and recurse.\n switch eq(outputCursor, baseEnd)\n case 0 {\n let newBase := outputCursor\n let newBaseEnd := add(newBase, sub(baseEnd, base))\n mstore(0x40, newBaseEnd)\n for { let inputCursor := base } lt(outputCursor, newBaseEnd) {\n inputCursor := add(inputCursor, 0x20)\n outputCursor := add(outputCursor, 0x20)\n } { mstore(outputCursor, mload(inputCursor)) }\n\n baseAfter := extendInline(newBase, extend)\n }\n case 1 {\n let totalLength_ := add(baseLength, mload(extend))\n let outputEnd_ := add(base, add(0x20, mul(totalLength_, 0x20)))\n mstore(base, totalLength_)\n mstore(0x40, outputEnd_)\n for { let inputCursor := add(extend, 0x20) } lt(outputCursor, outputEnd_) {\n inputCursor := add(inputCursor, 0x20)\n outputCursor := add(outputCursor, 0x20)\n } { mstore(outputCursor, mload(inputCursor)) }\n\n baseAfter := base\n }\n }\n\n extended := extendInline(b, e)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibMemory.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nlibrary LibMemory {\n /// Returns true if the free memory pointer is pointing at a multiple of 32\n /// bytes, false otherwise. If all memory allocations are handled by Solidity\n /// then this will always be true, but assembly blocks can violate this, so\n /// this is a useful tool to test compliance of a custom assembly block with\n /// the solidity allocator.\n /// @return isAligned true if the memory is currently aligned to 32 bytes.\n function memoryIsAligned() internal pure returns (bool isAligned) {\n assembly (\"memory-safe\") {\n isAligned := iszero(mod(mload(0x40), 0x20))\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibMemCpy.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibPointer.sol\";\n\nlibrary LibMemCpy {\n /// Copy an arbitrary number of bytes from one location in memory to another.\n /// As we can only read/write bytes in 32 byte chunks we first have to loop\n /// over 32 byte values to copy then handle any unaligned remaining data. The\n /// remaining data will be appropriately masked with the existing data in the\n /// final chunk so as to not write past the desired length. Note that the\n /// final unaligned write will be more gas intensive than the prior aligned\n /// writes. The writes are completely unsafe, the caller MUST ensure that\n /// sufficient memory is allocated and reading/writing the requested number\n /// of bytes from/to the requested locations WILL NOT corrupt memory in the\n /// opinion of solidity or other subsequent read/write operations.\n /// @param sourceCursor The starting pointer to read from.\n /// @param targetCursor The starting pointer to write to.\n /// @param length The number of bytes to read/write.\n function unsafeCopyBytesTo(Pointer sourceCursor, Pointer targetCursor, uint256 length) internal pure {\n assembly (\"memory-safe\") {\n // Precalculating the end here, rather than tracking the remaining\n // length each iteration uses relatively more gas for less data, but\n // scales better for more data. Copying 1-2 words is ~30 gas more\n // expensive but copying 3+ words favours a precalculated end point\n // increasingly for more data.\n let m := mod(length, 0x20)\n let end := add(sourceCursor, sub(length, m))\n for {} lt(sourceCursor, end) {\n sourceCursor := add(sourceCursor, 0x20)\n targetCursor := add(targetCursor, 0x20)\n } { mstore(targetCursor, mload(sourceCursor)) }\n\n if iszero(iszero(m)) {\n //slither-disable-next-line incorrect-shift\n let mask_ := shr(mul(m, 8), 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)\n // preserve existing bytes\n mstore(\n targetCursor,\n or(\n // input\n and(mload(sourceCursor), not(mask_)),\n and(mload(targetCursor), mask_)\n )\n )\n }\n }\n }\n\n /// Copies `length` `uint256` values starting from `source` to `target`\n /// with NO attempt to check that this is safe to do so. The caller MUST\n /// ensure that there exists allocated memory at `target` in which it is\n /// safe and appropriate to copy `length * 32` bytes to. Anything that was\n /// already written to memory at `[target:target+(length * 32 bytes)]`\n /// will be overwritten.\n /// There is no return value as memory is modified directly.\n /// @param source The starting position in memory that data will be copied\n /// from.\n /// @param target The starting position in memory that data will be copied\n /// to.\n /// @param length The number of 32 byte (i.e. `uint256`) words that will\n /// be copied.\n function unsafeCopyWordsTo(Pointer source, Pointer target, uint256 length) internal pure {\n assembly (\"memory-safe\") {\n for { let end_ := add(source, mul(0x20, length)) } lt(source, end_) {\n source := add(source, 0x20)\n target := add(target, 0x20)\n } { mstore(target, mload(source)) }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.erc1820/src/interface/IERC1820Registry.sol": {
"content": "// SPDX-License-Identifier: MIT\n// Copied from (under MIT license):\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/IERC1820Registry.sol)\n\n/// This was MODIFIED from the original to bump the minimum Solidity version from\n/// ^0.8.0 to ^0.8.18, inline with slither recommendations.\npragma solidity ^0.8.18;\n\n/**\n * @dev Interface of the global ERC1820 Registry, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register\n * implementers for interfaces in this registry, as well as query support.\n *\n * Implementers may be shared by multiple accounts, and can also implement more\n * than a single interface for each account. Contracts can implement interfaces\n * for themselves, but externally-owned accounts (EOA) must delegate this to a\n * contract.\n *\n * {IERC165} interfaces can also be queried via the registry.\n *\n * For an in-depth explanation and source code analysis, see the EIP text.\n */\ninterface IERC1820Registry {\n event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);\n\n event ManagerChanged(address indexed account, address indexed newManager);\n\n /**\n * @dev Sets `newManager` as the manager for `account`. A manager of an\n * account is able to set interface implementers for it.\n *\n * By default, each account is its own manager. Passing a value of `0x0` in\n * `newManager` will reset the manager to this initial state.\n *\n * Emits a {ManagerChanged} event.\n *\n * Requirements:\n *\n * - the caller must be the current manager for `account`.\n */\n function setManager(address account, address newManager) external;\n\n /**\n * @dev Returns the manager for `account`.\n *\n * See {setManager}.\n */\n function getManager(address account) external view returns (address);\n\n /**\n * @dev Sets the `implementer` contract as ``account``'s implementer for\n * `interfaceHash`.\n *\n * `account` being the zero address is an alias for the caller's address.\n * The zero address can also be used in `implementer` to remove an old one.\n *\n * See {interfaceHash} to learn how these are created.\n *\n * Emits an {InterfaceImplementerSet} event.\n *\n * Requirements:\n *\n * - the caller must be the current manager for `account`.\n * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not\n * end in 28 zeroes).\n * - `implementer` must implement {IERC1820Implementer} and return true when\n * queried for support, unless `implementer` is the caller. See\n * {IERC1820Implementer-canImplementInterfaceForAddress}.\n */\n function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external;\n\n /**\n * @dev Returns the implementer of `interfaceHash` for `account`. If no such\n * implementer is registered, returns the zero address.\n *\n * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28\n * zeroes), `account` will be queried for support of it.\n *\n * `account` being the zero address is an alias for the caller's address.\n */\n function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);\n\n /**\n * @dev Returns the interface hash for an `interfaceName`, as defined in the\n * corresponding\n * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP].\n */\n function interfaceHash(string calldata interfaceName) external pure returns (bytes32);\n\n /**\n * @notice Updates the cache with whether the contract implements an ERC165 interface or not.\n * @param account Address of the contract for which to update the cache.\n * @param interfaceId ERC165 interface for which to update the cache.\n */\n function updateERC165Cache(address account, bytes4 interfaceId) external;\n\n /**\n * @notice Checks whether a contract implements an ERC165 interface or not.\n * If the result is not cached a direct lookup on the contract address is performed.\n * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling\n * {updateERC165Cache} with the contract address.\n * @param account Address of the contract to check.\n * @param interfaceId ERC165 interface to check.\n * @return True if `account` implements `interfaceId`, false otherwise.\n */\n function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);\n\n /**\n * @notice Checks whether a contract implements an ERC165 interface or not without using or updating the cache.\n * @param account Address of the contract to check.\n * @param interfaceId ERC165 interface to check.\n * @return True if `account` implements `interfaceId`, false otherwise.\n */\n function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/IInterpreterV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterStoreV1.sol\";\n\n/// @dev The index of a source within a deployed expression that can be evaluated\n/// by an `IInterpreterV1`. MAY be an entrypoint or the index of a source called\n/// internally such as by the `call` opcode.\ntype SourceIndex is uint16;\n\n/// @dev Encoded information about a specific evaluation including the expression\n/// address onchain, entrypoint and expected return values.\ntype EncodedDispatch is uint256;\n\n/// @dev The namespace for state changes as requested by the calling contract.\n/// The interpreter MUST apply this namespace IN ADDITION to namespacing by\n/// caller etc.\ntype StateNamespace is uint256;\n\n/// @dev Additional bytes that can be used to configure a single opcode dispatch.\n/// Commonly used to specify the number of inputs to a variadic function such\n/// as addition or multiplication.\ntype Operand is uint256;\n\n/// @dev The default state namespace MUST be used when a calling contract has no\n/// particular opinion on or need for dynamic namespaces.\nStateNamespace constant DEFAULT_STATE_NAMESPACE = StateNamespace.wrap(0);\n\n/// @title IInterpreterV1\n/// Interface into a standard interpreter that supports:\n///\n/// - evaluating `view` logic deployed onchain by an `IExpressionDeployerV1`\n/// - receiving arbitrary `uint256[][]` supporting context to be made available\n/// to the evaluated logic\n/// - handling subsequent state changes in bulk in response to evaluated logic\n/// - namespacing state changes according to the caller's preferences to avoid\n/// unwanted key collisions\n/// - exposing its internal function pointers to support external precompilation\n/// of logic for more gas efficient runtime evaluation by the interpreter\n///\n/// The interface is designed to be stable across many versions and\n/// implementations of an interpreter, balancing minimalism with features\n/// required for a general purpose onchain interpreted compute environment.\n///\n/// The security model of an interpreter is that it MUST be resilient to\n/// malicious expressions even if they dispatch arbitrary internal function\n/// pointers during an eval. The interpreter MAY return garbage or exhibit\n/// undefined behaviour or error during an eval, _provided that no state changes\n/// are persisted_ e.g. in storage, such that only the caller that specifies the\n/// malicious expression can be negatively impacted by the result. In turn, the\n/// caller must guard itself against arbitrarily corrupt/malicious reverts and\n/// return values from any interpreter that it requests an expression from. And\n/// so on and so forth up to the externally owned account (EOA) who signs the\n/// transaction and agrees to a specific combination of contracts, expressions\n/// and interpreters, who can presumably make an informed decision about which\n/// ones to trust to get the job done.\n///\n/// The state changes for an interpreter are expected to be produces by an `eval`\n/// and passed to the `IInterpreterStoreV1` returned by the eval, as-is by the\n/// caller, after the caller has had an opportunity to apply their own\n/// intermediate logic such as reentrancy defenses against malicious\n/// interpreters. The interpreter is free to structure the state changes however\n/// it wants but MUST guard against the calling contract corrupting the changes\n/// between `eval` and `set`. For example a store could sandbox storage writes\n/// per-caller so that a malicious caller can only damage their own state\n/// changes, while honest callers respect, benefit from and are protected by the\n/// interpreter store's state change handling.\n///\n/// The two step eval-state model allows eval to be read-only which provides\n/// security guarantees for the caller such as no stateful reentrancy, either\n/// from the interpreter or some contract interface used by some word, while\n/// still allowing for storage writes. As the storage writes happen on the\n/// interpreter rather than the caller (c.f. delegate call) the caller DOES NOT\n/// need to trust the interpreter, which allows for permissionless selection of\n/// interpreters by end users. Delegate call always implies an admin key on the\n/// caller because the delegatee contract can write arbitrarily to the state of\n/// the delegator, which severely limits the generality of contract composition.\ninterface IInterpreterV1 {\n /// Exposes the function pointers as `uint16` values packed into a single\n /// `bytes` in the same order as they would be indexed into by opcodes. For\n /// example, if opcode `2` should dispatch function at position `0x1234` then\n /// the start of the returned bytes would be `0xXXXXXXXX1234` where `X` is\n /// a placeholder for the function pointers of opcodes `0` and `1`.\n ///\n /// `IExpressionDeployerV1` contracts use these function pointers to\n /// \"compile\" the expression into something that an interpreter can dispatch\n /// directly without paying gas to lookup the same at runtime. As the\n /// validity of any integrity check and subsequent dispatch is highly\n /// sensitive to both the function pointers and overall bytecode of the\n /// interpreter, `IExpressionDeployerV1` contracts SHOULD implement guards\n /// against accidentally being deployed onchain paired against an unknown\n /// interpreter. It is very easy for an apparent compatible pairing to be\n /// subtly and critically incompatible due to addition/removal/reordering of\n /// opcodes and compiler optimisations on the interpreter bytecode.\n ///\n /// This MAY return different values during construction vs. all other times\n /// after the interpreter has been successfully deployed onchain. DO NOT rely\n /// on function pointers reported during contract construction.\n function functionPointers() external view returns (bytes memory);\n\n /// The raison d'etre for an interpreter. Given some expression and per-call\n /// additional contextual data, produce a stack of results and a set of state\n /// changes that the caller MAY OPTIONALLY pass back to be persisted by a\n /// call to `IInterpreterStoreV1.set`.\n /// @param store The storage contract that the returned key/value pairs\n /// MUST be passed to IF the calling contract is in a non-static calling\n /// context. Static calling contexts MUST pass `address(0)`.\n /// @param namespace The state namespace that will be fully qualified by the\n /// interpreter at runtime in order to perform gets on the underlying store.\n /// MUST be the same namespace passed to the store by the calling contract\n /// when sending the resulting key/value items to storage.\n /// @param dispatch All the information required for the interpreter to load\n /// an expression, select an entrypoint and return the values expected by the\n /// caller. The interpreter MAY encode dispatches differently to\n /// `LibEncodedDispatch` but this WILL negatively impact compatibility for\n /// calling contracts that hardcode the encoding logic.\n /// @param context A 2-dimensional array of data that can be indexed into at\n /// runtime by the interpreter. The calling contract is responsible for\n /// ensuring the authenticity and completeness of context data. The\n /// interpreter MUST revert at runtime if an expression attempts to index\n /// into some context value that is not provided by the caller. This implies\n /// that context reads cannot be checked for out of bounds reads at deploy\n /// time, as the runtime context MAY be provided in a different shape to what\n /// the expression is expecting.\n /// Same as `eval` but allowing the caller to specify a namespace under which\n /// the state changes will be applied. The interpeter MUST ensure that keys\n /// will never collide across namespaces, even if, for example:\n ///\n /// - The calling contract is malicious and attempts to craft a collision\n /// with state changes from another contract\n /// - The expression is malicious and attempts to craft a collision with\n /// other expressions evaluated by the same calling contract\n ///\n /// A malicious entity MAY have access to significant offchain resources to\n /// attempt to precompute key collisions through brute force. The collision\n /// resistance of namespaces should be comparable or equivalent to the\n /// collision resistance of the hashing algorithms employed by the blockchain\n /// itself, such as the design of `mapping` in Solidity that hashes each\n /// nested key to produce a collision resistant compound key.\n /// @return stack The list of values produced by evaluating the expression.\n /// MUST NOT be longer than the maximum length specified by `dispatch`, if\n /// applicable.\n /// @return kvs A list of pairwise key/value items to be saved in the store.\n function eval(\n IInterpreterStoreV1 store,\n StateNamespace namespace,\n EncodedDispatch dispatch,\n uint256[][] calldata context\n ) external view returns (uint256[] memory stack, uint256[] memory kvs);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/bytecode/LibBytecode.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.19;\n\nimport {LibPointer, Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {LibBytes} from \"rain.solmem/lib/LibBytes.sol\";\nimport {LibMemCpy} from \"rain.solmem/lib/LibMemCpy.sol\";\n\n/// Thrown when a bytecode source index is out of bounds.\n/// @param bytecode The bytecode that was inspected.\n/// @param sourceIndex The source index that was out of bounds.\nerror SourceIndexOutOfBounds(bytes bytecode, uint256 sourceIndex);\n\n/// Thrown when a bytecode reports itself as 0 sources but has more than 1 byte.\n/// @param bytecode The bytecode that was inspected.\nerror UnexpectedSources(bytes bytecode);\n\n/// Thrown when bytes are discovered between the offsets and the sources.\n/// @param bytecode The bytecode that was inspected.\nerror UnexpectedTrailingOffsetBytes(bytes bytecode);\n\n/// Thrown when the end of a source as self reported by its header doesnt match\n/// the start of the next source or the end of the bytecode.\n/// @param bytecode The bytecode that was inspected.\nerror TruncatedSource(bytes bytecode);\n\n/// Thrown when the offset to a source points to a location that cannot fit a\n/// header before the start of the next source or the end of the bytecode.\n/// @param bytecode The bytecode that was inspected.\nerror TruncatedHeader(bytes bytecode);\n\n/// Thrown when the bytecode is truncated before the end of the header offsets.\n/// @param bytecode The bytecode that was inspected.\nerror TruncatedHeaderOffsets(bytes bytecode);\n\n/// Thrown when the stack sizings, allocation, inputs and outputs, are not\n/// monotonically increasing.\n/// @param bytecode The bytecode that was inspected.\n/// @param relativeOffset The relative offset of the source that was inspected.\nerror StackSizingsNotMonotonic(bytes bytecode, uint256 relativeOffset);\n\n/// @title LibBytecode\n/// @notice A library for inspecting the bytecode of an expression. Largely\n/// focused on reading the source headers rather than the opcodes themselves.\n/// Designed to be efficient enough to be used in the interpreter directly.\n/// As such, it is not particularly safe, notably it always assumes that the\n/// headers are not lying about the structure and runtime behaviour of the\n/// bytecode. This is by design as it allows much more simple, efficient and\n/// decoupled implementation of authoring/parsing logic, which makes the author\n/// of an expression responsible for producing well formed bytecode, such as\n/// balanced LHS/RHS stacks. The deployment integrity checks are responsible for\n/// checking that the headers match the structure and behaviour of the bytecode.\nlibrary LibBytecode {\n using LibPointer for Pointer;\n using LibBytes for bytes;\n using LibMemCpy for Pointer;\n\n /// The number of sources in the bytecode.\n /// If the bytecode is empty, returns 0.\n /// Otherwise, returns the first byte of the bytecode, which is the number\n /// of sources.\n /// Implies that 0x and 0x00 are equivalent, both having 0 sources. For this\n /// reason, contracts that handle bytecode MUST NOT rely on simple data\n /// length checks to determine if the bytecode is empty or not.\n /// DOES NOT check the integrity or even existence of the sources.\n /// @param bytecode The bytecode to inspect.\n /// @return count The number of sources in the bytecode.\n function sourceCount(bytes memory bytecode) internal pure returns (uint256 count) {\n if (bytecode.length == 0) {\n return 0;\n }\n assembly {\n // The first byte of rain bytecode is the count of how many sources\n // there are.\n count := byte(0, mload(add(bytecode, 0x20)))\n }\n }\n\n /// Checks the structural integrity of the bytecode from the perspective of\n /// potential out of bounds reads. Will revert if the bytecode is not\n /// well-formed. This check MUST be done BEFORE any attempts at per-opcode\n /// integrity checks, as the per-opcode checks assume that the headers define\n /// valid regions in memory to iterate over.\n ///\n /// Checks:\n /// - The offsets are populated according to the source count.\n /// - The offsets point to positions within the bytecode `bytes`.\n /// - There exists at least the 4 byte header for each source at the offset,\n /// within the bounds of the bytecode `bytes`.\n /// - The number of opcodes specified in the header of each source locates\n /// the end of the source exactly at either the offset of the next source\n /// or the end of the bytecode `bytes`.\n function checkNoOOBPointers(bytes memory bytecode) internal pure {\n unchecked {\n uint256 count = sourceCount(bytecode);\n // The common case is that there are more than 0 sources.\n if (count > 0) {\n uint256 sourcesRelativeStart = 1 + count * 2;\n if (sourcesRelativeStart > bytecode.length) {\n revert TruncatedHeaderOffsets(bytecode);\n }\n uint256 sourcesStart;\n assembly (\"memory-safe\") {\n sourcesStart := add(bytecode, add(0x20, sourcesRelativeStart))\n }\n\n // Start at the end of the bytecode and work backwards. Find the\n // last unchecked relative offset, follow it, read the opcode\n // count from the header, and check that ends at the end cursor.\n // Set the end cursor to the relative offset then repeat until\n // there are no more unchecked relative offsets. The endCursor\n // as a relative offset must be 0 at the end of this process\n // (i.e. the first relative offset is always 0).\n uint256 endCursor;\n assembly (\"memory-safe\") {\n endCursor := add(bytecode, add(0x20, mload(bytecode)))\n }\n // This cursor points at the 2 byte relative offset that we need\n // to check next.\n uint256 uncheckedOffsetCursor;\n uint256 end;\n assembly (\"memory-safe\") {\n uncheckedOffsetCursor := add(bytecode, add(0x21, mul(sub(count, 1), 2)))\n end := add(bytecode, 0x21)\n }\n\n while (uncheckedOffsetCursor >= end) {\n // Read the relative offset from the bytecode.\n uint256 relativeOffset;\n assembly (\"memory-safe\") {\n relativeOffset := shr(0xF0, mload(uncheckedOffsetCursor))\n }\n uint256 absoluteOffset = sourcesStart + relativeOffset;\n\n // Check that the 4 byte header is within the upper bound\n // established by the end cursor before attempting to read\n // from it.\n uint256 headerEnd = absoluteOffset + 4;\n if (headerEnd > endCursor) {\n revert TruncatedHeader(bytecode);\n }\n\n // The ops count is the first byte of the header.\n uint256 opsCount;\n {\n // The stack allocation, inputs, and outputs are the next\n // 3 bytes of the header. We can't know exactly what they\n // need to be according to the opcodes without checking\n // every opcode implementation, but we can check that\n // they satisfy the invariant\n // `inputs <= outputs <= stackAllocation`.\n // Note that the outputs may include the inputs, as the\n // outputs is merely the final stack size.\n uint256 stackAllocation;\n uint256 inputs;\n uint256 outputs;\n assembly (\"memory-safe\") {\n let data := mload(absoluteOffset)\n opsCount := byte(0, data)\n stackAllocation := byte(1, data)\n inputs := byte(2, data)\n outputs := byte(3, data)\n }\n\n if (inputs > outputs || outputs > stackAllocation) {\n revert StackSizingsNotMonotonic(bytecode, relativeOffset);\n }\n }\n\n // The ops count is the number of 4 byte opcodes in the\n // source. Check that the end of the source is at the end\n // cursor.\n uint256 sourceEnd = headerEnd + opsCount * 4;\n if (sourceEnd != endCursor) {\n revert TruncatedSource(bytecode);\n }\n\n // Move the end cursor to the start of the header.\n endCursor = absoluteOffset;\n // Move the unchecked offset cursor to the previous offset.\n uncheckedOffsetCursor -= 2;\n }\n\n // If the end cursor is not pointing at the absolute start of the\n // sources, then somehow the bytecode has malformed data between\n // the offsets and the sources.\n if (endCursor != sourcesStart) {\n revert UnexpectedTrailingOffsetBytes(bytecode);\n }\n } else {\n // If there are no sources the bytecode is either 0 length or a\n // single 0 byte, which we already implicity checked by reaching\n // this code path. Ensure the bytecode has no trailing bytes.\n if (bytecode.length > 1) {\n revert UnexpectedSources(bytecode);\n }\n }\n }\n }\n\n /// The relative byte offset of a source in the bytecode.\n /// This is the offset from the start of the first source header, which is\n /// after the source count byte and the source offsets.\n /// This function DOES NOT check that the relative offset is within the\n /// bounds of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE\n /// attempting to traverse the bytecode, otherwise the relative offset MAY\n /// point to memory outside the bytecode `bytes`.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return offset The relative byte offset of the source in the bytecode.\n function sourceRelativeOffset(bytes memory bytecode, uint256 sourceIndex) internal pure returns (uint256 offset) {\n // If the source index requested is out of bounds, revert.\n if (sourceIndex >= sourceCount(bytecode)) {\n revert SourceIndexOutOfBounds(bytecode, sourceIndex);\n }\n assembly {\n // After the first byte, all the relative offset pointers are\n // stored sequentially as 16 bit values.\n offset := and(mload(add(add(bytecode, 3), mul(sourceIndex, 2))), 0xFFFF)\n }\n }\n\n /// The absolute byte pointer of a source in the bytecode. Points to the\n /// header of the source, NOT the first opcode.\n /// This function DOES NOT check that the source index is within the bounds\n /// of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE attempting to\n /// traverse the bytecode, otherwise the relative offset MAY point to memory\n /// outside the bytecode `bytes`.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return pointer The absolute byte pointer of the source in the bytecode.\n function sourcePointer(bytes memory bytecode, uint256 sourceIndex) internal pure returns (Pointer pointer) {\n unchecked {\n uint256 sourcesStartOffset = 1 + sourceCount(bytecode) * 2;\n uint256 offset = sourceRelativeOffset(bytecode, sourceIndex);\n assembly {\n pointer := add(add(add(bytecode, 0x20), sourcesStartOffset), offset)\n }\n }\n }\n\n /// The number of opcodes in a source.\n /// This function DOES NOT check that the source index is within the bounds\n /// of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE attempting to\n /// traverse the bytecode, otherwise the relative offset MAY point to memory\n /// outside the bytecode `bytes`.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return opsCount The number of opcodes in the source.\n function sourceOpsCount(bytes memory bytecode, uint256 sourceIndex) internal pure returns (uint256 opsCount) {\n unchecked {\n Pointer pointer = sourcePointer(bytecode, sourceIndex);\n assembly (\"memory-safe\") {\n opsCount := byte(0, mload(pointer))\n }\n }\n }\n\n /// The number of stack slots allocated by a source. This is the number of\n /// 32 byte words that MUST be allocated for the stack for the given source\n /// index to avoid memory corruption when executing the source.\n /// This function DOES NOT check that the source index is within the bounds\n /// of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE attempting to\n /// traverse the bytecode, otherwise the relative offset MAY point to memory\n /// outside the bytecode `bytes`.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return allocation The number of stack slots allocated by the source.\n function sourceStackAllocation(bytes memory bytecode, uint256 sourceIndex)\n internal\n pure\n returns (uint256 allocation)\n {\n unchecked {\n Pointer pointer = sourcePointer(bytecode, sourceIndex);\n assembly (\"memory-safe\") {\n allocation := byte(1, mload(pointer))\n }\n }\n }\n\n /// The number of inputs and outputs of a source.\n /// This function DOES NOT check that the source index is within the bounds\n /// of the bytecode. Callers MUST `checkNoOOBPointers` BEFORE attempting to\n /// traverse the bytecode, otherwise the relative offset MAY point to memory\n /// outside the bytecode `bytes`.\n /// Note that both the inputs and outputs are always returned togther, this\n /// is because the caller SHOULD be checking both together whenever using\n /// some bytecode. Returning two values is more efficient than two separate\n /// function calls.\n /// @param bytecode The bytecode to inspect.\n /// @param sourceIndex The index of the source to inspect.\n /// @return inputs The number of inputs of the source.\n /// @return outputs The number of outputs of the source.\n function sourceInputsOutputsLength(bytes memory bytecode, uint256 sourceIndex)\n internal\n pure\n returns (uint256 inputs, uint256 outputs)\n {\n unchecked {\n Pointer pointer = sourcePointer(bytecode, sourceIndex);\n assembly (\"memory-safe\") {\n let data := mload(pointer)\n inputs := byte(2, data)\n outputs := byte(3, data)\n }\n }\n }\n\n /// Backwards compatibility with the old way of representing sources.\n /// Requires allocation and copying so it isn't particularly efficient, but\n /// allows us to use the new bytecode format with old interpreter code. Not\n /// recommended for production code but useful for testing.\n function bytecodeToSources(bytes memory bytecode) internal pure returns (bytes[] memory) {\n unchecked {\n uint256 count = sourceCount(bytecode);\n bytes[] memory sources = new bytes[](count);\n for (uint256 i = 0; i < count; i++) {\n // Skip over the prefix 4 bytes.\n Pointer pointer = sourcePointer(bytecode, i).unsafeAddBytes(4);\n uint256 length = sourceOpsCount(bytecode, i) * 4;\n bytes memory source = new bytes(length);\n pointer.unsafeCopyBytesTo(source.dataPointer(), length);\n // Move the opcode index one byte for each opcode, into the input\n // position, as legacly sources did not have input bytes.\n assembly (\"memory-safe\") {\n for {\n let cursor := add(source, 0x20)\n let end := add(cursor, length)\n } lt(cursor, end) { cursor := add(cursor, 4) } {\n mstore8(add(cursor, 1), byte(0, mload(cursor)))\n mstore8(cursor, 0)\n }\n }\n sources[i] = source;\n }\n return sources;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/lib/LibBytes.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibPointer.sol\";\n\n/// Thrown when asked to truncate data to a longer length.\n/// @param length Actual bytes length.\n/// @param truncate Attempted truncation length.\nerror TruncateError(uint256 length, uint256 truncate);\n\n/// @title LibBytes\n/// @notice Tools for working directly with memory in a Solidity compatible way.\nlibrary LibBytes {\n /// Truncates bytes of data by mutating its length directly.\n /// Any excess bytes are leaked\n function truncate(bytes memory data, uint256 length) internal pure {\n if (data.length < length) {\n revert TruncateError(data.length, length);\n }\n assembly (\"memory-safe\") {\n mstore(data, length)\n }\n }\n\n /// Pointer to the data of a bytes array NOT the length prefix.\n /// @param data Bytes to get the data pointer for.\n /// @return pointer Pointer to the data of the bytes in memory.\n function dataPointer(bytes memory data) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(data, 0x20)\n }\n }\n\n /// Pointer to the start of a bytes array (the length prefix).\n /// @param data Bytes to get the pointer to.\n /// @return pointer Pointer to the start of the bytes data structure.\n function startPointer(bytes memory data) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := data\n }\n }\n\n /// Pointer to the end of some bytes.\n ///\n /// Note that this pointer MAY NOT BE ALIGNED, i.e. it MAY NOT point to the\n /// start of a multiple of 32, UNLIKE the free memory pointer at 0x40.\n ///\n /// @param data Bytes to get the pointer to the end of.\n /// @return pointer Pointer to the end of the bytes data structure.\n function endDataPointer(bytes memory data) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(data, add(0x20, mload(data)))\n }\n }\n\n /// Pointer to the end of the memory allocated for bytes.\n ///\n /// The allocator is ALWAYS aligned to whole words, i.e. 32 byte multiples,\n /// for data structures allocated by Solidity. This includes `bytes` which\n /// means that any time the length of some `bytes` is NOT a multiple of 32\n /// the alloation will point past the end of the `bytes` data.\n ///\n /// There is no guarantee that the memory region between `endDataPointer`\n /// and `endAllocatedPointer` is zeroed out. It is best to think of that\n /// space as leaked garbage.\n ///\n /// Almost always, e.g. for the purpose of copying data between regions, you\n /// will want `endDataPointer` rather than this function.\n /// @param data Bytes to get the end of the allocated data region for.\n /// @return pointer Pointer to the end of the allocated data region.\n function endAllocatedPointer(bytes memory data) internal pure returns (Pointer pointer) {\n assembly (\"memory-safe\") {\n pointer := add(data, and(add(add(mload(data), 0x20), 0x1f), not(0x1f)))\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/ns/LibNamespace.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../../interface/IInterpreterV1.sol\";\n\nlibrary LibNamespace {\n /// Standard way to elevate a caller-provided state namespace to a universal\n /// namespace that is disjoint from all other caller-provided namespaces.\n /// Essentially just hashes the `msg.sender` into the state namespace as-is.\n ///\n /// This is deterministic such that the same combination of state namespace\n /// and caller will produce the same fully qualified namespace, even across\n /// multiple transactions/blocks.\n ///\n /// @param stateNamespace The state namespace as specified by the caller.\n /// @param sender The caller this namespace is bound to.\n /// @return qualifiedNamespace A fully qualified namespace that cannot\n /// collide with any other state namespace specified by any other caller.\n function qualifyNamespace(StateNamespace stateNamespace, address sender)\n internal\n pure\n returns (FullyQualifiedNamespace qualifiedNamespace)\n {\n assembly (\"memory-safe\") {\n mstore(0, stateNamespace)\n mstore(0x20, sender)\n qualifiedNamespace := keccak256(0, 0x40)\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/state/LibInterpreterStateNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.solmem/lib/LibPointer.sol\";\nimport \"rain.lib.memkv/lib/LibMemoryKV.sol\";\nimport \"../ns/LibNamespace.sol\";\n\nstruct InterpreterStateNP {\n Pointer[] stackBottoms;\n uint256[] constants;\n uint256 sourceIndex;\n MemoryKV stateKV;\n FullyQualifiedNamespace namespace;\n IInterpreterStoreV1 store;\n uint256[][] context;\n bytes bytecode;\n bytes fs;\n}\n\nlibrary LibInterpreterStateNP {\n function fingerprint(InterpreterStateNP memory state) internal pure returns (bytes32) {\n return keccak256(abi.encode(state));\n }\n\n function stackBottoms(uint256[][] memory stacks) internal pure returns (Pointer[] memory) {\n Pointer[] memory bottoms = new Pointer[](stacks.length);\n assembly (\"memory-safe\") {\n for {\n let cursor := add(stacks, 0x20)\n let end := add(cursor, mul(mload(stacks), 0x20))\n let bottomsCursor := add(bottoms, 0x20)\n } lt(cursor, end) {\n cursor := add(cursor, 0x20)\n bottomsCursor := add(bottomsCursor, 0x20)\n } {\n let stack := mload(cursor)\n let stackBottom := add(stack, mul(0x20, add(mload(stack), 1)))\n mstore(bottomsCursor, stackBottom)\n }\n }\n return bottoms;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.lib.typecast/src/LibConvert.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @title LibConvert\n/// @notice Type conversions that require additional structural changes to\n/// complete safely. These are NOT mere type casts and involve additional\n/// reads and writes to complete, such as recalculating the length of an array.\n/// The convention \"toX\" is adopted from Rust to imply the additional costs and\n/// consumption of the source to produce the target.\nlibrary LibConvert {\n /// Convert an array of integers to `bytes` data. This requires modifying\n /// the length in situ as the integer array length is measured in 32 byte\n /// increments while the length of `bytes` is the literal number of bytes.\n ///\n /// It is unsafe for the caller to use `us_` after it has been converted to\n /// bytes because there is now two pointers to the same mutable data\n /// structure AND the length prefix for the `uint256[]` version is corrupt.\n ///\n /// @param us_ The integer array to convert to `bytes`.\n /// @return bytes_ The integer array converted to `bytes` data.\n function unsafeToBytes(uint256[] memory us_) internal pure returns (bytes memory bytes_) {\n assembly (\"memory-safe\") {\n bytes_ := us_\n // Length in bytes is 32x the length in uint256\n mstore(bytes_, mul(0x20, mload(bytes_)))\n }\n }\n\n /// Truncate `uint256[]` values down to `uint16[]` then pack this to `bytes`\n /// without padding or length prefix. Unsafe because the starting `uint256`\n /// values are not checked for overflow due to the truncation. The caller\n /// MUST ensure that all values fit in `type(uint16).max` or that silent\n /// overflow is safe.\n /// @param us_ The `uint256[]` to truncate and concatenate to 16 bit `bytes`.\n /// @return The concatenated 2-byte chunks.\n function unsafeTo16BitBytes(uint256[] memory us_) internal pure returns (bytes memory) {\n unchecked {\n // We will keep 2 bytes (16 bits) from each integer.\n bytes memory bytes_ = new bytes(us_.length * 2);\n assembly (\"memory-safe\") {\n let replaceMask_ := 0xFFFF\n let preserveMask_ := not(replaceMask_)\n for {\n let cursor_ := add(us_, 0x20)\n let end_ := add(cursor_, mul(mload(us_), 0x20))\n let bytesCursor_ := add(bytes_, 0x02)\n } lt(cursor_, end_) {\n cursor_ := add(cursor_, 0x20)\n bytesCursor_ := add(bytesCursor_, 0x02)\n } {\n let data_ := mload(bytesCursor_)\n mstore(bytesCursor_, or(and(preserveMask_, data_), and(replaceMask_, mload(cursor_))))\n }\n }\n return bytes_;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseMeta.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../bitwise/LibCtPop.sol\";\nimport \"../../interface/IInterpreterV1.sol\";\nimport \"./LibParseOperand.sol\";\n\n/// @dev For metadata builder.\nerror DuplicateFingerprint();\n\n/// @dev Words and io fn pointers aren't the same length.\nerror WordIOFnPointerMismatch(uint256 wordsLength, uint256 ioFnPointersLength);\n\n/// @dev 0xFFFFFF = 3 byte fingerprint\n/// The fingerprint is 3 bytes because we're targetting the same collision\n/// resistance on words as solidity functions. As we already use a fully byte to\n/// map words across the expander, we only need 3 bytes for the fingerprint to\n/// achieve 4 bytes of collision resistance, which is the same as a solidity\n/// selector. This assumes that the byte selected to expand is uncorrelated with\n/// the fingerprint bytes, which is a reasonable assumption as long as we use\n/// different bytes from a keccak256 hash for each.\n/// This assumes a single expander, if there are multiple expanders, then the\n/// collision resistance only improves, so this is still safe.\nuint256 constant FINGERPRINT_MASK = 0xFFFFFF;\n/// @dev 4 = 1 byte opcode index + 1 byte operand parser offset + 3 byte fingerprint\nuint256 constant META_ITEM_SIZE = 5;\nuint256 constant META_ITEM_MASK = (1 << META_ITEM_SIZE) - 1;\n/// @dev 33 = 32 bytes for expansion + 1 byte for seed\nuint256 constant META_EXPANSION_SIZE = 0x21;\n/// @dev 1 = 1 byte for depth\nuint256 constant META_PREFIX_SIZE = 1;\n\nstruct AuthoringMeta {\n // `word` is referenced directly in assembly so don't move the field.\n bytes32 word;\n uint8 operandParserOffset;\n string description;\n}\n\nlibrary LibParseMeta {\n function wordBitmapped(uint256 seed, bytes32 word) internal pure returns (uint256 bitmap, uint256 hashed) {\n assembly (\"memory-safe\") {\n mstore(0, word)\n mstore8(0x20, seed)\n hashed := keccak256(0, 0x21)\n // We have to be careful here to avoid using the same byte for both\n // the expansion and the fingerprint. This is because we are relying\n // on the combined effect of both for collision resistance. We do\n // this by using the high byte of the hash for the bitmap, and the\n // low 3 bytes for the fingerprint.\n //slither-disable-next-line incorrect-shift\n bitmap := shl(byte(0, hashed), 1)\n }\n }\n\n function copyWordsFromAuthoringMeta(AuthoringMeta[] memory authoringMeta)\n internal\n pure\n returns (bytes32[] memory)\n {\n bytes32[] memory words = new bytes32[](authoringMeta.length);\n for (uint256 i = 0; i < authoringMeta.length; i++) {\n words[i] = authoringMeta[i].word;\n }\n return words;\n }\n\n function findBestExpander(AuthoringMeta[] memory metas)\n internal\n pure\n returns (uint8 bestSeed, uint256 bestExpansion, AuthoringMeta[] memory remaining)\n {\n unchecked {\n {\n uint256 bestCt = 0;\n for (uint256 seed = 0; seed < type(uint8).max; seed++) {\n uint256 expansion = 0;\n for (uint256 i = 0; i < metas.length; i++) {\n (uint256 shifted, uint256 hashed) = wordBitmapped(seed, metas[i].word);\n (hashed);\n expansion = shifted | expansion;\n }\n uint256 ct = LibCtPop.ctpop(expansion);\n if (ct > bestCt) {\n bestCt = ct;\n bestSeed = uint8(seed);\n bestExpansion = expansion;\n }\n // perfect expansion.\n if (ct == metas.length) {\n break;\n }\n }\n\n uint256 remainingLength = metas.length - bestCt;\n assembly (\"memory-safe\") {\n remaining := mload(0x40)\n mstore(remaining, remainingLength)\n mstore(0x40, add(remaining, mul(0x20, add(1, remainingLength))))\n }\n }\n uint256 usedExpansion = 0;\n uint256 j = 0;\n for (uint256 i = 0; i < metas.length; i++) {\n (uint256 shifted, uint256 hashed) = wordBitmapped(bestSeed, metas[i].word);\n (hashed);\n if ((shifted & usedExpansion) == 0) {\n usedExpansion = shifted | usedExpansion;\n } else {\n remaining[j] = metas[i];\n j++;\n }\n }\n }\n }\n\n function buildParseMeta(AuthoringMeta[] memory authoringMeta, uint8 maxDepth)\n internal\n pure\n returns (bytes memory parseMeta)\n {\n unchecked {\n // Write out expansions.\n uint8[] memory seeds;\n uint256[] memory expansions;\n uint256 dataStart;\n {\n uint256 depth = 0;\n seeds = new uint8[](maxDepth);\n expansions = new uint256[](maxDepth);\n {\n AuthoringMeta[] memory remainingAuthoringMeta = authoringMeta;\n while (remainingAuthoringMeta.length > 0) {\n uint8 seed;\n uint256 expansion;\n (seed, expansion, remainingAuthoringMeta) = findBestExpander(remainingAuthoringMeta);\n seeds[depth] = seed;\n expansions[depth] = expansion;\n depth++;\n }\n }\n\n uint256 parseMetaLength =\n META_PREFIX_SIZE + depth * META_EXPANSION_SIZE + authoringMeta.length * META_ITEM_SIZE;\n parseMeta = new bytes(parseMetaLength);\n assembly (\"memory-safe\") {\n mstore8(add(parseMeta, 0x20), depth)\n }\n for (uint256 j = 0; j < depth; j++) {\n assembly (\"memory-safe\") {\n // Write each seed immediately before its expansion.\n let seedWriteAt := add(add(parseMeta, 0x21), mul(0x21, j))\n mstore8(seedWriteAt, mload(add(seeds, add(0x20, mul(0x20, j)))))\n mstore(add(seedWriteAt, 1), mload(add(expansions, add(0x20, mul(0x20, j)))))\n }\n }\n\n {\n uint256 dataOffset = META_PREFIX_SIZE + META_ITEM_SIZE + depth * META_EXPANSION_SIZE;\n assembly (\"memory-safe\") {\n dataStart := add(parseMeta, dataOffset)\n }\n }\n }\n\n // Write words.\n for (uint256 k = 0; k < authoringMeta.length; k++) {\n uint256 s = 0;\n uint256 cumulativePos = 0;\n while (true) {\n uint256 toWrite;\n uint256 writeAt;\n\n // Need some careful scoping here to avoid stack too deep.\n {\n uint256 expansion = expansions[s];\n\n uint256 hashed;\n {\n uint256 shifted;\n (shifted, hashed) = wordBitmapped(seeds[s], authoringMeta[k].word);\n\n uint256 metaItemSize = META_ITEM_SIZE;\n uint256 pos = LibCtPop.ctpop(expansion & (shifted - 1)) + cumulativePos;\n assembly (\"memory-safe\") {\n writeAt := add(dataStart, mul(pos, metaItemSize))\n }\n }\n\n {\n uint256 wordFingerprint = hashed & FINGERPRINT_MASK;\n uint256 posFingerprint;\n assembly (\"memory-safe\") {\n posFingerprint := mload(writeAt)\n }\n posFingerprint &= FINGERPRINT_MASK;\n if (posFingerprint != 0) {\n if (posFingerprint == wordFingerprint) {\n revert DuplicateFingerprint();\n }\n // Collision, try next expansion.\n s++;\n cumulativePos = cumulativePos + LibCtPop.ctpop(expansion);\n continue;\n }\n // Not collision, start preparing the write with the\n // fingerprint.\n toWrite = wordFingerprint;\n }\n }\n\n // Write the io fn pointer and index offset.\n toWrite |= (k << 0x20) | (uint256(authoringMeta[k].operandParserOffset) << 0x18);\n\n uint256 mask = ~META_ITEM_MASK;\n assembly (\"memory-safe\") {\n mstore(writeAt, or(and(mload(writeAt), mask), toWrite))\n }\n // We're done with this word.\n break;\n }\n }\n }\n }\n\n /// Given the parse meta and a word, return the index and io fn pointer for\n /// the word. If the word is not found, then `exists` will be false. The\n /// caller MUST check `exists` before using the other return values.\n /// @param meta The parse meta.\n /// @param word The word to lookup.\n /// @return True if the word exists in the parse meta.\n /// @return The index of the word in the parse meta.\n function lookupWord(bytes memory meta, uint256 operandParsers, bytes32 word)\n internal\n pure\n returns (bool, uint256, function(uint256, bytes memory, uint256) pure returns (uint256, Operand))\n {\n unchecked {\n uint256 dataStart;\n uint256 cursor;\n uint256 end;\n {\n uint256 metaExpansionSize = META_EXPANSION_SIZE;\n uint256 metaItemSize = META_ITEM_SIZE;\n assembly (\"memory-safe\") {\n // Read depth from first meta byte.\n cursor := add(meta, 1)\n let depth := and(mload(cursor), 0xFF)\n // 33 bytes per depth\n end := add(cursor, mul(depth, metaExpansionSize))\n dataStart := add(end, metaItemSize)\n }\n }\n\n uint256 cumulativeCt = 0;\n while (cursor < end) {\n uint256 expansion;\n uint256 posData;\n uint256 wordFingerprint;\n // Lookup the data at pos.\n {\n uint256 seed;\n assembly (\"memory-safe\") {\n cursor := add(cursor, 1)\n seed := and(mload(cursor), 0xFF)\n cursor := add(cursor, 0x20)\n expansion := mload(cursor)\n }\n\n (uint256 shifted, uint256 hashed) = wordBitmapped(seed, word);\n uint256 pos = LibCtPop.ctpop(expansion & (shifted - 1)) + cumulativeCt;\n wordFingerprint = hashed & FINGERPRINT_MASK;\n uint256 metaItemSize = META_ITEM_SIZE;\n assembly (\"memory-safe\") {\n posData := mload(add(dataStart, mul(pos, metaItemSize)))\n }\n }\n\n // Match\n if (wordFingerprint == posData & FINGERPRINT_MASK) {\n uint256 index;\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParser;\n assembly (\"memory-safe\") {\n index := byte(27, posData)\n operandParser := and(shr(byte(28, posData), operandParsers), 0xFFFF)\n }\n return (true, index, operandParser);\n } else {\n cumulativeCt += LibCtPop.ctpop(expansion);\n }\n }\n // The caller MUST NOT use this operand parser as `exists` is false.\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParserZero;\n assembly (\"memory-safe\") {\n operandParserZero := 0\n }\n return (false, 0, operandParserZero);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseOperand.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../../interface/IInterpreterV1.sol\";\nimport \"./LibParseCMask.sol\";\nimport \"./LibParse.sol\";\nimport \"./LibParseLiteral.sol\";\n\nuint8 constant OPERAND_PARSER_OFFSET_DISALLOWED = 0;\nuint8 constant OPERAND_PARSER_OFFSET_SINGLE_FULL = 0x10;\nuint8 constant OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT = 0x20;\nuint8 constant OPERAND_PARSER_OFFSET_M1_M1 = 0x30;\nuint8 constant OPERAND_PARSER_OFFSET_8_M1_M1 = 0x40;\n\nerror UnexpectedOperand(uint256 offset);\n\nerror ExpectedOperand(uint256 offset);\n\nerror OperandOverflow(uint256 offset);\n\nerror UnclosedOperand(uint256 offset);\n\nlibrary LibParseOperand {\n function buildOperandParsers() internal pure returns (uint256 operandParsers) {\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParserDisallowed =\n LibParseOperand.parseOperandDisallowed;\n uint256 parseOperandDisallowedOffset = OPERAND_PARSER_OFFSET_DISALLOWED;\n assembly {\n operandParsers := or(operandParsers, shl(parseOperandDisallowedOffset, operandParserDisallowed))\n }\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParserSingleFull =\n LibParseOperand.parseOperandSingleFull;\n uint256 parseOperandSingleFullOffset = OPERAND_PARSER_OFFSET_SINGLE_FULL;\n assembly {\n operandParsers := or(operandParsers, shl(parseOperandSingleFullOffset, operandParserSingleFull))\n }\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParserDoublePerByteNoDefault =\n LibParseOperand.parseOperandDoublePerByteNoDefault;\n uint256 parseOperandDoublePerByteNoDefaultOffset = OPERAND_PARSER_OFFSET_DOUBLE_PERBYTE_NO_DEFAULT;\n assembly {\n operandParsers :=\n or(operandParsers, shl(parseOperandDoublePerByteNoDefaultOffset, operandParserDoublePerByteNoDefault))\n }\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParser_m1_m1 =\n LibParseOperand.parseOperandM1M1;\n uint256 parseOperand_m1_m1Offset = OPERAND_PARSER_OFFSET_M1_M1;\n assembly {\n operandParsers := or(operandParsers, shl(parseOperand_m1_m1Offset, operandParser_m1_m1))\n }\n function(uint256, bytes memory, uint256) pure returns (uint256, Operand) operandParser_8_m1_m1 =\n LibParseOperand.parseOperand8M1M1;\n uint256 parseOperand_8_m1_m1Offset = OPERAND_PARSER_OFFSET_8_M1_M1;\n assembly {\n operandParsers := or(operandParsers, shl(parseOperand_8_m1_m1Offset, operandParser_8_m1_m1))\n }\n }\n\n /// Parse a literal for an operand.\n function parseOperandLiteral(uint256 literalParsers, bytes memory data, uint256 max, uint256 cursor)\n internal\n pure\n returns (uint256, uint256)\n {\n uint256 char;\n assembly {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n revert ExpectedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n (\n function(bytes memory, uint256, uint256) pure returns (uint256) literalParser,\n uint256 innerStart,\n uint256 innerEnd,\n uint256 outerEnd\n ) = LibParseLiteral.boundLiteral(literalParsers, data, cursor);\n uint256 value = literalParser(data, innerStart, innerEnd);\n if (value > max) {\n revert OperandOverflow(LibParse.parseErrorOffset(data, cursor));\n }\n cursor = outerEnd;\n return (cursor, value);\n }\n\n /// Operand is disallowed for this word.\n function parseOperandDisallowed(uint256, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n uint256 char;\n assembly {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n revert UnexpectedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n // Don't move the cursor. This is a no-op.\n return (cursor, Operand.wrap(0));\n }\n\n /// Operand is a 16-bit unsigned integer.\n function parseOperandSingleFull(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n unchecked {\n uint256 char;\n uint256 end;\n assembly {\n end := add(data, add(mload(data), 0x20))\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n cursor = LibParse.skipMask(cursor + 1, end, CMASK_WHITESPACE);\n\n uint256 value;\n (cursor, value) = parseOperandLiteral(literalParsers, data, type(uint16).max, cursor);\n\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char != CMASK_OPERAND_END) {\n revert UnclosedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n return (cursor + 1, Operand.wrap(value));\n }\n // Default is 0.\n else {\n return (cursor, Operand.wrap(0));\n }\n }\n }\n\n /// Operand is two bytes.\n function parseOperandDoublePerByteNoDefault(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n unchecked {\n uint256 char;\n uint256 end;\n assembly (\"memory-safe\") {\n end := add(data, add(mload(data), 0x20))\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n cursor = LibParse.skipMask(cursor + 1, end, CMASK_WHITESPACE);\n\n uint256 a;\n (cursor, a) = parseOperandLiteral(literalParsers, data, type(uint8).max, cursor);\n Operand operand = Operand.wrap(a);\n\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n\n uint256 b;\n (cursor, b) = parseOperandLiteral(literalParsers, data, type(uint8).max, cursor);\n operand = Operand.wrap(Operand.unwrap(operand) | (b << 8));\n\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char != CMASK_OPERAND_END) {\n revert UnclosedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n return (cursor + 1, operand);\n }\n // There is no default fallback value.\n else {\n revert ExpectedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n }\n }\n\n /// 8 bit value, maybe 1 bit flag, maybe 1 big flag.\n function parseOperand8M1M1(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n unchecked {\n uint256 char;\n uint256 end;\n assembly {\n end := add(data, add(mload(data), 0x20))\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n cursor = LibParse.skipMask(cursor + 1, end, CMASK_WHITESPACE);\n\n // 8 bit value. Required.\n uint256 a;\n (cursor, a) = parseOperandLiteral(literalParsers, data, type(uint8).max, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n\n // Maybe 1 bit flag.\n uint256 b;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n b = 0;\n } else {\n (cursor, b) = parseOperandLiteral(literalParsers, data, 1, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n }\n\n // Maybe 1 bit flag.\n uint256 c;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n c = 0;\n } else {\n (cursor, c) = parseOperandLiteral(literalParsers, data, 1, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n }\n\n Operand operand = Operand.wrap(a | (b << 8) | (c << 9));\n\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char != CMASK_OPERAND_END) {\n revert UnclosedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n return (cursor + 1, operand);\n }\n // There is no default fallback value. The first 8 bits are\n // required.\n else {\n revert ExpectedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n }\n }\n\n /// 2x maybe 1 bit flags.\n function parseOperandM1M1(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (uint256, Operand)\n {\n unchecked {\n uint256 char;\n uint256 end;\n assembly {\n end := add(data, add(mload(data), 0x20))\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_START) {\n cursor = LibParse.skipMask(cursor + 1, end, CMASK_WHITESPACE);\n\n uint256 a;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n a = 0;\n } else {\n (cursor, a) = parseOperandLiteral(literalParsers, data, 1, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n }\n\n uint256 b;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char == CMASK_OPERAND_END) {\n b = 0;\n } else {\n (cursor, b) = parseOperandLiteral(literalParsers, data, 1, cursor);\n cursor = LibParse.skipMask(cursor, end, CMASK_WHITESPACE);\n }\n\n Operand operand = Operand.wrap(a | (b << 1));\n\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n char := shl(byte(0, mload(cursor)), 1)\n }\n if (char != CMASK_OPERAND_END) {\n revert UnclosedOperand(LibParse.parseErrorOffset(data, cursor));\n }\n return (cursor + 1, operand);\n }\n // Default is 0.\n else {\n return (cursor, Operand.wrap(0));\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/00/LibOpStackNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\n\n/// Thrown when a stack read index is outside the current stack top.\nerror OutOfBoundsStackRead(uint256 opIndex, uint256 stackTopIndex, uint256 stackRead);\n\n/// @title LibOpStackNP\n/// Implementation of copying a stack item from the stack to the stack.\n/// Integrated deeply into LibParse, which requires this opcode or a variant\n/// to be present at a known opcode index.\nlibrary LibOpStackNP {\n function integrity(IntegrityCheckStateNP memory state, Operand operand) internal pure returns (uint256, uint256) {\n uint256 readIndex = Operand.unwrap(operand);\n // Operand is the index so ensure it doesn't exceed the stack index.\n if (readIndex >= state.stackIndex) {\n revert OutOfBoundsStackRead(state.opIndex, state.stackIndex, readIndex);\n }\n\n // Move the read highwater if needed.\n if (readIndex > state.readHighwater) {\n state.readHighwater = readIndex;\n }\n\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory state, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 sourceIndex = state.sourceIndex;\n assembly (\"memory-safe\") {\n let stackBottom := mload(add(mload(state), mul(0x20, add(sourceIndex, 1))))\n let stackValue := mload(sub(stackBottom, mul(0x20, add(operand, 1))))\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, stackValue)\n }\n return stackTop;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/00/LibOpConstantNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// Thrown when a constant read index is outside the constants array.\nerror OutOfBoundsConstantRead(uint256 opIndex, uint256 constantsLength, uint256 constantRead);\n\n/// @title LibOpConstantNP\n/// Implementation of copying a constant from the constants array to the stack.\n/// Integrated deeply into LibParse, which requires this opcode or a variant\n/// to be present at a known opcode index.\nlibrary LibOpConstantNP {\n function integrity(IntegrityCheckStateNP memory state, Operand operand) internal pure returns (uint256, uint256) {\n // Operand is the index so ensure it doesn't exceed the constants length.\n if (Operand.unwrap(operand) >= state.constantsLength) {\n revert OutOfBoundsConstantRead(state.opIndex, state.constantsLength, Operand.unwrap(operand));\n }\n // As inputs MUST always be 0, we don't have to check the high byte of\n // the operand here, the integrity check will do that for us.\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory state, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256[] memory constants = state.constants;\n // Skip index OOB check and rely on integrity check for that.\n assembly (\"memory-safe\") {\n let value := mload(add(constants, mul(add(operand, 1), 0x20)))\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, value)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory state, Operand operand, uint256[] memory)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n uint256 index = Operand.unwrap(operand);\n outputs = new uint256[](1);\n outputs[0] = state.constants[index];\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/bitwise/LibOpCtPopNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {LibCtPop} from \"../../bitwise/LibCtPop.sol\";\n\n/// @title LibOpCtPopNP\n/// @notice An opcode that counts the number of bits set in a word. This is\n/// called ctpop because that's the name of this kind of thing elsewhere, but\n/// the more common name is \"population count\" or \"Hamming weight\". The word\n/// in the standard ops lib is called `bitwise-count-ones`, which follows the\n/// Rust naming convention.\n/// There is no evm opcode for this, so we have to implement it ourselves.\nlibrary LibOpCtPopNP {\n /// ctpop unconditionally takes one value and returns one value.\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (1, 1);\n }\n\n /// Output is the number of bits set to one in the input. Thin wrapper around\n /// `LibCtPop.ctpop`.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 value;\n assembly (\"memory-safe\") {\n value := mload(stackTop)\n }\n value = LibCtPop.ctpop(value);\n assembly (\"memory-safe\") {\n mstore(stackTop, value)\n }\n return stackTop;\n }\n\n /// The reference implementation of ctpop.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory)\n {\n inputs[0] = LibCtPop.ctpopSlow(inputs[0]);\n return inputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/call/LibOpCallNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {LibInterpreterStateNP, InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {LibIntegrityCheckNP, IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Pointer, LibPointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {LibBytecode} from \"../../bytecode/LibBytecode.sol\";\nimport {LibEvalNP} from \"../../eval/LibEvalNP.sol\";\n\n/// Thrown when the outputs requested by the operand exceed the outputs\n/// available from the source.\n/// @param sourceOutputs The number of outputs available from the source.\n/// @param outputs The number of outputs requested by the operand.\nerror CallOutputsExceedSource(uint256 sourceOutputs, uint256 outputs);\n\n/// @title LibOpCallNP\n/// @notice Contains the call operation. This allows sources to be treated in a\n/// function-like manner. Primarily intended as a way for expression authors to\n/// create reusable logic inline with their expression, in a way that mimics how\n/// words and stack consumption works at the Solidity level.\n///\n/// Similarities between `call` and a traditional function:\n/// - The source is called with a set of 0+ inputs.\n/// - The source returns a set of 0+ outputs.\n/// - The source has a fixed number of inputs and outputs.\n/// - When the source executes it has its own stack/scope.\n/// - Sources use lexical scoping rules for named LHS items.\n/// - The source can be called from multiple places.\n/// - The source can `call` other sources.\n/// - The source is stateless across calls\n/// (although it can use words like get/set to read/write external state).\n/// - The caller and callee have to agree on the number of inputs\n/// (but not outputs, see below).\n/// - Generally speaking, the behaviour of a source can be reasoned about\n/// without needing to know the context in which it is called. Which is the\n/// basic requirement for reusability.\n///\n/// Differences between `call` and a traditional function:\n/// - The caller defines the number of outputs to be returned, NOT the callee.\n/// This is because the caller is responsible for allocating space on the\n/// stack for the outputs, and the callee is responsible for providing the\n/// outputs. The only limitation is that the caller cannot request more\n/// outputs than the callee has available. This means that two calls to the\n/// same source can return different numbers of outputs in different contexts.\n/// - The inputs to a source are considered to be the top of the callee's stack\n/// from the perspective of the caller. This means that the inputs are eligible\n/// to be read as outputs, if the caller chooses to do so.\n/// - The sources are not named, they are identified by their index in the\n/// bytecode. Tooling can provide sugar over this but the underlying\n/// representation is just an index.\n/// - Sources are not \"first class\" like functions often are, i.e. they cannot\n/// be passed as arguments to other sources or otherwise be treated as values.\n/// - Recursion is not supported. This is because currently there is no laziness\n/// in the interpreter, so a recursive call would result in an infinite loop\n/// unconditionally (even when wrapped in an `if`). This may change in the\n/// future.\n/// - The memory allocation for a source must be known at compile time.\n/// - There's no way to return early from a source.\n///\n/// The order of inputs and outputs is designed so that the visual representation\n/// of a source call matches the visual representation of a function call. This\n/// requires some reversals of order \"under the hood\" while copying data around\n/// but it makes the behaviour of `call` more intuitive.\n///\n/// Illustrative example:\n/// ```\n/// /* Final result */\n/// /* a = 2 */\n/// /* b = 9 */\n/// a b: call<1 2>(10 5); ten five:, a b: int-div(ten five) 9;\n/// ```\nlibrary LibOpCallNP {\n using LibPointer for Pointer;\n\n function integrity(IntegrityCheckStateNP memory state, Operand operand) internal pure returns (uint256, uint256) {\n uint256 sourceIndex = Operand.unwrap(operand) & 0xFF;\n uint256 outputs = (Operand.unwrap(operand) >> 8) & 0xFF;\n\n (uint256 sourceInputs, uint256 sourceOutputs) =\n LibBytecode.sourceInputsOutputsLength(state.bytecode, sourceIndex);\n\n if (sourceOutputs < outputs) {\n revert CallOutputsExceedSource(sourceOutputs, outputs);\n }\n\n return (sourceInputs, outputs);\n }\n\n /// The `call` word is conceptually very simple. It takes a source index, a\n /// number of outputs, and a number of inputs. It then runs the standard\n /// eval loop for the source, with a starting stack pointer above the inputs,\n /// and then copies the outputs to the calling stack.\n function run(InterpreterStateNP memory state, Operand operand, Pointer stackTop) internal view returns (Pointer) {\n // Extract config from the operand.\n uint256 sourceIndex = Operand.unwrap(operand) & 0xFF;\n uint256 outputs = (Operand.unwrap(operand) >> 8) & 0xFF;\n uint256 inputs = (Operand.unwrap(operand) >> 0x10) & 0xFF;\n\n // Copy inputs in. The inputs have to be copied in reverse order so that\n // the top of the stack from the perspective of `call`, i.e. the first\n // input to call, is the bottom of the stack from the perspective of the\n // callee.\n Pointer[] memory stackBottoms = state.stackBottoms;\n Pointer evalStackTop;\n assembly (\"memory-safe\") {\n evalStackTop := mload(add(stackBottoms, mul(add(sourceIndex, 1), 0x20)))\n let end := add(stackTop, mul(inputs, 0x20))\n for {} lt(stackTop, end) { stackTop := add(stackTop, 0x20) } {\n evalStackTop := sub(evalStackTop, 0x20)\n mstore(evalStackTop, mload(stackTop))\n }\n }\n\n // Keep a copy of the current source index so that we can restore it\n // after the call.\n uint256 currentSourceIndex = state.sourceIndex;\n\n // Set the state to the source we are calling.\n state.sourceIndex = sourceIndex;\n\n // Run the eval loop.\n evalStackTop = LibEvalNP.evalLoopNP(state, evalStackTop);\n\n // Restore the source index in the state.\n state.sourceIndex = currentSourceIndex;\n\n // Copy outputs out.\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, mul(outputs, 0x20))\n let end := add(evalStackTop, mul(outputs, 0x20))\n let cursor := stackTop\n for {} lt(evalStackTop, end) {\n cursor := add(cursor, 0x20)\n evalStackTop := add(evalStackTop, 0x20)\n } { mstore(cursor, mload(evalStackTop)) }\n }\n\n return stackTop;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/context/LibOpContextNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\nlibrary LibOpContextNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Context doesn't have any inputs. The operand defines the reads.\n // Unfortunately we don't know the shape of the context that we will\n // receive at runtime, so we can't check the reads at integrity time.\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory state, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 i = Operand.unwrap(operand) & 0xFF;\n // Integrity check enforces the inputs byte is 0.\n uint256 j = Operand.unwrap(operand) >> 8;\n // We want these indexes to be checked at runtime for OOB accesses\n // because we don't know the shape of the context at compile time.\n // Solidity handles that for us as long as we don't invoke yul for the\n // reads.\n if (Pointer.unwrap(stackTop) < 0x20) {\n revert(\"stack underflow\");\n }\n uint256 v = state.context[i][j];\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, v)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory state, Operand operand, uint256[] memory)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n uint256 i = Operand.unwrap(operand) & 0xFF;\n uint256 j = (Operand.unwrap(operand) >> 8) & 0xFF;\n // We want these indexes to be checked at runtime for OOB accesses\n // because we don't know the shape of the context at compile time.\n // Solidity handles that for us as long as we don't invoke yul for the\n // reads.\n uint256 v = state.context[i][j];\n outputs = new uint256[](1);\n outputs[0] = v;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/crypto/LibOpHashNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpHashNP\n/// Implementation of keccak256 hashing as a standard Rainlang opcode.\nlibrary LibOpHashNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // Any number of inputs are valid.\n // 0 inputs will be the hash of empty (0 length) bytes.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n return (inputs, 1);\n }\n\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let length := mul(shr(0x10, operand), 0x20)\n let value := keccak256(stackTop, length)\n stackTop := sub(add(stackTop, length), 0x20)\n mstore(stackTop, value)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = uint256(keccak256(abi.encodePacked(inputs)));\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/erc721/LibOpERC721BalanceOfNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IERC721} from \"openzeppelin-contracts/contracts/token/ERC721/IERC721.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title OpERC721BalanceOfNP\n/// @notice Opcode for getting the current erc721 balance of an account.\nlibrary LibOpERC721BalanceOfNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Always 2 inputs, the token and the account.\n // Always 1 output, the balance.\n return (2, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 token;\n uint256 account;\n assembly {\n token := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n account := mload(stackTop)\n }\n uint256 tokenBalance = IERC721(address(uint160(token))).balanceOf(address(uint160(account)));\n assembly {\n mstore(stackTop, tokenBalance)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory)\n {\n uint256 token = inputs[0];\n uint256 account = inputs[1];\n uint256 tokenBalance = IERC721(address(uint160(token))).balanceOf(address(uint160(account)));\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = tokenBalance;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/erc721/LibOpERC721OwnerOfNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IERC721} from \"openzeppelin-contracts/contracts/token/ERC721/IERC721.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpERC721OwnerOfNP\n/// @notice Opcode for getting the current owner of an erc721 token.\nlibrary LibOpERC721OwnerOfNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Always 2 inputs, the token and the tokenId.\n // Always 1 output, the owner.\n return (2, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 token;\n uint256 tokenId;\n assembly {\n token := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n tokenId := mload(stackTop)\n }\n address tokenOwner = IERC721(address(uint160(token))).ownerOf(tokenId);\n assembly {\n mstore(stackTop, tokenOwner)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory)\n {\n uint256 token = inputs[0];\n uint256 tokenId = inputs[1];\n address tokenOwner = IERC721(address(uint160(token))).ownerOf(tokenId);\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = uint256(uint160(tokenOwner));\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/evm/LibOpBlockNumberNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpBlockNumberNP\n/// Implementation of the EVM `BLOCKNUMBER` opcode as a standard Rainlang opcode.\nlibrary LibOpBlockNumberNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, number())\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory)\n internal\n view\n returns (uint256[] memory)\n {\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = block.number;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/evm/LibOpChainIdNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpChainIdNP\n/// Implementation of the EVM `CHAINID` opcode as a standard Rainlang opcode.\nlibrary LibOpChainIdNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, chainid())\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory)\n internal\n view\n returns (uint256[] memory)\n {\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = block.chainid;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/evm/LibOpMaxUint256NP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpMaxUint256NP\n/// Exposes `type(uint256).max` as a Rainlang opcode.\nlibrary LibOpMaxUint256NP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 value = type(uint256).max;\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, value)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory)\n internal\n pure\n returns (uint256[] memory)\n {\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = type(uint256).max;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/evm/LibOpTimestampNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP, LibInterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpTimestampNP\n/// Implementation of the EVM `TIMESTAMP` opcode as a standard Rainlang opcode.\nlibrary LibOpTimestampNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (0, 1);\n }\n\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal view returns (Pointer) {\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, timestamp())\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory)\n internal\n view\n returns (uint256[] memory)\n {\n uint256[] memory outputs = new uint256[](1);\n outputs[0] = block.timestamp;\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpAnyNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpAnyNP\n/// @notice Opcode to return the first nonzero item on the stack up to the inputs\n/// limit.\nlibrary LibOpAnyNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least one input.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 0 ? inputs : 1;\n return (inputs, 1);\n }\n\n /// ANY\n /// ANY is the first nonzero item, else 0.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let length := mul(shr(0x10, operand), 0x20)\n let cursor := stackTop\n stackTop := sub(add(stackTop, length), 0x20)\n for { let end := add(cursor, length) } lt(cursor, end) { cursor := add(cursor, 0x20) } {\n let item := mload(cursor)\n if gt(item, 0) {\n mstore(stackTop, item)\n break\n }\n }\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of ANY for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Zero length inputs is not supported so this 0 will always be written\n // over.\n uint256 value = 0;\n for (uint256 i = 0; i < inputs.length; i++) {\n value = inputs[i];\n if (value != 0) {\n break;\n }\n }\n outputs = new uint256[](1);\n outputs[0] = value;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpConditionsNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// Thrown if no nonzero condition is found.\n/// @param condCode The condition code that was evaluated. This is the low 16\n/// bits of the operand. Allows the author to provide more context about which\n/// condition failed if there is more than one in the expression.\nerror NoConditionsMet(uint256 condCode);\n\n/// @title LibOpConditionsNP\n/// @notice Opcode to return the first nonzero item on the stack up to the inputs\n/// limit.\nlibrary LibOpConditionsNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 0 ? inputs : 2;\n // Odd inputs are not allowed.\n unchecked {\n inputs = inputs % 2 == 0 ? inputs : inputs + 1;\n }\n return (inputs, 1);\n }\n\n /// `conditions`\n /// Pairwise list of conditions and values. The first nonzero condition\n /// evaluated puts its corresponding value on the stack. `conditions` is\n /// eagerly evaluated. If no condition is nonzero, the expression will\n /// revert. The number of inputs must be even. The number of outputs is 1.\n /// If an author wants to provide some default value, they can set the last\n /// condition to some nonzero constant value such as 1.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 condition;\n assembly (\"memory-safe\") {\n let cursor := stackTop\n for {\n let end := add(cursor, mul(shr(0x10, operand), 0x20))\n stackTop := sub(end, 0x20)\n } lt(cursor, end) { cursor := add(cursor, 0x40) } {\n condition := mload(cursor)\n if condition {\n mstore(stackTop, mload(add(cursor, 0x20)))\n break\n }\n }\n }\n if (condition == 0) {\n revert NoConditionsMet(uint16(Operand.unwrap(operand)));\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of `condition` for testing.\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that any overflow errors come from the real\n // implementation.\n unchecked {\n uint256 length = inputs.length;\n require(length % 2 == 0, \"Odd number of inputs\");\n outputs = new uint256[](1);\n for (uint256 i = 0; i < length; i += 2) {\n if (inputs[i] != 0) {\n outputs[0] = inputs[i + 1];\n return outputs;\n }\n }\n revert NoConditionsMet(uint16(Operand.unwrap(operand)));\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpEnsureNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// Thrown if a zero condition is found.\n/// @param ensureCode The ensure code that was evaluated. This is the low 16\n/// bits of the operand. Allows the author to provide more context about which\n/// condition failed if there is more than one in the expression.\n/// @param errorIndex The index of the condition that failed.\nerror EnsureFailed(uint256 ensureCode, uint256 errorIndex);\n\n/// @title LibOpEnsureNP\n/// @notice Opcode to revert if any condition is zero.\nlibrary LibOpEnsureNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least one input.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 0 ? inputs : 1;\n return (inputs, 0);\n }\n\n /// `ensure`\n /// List of conditions. If any condition is zero, the expression will revert.\n /// All conditions are eagerly evaluated and there are no outputs.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 condition;\n Pointer cursor = stackTop;\n assembly (\"memory-safe\") {\n for {\n let end := add(cursor, mul(shr(0x10, operand), 0x20))\n condition := mload(cursor)\n cursor := add(cursor, 0x20)\n } and(lt(cursor, end), gt(condition, 0)) {} {\n condition := mload(cursor)\n cursor := add(cursor, 0x20)\n }\n }\n if (condition == 0) {\n // If somehow we hit an underflow on the pointer math, we'd still\n // prefer to see our ensure error rather than the generic underflow\n // error.\n unchecked {\n revert EnsureFailed(\n uint16(Operand.unwrap(operand)), (Pointer.unwrap(cursor) - Pointer.unwrap(stackTop) - 0x20) / 0x20\n );\n }\n }\n return cursor;\n }\n\n /// Gas intensive reference implementation of `ensure` for testing.\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that any overflow errors come from the real\n // implementation.\n unchecked {\n for (uint256 i = 0; i < inputs.length; i++) {\n if (inputs[i] == 0) {\n revert EnsureFailed(uint16(Operand.unwrap(operand)), i);\n }\n }\n outputs = new uint256[](0);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpEqualToNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpEqualToNP\n/// @notice Opcode to return 1 if the first item on the stack is equal to\n/// the second item on the stack, else 0.\nlibrary LibOpEqualToNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// EQ\n /// EQ is 1 if the first item is equal to the second item, else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, eq(a, mload(stackTop)))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of EQ for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] == inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpEveryNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpEveryNP\n/// @notice Opcode to return the last item out of N items if they are all true,\n/// else 0.\nlibrary LibOpEveryNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least one input.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 0 ? inputs : 1;\n return (inputs, 1);\n }\n\n /// EVERY is the last nonzero item, else 0.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let length := mul(shr(0x10, operand), 0x20)\n let cursor := stackTop\n stackTop := sub(add(stackTop, length), 0x20)\n for { let end := add(cursor, length) } lt(cursor, end) { cursor := add(cursor, 0x20) } {\n let item := mload(cursor)\n if iszero(item) {\n mstore(stackTop, item)\n break\n }\n }\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of EVERY for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Zero length inputs is not supported so this 0 will always be written\n // over.\n uint256 value = 0;\n for (uint256 i = 0; i < inputs.length; i++) {\n value = inputs[i];\n if (value == 0) {\n break;\n }\n }\n outputs = new uint256[](1);\n outputs[0] = value;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpGreaterThanNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpGreaterThanNP\n/// @notice Opcode to return 1 if the first item on the stack is greater than\n/// the second item on the stack, else 0.\nlibrary LibOpGreaterThanNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// GT\n /// GT is 1 if the first item is greater than the second item, else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, gt(a, mload(stackTop)))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of GT for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] > inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpGreaterThanOrEqualToNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpGreaterThanOrEqualToNP\n/// @notice Opcode to return 1 if the first item on the stack is greater than or\n/// equal to the second item on the stack, else 0.\nlibrary LibOpGreaterThanOrEqualToNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// GTE\n /// GTE is 1 if the first item is greater than or equal to the second item,\n /// else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, iszero(lt(a, mload(stackTop))))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of GTE for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] >= inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpIfNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIfNP\n/// @notice Opcode to choose between two values based on a condition. If is\n/// eager, meaning both values are evaluated before the condition is checked.\nlibrary LibOpIfNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (3, 1);\n }\n\n /// IF\n /// IF is a conditional. If the first item on the stack is nonero, the second\n /// item is returned, else the third item is returned.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let condition := mload(stackTop)\n stackTop := add(stackTop, 0x40)\n mstore(stackTop, mload(sub(stackTop, mul(0x20, iszero(iszero(condition))))))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of IF for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] > 0 ? inputs[1] : inputs[2];\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpIsZeroNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIsZeroNP\n/// @notice Opcode to return 1 if the top item on the stack is zero, else 0.\nlibrary LibOpIsZeroNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (1, 1);\n }\n\n /// ISZERO\n /// ISZERO is 1 if the top item is zero, else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n mstore(stackTop, iszero(mload(stackTop)))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of ISZERO for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] == 0 ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpLessThanNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpLessThanNP\n/// @notice Opcode to return 1 if the first item on the stack is less than\n/// the second item on the stack, else 0.\nlibrary LibOpLessThanNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// LT\n /// LT is 1 if the first item is less than the second item, else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, lt(a, mload(stackTop)))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of LT for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] < inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/logic/LibOpLessThanOrEqualToNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpLessThanOrEqualToNP\n/// @notice Opcode to return 1 if the first item on the stack is less than or\n/// equal to the second item on the stack, else 0.\nlibrary LibOpLessThanOrEqualToNP {\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// LTE\n /// LTE is 1 if the first item is less than or equal to the second item,\n /// else 0.\n function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) {\n assembly (\"memory-safe\") {\n let a := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n mstore(stackTop, iszero(gt(a, mload(stackTop))))\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of LTE for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0] <= inputs[1] ? 1 : 0;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18MulNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// Used for reference implementation so that we have two independent\n/// upstreams to compare against.\nimport {Math as OZMath} from \"openzeppelin-contracts/contracts/utils/math/Math.sol\";\nimport {UD60x18, mul} from \"prb-math/UD60x18.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {LibWillOverflow} from \"rain.math.fixedpoint/lib/LibWillOverflow.sol\";\n\n/// @title LibOpDecimal18MulNP\n/// @notice Opcode to mul N 18 decimal fixed point values. Errors on overflow.\nlibrary LibOpDecimal18MulNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// decimal18-mul\n /// 18 decimal fixed point multiplication with implied overflow checks from\n /// PRB Math.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a = UD60x18.unwrap(mul(UD60x18.wrap(a), UD60x18.wrap(b)));\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a = UD60x18.unwrap(mul(UD60x18.wrap(a), UD60x18.wrap(b)));\n unchecked {\n i++;\n }\n }\n }\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of multiplication for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 a = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n uint256 b = inputs[i];\n if (LibWillOverflow.mulDivWillOverflow(a, b, 1e18)) {\n a = uint256(keccak256(abi.encodePacked(\"overflow sentinel\")));\n break;\n }\n a = OZMath.mulDiv(a, b, 1e18);\n }\n outputs = new uint256[](1);\n outputs[0] = a;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18DivNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// Used for reference implementation so that we have two independent\n/// upstreams to compare against.\nimport {Math as OZMath} from \"openzeppelin-contracts/contracts/utils/math/Math.sol\";\nimport {LibWillOverflow} from \"rain.math.fixedpoint/lib/LibWillOverflow.sol\";\nimport {UD60x18, div} from \"prb-math/UD60x18.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpDecimal18DivNP\n/// @notice Opcode to div N 18 decimal fixed point values. Errors on overflow.\nlibrary LibOpDecimal18DivNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// decimal18-div\n /// 18 decimal fixed point division with implied overflow checks from PRB\n /// Math.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a = UD60x18.unwrap(div(UD60x18.wrap(a), UD60x18.wrap(b)));\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a = UD60x18.unwrap(div(UD60x18.wrap(a), UD60x18.wrap(b)));\n unchecked {\n i++;\n }\n }\n }\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of division for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 a = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n uint256 b = inputs[i];\n // Just bail out with a = some sentinel value if we're going to\n // overflow or divide by zero. This gives the real implementation\n // space to throw its own error that the test harness is expecting.\n // We don't want the real implementation to fail to throw the\n // error and also produce the same result, so a needs to have\n // some collision resistant value.\n if (b == 0 || LibWillOverflow.mulDivWillOverflow(a, 1e18, b)) {\n a = uint256(keccak256(abi.encodePacked(\"overflow sentinel\")));\n break;\n }\n a = OZMath.mulDiv(a, 1e18, b);\n }\n outputs = new uint256[](1);\n outputs[0] = a;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18Scale18DynamicNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {LibFixedPointDecimalScale} from \"rain.math.fixedpoint/lib/LibFixedPointDecimalScale.sol\";\nimport {MASK_2BIT} from \"sol.lib.binmaskflag/Binary.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpDecimal18Scale18DynamicNP\n/// @notice Opcode for scaling a number to 18 decimal fixed point based on\n/// runtime scale input.\nlibrary LibOpDecimal18Scale18DynamicNP {\n using LibFixedPointDecimalScale for uint256;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (2, 1);\n }\n\n /// decimal18-scale18-dynamic\n /// 18 decimal fixed point scaling from runtime value.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 scale;\n assembly (\"memory-safe\") {\n scale := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n a := mload(stackTop)\n }\n a = a.scale18(scale, Operand.unwrap(operand));\n assembly (\"memory-safe\") {\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[1].scale18(inputs[0], Operand.unwrap(operand) & MASK_2BIT);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18Scale18NP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {LibFixedPointDecimalScale} from \"rain.math.fixedpoint/lib/LibFixedPointDecimalScale.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpDecimal18Scale18NP\n/// @notice Opcode for scaling a number to 18 decimal fixed point.\nlibrary LibOpDecimal18Scale18NP {\n using LibFixedPointDecimalScale for uint256;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (1, 1);\n }\n\n /// decimal18-scale18\n /// 18 decimal fixed point scaling.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n }\n a = a.scale18(Operand.unwrap(operand) & 0xFF, Operand.unwrap(operand) >> 8);\n assembly (\"memory-safe\") {\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0].scale18(Operand.unwrap(operand) & 0xFF, Operand.unwrap(operand) >> 8);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/decimal18/LibOpDecimal18ScaleNNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {LibFixedPointDecimalScale} from \"rain.math.fixedpoint/lib/LibFixedPointDecimalScale.sol\";\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpDecimal18ScaleNNP\n/// @notice Opcode for scaling a decimal18 number to some other scale N.\nlibrary LibOpDecimal18ScaleNNP {\n using LibFixedPointDecimalScale for uint256;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n return (1, 1);\n }\n\n /// decimal18-scale-n\n /// Scale from 18 decimal to n decimal.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n }\n a = a.scaleN(Operand.unwrap(operand) & 0xFF, Operand.unwrap(operand) >> 8);\n assembly (\"memory-safe\") {\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n outputs = new uint256[](1);\n outputs[0] = inputs[0].scaleN(Operand.unwrap(operand) & 0xFF, Operand.unwrap(operand) >> 8);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntAddNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIntAddNP\n/// @notice Opcode to add N integers. Errors on overflow.\nlibrary LibOpIntAddNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-add\n /// Addition with implied overflow checks from the Solidity 0.8.x compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a += b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a += b;\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of addition for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc += inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntDivNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpIntDivNP\n/// @notice Opcode to divide N integers. Errors on divide by zero. Truncates\n/// towards zero.\nlibrary LibOpIntDivNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-div\n /// Division with implied checks from the Solidity 0.8.x compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a /= b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a /= b;\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of division for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc /= inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntExpNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIntExpNP\n/// @notice Opcode to raise x successively to N integers. Errors on overflow.\nlibrary LibOpIntExpNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-exp\n /// Exponentiation with implied overflow checks from the Solidity 0.8.x\n /// compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a = a ** b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a = a ** b;\n unchecked {\n i++;\n }\n }\n }\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of exponentiation for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc = acc ** inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntMaxNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIntMaxNP\n/// @notice Opcode to find the max from N integers.\nlibrary LibOpIntMaxNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-max\n /// Finds the maximum value from N integers.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n if (a < b) {\n a = b;\n }\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n if (a < b) {\n a = b;\n }\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of maximum for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc = acc < inputs[i] ? inputs[i] : acc;\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntMinNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpIntMinNP\n/// @notice Opcode to find the min from N integers.\nlibrary LibOpIntMinNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-min\n /// Finds the minimum value from N integers.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n if (a > b) {\n a = b;\n }\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n if (a > b) {\n a = b;\n }\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of minimum for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc = acc > inputs[i] ? inputs[i] : acc;\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntModNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer, LibPointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpIntModNP\n/// @notice Opcode to modulo N integers. Errors on modulo by zero.\nlibrary LibOpIntModNP {\n using LibPointer for Pointer;\n\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-mod\n /// Modulo with implied checks from the Solidity 0.8.x compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a %= b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a %= b;\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of modulo for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc %= inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntMulNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpIntMulNP\n/// @notice Opcode to mul N integers. Errors on overflow.\nlibrary LibOpIntMulNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-mul\n /// Multiplication with implied overflow checks from the Solidity 0.8.x\n /// compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a *= b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a *= b;\n unchecked {\n i++;\n }\n }\n }\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of multiplication for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc *= inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/math/int/LibOpIntSubNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Operand} from \"../../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {IntegrityCheckStateNP} from \"../../../integrity/LibIntegrityCheckNP.sol\";\nimport {InterpreterStateNP} from \"../../../state/LibInterpreterStateNP.sol\";\n\n/// @title LibOpIntSubNP\n/// @notice Opcode to subtract N integers.\nlibrary LibOpIntSubNP {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n // There must be at least two inputs.\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n inputs = inputs > 1 ? inputs : 2;\n return (inputs, 1);\n }\n\n /// int-sub\n /// Subtraction with implied overflow checks from the Solidity 0.8.x compiler.\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal pure returns (Pointer) {\n uint256 a;\n uint256 b;\n assembly (\"memory-safe\") {\n a := mload(stackTop)\n b := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n a -= b;\n\n {\n uint256 inputs = Operand.unwrap(operand) >> 0x10;\n uint256 i = 2;\n while (i < inputs) {\n assembly (\"memory-safe\") {\n b := mload(stackTop)\n stackTop := add(stackTop, 0x20)\n }\n a -= b;\n unchecked {\n i++;\n }\n }\n }\n\n assembly (\"memory-safe\") {\n stackTop := sub(stackTop, 0x20)\n mstore(stackTop, a)\n }\n return stackTop;\n }\n\n /// Gas intensive reference implementation of subtraction for testing.\n function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory outputs)\n {\n // Unchecked so that when we assert that an overflow error is thrown, we\n // see the revert from the real function and not the reference function.\n unchecked {\n uint256 acc = inputs[0];\n for (uint256 i = 1; i < inputs.length; i++) {\n acc -= inputs[i];\n }\n outputs = new uint256[](1);\n outputs[0] = acc;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/store/LibOpGetNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {MemoryKVKey, MemoryKVVal, MemoryKV, LibMemoryKV} from \"rain.lib.memkv/lib/LibMemoryKV.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\n\n/// @title LibOpGetNP\n/// @notice Opcode for reading from storage.\nlibrary LibOpGetNP {\n using LibMemoryKV for MemoryKV;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Always 1 input. The key. `hash()` is recommended to build compound\n // keys.\n return (1, 1);\n }\n\n /// Implements runtime behaviour of the `get` opcode. Attempts to lookup the\n /// key in the memory key/value store then falls back to the interpreter's\n /// storage interface as an external call. If the key is not found in either,\n /// the value will fallback to `0` as per default Solidity/EVM behaviour.\n /// @param state The interpreter state of the current eval.\n /// @param stackTop Pointer to the current stack top.\n function run(InterpreterStateNP memory state, Operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 key;\n assembly (\"memory-safe\") {\n key := mload(stackTop)\n }\n (uint256 exists, MemoryKVVal value) = state.stateKV.get(MemoryKVKey.wrap(key));\n\n // Cache MISS, get from external store.\n if (exists == 0) {\n uint256 storeValue = state.store.get(state.namespace, key);\n\n // Push fetched value to memory to make subsequent lookups on the\n // same key find a cache HIT.\n state.stateKV = state.stateKV.set(MemoryKVKey.wrap(key), MemoryKVVal.wrap(storeValue));\n\n assembly (\"memory-safe\") {\n mstore(stackTop, storeValue)\n }\n }\n // Cache HIT.\n else {\n assembly (\"memory-safe\") {\n mstore(stackTop, value)\n }\n }\n\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory state, Operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory)\n {\n uint256 key = inputs[0];\n (uint256 exists, MemoryKVVal value) = state.stateKV.get(MemoryKVKey.wrap(key));\n uint256[] memory outputs = new uint256[](1);\n // Cache MISS, get from external store.\n if (exists == 0) {\n uint256 storeValue = state.store.get(state.namespace, key);\n\n // Push fetched value to memory to make subsequent lookups on the\n // same key find a cache HIT.\n state.stateKV = state.stateKV.set(MemoryKVKey.wrap(key), MemoryKVVal.wrap(storeValue));\n\n outputs[0] = storeValue;\n }\n // Cache HIT.\n else {\n outputs[0] = MemoryKVVal.unwrap(value);\n }\n\n return outputs;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/store/LibOpSetNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {MemoryKV, MemoryKVKey, MemoryKVVal, LibMemoryKV} from \"rain.lib.memkv/lib/LibMemoryKV.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpSetNP\n/// @notice Opcode for recording k/v state changes to be set in storage.\nlibrary LibOpSetNP {\n using LibMemoryKV for MemoryKV;\n\n function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) {\n // Always 2 inputs. The key and the value. `hash()` is recommended to\n // build compound keys.\n return (2, 0);\n }\n\n function run(InterpreterStateNP memory state, Operand, Pointer stackTop) internal pure returns (Pointer) {\n unchecked {\n uint256 key;\n uint256 value;\n assembly {\n key := mload(stackTop)\n value := mload(add(stackTop, 0x20))\n stackTop := add(stackTop, 0x40)\n }\n\n state.stateKV = state.stateKV.set(MemoryKVKey.wrap(key), MemoryKVVal.wrap(value));\n return stackTop;\n }\n }\n\n function referenceFn(InterpreterStateNP memory state, Operand, uint256[] memory inputs)\n internal\n pure\n returns (uint256[] memory)\n {\n uint256 key = inputs[0];\n uint256 value = inputs[1];\n state.stateKV = state.stateKV.set(MemoryKVKey.wrap(key), MemoryKVVal.wrap(value));\n return new uint256[](0);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/uniswap/LibOpUniswapV2AmountIn.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {LibUniswapV2} from \"../../uniswap/LibUniswapV2.sol\";\n\n/// @title LibOpUniswapV2AmountIn\n/// @notice Opcode to calculate the amount in for a Uniswap V2 pair.\nlibrary LibOpUniswapV2AmountIn {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n unchecked {\n // Outputs is 1 if we don't want the timestamp (operand 0) or 2 if we\n // do (operand 1).\n uint256 outputs = 1 + (Operand.unwrap(operand) & 1);\n return (4, outputs);\n }\n }\n\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 factory;\n uint256 amountOut;\n uint256 tokenIn;\n uint256 tokenOut;\n assembly (\"memory-safe\") {\n factory := mload(stackTop)\n amountOut := mload(add(stackTop, 0x20))\n tokenIn := mload(add(stackTop, 0x40))\n tokenOut := mload(add(stackTop, 0x60))\n stackTop := add(stackTop, add(0x40, mul(0x20, iszero(and(operand, 1)))))\n }\n (uint256 amountIn, uint256 reserveTimestamp) = LibUniswapV2.getAmountInByTokenWithTime(\n address(uint160(factory)), address(uint160(tokenIn)), address(uint160(tokenOut)), amountOut\n );\n\n assembly (\"memory-safe\") {\n mstore(stackTop, amountIn)\n if and(operand, 1) { mstore(add(stackTop, 0x20), reserveTimestamp) }\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory outputs)\n {\n uint256 factory = inputs[0];\n uint256 amountOut = inputs[1];\n uint256 tokenIn = inputs[2];\n uint256 tokenOut = inputs[3];\n (uint256 amountIn, uint256 reserveTimestamp) = LibUniswapV2.getAmountInByTokenWithTime(\n address(uint160(factory)), address(uint160(tokenIn)), address(uint160(tokenOut)), amountOut\n );\n outputs = new uint256[](1 + (Operand.unwrap(operand) & 1));\n outputs[0] = amountIn;\n if (Operand.unwrap(operand) & 1 == 1) outputs[1] = reserveTimestamp;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/op/uniswap/LibOpUniswapV2AmountOut.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport {LibUniswapV2} from \"../../uniswap/LibUniswapV2.sol\";\nimport {IntegrityCheckStateNP} from \"../../integrity/LibIntegrityCheckNP.sol\";\nimport {Operand} from \"../../../interface/IInterpreterV1.sol\";\nimport {InterpreterStateNP} from \"../../state/LibInterpreterStateNP.sol\";\nimport {Pointer} from \"rain.solmem/lib/LibPointer.sol\";\n\n/// @title LibOpUniswapV2AmountOut\n/// @notice Opcode to calculate the amount out for a Uniswap V2 pair.\nlibrary LibOpUniswapV2AmountOut {\n function integrity(IntegrityCheckStateNP memory, Operand operand) internal pure returns (uint256, uint256) {\n unchecked {\n // Outputs is 1 if we don't want the timestamp (operand 0) or 2 if we\n // do (operand 1).\n uint256 outputs = 1 + (Operand.unwrap(operand) & 1);\n return (4, outputs);\n }\n }\n\n function run(InterpreterStateNP memory, Operand operand, Pointer stackTop) internal view returns (Pointer) {\n uint256 factory;\n uint256 amountIn;\n uint256 tokenIn;\n uint256 tokenOut;\n assembly (\"memory-safe\") {\n factory := mload(stackTop)\n amountIn := mload(add(stackTop, 0x20))\n tokenIn := mload(add(stackTop, 0x40))\n tokenOut := mload(add(stackTop, 0x60))\n stackTop := add(stackTop, add(0x40, mul(0x20, iszero(and(operand, 1)))))\n }\n (uint256 amountOut, uint256 reserveTimestamp) = LibUniswapV2.getAmountOutByTokenWithTime(\n address(uint160(factory)), address(uint160(tokenIn)), address(uint160(tokenOut)), amountIn\n );\n\n assembly (\"memory-safe\") {\n mstore(stackTop, amountOut)\n if and(operand, 1) { mstore(add(stackTop, 0x20), reserveTimestamp) }\n }\n return stackTop;\n }\n\n function referenceFn(InterpreterStateNP memory, Operand operand, uint256[] memory inputs)\n internal\n view\n returns (uint256[] memory outputs)\n {\n uint256 factory = inputs[0];\n uint256 amountIn = inputs[1];\n uint256 tokenIn = inputs[2];\n uint256 tokenOut = inputs[3];\n (uint256 amountOut, uint256 reserveTimestamp) = LibUniswapV2.getAmountOutByTokenWithTime(\n address(uint160(factory)), address(uint160(tokenIn)), address(uint160(tokenOut)), amountIn\n );\n outputs = new uint256[](1 + (Operand.unwrap(operand) & 1));\n outputs[0] = amountOut;\n if (Operand.unwrap(operand) & 1 == 1) outputs[1] = reserveTimestamp;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/bitwise/LibCtPop.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev 010101... for ctpop\nuint256 constant CTPOP_M1 = 0x5555555555555555555555555555555555555555555555555555555555555555;\n/// @dev 00110011.. for ctpop\nuint256 constant CTPOP_M2 = 0x3333333333333333333333333333333333333333333333333333333333333333;\n/// @dev 4 bits alternating for ctpop\nuint256 constant CTPOP_M4 = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F;\n/// @dev 8 bits alternating for ctpop\nuint256 constant CTPOP_M8 = 0x00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF;\n/// @dev 16 bits alternating for ctpop\nuint256 constant CTPOP_M16 = 0x0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF0000FFFF;\n/// @dev 32 bits alternating for ctpop\nuint256 constant CTPOP_M32 = 0x00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF00000000FFFFFFFF;\n/// @dev 64 bits alternating for ctpop\nuint256 constant CTPOP_M64 = 0x0000000000000000FFFFFFFFFFFFFFFF0000000000000000FFFFFFFFFFFFFFFF;\n/// @dev 128 bits alternating for ctpop\nuint256 constant CTPOP_M128 = 0x00000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;\n/// @dev 1 bytes for ctpop\nuint256 constant CTPOP_H01 = 0x0101010101010101010101010101010101010101010101010101010101010101;\n\nlibrary LibCtPop {\n /// Optimised version of ctpop.\n /// https://en.wikipedia.org/wiki/Hamming_weight\n function ctpop(uint256 x) internal pure returns (uint256) {\n // This edge case is not handled by the algorithm below.\n if (x == type(uint256).max) {\n return 256;\n }\n unchecked {\n x -= (x >> 1) & CTPOP_M1;\n x = (x & CTPOP_M2) + ((x >> 2) & CTPOP_M2);\n x = (x + (x >> 4)) & CTPOP_M4;\n x = (x * CTPOP_H01) >> 248;\n }\n return x;\n }\n\n /// This is the slowest possible implementation of ctpop. It is used to\n /// verify the correctness of the optimized implementation in LibCtPop.\n /// It should be obviously correct by visual inspection, referencing the\n /// wikipedia article.\n /// https://en.wikipedia.org/wiki/Hamming_weight\n function ctpopSlow(uint256 x) internal pure returns (uint256) {\n unchecked {\n x = (x & CTPOP_M1) + ((x >> 1) & CTPOP_M1);\n x = (x & CTPOP_M2) + ((x >> 2) & CTPOP_M2);\n x = (x & CTPOP_M4) + ((x >> 4) & CTPOP_M4);\n x = (x & CTPOP_M8) + ((x >> 8) & CTPOP_M8);\n x = (x & CTPOP_M16) + ((x >> 16) & CTPOP_M16);\n x = (x & CTPOP_M32) + ((x >> 32) & CTPOP_M32);\n x = (x & CTPOP_M64) + ((x >> 64) & CTPOP_M64);\n x = (x & CTPOP_M128) + ((x >> 128) & CTPOP_M128);\n }\n return x;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseCMask.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev ASCII null\nuint128 constant CMASK_NULL = uint128(1) << uint128(uint8(bytes1(\"\\x00\")));\n\n/// @dev ASCII start of heading\nuint128 constant CMASK_START_OF_HEADING = uint128(1) << uint128(uint8(bytes1(\"\\x01\")));\n\n/// @dev ASCII start of text\nuint128 constant CMASK_START_OF_TEXT = uint128(1) << uint128(uint8(bytes1(\"\\x02\")));\n\n/// @dev ASCII end of text\nuint128 constant CMASK_END_OF_TEXT = uint128(1) << uint128(uint8(bytes1(\"\\x03\")));\n\n/// @dev ASCII end of transmission\nuint128 constant CMASK_END_OF_TRANSMISSION = uint128(1) << uint128(uint8(bytes1(\"\\x04\")));\n\n/// @dev ASCII enquiry\nuint128 constant CMASK_ENQUIRY = uint128(1) << uint128(uint8(bytes1(\"\\x05\")));\n\n/// @dev ASCII acknowledge\nuint128 constant CMASK_ACKNOWLEDGE = uint128(1) << uint128(uint8(bytes1(\"\\x06\")));\n\n/// @dev ASCII bell\nuint128 constant CMASK_BELL = uint128(1) << uint128(uint8(bytes1(\"\\x07\")));\n\n/// @dev ASCII backspace\nuint128 constant CMASK_BACKSPACE = uint128(1) << uint128(uint8(bytes1(\"\\x08\")));\n\n/// @dev ASCII horizontal tab\nuint128 constant CMASK_HORIZONTAL_TAB = uint128(1) << uint128(uint8(bytes1(\"\\t\")));\n\n/// @dev ASCII line feed\nuint128 constant CMASK_LINE_FEED = uint128(1) << uint128(uint8(bytes1(\"\\n\")));\n\n/// @dev ASCII vertical tab\nuint128 constant CMASK_VERTICAL_TAB = uint128(1) << uint128(uint8(bytes1(\"\\x0B\")));\n\n/// @dev ASCII form feed\nuint128 constant CMASK_FORM_FEED = uint128(1) << uint128(uint8(bytes1(\"\\x0C\")));\n\n/// @dev ASCII carriage return\nuint128 constant CMASK_CARRIAGE_RETURN = uint128(1) << uint128(uint8(bytes1(\"\\r\")));\n\n/// @dev ASCII shift out\nuint128 constant CMASK_SHIFT_OUT = uint128(1) << uint128(uint8(bytes1(\"\\x0E\")));\n\n/// @dev ASCII shift in\nuint128 constant CMASK_SHIFT_IN = uint128(1) << uint128(uint8(bytes1(\"\\x0F\")));\n\n/// @dev ASCII data link escape\nuint128 constant CMASK_DATA_LINK_ESCAPE = uint128(1) << uint128(uint8(bytes1(\"\\x10\")));\n\n/// @dev ASCII device control 1\nuint128 constant CMASK_DEVICE_CONTROL_1 = uint128(1) << uint128(uint8(bytes1(\"\\x11\")));\n\n/// @dev ASCII device control 2\nuint128 constant CMASK_DEVICE_CONTROL_2 = uint128(1) << uint128(uint8(bytes1(\"\\x12\")));\n\n/// @dev ASCII device control 3\nuint128 constant CMASK_DEVICE_CONTROL_3 = uint128(1) << uint128(uint8(bytes1(\"\\x13\")));\n\n/// @dev ASCII device control 4\nuint128 constant CMASK_DEVICE_CONTROL_4 = uint128(1) << uint128(uint8(bytes1(\"\\x14\")));\n\n/// @dev ASCII negative acknowledge\nuint128 constant CMASK_NEGATIVE_ACKNOWLEDGE = uint128(1) << uint128(uint8(bytes1(\"\\x15\")));\n\n/// @dev ASCII synchronous idle\nuint128 constant CMASK_SYNCHRONOUS_IDLE = uint128(1) << uint128(uint8(bytes1(\"\\x16\")));\n\n/// @dev ASCII end of transmission block\nuint128 constant CMASK_END_OF_TRANSMISSION_BLOCK = uint128(1) << uint128(uint8(bytes1(\"\\x17\")));\n\n/// @dev ASCII cancel\nuint128 constant CMASK_CANCEL = uint128(1) << uint128(uint8(bytes1(\"\\x18\")));\n\n/// @dev ASCII end of medium\nuint128 constant CMASK_END_OF_MEDIUM = uint128(1) << uint128(uint8(bytes1(\"\\x19\")));\n\n/// @dev ASCII substitute\nuint128 constant CMASK_SUBSTITUTE = uint128(1) << uint128(uint8(bytes1(\"\\x1A\")));\n\n/// @dev ASCII escape\nuint128 constant CMASK_ESCAPE = uint128(1) << uint128(uint8(bytes1(\"\\x1B\")));\n\n/// @dev ASCII file separator\nuint128 constant CMASK_FILE_SEPARATOR = uint128(1) << uint128(uint8(bytes1(\"\\x1C\")));\n\n/// @dev ASCII group separator\nuint128 constant CMASK_GROUP_SEPARATOR = uint128(1) << uint128(uint8(bytes1(\"\\x1D\")));\n\n/// @dev ASCII record separator\nuint128 constant CMASK_RECORD_SEPARATOR = uint128(1) << uint128(uint8(bytes1(\"\\x1E\")));\n\n/// @dev ASCII unit separator\nuint128 constant CMASK_UNIT_SEPARATOR = uint128(1) << uint128(uint8(bytes1(\"\\x1F\")));\n\n/// @dev ASCII space\nuint128 constant CMASK_SPACE = uint128(1) << uint128(uint8(bytes1(\" \")));\n\n/// @dev ASCII !\nuint128 constant CMASK_EXCLAMATION_MARK = uint128(1) << uint128(uint8(bytes1(\"!\")));\n\n/// @dev ASCII \"\nuint128 constant CMASK_QUOTATION_MARK = uint128(1) << uint128(uint8(bytes1(\"\\\"\")));\n\n/// @dev ASCII #\nuint128 constant CMASK_NUMBER_SIGN = uint128(1) << uint128(uint8(bytes1(\"#\")));\n\n/// @dev ASCII $\nuint128 constant CMASK_DOLLAR_SIGN = uint128(1) << uint128(uint8(bytes1(\"$\")));\n\n/// @dev ASCII %\nuint128 constant CMASK_PERCENT_SIGN = uint128(1) << uint128(uint8(bytes1(\"%\")));\n\n/// @dev ASCII &\nuint128 constant CMASK_AMPERSAND = uint128(1) << uint128(uint8(bytes1(\"&\")));\n\n/// @dev ASCII '\nuint128 constant CMASK_APOSTROPHE = uint128(1) << uint128(uint8(bytes1(\"'\")));\n\n/// @dev ASCII (\nuint128 constant CMASK_LEFT_PAREN = uint128(1) << uint128(uint8(bytes1(\"(\")));\n\n/// @dev ASCII )\nuint128 constant CMASK_RIGHT_PAREN = uint128(1) << uint128(uint8(bytes1(\")\")));\n\n/// @dev ASCII *\nuint128 constant CMASK_ASTERISK = uint128(1) << uint128(uint8(bytes1(\"*\")));\n\n/// @dev ASCII +\nuint128 constant CMASK_PLUS_SIGN = uint128(1) << uint128(uint8(bytes1(\"+\")));\n\n/// @dev ASCII ,\nuint128 constant CMASK_COMMA = uint128(1) << uint128(uint8(bytes1(\",\")));\n\n/// @dev ASCII -\nuint128 constant CMASK_DASH = uint128(1) << uint128(uint8(bytes1(\"-\")));\n\n/// @dev ASCII .\nuint128 constant CMASK_FULL_STOP = uint128(1) << uint128(uint8(bytes1(\".\")));\n\n/// @dev ASCII /\nuint128 constant CMASK_SLASH = uint128(1) << uint128(uint8(bytes1(\"/\")));\n\n/// @dev ASCII 0\nuint128 constant CMASK_ZERO = uint128(1) << uint128(uint8(bytes1(\"0\")));\n\n/// @dev ASCII 1\nuint128 constant CMASK_ONE = uint128(1) << uint128(uint8(bytes1(\"1\")));\n\n/// @dev ASCII 2\nuint128 constant CMASK_TWO = uint128(1) << uint128(uint8(bytes1(\"2\")));\n\n/// @dev ASCII 3\nuint128 constant CMASK_THREE = uint128(1) << uint128(uint8(bytes1(\"3\")));\n\n/// @dev ASCII 4\nuint128 constant CMASK_FOUR = uint128(1) << uint128(uint8(bytes1(\"4\")));\n\n/// @dev ASCII 5\nuint128 constant CMASK_FIVE = uint128(1) << uint128(uint8(bytes1(\"5\")));\n\n/// @dev ASCII 6\nuint128 constant CMASK_SIX = uint128(1) << uint128(uint8(bytes1(\"6\")));\n\n/// @dev ASCII 7\nuint128 constant CMASK_SEVEN = uint128(1) << uint128(uint8(bytes1(\"7\")));\n\n/// @dev ASCII 8\nuint128 constant CMASK_EIGHT = uint128(1) << uint128(uint8(bytes1(\"8\")));\n\n/// @dev ASCII 9\nuint128 constant CMASK_NINE = uint128(1) << uint128(uint8(bytes1(\"9\")));\n\n/// @dev ASCII :\nuint128 constant CMASK_COLON = uint128(1) << uint128(uint8(bytes1(\":\")));\n\n/// @dev ASCII ;\nuint128 constant CMASK_SEMICOLON = uint128(1) << uint128(uint8(bytes1(\";\")));\n\n/// @dev ASCII <\nuint128 constant CMASK_LESS_THAN_SIGN = uint128(1) << uint128(uint8(bytes1(\"<\")));\n\n/// @dev ASCII =\nuint128 constant CMASK_EQUALS_SIGN = uint128(1) << uint128(uint8(bytes1(\"=\")));\n\n/// @dev ASCII >\nuint128 constant CMASK_GREATER_THAN_SIGN = uint128(1) << uint128(uint8(bytes1(\">\")));\n\n/// @dev ASCII ?\nuint128 constant CMASK_QUESTION_MARK = uint128(1) << uint128(uint8(bytes1(\"?\")));\n\n/// @dev ASCII @\nuint128 constant CMASK_AT_SIGN = uint128(1) << uint128(uint8(bytes1(\"@\")));\n\n/// @dev ASCII A\nuint128 constant CMASK_UPPER_A = uint128(1) << uint128(uint8(bytes1(\"A\")));\n\n/// @dev ASCII B\nuint128 constant CMASK_UPPER_B = uint128(1) << uint128(uint8(bytes1(\"B\")));\n\n/// @dev ASCII C\nuint128 constant CMASK_UPPER_C = uint128(1) << uint128(uint8(bytes1(\"C\")));\n\n/// @dev ASCII D\nuint128 constant CMASK_UPPER_D = uint128(1) << uint128(uint8(bytes1(\"D\")));\n\n/// @dev ASCII E\nuint128 constant CMASK_UPPER_E = uint128(1) << uint128(uint8(bytes1(\"E\")));\n\n/// @dev ASCII F\nuint128 constant CMASK_UPPER_F = uint128(1) << uint128(uint8(bytes1(\"F\")));\n\n/// @dev ASCII G\nuint128 constant CMASK_UPPER_G = uint128(1) << uint128(uint8(bytes1(\"G\")));\n\n/// @dev ASCII H\nuint128 constant CMASK_UPPER_H = uint128(1) << uint128(uint8(bytes1(\"H\")));\n\n/// @dev ASCII I\nuint128 constant CMASK_UPPER_I = uint128(1) << uint128(uint8(bytes1(\"I\")));\n\n/// @dev ASCII J\nuint128 constant CMASK_UPPER_J = uint128(1) << uint128(uint8(bytes1(\"J\")));\n\n/// @dev ASCII K\nuint128 constant CMASK_UPPER_K = uint128(1) << uint128(uint8(bytes1(\"K\")));\n\n/// @dev ASCII L\nuint128 constant CMASK_UPPER_L = uint128(1) << uint128(uint8(bytes1(\"L\")));\n\n/// @dev ASCII M\nuint128 constant CMASK_UPPER_M = uint128(1) << uint128(uint8(bytes1(\"M\")));\n\n/// @dev ASCII N\nuint128 constant CMASK_UPPER_N = uint128(1) << uint128(uint8(bytes1(\"N\")));\n\n/// @dev ASCII O\nuint128 constant CMASK_UPPER_O = uint128(1) << uint128(uint8(bytes1(\"O\")));\n\n/// @dev ASCII P\nuint128 constant CMASK_UPPER_P = uint128(1) << uint128(uint8(bytes1(\"P\")));\n\n/// @dev ASCII Q\nuint128 constant CMASK_UPPER_Q = uint128(1) << uint128(uint8(bytes1(\"Q\")));\n\n/// @dev ASCII R\nuint128 constant CMASK_UPPER_R = uint128(1) << uint128(uint8(bytes1(\"R\")));\n\n/// @dev ASCII S\nuint128 constant CMASK_UPPER_S = uint128(1) << uint128(uint8(bytes1(\"S\")));\n\n/// @dev ASCII T\nuint128 constant CMASK_UPPER_T = uint128(1) << uint128(uint8(bytes1(\"T\")));\n\n/// @dev ASCII U\nuint128 constant CMASK_UPPER_U = uint128(1) << uint128(uint8(bytes1(\"U\")));\n\n/// @dev ASCII V\nuint128 constant CMASK_UPPER_V = uint128(1) << uint128(uint8(bytes1(\"V\")));\n\n/// @dev ASCII W\nuint128 constant CMASK_UPPER_W = uint128(1) << uint128(uint8(bytes1(\"W\")));\n\n/// @dev ASCII X\nuint128 constant CMASK_UPPER_X = uint128(1) << uint128(uint8(bytes1(\"X\")));\n\n/// @dev ASCII Y\nuint128 constant CMASK_UPPER_Y = uint128(1) << uint128(uint8(bytes1(\"Y\")));\n\n/// @dev ASCII Z\nuint128 constant CMASK_UPPER_Z = uint128(1) << uint128(uint8(bytes1(\"Z\")));\n\n/// @dev ASCII [\nuint128 constant CMASK_LEFT_SQUARE_BRACKET = uint128(1) << uint128(uint8(bytes1(\"[\")));\n\n/// @dev ASCII \\\nuint128 constant CMASK_BACKSLASH = uint128(1) << uint128(uint8(bytes1(\"\\\\\")));\n\n/// @dev ASCII ]\nuint128 constant CMASK_RIGHT_SQUARE_BRACKET = uint128(1) << uint128(uint8(bytes1(\"]\")));\n\n/// @dev ASCII ^\nuint128 constant CMASK_CIRCUMFLEX_ACCENT = uint128(1) << uint128(uint8(bytes1(\"^\")));\n\n/// @dev ASCII _\nuint128 constant CMASK_UNDERSCORE = uint128(1) << uint128(uint8(bytes1(\"_\")));\n\n/// @dev ASCII `\nuint128 constant CMASK_GRAVE_ACCENT = uint128(1) << uint128(uint8(bytes1(\"`\")));\n\n/// @dev ASCII a\nuint128 constant CMASK_LOWER_A = uint128(1) << uint128(uint8(bytes1(\"a\")));\n\n/// @dev ASCII b\nuint128 constant CMASK_LOWER_B = uint128(1) << uint128(uint8(bytes1(\"b\")));\n\n/// @dev ASCII c\nuint128 constant CMASK_LOWER_C = uint128(1) << uint128(uint8(bytes1(\"c\")));\n\n/// @dev ASCII d\nuint128 constant CMASK_LOWER_D = uint128(1) << uint128(uint8(bytes1(\"d\")));\n\n/// @dev ASCII e\nuint128 constant CMASK_LOWER_E = uint128(1) << uint128(uint8(bytes1(\"e\")));\n\n/// @dev ASCII f\nuint128 constant CMASK_LOWER_F = uint128(1) << uint128(uint8(bytes1(\"f\")));\n\n/// @dev ASCII g\nuint128 constant CMASK_LOWER_G = uint128(1) << uint128(uint8(bytes1(\"g\")));\n\n/// @dev ASCII h\nuint128 constant CMASK_LOWER_H = uint128(1) << uint128(uint8(bytes1(\"h\")));\n\n/// @dev ASCII i\nuint128 constant CMASK_LOWER_I = uint128(1) << uint128(uint8(bytes1(\"i\")));\n\n/// @dev ASCII j\nuint128 constant CMASK_LOWER_J = uint128(1) << uint128(uint8(bytes1(\"j\")));\n\n/// @dev ASCII k\nuint128 constant CMASK_LOWER_K = uint128(1) << uint128(uint8(bytes1(\"k\")));\n\n/// @dev ASCII l\nuint128 constant CMASK_LOWER_L = uint128(1) << uint128(uint8(bytes1(\"l\")));\n\n/// @dev ASCII m\nuint128 constant CMASK_LOWER_M = uint128(1) << uint128(uint8(bytes1(\"m\")));\n\n/// @dev ASCII n\nuint128 constant CMASK_LOWER_N = uint128(1) << uint128(uint8(bytes1(\"n\")));\n\n/// @dev ASCII o\nuint128 constant CMASK_LOWER_O = uint128(1) << uint128(uint8(bytes1(\"o\")));\n\n/// @dev ASCII p\nuint128 constant CMASK_LOWER_P = uint128(1) << uint128(uint8(bytes1(\"p\")));\n\n/// @dev ASCII q\nuint128 constant CMASK_LOWER_Q = uint128(1) << uint128(uint8(bytes1(\"q\")));\n\n/// @dev ASCII r\nuint128 constant CMASK_LOWER_R = uint128(1) << uint128(uint8(bytes1(\"r\")));\n\n/// @dev ASCII s\nuint128 constant CMASK_LOWER_S = uint128(1) << uint128(uint8(bytes1(\"s\")));\n\n/// @dev ASCII t\nuint128 constant CMASK_LOWER_T = uint128(1) << uint128(uint8(bytes1(\"t\")));\n\n/// @dev ASCII u\nuint128 constant CMASK_LOWER_U = uint128(1) << uint128(uint8(bytes1(\"u\")));\n\n/// @dev ASCII v\nuint128 constant CMASK_LOWER_V = uint128(1) << uint128(uint8(bytes1(\"v\")));\n\n/// @dev ASCII w\nuint128 constant CMASK_LOWER_W = uint128(1) << uint128(uint8(bytes1(\"w\")));\n\n/// @dev ASCII x\nuint128 constant CMASK_LOWER_X = uint128(1) << uint128(uint8(bytes1(\"x\")));\n\n/// @dev ASCII y\nuint128 constant CMASK_LOWER_Y = uint128(1) << uint128(uint8(bytes1(\"y\")));\n\n/// @dev ASCII z\nuint128 constant CMASK_LOWER_Z = uint128(1) << uint128(uint8(bytes1(\"z\")));\n\n/// @dev ASCII {\nuint128 constant CMASK_LEFT_CURLY_BRACKET = uint128(1) << uint128(uint8(bytes1(\"{\")));\n\n/// @dev ASCII |\nuint128 constant CMASK_VERTICAL_BAR = uint128(1) << uint128(uint8(bytes1(\"|\")));\n\n/// @dev ASCII }\nuint128 constant CMASK_RIGHT_CURLY_BRACKET = uint128(1) << uint128(uint8(bytes1(\"}\")));\n\n/// @dev ASCII ~\nuint128 constant CMASK_TILDE = uint128(1) << uint128(uint8(bytes1(\"~\")));\n\n/// @dev ASCII delete\nuint128 constant CMASK_DELETE = uint128(1) << uint128(uint8(bytes1(\"\\x7F\")));\n\n/// @dev numeric 0-9\nuint128 constant CMASK_NUMERIC_0_9 = CMASK_ZERO | CMASK_ONE | CMASK_TWO | CMASK_THREE | CMASK_FOUR | CMASK_FIVE\n | CMASK_SIX | CMASK_SEVEN | CMASK_EIGHT | CMASK_NINE;\n\n/// @dev e notation eE\nuint128 constant CMASK_E_NOTATION = CMASK_LOWER_E | CMASK_UPPER_E;\n\n/// @dev lower alpha a-z\nuint128 constant CMASK_LOWER_ALPHA_A_Z = CMASK_LOWER_A | CMASK_LOWER_B | CMASK_LOWER_C | CMASK_LOWER_D | CMASK_LOWER_E\n | CMASK_LOWER_F | CMASK_LOWER_G | CMASK_LOWER_H | CMASK_LOWER_I | CMASK_LOWER_J | CMASK_LOWER_K | CMASK_LOWER_L\n | CMASK_LOWER_M | CMASK_LOWER_N | CMASK_LOWER_O | CMASK_LOWER_P | CMASK_LOWER_Q | CMASK_LOWER_R | CMASK_LOWER_S\n | CMASK_LOWER_T | CMASK_LOWER_U | CMASK_LOWER_V | CMASK_LOWER_W | CMASK_LOWER_X | CMASK_LOWER_Y | CMASK_LOWER_Z;\n\n/// @dev upper alpha A-Z\nuint128 constant CMASK_UPPER_ALPHA_A_Z = CMASK_UPPER_A | CMASK_UPPER_B | CMASK_UPPER_C | CMASK_UPPER_D | CMASK_UPPER_E\n | CMASK_UPPER_F | CMASK_UPPER_G | CMASK_UPPER_H | CMASK_UPPER_I | CMASK_UPPER_J | CMASK_UPPER_K | CMASK_UPPER_L\n | CMASK_UPPER_M | CMASK_UPPER_N | CMASK_UPPER_O | CMASK_UPPER_P | CMASK_UPPER_Q | CMASK_UPPER_R | CMASK_UPPER_S\n | CMASK_UPPER_T | CMASK_UPPER_U | CMASK_UPPER_V | CMASK_UPPER_W | CMASK_UPPER_X | CMASK_UPPER_Y | CMASK_UPPER_Z;\n\n/// @dev lower alpha a-f (hex)\nuint128 constant CMASK_LOWER_ALPHA_A_F =\n CMASK_LOWER_A | CMASK_LOWER_B | CMASK_LOWER_C | CMASK_LOWER_D | CMASK_LOWER_E | CMASK_LOWER_F;\n\n/// @dev upper alpha A-F (hex)\nuint128 constant CMASK_UPPER_ALPHA_A_F =\n CMASK_UPPER_A | CMASK_UPPER_B | CMASK_UPPER_C | CMASK_UPPER_D | CMASK_UPPER_E | CMASK_UPPER_F;\n\n/// @dev hex 0-9 a-f A-F\nuint128 constant CMASK_HEX = CMASK_NUMERIC_0_9 | CMASK_LOWER_ALPHA_A_F | CMASK_UPPER_ALPHA_A_F;\n\n/// @dev Rainlang end of line is ,\nuint128 constant CMASK_EOL = CMASK_COMMA;\n\n/// @dev Rainlang LHS/RHS delimiter is :\nuint128 constant CMASK_LHS_RHS_DELIMITER = CMASK_COLON;\n\n/// @dev Rainlang end of source is ;\nuint128 constant CMASK_EOS = CMASK_SEMICOLON;\n\n/// @dev Rainlang stack head is lower alpha and underscore a-z _\nuint128 constant CMASK_LHS_STACK_HEAD = CMASK_LOWER_ALPHA_A_Z | CMASK_UNDERSCORE;\n\n/// @dev Rainlang identifier head is lower alpha a-z\nuint128 constant CMASK_IDENTIFIER_HEAD = CMASK_LOWER_ALPHA_A_Z;\nuint128 constant CMASK_RHS_WORD_HEAD = CMASK_IDENTIFIER_HEAD;\n\n/// @dev Rainlang stack/identifier tail is lower alphanumeric kebab a-z 0-9 -\nuint128 constant CMASK_IDENTIFIER_TAIL = CMASK_IDENTIFIER_HEAD | CMASK_NUMERIC_0_9 | CMASK_DASH;\nuint128 constant CMASK_LHS_STACK_TAIL = CMASK_IDENTIFIER_TAIL;\nuint128 constant CMASK_RHS_WORD_TAIL = CMASK_IDENTIFIER_TAIL;\n\n/// @dev Rainlang operand start is <\nuint128 constant CMASK_OPERAND_START = CMASK_LESS_THAN_SIGN;\n\n/// @dev Rainlang operand end is >\nuint128 constant CMASK_OPERAND_END = CMASK_GREATER_THAN_SIGN;\n\n/// @dev NOT lower alphanumeric kebab\nuint128 constant CMASK_NOT_IDENTIFIER_TAIL = ~CMASK_IDENTIFIER_TAIL;\n\n/// @dev Rainlang whitespace is \\n \\r \\t space\nuint128 constant CMASK_WHITESPACE = CMASK_LINE_FEED | CMASK_CARRIAGE_RETURN | CMASK_HORIZONTAL_TAB | CMASK_SPACE;\n\n/// @dev Rainlang stack item delimiter is whitespace\nuint128 constant CMASK_LHS_STACK_DELIMITER = CMASK_WHITESPACE;\n\n/// @dev Rainlang supports numeric literals as anything starting with 0-9\nuint128 constant CMASK_NUMERIC_LITERAL_HEAD = CMASK_NUMERIC_0_9;\n\n/// @dev Rainlang literal head\nuint128 constant CMASK_LITERAL_HEAD = CMASK_NUMERIC_LITERAL_HEAD;\n\n/// @dev Rainlang comment head is /\nuint128 constant CMASK_COMMENT_HEAD = CMASK_SLASH;\n\n/// @dev Rainlang comment starting sequence is /*\nuint256 constant COMMENT_START_SEQUENCE = uint256(uint16(bytes2(\"/*\")));\n\n/// @dev Rainlang comment ending sequence is */\nuint256 constant COMMENT_END_SEQUENCE = uint256(uint16(bytes2(\"*/\")));\n\n/// @dev Rainlang literal hexadecimal dispatch is 0x\n/// We compare the head and dispatch together to avoid a second comparison.\n/// This is safe because the head is prefiltered to be 0-9 due to the numeric\n/// literal head, therefore the only possible match is 0x (not x0).\nuint128 constant CMASK_LITERAL_HEX_DISPATCH = CMASK_ZERO | CMASK_LOWER_X;\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseLiteral.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibParseCMask.sol\";\nimport \"./LibParse.sol\";\n\n/// The parser tried to bound an unsupported literal that we have no type for.\nerror UnsupportedLiteralType(uint256 offset);\n\n/// Encountered a literal that is larger than supported.\nerror HexLiteralOverflow(uint256 offset);\n\n/// Encountered a zero length hex literal.\nerror ZeroLengthHexLiteral(uint256 offset);\n\n/// Encountered an odd sized hex literal.\nerror OddLengthHexLiteral(uint256 offset);\n\n/// Encountered a hex literal with an invalid character.\nerror MalformedHexLiteral(uint256 offset);\n\n/// Encountered a decimal literal that is larger than supported.\nerror DecimalLiteralOverflow(uint256 offset);\n\n/// Encountered a decimal literal with an exponent that has too many or no\n/// digits.\nerror MalformedExponentDigits(uint256 offset);\n\n/// Encountered a zero length decimal literal.\nerror ZeroLengthDecimal(uint256 offset);\n\n/// @dev The type of a literal is both a unique value and a literal offset used\n/// to index into the literal parser array as a uint256.\nuint256 constant LITERAL_TYPE_INTEGER_HEX = 0;\n/// @dev The type of a literal is both a unique value and a literal offset used\n/// to index into the literal parser array as a uint256.\nuint256 constant LITERAL_TYPE_INTEGER_DECIMAL = 0x10;\n\nlibrary LibParseLiteral {\n function buildLiteralParsers() internal pure returns (uint256 literalParsers) {\n // Register all the literal parsers in the parse state. Each is a 16 bit\n // function pointer so we can have up to 16 literal types. This needs to\n // be done at runtime because the library code doesn't know the bytecode\n // offsets of the literal parsers until it is compiled into a contract.\n {\n function(bytes memory, uint256, uint256) pure returns (uint256) literalParserHex =\n LibParseLiteral.parseLiteralHex;\n uint256 parseLiteralHexOffset = LITERAL_TYPE_INTEGER_HEX;\n function(bytes memory, uint256, uint256) pure returns (uint256) literalParserDecimal =\n LibParseLiteral.parseLiteralDecimal;\n uint256 parseLiteralDecimalOffset = LITERAL_TYPE_INTEGER_DECIMAL;\n\n assembly (\"memory-safe\") {\n literalParsers :=\n or(shl(parseLiteralHexOffset, literalParserHex), shl(parseLiteralDecimalOffset, literalParserDecimal))\n }\n }\n }\n\n /// Find the bounds for some literal at the cursor. The caller is responsible\n /// for checking that the cursor is at the start of a literal. As each\n /// literal type has a different format, this function returns the bounds\n /// for the literal and the type of the literal. The bounds are:\n /// - innerStart: the start of the literal, e.g. after the 0x in 0x1234\n /// - innerEnd: the end of the literal, e.g. after the 1234 in 0x1234\n /// - outerEnd: the end of the literal including any suffixes, MAY be the\n /// same as innerEnd if there is no suffix.\n /// The outerStart is the cursor, so it is not returned.\n /// @param cursor The start of the literal.\n /// @return The literal parser. This function can be called to convert the\n /// bounds into a uint256 value.\n /// @return The inner start.\n /// @return The inner end.\n /// @return The outer end.\n function boundLiteral(uint256 literalParsers, bytes memory data, uint256 cursor)\n internal\n pure\n returns (function(bytes memory, uint256, uint256) pure returns (uint256), uint256, uint256, uint256)\n {\n unchecked {\n uint256 word;\n uint256 head;\n assembly (\"memory-safe\") {\n word := mload(cursor)\n //slither-disable-next-line incorrect-shift\n head := shl(byte(0, word), 1)\n }\n\n // numeric literal head is 0-9\n if (head & CMASK_NUMERIC_LITERAL_HEAD != 0) {\n uint256 dispatch;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n dispatch := shl(byte(1, word), 1)\n }\n\n // hexadecimal literal dispatch is 0x\n if ((head | dispatch) == CMASK_LITERAL_HEX_DISPATCH) {\n uint256 innerStart = cursor + 2;\n uint256 innerEnd = innerStart;\n {\n uint256 hexCharMask = CMASK_HEX;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n for {} iszero(iszero(and(shl(byte(0, mload(innerEnd)), 1), hexCharMask))) {\n innerEnd := add(innerEnd, 1)\n } {}\n }\n }\n\n function(bytes memory, uint256, uint256) pure returns (uint256) parser;\n {\n uint256 p = (literalParsers >> LITERAL_TYPE_INTEGER_HEX) & 0xFFFF;\n assembly {\n parser := p\n }\n }\n {\n uint256 endHex;\n assembly (\"memory-safe\") {\n endHex := add(data, add(mload(data), 0x20))\n }\n if (innerEnd > endHex) {\n revert ParserOutOfBounds();\n }\n }\n return (parser, innerStart, innerEnd, innerEnd);\n }\n // decimal is the fallback as continuous numeric digits 0-9.\n else {\n uint256 innerStart = cursor;\n // We know the head is a numeric so we can move past it.\n uint256 innerEnd = innerStart + 1;\n uint256 ePosition = 0;\n\n {\n uint256 decimalCharMask = CMASK_NUMERIC_0_9;\n uint256 eMask = CMASK_E_NOTATION;\n assembly (\"memory-safe\") {\n //slither-disable-next-line incorrect-shift\n for {} iszero(iszero(and(shl(byte(0, mload(innerEnd)), 1), decimalCharMask))) {\n innerEnd := add(innerEnd, 1)\n } {}\n\n // If we're now pointing at an e notation, then we need\n // to move past it. Negative exponents are not supported.\n //slither-disable-next-line incorrect-shift\n if iszero(iszero(and(shl(byte(0, mload(innerEnd)), 1), eMask))) {\n ePosition := innerEnd\n innerEnd := add(innerEnd, 1)\n\n // Move past the exponent digits.\n //slither-disable-next-line incorrect-shift\n for {} iszero(iszero(and(shl(byte(0, mload(innerEnd)), 1), decimalCharMask))) {\n innerEnd := add(innerEnd, 1)\n } {}\n }\n }\n }\n if (ePosition != 0 && (innerEnd > ePosition + 3 || innerEnd == ePosition + 1)) {\n revert MalformedExponentDigits(LibParse.parseErrorOffset(data, ePosition));\n }\n\n function(bytes memory, uint256, uint256) pure returns (uint256) parser;\n {\n uint256 p = (literalParsers >> LITERAL_TYPE_INTEGER_DECIMAL) & 0xFFFF;\n assembly {\n parser := p\n }\n }\n {\n uint256 endDecimal;\n assembly (\"memory-safe\") {\n endDecimal := add(data, add(mload(data), 0x20))\n }\n if (innerEnd > endDecimal) {\n revert ParserOutOfBounds();\n }\n }\n return (parser, innerStart, innerEnd, innerEnd);\n }\n }\n\n uint256 endUnknown;\n assembly (\"memory-safe\") {\n endUnknown := add(data, add(mload(data), 0x20))\n }\n if (cursor >= endUnknown) {\n revert ParserOutOfBounds();\n } else {\n revert UnsupportedLiteralType(LibParse.parseErrorOffset(data, cursor));\n }\n }\n }\n\n /// Algorithm for parsing hexadecimal literals:\n /// - start at the end of the literal\n /// - for each character:\n /// - convert the character to a nybble\n /// - shift the nybble into the total at the correct position\n /// (4 bits per nybble)\n /// - return the total\n function parseLiteralHex(bytes memory data, uint256 start, uint256 end) internal pure returns (uint256 value) {\n unchecked {\n uint256 length = end - start;\n if (length > 0x40) {\n revert HexLiteralOverflow(LibParse.parseErrorOffset(data, start));\n } else if (length == 0) {\n revert ZeroLengthHexLiteral(LibParse.parseErrorOffset(data, start));\n } else if (length % 2 == 1) {\n revert OddLengthHexLiteral(LibParse.parseErrorOffset(data, start));\n } else {\n uint256 cursor = end - 1;\n uint256 valueOffset = 0;\n while (cursor >= start) {\n uint256 hexCharByte;\n assembly (\"memory-safe\") {\n hexCharByte := byte(0, mload(cursor))\n }\n //slither-disable-next-line incorrect-shift\n uint256 hexChar = 1 << hexCharByte;\n\n uint256 nybble;\n // 0-9\n if (hexChar & CMASK_NUMERIC_0_9 != 0) {\n nybble = hexCharByte - uint256(uint8(bytes1(\"0\")));\n }\n // a-f\n else if (hexChar & CMASK_LOWER_ALPHA_A_F != 0) {\n nybble = hexCharByte - uint256(uint8(bytes1(\"a\"))) + 10;\n }\n // A-F\n else if (hexChar & CMASK_UPPER_ALPHA_A_F != 0) {\n nybble = hexCharByte - uint256(uint8(bytes1(\"A\"))) + 10;\n } else {\n revert MalformedHexLiteral(LibParse.parseErrorOffset(data, cursor));\n }\n\n value |= nybble << valueOffset;\n valueOffset += 4;\n cursor--;\n }\n }\n }\n }\n\n /// Algorithm for parsing decimal literals:\n /// - start at the end of the literal\n /// - for each digit:\n /// - multiply the digit by 10^digit position\n /// - add the result to the total\n /// - return the total\n ///\n /// This algorithm is ONLY safe if the caller has already checked that the\n /// start/end span a non-zero length of valid decimal chars. The caller\n /// can most easily do this by using the `boundLiteral` function.\n ///\n /// Unsafe behavior is undefined and can easily result in out of bounds\n /// reads as there are no checks that start/end are within `data`.\n function parseLiteralDecimal(bytes memory data, uint256 start, uint256 end) internal pure returns (uint256 value) {\n unchecked {\n // Tracks which digit we're on.\n uint256 cursor;\n // The ASCII byte can be translated to a numeric digit by subtracting\n // the digit offset.\n uint256 digitOffset = uint256(uint8(bytes1(\"0\")));\n // Tracks the exponent of the current digit. Can start above 0 if\n // the literal is in e notation.\n uint256 exponent;\n {\n uint256 word;\n //slither-disable-next-line similar-names\n uint256 decimalCharByte;\n uint256 length = end - start;\n assembly (\"memory-safe\") {\n word := mload(sub(end, 3))\n decimalCharByte := byte(0, word)\n }\n // If the last 3 bytes are e notation, then we need to parse\n // the exponent as a 2 digit number.\n //slither-disable-next-line incorrect-shift\n if (length > 3 && ((1 << decimalCharByte) & CMASK_E_NOTATION) != 0) {\n cursor = end - 4;\n assembly (\"memory-safe\") {\n exponent := add(sub(byte(2, word), digitOffset), mul(sub(byte(1, word), digitOffset), 10))\n }\n } else {\n assembly (\"memory-safe\") {\n decimalCharByte := byte(1, word)\n }\n // If the last 2 bytes are e notation, then we need to parse\n // the exponent as a 1 digit number.\n //slither-disable-next-line incorrect-shift\n if (length > 2 && ((1 << decimalCharByte) & CMASK_E_NOTATION) != 0) {\n cursor = end - 3;\n assembly (\"memory-safe\") {\n exponent := sub(byte(2, word), digitOffset)\n }\n }\n // Otherwise, we're not in e notation and we can start at the\n // end of the literal with 0 starting exponent.\n else if (length > 0) {\n cursor = end - 1;\n exponent = 0;\n } else {\n revert ZeroLengthDecimal(LibParse.parseErrorOffset(data, start));\n }\n }\n }\n\n // Anything under 10^77 is safe to raise to its power of 10 without\n // overflowing a uint256.\n while (cursor >= start && exponent < 77) {\n // We don't need to check the bounds of the byte because\n // we know it is a decimal literal as long as the bounds\n // are correct (calculated in `boundLiteral`).\n assembly (\"memory-safe\") {\n value := add(value, mul(sub(byte(0, mload(cursor)), digitOffset), exp(10, exponent)))\n }\n exponent++;\n cursor--;\n }\n\n // If we didn't consume the entire literal, then we have\n // to check if the remaining digit is safe to multiply\n // by 10 without overflowing a uint256.\n if (cursor >= start) {\n {\n uint256 digit;\n assembly (\"memory-safe\") {\n digit := sub(byte(0, mload(cursor)), digitOffset)\n }\n // If the digit is greater than 1, then we know that\n // multiplying it by 10^77 will overflow a uint256.\n if (digit > 1) {\n revert DecimalLiteralOverflow(LibParse.parseErrorOffset(data, cursor));\n } else {\n uint256 scaled = digit * (10 ** exponent);\n if (value + scaled < value) {\n revert DecimalLiteralOverflow(LibParse.parseErrorOffset(data, cursor));\n }\n value += scaled;\n }\n cursor--;\n }\n\n {\n // If we didn't consume the entire literal, then only\n // leading zeros are allowed.\n while (cursor >= start) {\n //slither-disable-next-line similar-names\n uint256 decimalCharByte;\n assembly (\"memory-safe\") {\n decimalCharByte := byte(0, mload(cursor))\n }\n if (decimalCharByte != uint256(uint8(bytes1(\"0\")))) {\n revert DecimalLiteralOverflow(LibParse.parseErrorOffset(data, cursor));\n }\n cursor--;\n }\n }\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/parse/LibParseStackName.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./LibParse.sol\";\n\nlibrary LibParseStackName {\n /// Push a word onto the stack name stack.\n /// @return exists Whether the word already existed.\n /// @return index The new index after the word was pushed. Will be unchanged\n /// if the word already existed.\n function pushStackName(ParseState memory state, bytes32 word) internal pure returns (bool exists, uint256 index) {\n unchecked {\n (exists, index) = stackNameIndex(state, word);\n if (!exists) {\n uint256 fingerprint;\n uint256 ptr;\n uint256 oldStackNames = state.stackNames;\n assembly (\"memory-safe\") {\n ptr := mload(0x40)\n mstore(ptr, word)\n fingerprint := and(keccak256(ptr, 0x20), not(0xFFFFFFFF))\n mstore(ptr, oldStackNames)\n mstore(0x40, add(ptr, 0x20))\n }\n // Add the start of line height to the LHS line parse count.\n uint256 stackLHSIndex = state.topLevel1 & 0xFF;\n state.stackNames = fingerprint | (stackLHSIndex << 0x10) | ptr;\n index = stackLHSIndex + 1;\n }\n }\n }\n\n /// Retrieve the index of a previously pushed stack name.\n function stackNameIndex(ParseState memory state, bytes32 word) internal pure returns (bool exists, uint256 index) {\n uint256 fingerprint;\n uint256 stackNames = state.stackNames;\n uint256 stackNameBloom = state.stackNameBloom;\n uint256 bloom;\n assembly (\"memory-safe\") {\n mstore(0, word)\n fingerprint := shr(0x20, keccak256(0, 0x20))\n //slither-disable-next-line incorrect-shift\n bloom := shl(and(fingerprint, 0xFF), 1)\n\n // If the bloom matches then maybe the stack name is in the stack.\n if and(bloom, stackNameBloom) {\n for { let ptr := and(stackNames, 0xFFFF) } iszero(iszero(ptr)) {\n stackNames := mload(ptr)\n ptr := and(stackNames, 0xFFFF)\n } {\n if eq(fingerprint, shr(0x20, stackNames)) {\n exists := true\n index := and(shr(0x10, stackNames), 0xFFFF)\n break\n }\n }\n }\n }\n state.stackNameBloom = bloom | stackNameBloom;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.lib.typecast/src/LibCast.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @title LibCast\n/// @notice Additional type casting logic that the Solidity compiler doesn't\n/// give us by default. A type cast (vs. conversion) is considered one where the\n/// structure is unchanged by the cast. The cast does NOT (can't) check that the\n/// input is a valid output, for example any integer MAY be cast to a function\n/// pointer but almost all integers are NOT valid function pointers. It is the\n/// calling context that MUST ensure the validity of the data, the cast will\n/// merely retype the data in place, generally without additional checks.\n/// As most structures in solidity have the same memory structure as a `uint256`\n/// or fixed/dynamic array of `uint256` there are many conversions that can be\n/// done with near zero or minimal overhead.\nlibrary LibCast {\n /// Retype an array of `uint256[]` to `address[]`.\n /// @param us_ The array of integers to cast to addresses.\n /// @return addresses_ The array of addresses cast from each integer.\n function asAddressesArray(uint256[] memory us_) internal pure returns (address[] memory addresses_) {\n assembly (\"memory-safe\") {\n addresses_ := us_\n }\n }\n\n function asUint256Array(address[] memory addresses_) internal pure returns (uint256[] memory us_) {\n assembly (\"memory-safe\") {\n us_ := addresses_\n }\n }\n\n /// Retype an array of `uint256[]` to `bytes32[]`.\n /// @param us_ The array of integers to cast to 32 byte words.\n /// @return b32s_ The array of 32 byte words.\n function asBytes32Array(uint256[] memory us_) internal pure returns (bytes32[] memory b32s_) {\n assembly (\"memory-safe\") {\n b32s_ := us_\n }\n }\n\n function asUint256Array(bytes32[] memory b32s_) internal pure returns (uint256[] memory us_) {\n assembly (\"memory-safe\") {\n us_ := b32s_\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/eval/LibEvalNP.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../state/LibInterpreterStateNP.sol\";\n\nimport \"rain.solmem/lib/LibMemCpy.sol\";\nimport \"rain.lib.memkv/lib/LibMemoryKV.sol\";\nimport \"../bytecode/LibBytecode.sol\";\n\n/// Thrown when the inputs length does not match the expected inputs length.\n/// @param expected The expected number of inputs.\n/// @param actual The actual number of inputs.\nerror InputsLengthMismatch(uint256 expected, uint256 actual);\n\nlibrary LibEvalNP {\n using LibMemoryKV for MemoryKV;\n\n function evalLoopNP(InterpreterStateNP memory state, Pointer stackTop) internal view returns (Pointer) {\n uint256 sourceIndex = state.sourceIndex;\n uint256 cursor;\n uint256 end;\n uint256 m;\n uint256 fPointersStart;\n // We mod the indexes with the fsCount for each lookup to ensure that\n // the indexes are in bounds. A mod is cheaper than a bounds check.\n uint256 fsCount = state.fs.length / 2;\n {\n bytes memory bytecode = state.bytecode;\n bytes memory fPointers = state.fs;\n assembly (\"memory-safe\") {\n // SourceIndex is a uint16 so needs cleaning.\n sourceIndex := and(sourceIndex, 0xFFFF)\n // Cursor starts at the beginning of the source.\n cursor := add(bytecode, 0x20)\n let sourcesLength := byte(0, mload(cursor))\n cursor := add(cursor, 1)\n // Find start of sources.\n let sourcesStart := add(cursor, mul(sourcesLength, 2))\n // Find relative pointer to source.\n let sourcesPointer := shr(0xf0, mload(add(cursor, mul(sourceIndex, 2))))\n // Move cursor to start of source.\n cursor := add(sourcesStart, sourcesPointer)\n // Calculate the end.\n let opsLength := byte(0, mload(cursor))\n // Move cursor past 4 byte source prefix.\n cursor := add(cursor, 4)\n\n // Calculate the mod `m` which is the portion of the source\n // that can't be copied in 32 byte chunks.\n m := mod(opsLength, 8)\n\n // Each op is 4 bytes, and there's a 4 byte prefix for the\n // source. The initial end is only what can be processed in\n // 32 byte chunks.\n end := add(cursor, mul(sub(opsLength, m), 4))\n\n fPointersStart := add(fPointers, 0x20)\n }\n }\n\n function(InterpreterStateNP memory, Operand, Pointer)\n internal\n view\n returns (Pointer) f;\n Operand operand;\n uint256 word;\n while (cursor < end) {\n assembly (\"memory-safe\") {\n word := mload(cursor)\n }\n\n // Process high bytes [28, 31]\n // f needs to be looked up from the fn pointers table.\n // operand is 3 bytes.\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(0, word), fsCount), 2))))\n operand := and(shr(0xe0, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [24, 27].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(4, word), fsCount), 2))))\n operand := and(shr(0xc0, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [20, 23].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(8, word), fsCount), 2))))\n operand := and(shr(0xa0, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [16, 19].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(12, word), fsCount), 2))))\n operand := and(shr(0x80, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [12, 15].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(16, word), fsCount), 2))))\n operand := and(shr(0x60, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [8, 11].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(20, word), fsCount), 2))))\n operand := and(shr(0x40, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [4, 7].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(24, word), fsCount), 2))))\n operand := and(shr(0x20, word), 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n // Bytes [0, 3].\n assembly (\"memory-safe\") {\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(28, word), fsCount), 2))))\n operand := and(word, 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n\n cursor += 0x20;\n }\n\n // Loop over the remainder.\n // Need to shift the cursor back 28 bytes so that we're reading from\n // its 4 low bits rather than high bits, to make the loop logic more\n // efficient.\n cursor -= 0x1c;\n end = cursor + m * 4;\n while (cursor < end) {\n assembly (\"memory-safe\") {\n word := mload(cursor)\n f := shr(0xf0, mload(add(fPointersStart, mul(mod(byte(28, word), fsCount), 2))))\n // 3 bytes mask.\n operand := and(word, 0xFFFFFF)\n }\n stackTop = f(state, operand, stackTop);\n cursor += 4;\n }\n\n return stackTop;\n }\n\n function evalNP(InterpreterStateNP memory state, uint256[] memory inputs, uint256 maxOutputs)\n internal\n view\n returns (uint256[] memory, uint256[] memory)\n {\n unchecked {\n // Use the bytecode's own definition of its IO. Clear example of\n // how the bytecode could accidentally or maliciously force OOB reads\n // if the integrity check is not run.\n (uint256 sourceInputs, uint256 sourceOutputs) =\n LibBytecode.sourceInputsOutputsLength(state.bytecode, state.sourceIndex);\n\n Pointer stackTop;\n {\n stackTop = state.stackBottoms[state.sourceIndex];\n // Copy inputs into place if needed.\n if (inputs.length > 0) {\n // Inline some logic to avoid jumping due to function calls\n // on hot path.\n Pointer inputsDataPointer;\n assembly (\"memory-safe\") {\n // Move stack top by the number of inputs.\n stackTop := sub(stackTop, mul(mload(inputs), 0x20))\n inputsDataPointer := add(inputs, 0x20)\n }\n LibMemCpy.unsafeCopyWordsTo(inputsDataPointer, stackTop, inputs.length);\n } else if (inputs.length != sourceInputs) {\n revert InputsLengthMismatch(sourceInputs, inputs.length);\n }\n }\n\n // Run the loop.\n stackTop = evalLoopNP(state, stackTop);\n\n // Convert the stack top pointer to an array with the correct length.\n // If the stack top is pointing to the base of Solidity's understanding\n // of the stack array, then this will simply write the same length over\n // the length the stack was initialized with, otherwise a shorter array\n // will be built within the bounds of the stack. After this point `tail`\n // and the original stack MUST be immutable as they're both pointing to\n // the same memory region.\n uint256 outputs = maxOutputs < sourceOutputs ? maxOutputs : sourceOutputs;\n uint256[] memory result;\n assembly (\"memory-safe\") {\n result := sub(stackTop, 0x20)\n mstore(result, outputs)\n\n // Need to reverse the result array for backwards compatibility.\n // Ideally we'd not do this, but will need to roll a new interface\n // for such a breaking change.\n for {\n let a := add(result, 0x20)\n let b := add(result, mul(outputs, 0x20))\n } lt(a, b) {\n a := add(a, 0x20)\n b := sub(b, 0x20)\n } {\n let tmp := mload(a)\n mstore(a, mload(b))\n mstore(b, tmp)\n }\n }\n\n return (result, state.stateKV.toUint256Array());\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/caller/LibEncodedDispatch.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../../interface/IInterpreterV1.sol\";\n\n/// @title LibEncodedDispatch\n/// @notice Establishes and implements a convention for encoding an interpreter\n/// dispatch. Handles encoding of several things required for efficient dispatch.\nlibrary LibEncodedDispatch {\n /// Builds an `EncodedDispatch` from its constituent parts.\n /// @param expression The onchain address of the expression to run.\n /// @param sourceIndex The index of the source to run within the expression\n /// as an entrypoint.\n /// @param maxOutputs The maximum outputs the caller can meaningfully use.\n /// If the interpreter returns a larger stack than this it is merely wasting\n /// gas across the external call boundary.\n /// @return The encoded dispatch.\n function encode(address expression, SourceIndex sourceIndex, uint16 maxOutputs)\n internal\n pure\n returns (EncodedDispatch)\n {\n return EncodedDispatch.wrap(\n (uint256(uint160(expression)) << 32) | (uint256(SourceIndex.unwrap(sourceIndex)) << 16) | maxOutputs\n );\n }\n\n /// Decodes an `EncodedDispatch` to its constituent parts.\n /// @param dispatch_ The `EncodedDispatch` to decode.\n /// @return The expression, source index, and max outputs as per `encode`.\n function decode(EncodedDispatch dispatch_) internal pure returns (address, SourceIndex, uint16) {\n return (\n address(uint160(EncodedDispatch.unwrap(dispatch_) >> 32)),\n SourceIndex.wrap(uint16(EncodedDispatch.unwrap(dispatch_) >> 16)),\n uint16(EncodedDispatch.unwrap(dispatch_))\n );\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.lib.memkv/src/lib/LibMemoryKV.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// Entrypoint into the key/value store. Is a mutable pointer to the head of the\n/// linked list. Initially points to `0` for an empty list. The total word count\n/// of all inserts is also encoded alongside the pointer to allow efficient O(1)\n/// memory allocation for a `uint256[]` in the case of a final snapshot/export.\ntype MemoryKV is uint256;\n\n/// The key associated with the value for each item in the store.\ntype MemoryKVKey is uint256;\n\n/// The value associated with the key for each item in the store.\ntype MemoryKVVal is uint256;\n\n/// @title LibMemoryKV\nlibrary LibMemoryKV {\n /// Gets the value associated with a given key.\n /// The value returned will be `0` if the key exists and was set to zero OR\n /// the key DOES NOT exist, i.e. was never set.\n ///\n /// The caller MUST check the `exists` flag to disambiguate between zero\n /// values and unset keys.\n ///\n /// @param kv The entrypoint to the key/value store.\n /// @param key The key to lookup a `value` for.\n /// @return exists `0` if the key was not found. The `value` MUST NOT be\n /// used if the `key` does not exist.\n /// @return value The value for the `key`, if it exists, else `0`. MAY BE `0`\n /// even if the `key` exists. It is possible to set any key to a `0` value.\n function get(MemoryKV kv, MemoryKVKey key) internal pure returns (uint256 exists, MemoryKVVal value) {\n assembly (\"memory-safe\") {\n // Hash to find the internal linked list to walk.\n // Hash logic MUST match set.\n mstore(0, key)\n let bitOffset := mul(mod(keccak256(0, 0x20), 15), 0x10)\n\n // Loop until k found or give up if pointer is zero.\n for { let pointer := and(shr(bitOffset, kv), 0xFFFF) } iszero(iszero(pointer)) {\n pointer := mload(add(pointer, 0x40))\n } {\n if eq(key, mload(pointer)) {\n exists := 1\n value := mload(add(pointer, 0x20))\n break\n }\n }\n }\n }\n\n /// Upserts a value in the set by its key. I.e. if the key exists then the\n /// associated value will be mutated in place, else a new key/value pair will\n /// be inserted. The key/value store pointer will be mutated and returned as\n /// it MAY point to a new list item in memory.\n /// @param kv The key/value store pointer to modify.\n /// @param key The key to upsert against.\n /// @param value The value to associate with the upserted key.\n /// @return The final value of `kv` as it MAY be modified if the upsert\n /// resulted in an insert operation.\n function set(MemoryKV kv, MemoryKVKey key, MemoryKVVal value) internal pure returns (MemoryKV) {\n assembly (\"memory-safe\") {\n // Hash to spread inserts across internal lists.\n // This MUST remain in sync with `get` logic.\n mstore(0, key)\n let bitOffset := mul(mod(keccak256(0, 0x20), 15), 0x10)\n\n // Set aside the starting pointer as we'll need to include it in any\n // newly inserted linked list items.\n let startPointer := and(shr(bitOffset, kv), 0xFFFF)\n\n // Find a key match then break so that we populate a nonzero pointer.\n let pointer := startPointer\n for {} iszero(iszero(pointer)) { pointer := mload(add(pointer, 0x40)) } {\n if eq(key, mload(pointer)) { break }\n }\n\n // If the pointer is nonzero we have to update the associated value\n // directly, otherwise this is an insert operation.\n switch iszero(pointer)\n // Update.\n case 0 { mstore(add(pointer, 0x20), value) }\n // Insert.\n default {\n // Allocate 3 words of memory.\n pointer := mload(0x40)\n mstore(0x40, add(pointer, 0x60))\n\n // Write key/value/pointer.\n mstore(pointer, key)\n mstore(add(pointer, 0x20), value)\n mstore(add(pointer, 0x40), startPointer)\n\n // Update total stored word count.\n let length := add(shr(0xf0, kv), 2)\n\n //slither-disable-next-line incorrect-shift\n kv := or(shl(0xf0, length), and(kv, not(shl(0xf0, 0xFFFF))))\n\n // kv must point to new insertion.\n //slither-disable-next-line incorrect-shift\n kv :=\n or(\n shl(bitOffset, pointer),\n // Mask out the old pointer\n and(kv, not(shl(bitOffset, 0xFFFF)))\n )\n }\n }\n return kv;\n }\n\n /// Export/snapshot the underlying linked list of the key/value store into\n /// a standard `uint256[]`. Reads the total length to preallocate the\n /// `uint256[]` then bisects the bits of the `kv` to find non-zero pointers\n /// to linked lists, walking each found list to the end to extract all\n /// values. As a single `kv` has 15 slots for pointers to linked lists it is\n /// likely for smallish structures that many slots can simply be skipped, so\n /// the bisect approach can save ~1-1.5k gas vs. a naive linear loop over\n /// all 15 slots for every export.\n ///\n /// Note this is a one time export, if the key/value store is subsequently\n /// mutated the built array will not reflect these mutations.\n ///\n /// @param kv The entrypoint into the key/value store.\n /// @return array All the keys and values copied pairwise into a `uint256[]`.\n /// Slither is not wrong about the cyclomatic complexity but I don't know\n /// another way to implement the bisect and keep the gas savings.\n //slither-disable-next-line cyclomatic-complexity\n function toUint256Array(MemoryKV kv) internal pure returns (uint256[] memory array) {\n uint256 mask16 = type(uint16).max;\n uint256 mask32 = type(uint32).max;\n uint256 mask64 = type(uint64).max;\n uint256 mask128 = type(uint128).max;\n assembly (\"memory-safe\") {\n // Manually create an `uint256[]`.\n // No need to zero out memory as we're about to write to it.\n array := mload(0x40)\n let length := shr(0xf0, kv)\n mstore(0x40, add(array, add(0x20, mul(length, 0x20))))\n mstore(array, length)\n\n // Known false positives in slither\n // https://github.com/crytic/slither/issues/1815\n //slither-disable-next-line naming-convention\n function copyFromPtr(cursor, pointer) -> end {\n for {} iszero(iszero(pointer)) {\n pointer := mload(add(pointer, 0x40))\n cursor := add(cursor, 0x40)\n } {\n mstore(cursor, mload(pointer))\n mstore(add(cursor, 0x20), mload(add(pointer, 0x20)))\n }\n end := cursor\n }\n\n // Bisect.\n // This crazy tree saves ~1-1.5k gas vs. a simple loop with larger\n // relative savings for small-medium sized structures.\n // The internal scoping blocks are to provide some safety against\n // typos causing the incorrect symbol to be referenced by enforcing\n // each symbol is as tightly scoped as it can be.\n let cursor := add(array, 0x20)\n {\n // Remove the length from kv before iffing to save ~100 gas.\n let p0 := shr(0x90, shl(0x10, kv))\n if iszero(iszero(p0)) {\n {\n let p00 := shr(0x40, p0)\n if iszero(iszero(p00)) {\n {\n // This branch is a special case because we\n // already zeroed out the high bits which are\n // used by the length and are NOT a pointer.\n // We can skip processing where the pointer would\n // have been if it were not the length, and do\n // not need to scrub the high bits to move from\n // `p00` to `p0001`.\n let p0001 := shr(0x20, p00)\n if iszero(iszero(p0001)) { cursor := copyFromPtr(cursor, p0001) }\n }\n let p001 := and(mask32, p00)\n if iszero(iszero(p001)) {\n {\n let p0010 := shr(0x10, p001)\n if iszero(iszero(p0010)) { cursor := copyFromPtr(cursor, p0010) }\n }\n let p0011 := and(mask16, p001)\n if iszero(iszero(p0011)) { cursor := copyFromPtr(cursor, p0011) }\n }\n }\n }\n let p01 := and(mask64, p0)\n if iszero(iszero(p01)) {\n {\n let p010 := shr(0x20, p01)\n if iszero(iszero(p010)) {\n {\n let p0100 := shr(0x10, p010)\n if iszero(iszero(p0100)) { cursor := copyFromPtr(cursor, p0100) }\n }\n let p0101 := and(mask16, p010)\n if iszero(iszero(p0101)) { cursor := copyFromPtr(cursor, p0101) }\n }\n }\n\n let p011 := and(mask32, p01)\n if iszero(iszero(p011)) {\n {\n let p0110 := shr(0x10, p011)\n if iszero(iszero(p0110)) { cursor := copyFromPtr(cursor, p0110) }\n }\n\n let p0111 := and(mask16, p011)\n if iszero(iszero(p0111)) { cursor := copyFromPtr(cursor, p0111) }\n }\n }\n }\n }\n\n {\n let p1 := and(mask128, kv)\n if iszero(iszero(p1)) {\n {\n let p10 := shr(0x40, p1)\n if iszero(iszero(p10)) {\n {\n let p100 := shr(0x20, p10)\n if iszero(iszero(p100)) {\n {\n let p1000 := shr(0x10, p100)\n if iszero(iszero(p1000)) { cursor := copyFromPtr(cursor, p1000) }\n }\n let p1001 := and(mask16, p100)\n if iszero(iszero(p1001)) { cursor := copyFromPtr(cursor, p1001) }\n }\n }\n let p101 := and(mask32, p10)\n if iszero(iszero(p101)) {\n {\n let p1010 := shr(0x10, p101)\n if iszero(iszero(p1010)) { cursor := copyFromPtr(cursor, p1010) }\n }\n let p1011 := and(mask16, p101)\n if iszero(iszero(p1011)) { cursor := copyFromPtr(cursor, p1011) }\n }\n }\n }\n let p11 := and(mask64, p1)\n if iszero(iszero(p11)) {\n {\n let p110 := shr(0x20, p11)\n if iszero(iszero(p110)) {\n {\n let p1100 := shr(0x10, p110)\n if iszero(iszero(p1100)) { cursor := copyFromPtr(cursor, p1100) }\n }\n let p1101 := and(mask16, p110)\n if iszero(iszero(p1101)) { cursor := copyFromPtr(cursor, p1101) }\n }\n }\n\n let p111 := and(mask32, p11)\n if iszero(iszero(p111)) {\n {\n let p1110 := shr(0x10, p111)\n if iszero(iszero(p1110)) { cursor := copyFromPtr(cursor, p1110) }\n }\n\n let p1111 := and(mask16, p111)\n if iszero(iszero(p1111)) { cursor := copyFromPtr(cursor, p1111) }\n }\n }\n }\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/src/interface/IInterpreterStoreV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterV1.sol\";\n\n/// A fully qualified namespace includes the interpreter's own namespacing logic\n/// IN ADDITION to the calling contract's requested `StateNamespace`. Typically\n/// this involves hashing the `msg.sender` into the `StateNamespace` so that each\n/// caller operates within its own disjoint state universe. Intepreters MUST NOT\n/// allow either the caller nor any expression/word to modify this directly on\n/// pain of potential key collisions on writes to the interpreter's own storage.\ntype FullyQualifiedNamespace is uint256;\n\nIInterpreterStoreV1 constant NO_STORE = IInterpreterStoreV1(address(0));\n\n/// @title IInterpreterStoreV1\n/// @notice Tracks state changes on behalf of an interpreter. A single store can\n/// handle state changes for many calling contracts, many interpreters and many\n/// expressions. The store is responsible for ensuring that applying these state\n/// changes is safe from key collisions with calls to `set` from different\n/// `msg.sender` callers. I.e. it MUST NOT be possible for a caller to modify the\n/// state changes associated with some other caller.\n///\n/// The store defines the shape of its own state changes, which is opaque to the\n/// calling contract. For example, some store may treat the list of state changes\n/// as a pairwise key/value set, and some other store may treat it as a literal\n/// list to be stored as-is.\n///\n/// Each interpreter decides for itself which store to use based on the\n/// compatibility of its own opcodes.\n///\n/// The store MUST assume the state changes have been corrupted by the calling\n/// contract due to bugs or malicious intent, and enforce state isolation between\n/// callers despite arbitrarily invalid state changes. The store MUST revert if\n/// it can detect invalid state changes, such as a key/value list having an odd\n/// number of items, but this MAY NOT be possible if the corruption is\n/// undetectable.\ninterface IInterpreterStoreV1 {\n /// Mutates the interpreter store in bulk. The bulk values are provided in\n /// the form of a `uint256[]` which can be treated e.g. as pairwise keys and\n /// values to be stored in a Solidity mapping. The `IInterpreterStoreV1`\n /// defines the meaning of the `uint256[]` for its own storage logic.\n ///\n /// @param namespace The unqualified namespace for the set that MUST be\n /// fully qualified by the `IInterpreterStoreV1` to prevent key collisions\n /// between callers. The fully qualified namespace forms a compound key with\n /// the keys for each value to set.\n /// @param kvs The list of changes to apply to the store's internal state.\n function set(StateNamespace namespace, uint256[] calldata kvs) external;\n\n /// Given a fully qualified namespace and key, return the associated value.\n /// Ostensibly the interpreter can use this to implement opcodes that read\n /// previously set values. The interpreter MUST apply the same qualification\n /// logic as the store that it uses to guarantee consistent round tripping of\n /// data and prevent malicious behaviours. Technically also allows onchain\n /// reads of any set value from any contract, not just interpreters, but in\n /// this case readers MUST be aware and handle inconsistencies between get\n /// and set while the state changes are still in memory in the calling\n /// context and haven't yet been persisted to the store.\n ///\n /// `IInterpreterStoreV1` uses the same fallback behaviour for unset keys as\n /// Solidity. Specifically, any UNSET VALUES SILENTLY FALLBACK TO `0`.\n /// @param namespace The fully qualified namespace to get a single value for.\n /// @param key The key to get the value for within the namespace.\n /// @return The value OR ZERO IF NOT SET.\n function get(FullyQualifiedNamespace namespace, uint256 key) external view returns (uint256);\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n * understand this adds an external call which potentially creates a reentrancy vulnerability.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 tokenId) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
},
"lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/contracts/utils/math/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1, \"Math: mulDiv overflow\");\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/UD60x18.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n/*\n\n██████╗ ██████╗ ██████╗ ███╗ ███╗ █████╗ ████████╗██╗ ██╗\n██╔══██╗██╔══██╗██╔══██╗████╗ ████║██╔══██╗╚══██╔══╝██║ ██║\n██████╔╝██████╔╝██████╔╝██╔████╔██║███████║ ██║ ███████║\n██╔═══╝ ██╔══██╗██╔══██╗██║╚██╔╝██║██╔══██║ ██║ ██╔══██║\n██║ ██║ ██║██████╔╝██║ ╚═╝ ██║██║ ██║ ██║ ██║ ██║\n╚═╝ ╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝\n\n██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗ ██╗ █████╗\n██║ ██║██╔══██╗██╔════╝ ██╔═████╗╚██╗██╔╝███║██╔══██╗\n██║ ██║██║ ██║███████╗ ██║██╔██║ ╚███╔╝ ╚██║╚█████╔╝\n██║ ██║██║ ██║██╔═══██╗████╔╝██║ ██╔██╗ ██║██╔══██╗\n╚██████╔╝██████╔╝╚██████╔╝╚██████╔╝██╔╝ ██╗ ██║╚█████╔╝\n ╚═════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚════╝\n\n*/\n\nimport \"./ud60x18/Casting.sol\";\nimport \"./ud60x18/Constants.sol\";\nimport \"./ud60x18/Conversions.sol\";\nimport \"./ud60x18/Errors.sol\";\nimport \"./ud60x18/Helpers.sol\";\nimport \"./ud60x18/Math.sol\";\nimport \"./ud60x18/ValueType.sol\";\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/lib/LibWillOverflow.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./FixedPointDecimalConstants.sol\";\n\n/// @title LibWillOverflow\n/// @notice Often we want to know if some calculation is expected to overflow.\n/// Notably this is important for fuzzing as we have to be able to set\n/// expectations for arbitrary inputs over as broad a range of values as\n/// possible.\nlibrary LibWillOverflow {\n /// Relevant logic taken direct from Open Zeppelin.\n /// @param x As per Open Zeppelin.\n /// @param y As per Open Zeppelin.\n /// @param denominator As per Open Zeppelin.\n /// @return True if mulDiv will overflow.\n function mulDivWillOverflow(uint256 x, uint256 y, uint256 denominator) internal pure returns (bool) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n return !(denominator > prod1);\n }\n\n /// True if `scaleUp` will overflow.\n /// @param a The number to scale up.\n /// @param scaleBy The number of orders of magnitude to scale up by.\n /// @return True if `scaleUp` will overflow.\n function scaleUpWillOverflow(uint256 a, uint256 scaleBy) internal pure returns (bool) {\n unchecked {\n if (a == 0) {\n return false;\n }\n if (scaleBy >= OVERFLOW_RESCALE_OOMS) {\n return true;\n }\n uint256 b = 10 ** scaleBy;\n uint256 c = a * b;\n return c / b != a;\n }\n }\n\n /// True if `scaleDown` will round.\n /// @param a The number to scale down.\n /// @param scaleDownBy The number of orders of magnitude to scale down by.\n /// @return True if `scaleDown` will round.\n function scaleDownWillRound(uint256 a, uint256 scaleDownBy) internal pure returns (bool) {\n if (scaleDownBy >= OVERFLOW_RESCALE_OOMS) {\n return a != 0;\n }\n uint256 b = 10 ** scaleDownBy;\n uint256 c = a / b;\n // Discovering precision loss is the whole point of this check so the\n // thing slither is complaining about is exactly what we're measuring.\n //slither-disable-next-line divide-before-multiply\n return c * b != a;\n }\n\n /// True if `scale18` will overflow.\n /// @param a The number to scale.\n /// @param decimals The current number of decimals of `a`.\n /// @param flags The flags to use.\n /// @return True if `scale18` will overflow.\n function scale18WillOverflow(uint256 a, uint256 decimals, uint256 flags) internal pure returns (bool) {\n if (decimals < FIXED_POINT_DECIMALS && (FLAG_SATURATE & flags == 0)) {\n return scaleUpWillOverflow(a, FIXED_POINT_DECIMALS - decimals);\n } else {\n return false;\n }\n }\n\n /// True if `scaleN` will overflow.\n /// @param a The number to scale.\n /// @param decimals The current number of decimals of `a`.\n /// @param flags The flags to use.\n /// @return True if `scaleN` will overflow.\n function scaleNWillOverflow(uint256 a, uint256 decimals, uint256 flags) internal pure returns (bool) {\n if (decimals > FIXED_POINT_DECIMALS && (FLAG_SATURATE & flags == 0)) {\n return scaleUpWillOverflow(a, decimals - FIXED_POINT_DECIMALS);\n } else {\n return false;\n }\n }\n\n /// True if `scaleBy` will overflow.\n /// @param a The number to scale.\n /// @param scaleBy The number of orders of magnitude to scale by.\n /// @param flags The flags to use.\n /// @return True if `scaleBy` will overflow.\n function scaleByWillOverflow(uint256 a, int8 scaleBy, uint256 flags) internal pure returns (bool) {\n // If we're scaling up and not saturating check the overflow.\n if (scaleBy > 0 && (FLAG_SATURATE & flags == 0)) {\n return scaleUpWillOverflow(a, uint8(scaleBy));\n } else {\n return false;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/lib/LibFixedPointDecimalScale.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./FixedPointDecimalConstants.sol\";\n\n/// @title FixedPointDecimalScale\n/// @notice Tools to scale unsigned values to/from 18 decimal fixed point\n/// representation.\n///\n/// Overflows error and underflows are rounded up or down explicitly.\n///\n/// The max uint256 as decimal is roughly 1e77 so scaling values comparable to\n/// 1e18 is unlikely to ever overflow in most contexts. For a typical use case\n/// involving tokens, the entire supply of a token rescaled up a full 18 decimals\n/// would still put it \"only\" in the region of ~1e40 which has a full 30 orders\n/// of magnitude buffer before running into saturation issues. However, there's\n/// no theoretical reason that a token or any other use case couldn't use large\n/// numbers or extremely precise decimals that would push this library to\n/// overflow point, so it MUST be treated with caution around the edge cases.\n///\n/// Scaling down ANY fixed point decimal also reduces the precision which can\n/// lead to dust or in the worst case trapped funds if subsequent subtraction\n/// overflows a rounded-down number. Consider using saturating subtraction for\n/// safety against previously downscaled values, and whether trapped dust is a\n/// significant issue. If you need to retain full/arbitrary precision in the case\n/// of downscaling DO NOT use this library.\n///\n/// All rescaling and/or division operations in this library require a rounding\n/// flag. This allows and forces the caller to specify where dust sits due to\n/// rounding. For example the caller could round up when taking tokens from\n/// `msg.sender` and round down when returning them, ensuring that any dust in\n/// the round trip accumulates in the contract rather than opening an exploit or\n/// reverting and trapping all funds. This is exactly how the ERC4626 vault spec\n/// handles dust and is a good reference point in general. Typically the contract\n/// holding tokens and non-interactive participants should be favoured by\n/// rounding calculations rather than active participants. This is because we\n/// assume that an active participant, e.g. `msg.sender`, knowns something we\n/// don't and is carefully crafting an attack, so we are most conservative and\n/// suspicious of their inputs and actions.\nlibrary LibFixedPointDecimalScale {\n /// Scales `a` up by a specified number of decimals.\n /// @param a The number to scale up.\n /// @param scaleUpBy Number of orders of magnitude to scale `b_` up by.\n /// Errors if overflows.\n /// @return b `a` scaled up by `scaleUpBy`.\n function scaleUp(uint256 a, uint256 scaleUpBy) internal pure returns (uint256 b) {\n // Checked power is expensive so don't do that.\n unchecked {\n b = 10 ** scaleUpBy;\n }\n b = a * b;\n\n // We know exactly when 10 ** X overflows so replay the checked version\n // to get the standard Solidity overflow behaviour. The branching logic\n // here is still ~230 gas cheaper than unconditionally running the\n // overflow checks. We're optimising for standardisation rather than gas\n // in the unhappy revert case.\n if (scaleUpBy >= OVERFLOW_RESCALE_OOMS) {\n b = a == 0 ? 0 : 10 ** scaleUpBy;\n }\n }\n\n /// Identical to `scaleUp` but saturates instead of reverting on overflow.\n /// @param a As per `scaleUp`.\n /// @param scaleUpBy As per `scaleUp`.\n /// @return c As per `scaleUp` but saturates as `type(uint256).max` on\n /// overflow.\n function scaleUpSaturating(uint256 a, uint256 scaleUpBy) internal pure returns (uint256 c) {\n unchecked {\n if (scaleUpBy >= OVERFLOW_RESCALE_OOMS) {\n c = a == 0 ? 0 : type(uint256).max;\n } else {\n // Adapted from saturatingMath.\n // Inlining everything here saves ~250-300+ gas relative to slow.\n uint256 b_ = 10 ** scaleUpBy;\n c = a * b_;\n // Checking b_ here allows us to skip an \"is zero\" check because even\n // 10 ** 0 = 1, so we have a positive lower bound on b_.\n c = c / b_ == a ? c : type(uint256).max;\n }\n }\n }\n\n /// Scales `a` down by a specified number of decimals, rounding down.\n /// Used internally by several other functions in this lib.\n /// @param a The number to scale down.\n /// @param scaleDownBy Number of orders of magnitude to scale `a` down by.\n /// Overflows if greater than 77.\n /// @return c `a` scaled down by `scaleDownBy` and rounded down.\n function scaleDown(uint256 a, uint256 scaleDownBy) internal pure returns (uint256) {\n unchecked {\n return scaleDownBy >= OVERFLOW_RESCALE_OOMS ? 0 : a / (10 ** scaleDownBy);\n }\n }\n\n /// Scales `a` down by a specified number of decimals, rounding up.\n /// Used internally by several other functions in this lib.\n /// @param a The number to scale down.\n /// @param scaleDownBy Number of orders of magnitude to scale `a` down by.\n /// Overflows if greater than 77.\n /// @return c `a` scaled down by `scaleDownBy` and rounded up.\n function scaleDownRoundUp(uint256 a, uint256 scaleDownBy) internal pure returns (uint256 c) {\n unchecked {\n if (scaleDownBy >= OVERFLOW_RESCALE_OOMS) {\n c = a == 0 ? 0 : 1;\n } else {\n uint256 b = 10 ** scaleDownBy;\n c = a / b;\n\n // Intentionally doing a divide before multiply here to detect\n // the need to round up.\n //slither-disable-next-line divide-before-multiply\n if (a != c * b) {\n c += 1;\n }\n }\n }\n }\n\n /// Scale a fixed point decimal of some scale factor to 18 decimals.\n /// @param a Some fixed point decimal value.\n /// @param decimals The number of fixed decimals of `a`.\n /// @param flags Controls rounding and saturation.\n /// @return `a` scaled to 18 decimals.\n function scale18(uint256 a, uint256 decimals, uint256 flags) internal pure returns (uint256) {\n unchecked {\n if (FIXED_POINT_DECIMALS > decimals) {\n uint256 scaleUpBy = FIXED_POINT_DECIMALS - decimals;\n if (flags & FLAG_SATURATE > 0) {\n return scaleUpSaturating(a, scaleUpBy);\n } else {\n return scaleUp(a, scaleUpBy);\n }\n } else if (decimals > FIXED_POINT_DECIMALS) {\n uint256 scaleDownBy = decimals - FIXED_POINT_DECIMALS;\n if (flags & FLAG_ROUND_UP > 0) {\n return scaleDownRoundUp(a, scaleDownBy);\n } else {\n return scaleDown(a, scaleDownBy);\n }\n } else {\n return a;\n }\n }\n }\n\n /// Scale an 18 decimal fixed point value to some other scale.\n /// Exactly the inverse behaviour of `scale18`. Where `scale18` would scale\n /// up, `scaleN` scales down, and vice versa.\n /// @param a An 18 decimal fixed point number.\n /// @param targetDecimals The new scale of `a`.\n /// @param flags Controls rounding and saturation.\n /// @return `a` rescaled from 18 to `targetDecimals`.\n function scaleN(uint256 a, uint256 targetDecimals, uint256 flags) internal pure returns (uint256) {\n unchecked {\n if (FIXED_POINT_DECIMALS > targetDecimals) {\n uint256 scaleDownBy = FIXED_POINT_DECIMALS - targetDecimals;\n if (flags & FLAG_ROUND_UP > 0) {\n return scaleDownRoundUp(a, scaleDownBy);\n } else {\n return scaleDown(a, scaleDownBy);\n }\n } else if (targetDecimals > FIXED_POINT_DECIMALS) {\n uint256 scaleUpBy = targetDecimals - FIXED_POINT_DECIMALS;\n if (flags & FLAG_SATURATE > 0) {\n return scaleUpSaturating(a, scaleUpBy);\n } else {\n return scaleUp(a, scaleUpBy);\n }\n } else {\n return a;\n }\n }\n }\n\n /// Scale a fixed point up or down by `ooms` orders of magnitude.\n /// Notably `scaleBy` is a SIGNED integer so scaling down by negative OOMS\n /// IS supported.\n /// @param a Some integer of any scale.\n /// @param ooms OOMs to scale `a` up or down by. This is a SIGNED int8\n /// which means it can be negative, and also means that sign extension MUST\n /// be considered if changing it to another type.\n /// @param flags Controls rounding and saturating.\n /// @return `a` rescaled according to `ooms`.\n function scaleBy(uint256 a, int8 ooms, uint256 flags) internal pure returns (uint256) {\n unchecked {\n if (ooms > 0) {\n if (flags & FLAG_SATURATE > 0) {\n return scaleUpSaturating(a, uint8(ooms));\n } else {\n return scaleUp(a, uint8(ooms));\n }\n } else if (ooms < 0) {\n // We know that ooms is negative here, so we can convert it\n // to an absolute value with bitwise NOT + 1.\n // This is slightly less gas than multiplying by negative 1 and\n // casting it, and handles the case of -128 without overflow.\n uint8 scaleDownBy = uint8(~ooms) + 1;\n if (flags & FLAG_ROUND_UP > 0) {\n return scaleDownRoundUp(a, scaleDownBy);\n } else {\n return scaleDown(a, scaleDownBy);\n }\n } else {\n return a;\n }\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/sol.lib.binmaskflag/src/Binary.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev Binary 1.\nuint256 constant B_1 = 2 ** 1 - 1;\n/// @dev Binary 11.\nuint256 constant B_11 = 2 ** 2 - 1;\n/// @dev Binary 111.\nuint256 constant B_111 = 2 ** 3 - 1;\n/// @dev Binary 1111.\nuint256 constant B_1111 = 2 ** 4 - 1;\n/// @dev Binary 11111.\nuint256 constant B_11111 = 2 ** 5 - 1;\n/// @dev Binary 111111.\nuint256 constant B_111111 = 2 ** 6 - 1;\n/// @dev Binary 1111111.\nuint256 constant B_1111111 = 2 ** 7 - 1;\n/// @dev Binary 11111111.\nuint256 constant B_11111111 = 2 ** 8 - 1;\n/// @dev Binary 111111111.\nuint256 constant B_111111111 = 2 ** 9 - 1;\n/// @dev Binary 1111111111.\nuint256 constant B_1111111111 = 2 ** 10 - 1;\n/// @dev Binary 11111111111.\nuint256 constant B_11111111111 = 2 ** 11 - 1;\n/// @dev Binary 111111111111.\nuint256 constant B_111111111111 = 2 ** 12 - 1;\n/// @dev Binary 1111111111111.\nuint256 constant B_1111111111111 = 2 ** 13 - 1;\n/// @dev Binary 11111111111111.\nuint256 constant B_11111111111111 = 2 ** 14 - 1;\n/// @dev Binary 111111111111111.\nuint256 constant B_111111111111111 = 2 ** 15 - 1;\n/// @dev Binary 1111111111111111.\nuint256 constant B_1111111111111111 = 2 ** 16 - 1;\n\n/// @dev Bitmask for 1 bit.\nuint256 constant MASK_1BIT = B_1;\n/// @dev Bitmask for 2 bits.\nuint256 constant MASK_2BIT = B_11;\n/// @dev Bitmask for 3 bits.\nuint256 constant MASK_3BIT = B_111;\n/// @dev Bitmask for 4 bits.\nuint256 constant MASK_4BIT = B_1111;\n/// @dev Bitmask for 5 bits.\nuint256 constant MASK_5BIT = B_11111;\n/// @dev Bitmask for 6 bits.\nuint256 constant MASK_6BIT = B_111111;\n/// @dev Bitmask for 7 bits.\nuint256 constant MASK_7BIT = B_1111111;\n/// @dev Bitmask for 8 bits.\nuint256 constant MASK_8BIT = B_11111111;\n/// @dev Bitmask for 9 bits.\nuint256 constant MASK_9BIT = B_111111111;\n/// @dev Bitmask for 10 bits.\nuint256 constant MASK_10BIT = B_1111111111;\n/// @dev Bitmask for 11 bits.\nuint256 constant MASK_11BIT = B_11111111111;\n/// @dev Bitmask for 12 bits.\nuint256 constant MASK_12BIT = B_111111111111;\n/// @dev Bitmask for 13 bits.\nuint256 constant MASK_13BIT = B_1111111111111;\n/// @dev Bitmask for 14 bits.\nuint256 constant MASK_14BIT = B_11111111111111;\n/// @dev Bitmask for 15 bits.\nuint256 constant MASK_15BIT = B_111111111111111;\n/// @dev Bitmask for 16 bits.\nuint256 constant MASK_16BIT = B_1111111111111111;\n"
},
"lib/rain.flow/lib/rain.interpreter/src/lib/uniswap/LibUniswapV2.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"v2-core/interfaces/IUniswapV2Pair.sol\";\nimport \"v2-core/interfaces/IUniswapV2Factory.sol\";\n\n/// UniswapV2Library from uniswap/v2-periphery is compiled with a version of\n/// SafeMath that is locked to Solidity 0.6.x which means we can't use it in\n/// Solidity 0.8.x. This is a copy of the library with the SafeMath dependency\n/// removed, using Solidity's built-in overflow checking.\n/// Some minor modifications have been made to the reference functions. These\n/// are noted in the comments and/or made explicit by descriptively renaming the\n/// functions to differentiate them from the original.\nlibrary LibUniswapV2 {\n /// Copy of UniswapV2Library.sortTokens for solidity 0.8.x support.\n function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {\n require(tokenA != tokenB, \"UniswapV2Library: IDENTICAL_ADDRESSES\");\n (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);\n require(token0 != address(0), \"UniswapV2Library: ZERO_ADDRESS\");\n }\n\n /// Copy of UniswapV2Library.pairFor for solidity 0.8.x support.\n function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {\n (address token0, address token1) = sortTokens(tokenA, tokenB);\n pair = address(\n uint160(\n uint256(\n keccak256(\n abi.encodePacked(\n hex\"ff\",\n factory,\n keccak256(abi.encodePacked(token0, token1)),\n hex\"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f\" // init code hash\n )\n )\n )\n )\n );\n }\n\n /// UniswapV2Library.sol has a `getReserves` function but it discards the\n /// timestamp that the pair reserves were last updated at. This function\n /// duplicates the logic of `getReserves` but returns the timestamp as well.\n function getReservesWithTime(address factory, address tokenA, address tokenB)\n internal\n view\n returns (uint256 reserveA, uint256 reserveB, uint256 timestamp)\n {\n (address token0,) = sortTokens(tokenA, tokenB);\n // Reference implementation uses `pairFor` but for some reason this\n // doesn't seem to work on sushi's factory. Using `getPair` instead.\n // @todo investigate the discrepency.\n address pair = IUniswapV2Factory(factory).getPair(tokenA, tokenB);\n (uint256 reserve0, uint256 reserve1, uint256 blockTimestampLast) = IUniswapV2Pair(pair).getReserves();\n (reserveA, reserveB, timestamp) =\n tokenA == token0 ? (reserve0, reserve1, blockTimestampLast) : (reserve1, reserve0, blockTimestampLast);\n }\n\n /// Copy of UniswapV2Library.getAmountIn for solidity 0.8.x support.\n function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut)\n internal\n pure\n returns (uint256 amountIn)\n {\n require(amountOut > 0, \"UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 numerator = reserveIn * amountOut * 1000;\n uint256 denominator = (reserveOut - amountOut) * 997;\n amountIn = (numerator / denominator) + 1;\n }\n\n /// Copy of UniswapV2Library.getAmountOut for solidity 0.8.x support.\n function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut)\n internal\n pure\n returns (uint256 amountOut)\n {\n require(amountIn > 0, \"UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT\");\n require(reserveIn > 0 && reserveOut > 0, \"UniswapV2Library: INSUFFICIENT_LIQUIDITY\");\n uint256 amountInWithFee = amountIn * 997;\n uint256 numerator = amountInWithFee * reserveOut;\n uint256 denominator = (reserveIn * 1000) + amountInWithFee;\n amountOut = numerator / denominator;\n }\n\n /// Bundles the key library logic together to produce amounts based on tokens\n /// and amounts out rather than needing to handle reserves directly.\n /// Also maps 0 amountOut to 0 amountIn unconditionally, which is different\n /// to the reference implementation.\n function getAmountInByTokenWithTime(address factory, address tokenIn, address tokenOut, uint256 amountOut)\n internal\n view\n returns (uint256 amountIn, uint256 timestamp)\n {\n (uint256 reserveIn, uint256 reserveOut, uint256 reserveTimestamp) =\n getReservesWithTime(factory, tokenIn, tokenOut);\n // Perform the 0 amountOut to 0 amountIn mapping after getting the\n // reserves so that we still error on invalid reserves.\n amountIn = amountOut == 0 ? 0 : getAmountIn(amountOut, reserveIn, reserveOut);\n timestamp = reserveTimestamp;\n }\n\n /// Bundles the key library logic together to produce amounts based on tokens\n /// and amounts in rather than needing to handle reserves directly.\n /// Also maps 0 amountIn to 0 amountOut unconditionally, which is different\n /// to the reference implementation.\n function getAmountOutByTokenWithTime(address factory, address tokenIn, address tokenOut, uint256 amountIn)\n internal\n view\n returns (uint256 amountOut, uint256 timestamp)\n {\n (uint256 reserveIn, uint256 reserveOut, uint256 reserveTimestamp) =\n getReservesWithTime(factory, tokenIn, tokenOut);\n // Perform the 0 amountIn to 0 amountOut mapping after getting the\n // reserves so that we still error on invalid reserves.\n amountOut = amountIn == 0 ? 0 : getAmountOut(amountIn, reserveIn, reserveOut);\n timestamp = reserveTimestamp;\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Casting.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_SD59x18 } from \"../sd59x18/Constants.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD60x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD60x18 x) pure returns (SD1x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(int256(uMAX_SD1x18))) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(uint64(xUint)));\n}\n\n/// @notice Casts a UD60x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(UD60x18 x) pure returns (UD2x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uMAX_UD2x18) {\n revert CastingErrors.PRBMath_UD60x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(xUint));\n}\n\n/// @notice Casts a UD60x18 number into SD59x18.\n/// @dev Requirements:\n/// - x must be less than or equal to `uMAX_SD59x18`.\nfunction intoSD59x18(UD60x18 x) pure returns (SD59x18 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > uint256(uMAX_SD59x18)) {\n revert CastingErrors.PRBMath_UD60x18_IntoSD59x18_Overflow(x);\n }\n result = SD59x18.wrap(int256(xUint));\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev This is basically an alias for {unwrap}.\nfunction intoUint256(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Casts a UD60x18 number into uint128.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT128`.\nfunction intoUint128(UD60x18 x) pure returns (uint128 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT128) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint128_Overflow(x);\n }\n result = uint128(xUint);\n}\n\n/// @notice Casts a UD60x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD60x18 x) pure returns (uint40 result) {\n uint256 xUint = UD60x18.unwrap(x);\n if (xUint > MAX_UINT40) {\n revert CastingErrors.PRBMath_UD60x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud60x18(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n\n/// @notice Unwraps a UD60x18 number into uint256.\nfunction unwrap(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x);\n}\n\n/// @notice Wraps a uint256 number into the UD60x18 value type.\nfunction wrap(uint256 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(x);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as a UD60x18 number.\nUD60x18 constant E = UD60x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nuint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nUD60x18 constant EXP_MAX_INPUT = UD60x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nuint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nUD60x18 constant EXP2_MAX_INPUT = UD60x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nuint256 constant uHALF_UNIT = 0.5e18;\nUD60x18 constant HALF_UNIT = UD60x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as a UD60x18 number.\nuint256 constant uLOG2_10 = 3_321928094887362347;\nUD60x18 constant LOG2_10 = UD60x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as a UD60x18 number.\nuint256 constant uLOG2_E = 1_442695040888963407;\nUD60x18 constant LOG2_E = UD60x18.wrap(uLOG2_E);\n\n/// @dev The maximum value a UD60x18 number can have.\nuint256 constant uMAX_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_584007913129639935;\nUD60x18 constant MAX_UD60x18 = UD60x18.wrap(uMAX_UD60x18);\n\n/// @dev The maximum whole value a UD60x18 number can have.\nuint256 constant uMAX_WHOLE_UD60x18 = 115792089237316195423570985008687907853269984665640564039457_000000000000000000;\nUD60x18 constant MAX_WHOLE_UD60x18 = UD60x18.wrap(uMAX_WHOLE_UD60x18);\n\n/// @dev PI as a UD60x18 number.\nUD60x18 constant PI = UD60x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD60x18.\nuint256 constant uUNIT = 1e18;\nUD60x18 constant UNIT = UD60x18.wrap(uUNIT);\n\n/// @dev The unit number squared.\nuint256 constant uUNIT_SQUARED = 1e36;\nUD60x18 constant UNIT_SQUARED = UD60x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as a UD60x18 number.\nUD60x18 constant ZERO = UD60x18.wrap(0);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Conversions.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { uMAX_UD60x18, uUNIT } from \"./Constants.sol\";\nimport { PRBMath_UD60x18_Convert_Overflow } from \"./Errors.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Converts a UD60x18 number to a simple integer by dividing it by `UNIT`.\n/// @dev The result is rounded toward zero.\n/// @param x The UD60x18 number to convert.\n/// @return result The same number in basic integer form.\nfunction convert(UD60x18 x) pure returns (uint256 result) {\n result = UD60x18.unwrap(x) / uUNIT;\n}\n\n/// @notice Converts a simple integer to UD60x18 by multiplying it by `UNIT`.\n///\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UD60x18 / UNIT`.\n///\n/// @param x The basic integer to convert.\n/// @param result The same number converted to UD60x18.\nfunction convert(uint256 x) pure returns (UD60x18 result) {\n if (x > uMAX_UD60x18 / uUNIT) {\n revert PRBMath_UD60x18_Convert_Overflow(x);\n }\n unchecked {\n result = UD60x18.wrap(x * uUNIT);\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Errors.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when ceiling a number overflows UD60x18.\nerror PRBMath_UD60x18_Ceil_Overflow(UD60x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows UD60x18.\nerror PRBMath_UD60x18_Convert_Overflow(uint256 x);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_UD60x18_Exp_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_UD60x18_Exp2_InputTooBig(UD60x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows UD60x18.\nerror PRBMath_UD60x18_Gm_Overflow(UD60x18 x, UD60x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD60x18_IntoSD1x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD59x18.\nerror PRBMath_UD60x18_IntoSD59x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_UD60x18_IntoUD2x18_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_UD60x18_IntoUint128_Overflow(UD60x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_UD60x18_IntoUint40_Overflow(UD60x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than 1.\nerror PRBMath_UD60x18_Log_InputTooSmall(UD60x18 x);\n\n/// @notice Thrown when calculating the square root overflows UD60x18.\nerror PRBMath_UD60x18_Sqrt_Overflow(UD60x18 x);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Helpers.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the UD60x18 type.\nfunction add(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the UD60x18 type.\nfunction and2(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal operation (==) in the UD60x18 type.\nfunction eq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the UD60x18 type.\nfunction gt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the UD60x18 type.\nfunction gte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the UD60x18 type.\nfunction isZero(UD60x18 x) pure returns (bool result) {\n // This wouldn't work if x could be negative.\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the UD60x18 type.\nfunction lshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the UD60x18 type.\nfunction lt(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the UD60x18 type.\nfunction lte(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the checked modulo operation (%) in the UD60x18 type.\nfunction mod(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the UD60x18 type.\nfunction neq(UD60x18 x, UD60x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the UD60x18 type.\nfunction not(UD60x18 x) pure returns (UD60x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the UD60x18 type.\nfunction or(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the UD60x18 type.\nfunction rshift(UD60x18 x, uint256 bits) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the UD60x18 type.\nfunction sub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the UD60x18 type.\nfunction uncheckedAdd(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the UD60x18 type.\nfunction uncheckedSub(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the UD60x18 type.\nfunction xor(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { wrap } from \"./Casting.sol\";\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_UD60x18,\n uMAX_WHOLE_UD60x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { UD60x18 } from \"./ValueType.sol\";\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the arithmetic average of x and y using the following formula:\n///\n/// $$\n/// avg(x, y) = (x & y) + ((xUint ^ yUint) / 2)\n/// $$\n//\n/// In English, this is what this formula does:\n///\n/// 1. AND x and y.\n/// 2. Calculate half of XOR x and y.\n/// 3. Add the two results together.\n///\n/// This technique is known as SWAR, which stands for \"SIMD within a register\". You can read more about it here:\n/// https://devblogs.microsoft.com/oldnewthing/20220207-00/?p=106223\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The arithmetic average as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n unchecked {\n result = wrap((xUint & yUint) + ((xUint ^ yUint) >> 1));\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev This is optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_UD60x18`.\n///\n/// @param x The UD60x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint > uMAX_WHOLE_UD60x18) {\n revert Errors.PRBMath_UD60x18_Ceil_Overflow(x);\n }\n\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `UNIT - remainder`.\n let delta := sub(uUNIT, remainder)\n\n // Equivalent to `x + remainder > 0 ? delta : 0`.\n result := add(x, mul(delta, gt(remainder, 0)))\n }\n}\n\n/// @notice Divides two UD60x18 numbers, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @param x The numerator as a UD60x18 number.\n/// @param y The denominator as a UD60x18 number.\n/// @param result The quotient as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv(x.unwrap(), uUNIT, y.unwrap()));\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Requirements:\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xUint > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n uint256 doubleUnitProduct = xUint * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in UD60x18.\n///\n/// @param x The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xUint > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_UD60x18_Exp2_InputTooBig(x);\n }\n\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = (xUint << 64) / uUNIT;\n\n // Pass x to the {Common.exp2} function, which uses the 192.64-bit fixed-point number representation.\n result = wrap(Common.exp2(x_192x64));\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n/// @param x The UD60x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n // Equivalent to `x % UNIT`.\n let remainder := mod(x, uUNIT)\n\n // Equivalent to `x - remainder > 0 ? remainder : 0)`.\n result := sub(x, mul(remainder, gt(remainder, 0)))\n }\n}\n\n/// @notice Yields the excess beyond the floor of x using the odd function definition.\n/// @dev See https://en.wikipedia.org/wiki/Fractional_part.\n/// @param x The UD60x18 number to get the fractional part of.\n/// @param result The fractional part of x as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction frac(UD60x18 x) pure returns (UD60x18 result) {\n assembly (\"memory-safe\") {\n result := mod(x, uUNIT)\n }\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$, rounding down.\n///\n/// @dev Requirements:\n/// - x * y must fit in UD60x18.\n///\n/// @param x The first operand as a UD60x18 number.\n/// @param y The second operand as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n if (xUint == 0 || yUint == 0) {\n return ZERO;\n }\n\n unchecked {\n // Checking for overflow this way is faster than letting Solidity do it.\n uint256 xyUint = xUint * yUint;\n if (xyUint / xUint != yUint) {\n revert Errors.PRBMath_UD60x18_Gm_Overflow(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n result = wrap(Common.sqrt(xyUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The UD60x18 number for which to calculate the inverse.\n/// @return result The inverse as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n }\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(UD60x18 x) pure returns (UD60x18 result) {\n unchecked {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~196_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n }\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The UD60x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this assembly block is the standard multiplication operation, not {UD60x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 59) }\n default { result := uMAX_UD60x18 }\n }\n\n if (result.unwrap() == uMAX_UD60x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The UD60x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n if (xUint < uUNIT) {\n revert Errors.PRBMath_UD60x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(xUint / uUNIT);\n\n // This is the integer part of the logarithm as a UD60x18 number. The operation can't overflow because n\n // n is at most 255 and UNIT is 1e18.\n uint256 resultUint = n * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n uint256 y = xUint >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultUint);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n uint256 DOUBLE_UNIT = 2e18;\n for (uint256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultUint += delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n result = wrap(resultUint);\n }\n}\n\n/// @notice Multiplies two UD60x18 numbers together, returning a new UD60x18 number.\n///\n/// @dev Uses {Common.mulDiv} to enable overflow-safe multiplication and division.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n///\n/// @dev See the documentation in {Common.mulDiv18}.\n/// @param x The multiplicand as a UD60x18 number.\n/// @param y The multiplier as a UD60x18 number.\n/// @return result The product as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n result = wrap(Common.mulDiv18(x.unwrap(), y.unwrap()));\n}\n\n/// @notice Raises x to the power of y.\n///\n/// For $1 \\leq x \\leq \\infty$, the following standard formula is used:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, since the unsigned {log2} is undefined, an equivalent formula is used:\n///\n/// $$\n/// i = \\frac{1}{x}\n/// w = 2^{log_2{i} * y}\n/// x^y = \\frac{1}{w}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2} and {mul}.\n/// - Returns `UNIT` for 0^0.\n/// - It may not perform well with very small values of x. Consider using SD59x18 as an alternative.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a UD60x18 number.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(UD60x18 x, UD60x18 y) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n uint256 yUint = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xUint == 0) {\n return yUint == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xUint == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yUint == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yUint == uUNIT) {\n return x;\n }\n\n // If x is greater than `UNIT`, use the standard formula.\n if (xUint > uUNIT) {\n result = exp2(mul(log2(x), y));\n }\n // Conversely, if x is less than `UNIT`, use the equivalent formula.\n else {\n UD60x18 i = wrap(uUNIT_SQUARED / xUint);\n UD60x18 w = exp2(mul(log2(i), y));\n result = wrap(uUNIT_SQUARED / w.unwrap());\n }\n}\n\n/// @notice Raises x (a UD60x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - The result must fit in UD60x18.\n///\n/// @param x The base as a UD60x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(UD60x18 x, uint256 y) pure returns (UD60x18 result) {\n // Calculate the first iteration of the loop in advance.\n uint256 xUint = x.unwrap();\n uint256 resultUint = y & 1 > 0 ? xUint : uUNIT;\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n for (y >>= 1; y > 0; y >>= 1) {\n xUint = Common.mulDiv18(xUint, xUint);\n\n // Equivalent to `y % 2 == 1`.\n if (y & 1 > 0) {\n resultUint = Common.mulDiv18(resultUint, xUint);\n }\n }\n result = wrap(resultUint);\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must be less than `MAX_UD60x18 / UNIT`.\n///\n/// @param x The UD60x18 number for which to calculate the square root.\n/// @return result The result as a UD60x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(UD60x18 x) pure returns (UD60x18 result) {\n uint256 xUint = x.unwrap();\n\n unchecked {\n if (xUint > uMAX_UD60x18 / uUNIT) {\n revert Errors.PRBMath_UD60x18_Sqrt_Overflow(x);\n }\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two UD60x18 numbers.\n // In this case, the two numbers are both the square root.\n result = wrap(Common.sqrt(xUint * uUNIT));\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud60x18/ValueType.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The unsigned 60.18-decimal fixed-point number representation, which can have up to 60 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the Solidity type uint256.\n/// @dev The value type is defined here so it can be imported in all other files.\ntype UD60x18 is uint256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoSD59x18,\n Casting.intoUint128,\n Casting.intoUint256,\n Casting.intoUint40,\n Casting.unwrap\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.ln,\n Math.log10,\n Math.log2,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes the functions in this library callable on the UD60x18 type.\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.xor\n} for UD60x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the UD60x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.or as |,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.sub as -,\n Helpers.xor as ^\n} for UD60x18 global;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/lib/FixedPointDecimalConstants.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev The scale of all fixed point math. This is adopting the conventions of\n/// both ETH (wei) and most ERC20 tokens, so is hopefully uncontroversial.\nuint256 constant FIXED_POINT_DECIMALS = 18;\n\n/// @dev Value of \"one\" for fixed point math.\nuint256 constant FIXED_POINT_ONE = 1e18;\n\n/// @dev Calculations MUST round up.\nuint256 constant FLAG_ROUND_UP = 1;\n\n/// @dev Calculations MUST saturate NOT overflow.\nuint256 constant FLAG_SATURATE = 1 << 1;\n\n/// @dev Flags MUST NOT exceed this value.\nuint256 constant FLAG_MAX_INT = FLAG_SATURATE | FLAG_ROUND_UP;\n\n/// @dev Can't represent this many OOMs of decimals in `uint256`.\nuint256 constant OVERFLOW_RESCALE_OOMS = 78;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/v2-core/contracts/interfaces/IUniswapV2Pair.sol": {
"content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n function name() external pure returns (string memory);\n function symbol() external pure returns (string memory);\n function decimals() external pure returns (uint8);\n function totalSupply() external view returns (uint);\n function balanceOf(address owner) external view returns (uint);\n function allowance(address owner, address spender) external view returns (uint);\n\n function approve(address spender, uint value) external returns (bool);\n function transfer(address to, uint value) external returns (bool);\n function transferFrom(address from, address to, uint value) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n function nonces(address owner) external view returns (uint);\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n event Mint(address indexed sender, uint amount0, uint amount1);\n event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint amount0In,\n uint amount1In,\n uint amount0Out,\n uint amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint);\n function factory() external view returns (address);\n function token0() external view returns (address);\n function token1() external view returns (address);\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n function price0CumulativeLast() external view returns (uint);\n function price1CumulativeLast() external view returns (uint);\n function kLast() external view returns (uint);\n\n function mint(address to) external returns (uint liquidity);\n function burn(address to) external returns (uint amount0, uint amount1);\n function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n function skim(address to) external;\n function sync() external;\n\n function initialize(address, address) external;\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/v2-core/contracts/interfaces/IUniswapV2Factory.sol": {
"content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Factory {\n event PairCreated(address indexed token0, address indexed token1, address pair, uint);\n\n function feeTo() external view returns (address);\n function feeToSetter() external view returns (address);\n\n function getPair(address tokenA, address tokenB) external view returns (address pair);\n function allPairs(uint) external view returns (address pair);\n function allPairsLength() external view returns (uint);\n\n function createPair(address tokenA, address tokenB) external returns (address pair);\n\n function setFeeTo(address) external;\n function setFeeToSetter(address) external;\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/Common.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\n// Common.sol\n//\n// Common mathematical functions needed by both SD59x18 and UD60x18. Note that these global functions do not\n// always operate with SD59x18 and UD60x18 numbers.\n\n/*//////////////////////////////////////////////////////////////////////////\n CUSTOM ERRORS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Thrown when the resultant value in {mulDiv} overflows uint256.\nerror PRBMath_MulDiv_Overflow(uint256 x, uint256 y, uint256 denominator);\n\n/// @notice Thrown when the resultant value in {mulDiv18} overflows uint256.\nerror PRBMath_MulDiv18_Overflow(uint256 x, uint256 y);\n\n/// @notice Thrown when one of the inputs passed to {mulDivSigned} is `type(int256).min`.\nerror PRBMath_MulDivSigned_InputTooSmall();\n\n/// @notice Thrown when the resultant value in {mulDivSigned} overflows int256.\nerror PRBMath_MulDivSigned_Overflow(int256 x, int256 y);\n\n/*//////////////////////////////////////////////////////////////////////////\n CONSTANTS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @dev The maximum value a uint128 number can have.\nuint128 constant MAX_UINT128 = type(uint128).max;\n\n/// @dev The maximum value a uint40 number can have.\nuint40 constant MAX_UINT40 = type(uint40).max;\n\n/// @dev The unit number, which the decimal precision of the fixed-point types.\nuint256 constant UNIT = 1e18;\n\n/// @dev The unit number inverted mod 2^256.\nuint256 constant UNIT_INVERSE = 78156646155174841979727994598816262306175212592076161876661_508869554232690281;\n\n/// @dev The the largest power of two that divides the decimal value of `UNIT`. The logarithm of this value is the least significant\n/// bit in the binary representation of `UNIT`.\nuint256 constant UNIT_LPOTD = 262144;\n\n/*//////////////////////////////////////////////////////////////////////////\n FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\n/// @notice Calculates the binary exponent of x using the binary fraction method.\n/// @dev Has to use 192.64-bit fixed-point numbers. See https://ethereum.stackexchange.com/a/96594/24693.\n/// @param x The exponent as an unsigned 192.64-bit fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(uint256 x) pure returns (uint256 result) {\n unchecked {\n // Start from 0.5 in the 192.64-bit fixed-point format.\n result = 0x800000000000000000000000000000000000000000000000;\n\n // The following logic multiplies the result by $\\sqrt{2^{-i}}$ when the bit at position i is 1. Key points:\n //\n // 1. Intermediate results will not overflow, as the starting point is 2^191 and all magic factors are under 2^65.\n // 2. The rationale for organizing the if statements into groups of 8 is gas savings. If the result of performing\n // a bitwise AND operation between x and any value in the array [0x80; 0x40; 0x20; 0x10; 0x08; 0x04; 0x02; 0x01] is 1,\n // we know that `x & 0xFF` is also 1.\n if (x & 0xFF00000000000000 > 0) {\n if (x & 0x8000000000000000 > 0) {\n result = (result * 0x16A09E667F3BCC909) >> 64;\n }\n if (x & 0x4000000000000000 > 0) {\n result = (result * 0x1306FE0A31B7152DF) >> 64;\n }\n if (x & 0x2000000000000000 > 0) {\n result = (result * 0x1172B83C7D517ADCE) >> 64;\n }\n if (x & 0x1000000000000000 > 0) {\n result = (result * 0x10B5586CF9890F62A) >> 64;\n }\n if (x & 0x800000000000000 > 0) {\n result = (result * 0x1059B0D31585743AE) >> 64;\n }\n if (x & 0x400000000000000 > 0) {\n result = (result * 0x102C9A3E778060EE7) >> 64;\n }\n if (x & 0x200000000000000 > 0) {\n result = (result * 0x10163DA9FB33356D8) >> 64;\n }\n if (x & 0x100000000000000 > 0) {\n result = (result * 0x100B1AFA5ABCBED61) >> 64;\n }\n }\n\n if (x & 0xFF000000000000 > 0) {\n if (x & 0x80000000000000 > 0) {\n result = (result * 0x10058C86DA1C09EA2) >> 64;\n }\n if (x & 0x40000000000000 > 0) {\n result = (result * 0x1002C605E2E8CEC50) >> 64;\n }\n if (x & 0x20000000000000 > 0) {\n result = (result * 0x100162F3904051FA1) >> 64;\n }\n if (x & 0x10000000000000 > 0) {\n result = (result * 0x1000B175EFFDC76BA) >> 64;\n }\n if (x & 0x8000000000000 > 0) {\n result = (result * 0x100058BA01FB9F96D) >> 64;\n }\n if (x & 0x4000000000000 > 0) {\n result = (result * 0x10002C5CC37DA9492) >> 64;\n }\n if (x & 0x2000000000000 > 0) {\n result = (result * 0x1000162E525EE0547) >> 64;\n }\n if (x & 0x1000000000000 > 0) {\n result = (result * 0x10000B17255775C04) >> 64;\n }\n }\n\n if (x & 0xFF0000000000 > 0) {\n if (x & 0x800000000000 > 0) {\n result = (result * 0x1000058B91B5BC9AE) >> 64;\n }\n if (x & 0x400000000000 > 0) {\n result = (result * 0x100002C5C89D5EC6D) >> 64;\n }\n if (x & 0x200000000000 > 0) {\n result = (result * 0x10000162E43F4F831) >> 64;\n }\n if (x & 0x100000000000 > 0) {\n result = (result * 0x100000B1721BCFC9A) >> 64;\n }\n if (x & 0x80000000000 > 0) {\n result = (result * 0x10000058B90CF1E6E) >> 64;\n }\n if (x & 0x40000000000 > 0) {\n result = (result * 0x1000002C5C863B73F) >> 64;\n }\n if (x & 0x20000000000 > 0) {\n result = (result * 0x100000162E430E5A2) >> 64;\n }\n if (x & 0x10000000000 > 0) {\n result = (result * 0x1000000B172183551) >> 64;\n }\n }\n\n if (x & 0xFF00000000 > 0) {\n if (x & 0x8000000000 > 0) {\n result = (result * 0x100000058B90C0B49) >> 64;\n }\n if (x & 0x4000000000 > 0) {\n result = (result * 0x10000002C5C8601CC) >> 64;\n }\n if (x & 0x2000000000 > 0) {\n result = (result * 0x1000000162E42FFF0) >> 64;\n }\n if (x & 0x1000000000 > 0) {\n result = (result * 0x10000000B17217FBB) >> 64;\n }\n if (x & 0x800000000 > 0) {\n result = (result * 0x1000000058B90BFCE) >> 64;\n }\n if (x & 0x400000000 > 0) {\n result = (result * 0x100000002C5C85FE3) >> 64;\n }\n if (x & 0x200000000 > 0) {\n result = (result * 0x10000000162E42FF1) >> 64;\n }\n if (x & 0x100000000 > 0) {\n result = (result * 0x100000000B17217F8) >> 64;\n }\n }\n\n if (x & 0xFF000000 > 0) {\n if (x & 0x80000000 > 0) {\n result = (result * 0x10000000058B90BFC) >> 64;\n }\n if (x & 0x40000000 > 0) {\n result = (result * 0x1000000002C5C85FE) >> 64;\n }\n if (x & 0x20000000 > 0) {\n result = (result * 0x100000000162E42FF) >> 64;\n }\n if (x & 0x10000000 > 0) {\n result = (result * 0x1000000000B17217F) >> 64;\n }\n if (x & 0x8000000 > 0) {\n result = (result * 0x100000000058B90C0) >> 64;\n }\n if (x & 0x4000000 > 0) {\n result = (result * 0x10000000002C5C860) >> 64;\n }\n if (x & 0x2000000 > 0) {\n result = (result * 0x1000000000162E430) >> 64;\n }\n if (x & 0x1000000 > 0) {\n result = (result * 0x10000000000B17218) >> 64;\n }\n }\n\n if (x & 0xFF0000 > 0) {\n if (x & 0x800000 > 0) {\n result = (result * 0x1000000000058B90C) >> 64;\n }\n if (x & 0x400000 > 0) {\n result = (result * 0x100000000002C5C86) >> 64;\n }\n if (x & 0x200000 > 0) {\n result = (result * 0x10000000000162E43) >> 64;\n }\n if (x & 0x100000 > 0) {\n result = (result * 0x100000000000B1721) >> 64;\n }\n if (x & 0x80000 > 0) {\n result = (result * 0x10000000000058B91) >> 64;\n }\n if (x & 0x40000 > 0) {\n result = (result * 0x1000000000002C5C8) >> 64;\n }\n if (x & 0x20000 > 0) {\n result = (result * 0x100000000000162E4) >> 64;\n }\n if (x & 0x10000 > 0) {\n result = (result * 0x1000000000000B172) >> 64;\n }\n }\n\n if (x & 0xFF00 > 0) {\n if (x & 0x8000 > 0) {\n result = (result * 0x100000000000058B9) >> 64;\n }\n if (x & 0x4000 > 0) {\n result = (result * 0x10000000000002C5D) >> 64;\n }\n if (x & 0x2000 > 0) {\n result = (result * 0x1000000000000162E) >> 64;\n }\n if (x & 0x1000 > 0) {\n result = (result * 0x10000000000000B17) >> 64;\n }\n if (x & 0x800 > 0) {\n result = (result * 0x1000000000000058C) >> 64;\n }\n if (x & 0x400 > 0) {\n result = (result * 0x100000000000002C6) >> 64;\n }\n if (x & 0x200 > 0) {\n result = (result * 0x10000000000000163) >> 64;\n }\n if (x & 0x100 > 0) {\n result = (result * 0x100000000000000B1) >> 64;\n }\n }\n\n if (x & 0xFF > 0) {\n if (x & 0x80 > 0) {\n result = (result * 0x10000000000000059) >> 64;\n }\n if (x & 0x40 > 0) {\n result = (result * 0x1000000000000002C) >> 64;\n }\n if (x & 0x20 > 0) {\n result = (result * 0x10000000000000016) >> 64;\n }\n if (x & 0x10 > 0) {\n result = (result * 0x1000000000000000B) >> 64;\n }\n if (x & 0x8 > 0) {\n result = (result * 0x10000000000000006) >> 64;\n }\n if (x & 0x4 > 0) {\n result = (result * 0x10000000000000003) >> 64;\n }\n if (x & 0x2 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n if (x & 0x1 > 0) {\n result = (result * 0x10000000000000001) >> 64;\n }\n }\n\n // In the code snippet below, two operations are executed simultaneously:\n //\n // 1. The result is multiplied by $(2^n + 1)$, where $2^n$ represents the integer part, and the additional 1\n // accounts for the initial guess of 0.5. This is achieved by subtracting from 191 instead of 192.\n // 2. The result is then converted to an unsigned 60.18-decimal fixed-point format.\n //\n // The underlying logic is based on the relationship $2^{191-ip} = 2^{ip} / 2^{191}$, where $ip$ denotes the,\n // integer part, $2^n$.\n result *= UNIT;\n result >>= (191 - (x >> 64));\n }\n}\n\n/// @notice Finds the zero-based index of the first 1 in the binary representation of x.\n///\n/// @dev See the note on \"msb\" in this Wikipedia article: https://en.wikipedia.org/wiki/Find_first_set\n///\n/// Each step in this implementation is equivalent to this high-level code:\n///\n/// ```solidity\n/// if (x >= 2 ** 128) {\n/// x >>= 128;\n/// result += 128;\n/// }\n/// ```\n///\n/// Where 128 is replaced with each respective power of two factor. See the full high-level implementation here:\n/// https://gist.github.com/PaulRBerg/f932f8693f2733e30c4d479e8e980948\n///\n/// The Yul instructions used below are:\n///\n/// - \"gt\" is \"greater than\"\n/// - \"or\" is the OR bitwise operator\n/// - \"shl\" is \"shift left\"\n/// - \"shr\" is \"shift right\"\n///\n/// @param x The uint256 number for which to find the index of the most significant bit.\n/// @return result The index of the most significant bit as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction msb(uint256 x) pure returns (uint256 result) {\n // 2^128\n assembly (\"memory-safe\") {\n let factor := shl(7, gt(x, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^64\n assembly (\"memory-safe\") {\n let factor := shl(6, gt(x, 0xFFFFFFFFFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^32\n assembly (\"memory-safe\") {\n let factor := shl(5, gt(x, 0xFFFFFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^16\n assembly (\"memory-safe\") {\n let factor := shl(4, gt(x, 0xFFFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^8\n assembly (\"memory-safe\") {\n let factor := shl(3, gt(x, 0xFF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^4\n assembly (\"memory-safe\") {\n let factor := shl(2, gt(x, 0xF))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^2\n assembly (\"memory-safe\") {\n let factor := shl(1, gt(x, 0x3))\n x := shr(factor, x)\n result := or(result, factor)\n }\n // 2^1\n // No need to shift x any more.\n assembly (\"memory-safe\") {\n let factor := gt(x, 0x1)\n result := or(result, factor)\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev Credits to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - The denominator must not be zero.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as a uint256.\n/// @param y The multiplier as a uint256.\n/// @param denominator The divisor as a uint256.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv(uint256 x, uint256 y, uint256 denominator) pure returns (uint256 result) {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512-bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n unchecked {\n return prod0 / denominator;\n }\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (prod1 >= denominator) {\n revert PRBMath_MulDiv_Overflow(x, y, denominator);\n }\n\n ////////////////////////////////////////////////////////////////////////////\n // 512 by 256 division\n ////////////////////////////////////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly (\"memory-safe\") {\n // Compute remainder using the mulmod Yul instruction.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512-bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n unchecked {\n // Calculate the largest power of two divisor of the denominator using the unary operator ~. This operation cannot overflow\n // because the denominator cannot be zero at this point in the function execution. The result is always >= 1.\n // For more detail, see https://cs.stackexchange.com/q/138556/92363.\n uint256 lpotdod = denominator & (~denominator + 1);\n uint256 flippedLpotdod;\n\n assembly (\"memory-safe\") {\n // Factor powers of two out of denominator.\n denominator := div(denominator, lpotdod)\n\n // Divide [prod1 prod0] by lpotdod.\n prod0 := div(prod0, lpotdod)\n\n // Get the flipped value `2^256 / lpotdod`. If the `lpotdod` is zero, the flipped value is one.\n // `sub(0, lpotdod)` produces the two's complement version of `lpotdod`, which is equivalent to flipping all the bits.\n // However, `div` interprets this value as an unsigned value: https://ethereum.stackexchange.com/q/147168/24693\n flippedLpotdod := add(div(sub(0, lpotdod), lpotdod), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * flippedLpotdod;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n // in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n }\n}\n\n/// @notice Calculates x*y÷1e18 with 512-bit precision.\n///\n/// @dev A variant of {mulDiv} with constant folding, i.e. in which the denominator is hard coded to 1e18.\n///\n/// Notes:\n/// - The body is purposely left uncommented; to understand how this works, see the documentation in {mulDiv}.\n/// - The result is rounded toward zero.\n/// - We take as an axiom that the result cannot be `MAX_UINT256` when x and y solve the following system of equations:\n///\n/// $$\n/// \\begin{cases}\n/// x * y = MAX\\_UINT256 * UNIT \\\\\n/// (x * y) \\% UNIT \\geq \\frac{UNIT}{2}\n/// \\end{cases}\n/// $$\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - The result must fit in uint256.\n///\n/// @param x The multiplicand as an unsigned 60.18-decimal fixed-point number.\n/// @param y The multiplier as an unsigned 60.18-decimal fixed-point number.\n/// @return result The result as an unsigned 60.18-decimal fixed-point number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDiv18(uint256 x, uint256 y) pure returns (uint256 result) {\n uint256 prod0;\n uint256 prod1;\n assembly (\"memory-safe\") {\n let mm := mulmod(x, y, not(0))\n prod0 := mul(x, y)\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n if (prod1 == 0) {\n unchecked {\n return prod0 / UNIT;\n }\n }\n\n if (prod1 >= UNIT) {\n revert PRBMath_MulDiv18_Overflow(x, y);\n }\n\n uint256 remainder;\n assembly (\"memory-safe\") {\n remainder := mulmod(x, y, UNIT)\n result :=\n mul(\n or(\n div(sub(prod0, remainder), UNIT_LPOTD),\n mul(sub(prod1, gt(remainder, prod0)), add(div(sub(0, UNIT_LPOTD), UNIT_LPOTD), 1))\n ),\n UNIT_INVERSE\n )\n }\n}\n\n/// @notice Calculates x*y÷denominator with 512-bit precision.\n///\n/// @dev This is an extension of {mulDiv} for signed numbers, which works by computing the signs and the absolute values separately.\n///\n/// Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {mulDiv}.\n/// - None of the inputs can be `type(int256).min`.\n/// - The result must fit in int256.\n///\n/// @param x The multiplicand as an int256.\n/// @param y The multiplier as an int256.\n/// @param denominator The divisor as an int256.\n/// @return result The result as an int256.\n/// @custom:smtchecker abstract-function-nondet\nfunction mulDivSigned(int256 x, int256 y, int256 denominator) pure returns (int256 result) {\n if (x == type(int256).min || y == type(int256).min || denominator == type(int256).min) {\n revert PRBMath_MulDivSigned_InputTooSmall();\n }\n\n // Get hold of the absolute values of x, y and the denominator.\n uint256 xAbs;\n uint256 yAbs;\n uint256 dAbs;\n unchecked {\n xAbs = x < 0 ? uint256(-x) : uint256(x);\n yAbs = y < 0 ? uint256(-y) : uint256(y);\n dAbs = denominator < 0 ? uint256(-denominator) : uint256(denominator);\n }\n\n // Compute the absolute value of x*y÷denominator. The result must fit in int256.\n uint256 resultAbs = mulDiv(xAbs, yAbs, dAbs);\n if (resultAbs > uint256(type(int256).max)) {\n revert PRBMath_MulDivSigned_Overflow(x, y);\n }\n\n // Get the signs of x, y and the denominator.\n uint256 sx;\n uint256 sy;\n uint256 sd;\n assembly (\"memory-safe\") {\n // \"sgt\" is the \"signed greater than\" assembly instruction and \"sub(0,1)\" is -1 in two's complement.\n sx := sgt(x, sub(0, 1))\n sy := sgt(y, sub(0, 1))\n sd := sgt(denominator, sub(0, 1))\n }\n\n // XOR over sx, sy and sd. What this does is to check whether there are 1 or 3 negative signs in the inputs.\n // If there are, the result should be negative. Otherwise, it should be positive.\n unchecked {\n result = sx ^ sy ^ sd == 0 ? -int256(resultAbs) : int256(resultAbs);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - If x is not a perfect square, the result is rounded down.\n/// - Credits to OpenZeppelin for the explanations in comments below.\n///\n/// @param x The uint256 number for which to calculate the square root.\n/// @return result The result as a uint256.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(uint256 x) pure returns (uint256 result) {\n if (x == 0) {\n return 0;\n }\n\n // For our first guess, we calculate the biggest power of 2 which is smaller than the square root of x.\n //\n // We know that the \"msb\" (most significant bit) of x is a power of 2 such that we have:\n //\n // $$\n // msb(x) <= x <= 2*msb(x)$\n // $$\n //\n // We write $msb(x)$ as $2^k$, and we get:\n //\n // $$\n // k = log_2(x)\n // $$\n //\n // Thus, we can write the initial inequality as:\n //\n // $$\n // 2^{log_2(x)} <= x <= 2*2^{log_2(x)+1} \\\\\n // sqrt(2^k) <= sqrt(x) < sqrt(2^{k+1}) \\\\\n // 2^{k/2} <= sqrt(x) < 2^{(k+1)/2} <= 2^{(k/2)+1}\n // $$\n //\n // Consequently, $2^{log_2(x) /2} is a good first approximation of sqrt(x) with at least one correct bit.\n uint256 xAux = uint256(x);\n result = 1;\n if (xAux >= 2 ** 128) {\n xAux >>= 128;\n result <<= 64;\n }\n if (xAux >= 2 ** 64) {\n xAux >>= 64;\n result <<= 32;\n }\n if (xAux >= 2 ** 32) {\n xAux >>= 32;\n result <<= 16;\n }\n if (xAux >= 2 ** 16) {\n xAux >>= 16;\n result <<= 8;\n }\n if (xAux >= 2 ** 8) {\n xAux >>= 8;\n result <<= 4;\n }\n if (xAux >= 2 ** 4) {\n xAux >>= 4;\n result <<= 2;\n }\n if (xAux >= 2 ** 2) {\n result <<= 1;\n }\n\n // At this point, `result` is an estimation with at least one bit of precision. We know the true value has at\n // most 128 bits, since it is the square root of a uint256. Newton's method converges quadratically (precision\n // doubles at every iteration). We thus need at most 7 iteration to turn our partial result with one bit of\n // precision into the expected uint128 result.\n unchecked {\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n result = (result + x / result) >> 1;\n\n // If x is not a perfect square, round the result toward zero.\n uint256 roundedResult = x / result;\n if (result >= roundedResult) {\n result = roundedResult;\n }\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd1x18/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as an SD1x18 number.\nSD1x18 constant E = SD1x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMAX_SD1x18 = 9_223372036854775807;\nSD1x18 constant MAX_SD1x18 = SD1x18.wrap(uMAX_SD1x18);\n\n/// @dev The maximum value an SD1x18 number can have.\nint64 constant uMIN_SD1x18 = -9_223372036854775808;\nSD1x18 constant MIN_SD1x18 = SD1x18.wrap(uMIN_SD1x18);\n\n/// @dev PI as an SD1x18 number.\nSD1x18 constant PI = SD1x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD1x18.\nSD1x18 constant UNIT = SD1x18.wrap(1e18);\nint256 constant uUNIT = 1e18;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd1x18/ValueType.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The signed 1.18-decimal fixed-point number representation, which can have up to 1 digit and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int64. This is useful when end users want to use int64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype SD1x18 is int64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD59x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD1x18 global;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n// NOTICE: the \"u\" prefix stands for \"unwrapped\".\n\n/// @dev Euler's number as an SD59x18 number.\nSD59x18 constant E = SD59x18.wrap(2_718281828459045235);\n\n/// @dev The maximum input permitted in {exp}.\nint256 constant uEXP_MAX_INPUT = 133_084258667509499440;\nSD59x18 constant EXP_MAX_INPUT = SD59x18.wrap(uEXP_MAX_INPUT);\n\n/// @dev The maximum input permitted in {exp2}.\nint256 constant uEXP2_MAX_INPUT = 192e18 - 1;\nSD59x18 constant EXP2_MAX_INPUT = SD59x18.wrap(uEXP2_MAX_INPUT);\n\n/// @dev Half the UNIT number.\nint256 constant uHALF_UNIT = 0.5e18;\nSD59x18 constant HALF_UNIT = SD59x18.wrap(uHALF_UNIT);\n\n/// @dev $log_2(10)$ as an SD59x18 number.\nint256 constant uLOG2_10 = 3_321928094887362347;\nSD59x18 constant LOG2_10 = SD59x18.wrap(uLOG2_10);\n\n/// @dev $log_2(e)$ as an SD59x18 number.\nint256 constant uLOG2_E = 1_442695040888963407;\nSD59x18 constant LOG2_E = SD59x18.wrap(uLOG2_E);\n\n/// @dev The maximum value an SD59x18 number can have.\nint256 constant uMAX_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_792003956564819967;\nSD59x18 constant MAX_SD59x18 = SD59x18.wrap(uMAX_SD59x18);\n\n/// @dev The maximum whole value an SD59x18 number can have.\nint256 constant uMAX_WHOLE_SD59x18 = 57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MAX_WHOLE_SD59x18 = SD59x18.wrap(uMAX_WHOLE_SD59x18);\n\n/// @dev The minimum value an SD59x18 number can have.\nint256 constant uMIN_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_792003956564819968;\nSD59x18 constant MIN_SD59x18 = SD59x18.wrap(uMIN_SD59x18);\n\n/// @dev The minimum whole value an SD59x18 number can have.\nint256 constant uMIN_WHOLE_SD59x18 = -57896044618658097711785492504343953926634992332820282019728_000000000000000000;\nSD59x18 constant MIN_WHOLE_SD59x18 = SD59x18.wrap(uMIN_WHOLE_SD59x18);\n\n/// @dev PI as an SD59x18 number.\nSD59x18 constant PI = SD59x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of SD59x18.\nint256 constant uUNIT = 1e18;\nSD59x18 constant UNIT = SD59x18.wrap(1e18);\n\n/// @dev The unit number squared.\nint256 constant uUNIT_SQUARED = 1e36;\nSD59x18 constant UNIT_SQUARED = SD59x18.wrap(uUNIT_SQUARED);\n\n/// @dev Zero as an SD59x18 number.\nSD59x18 constant ZERO = SD59x18.wrap(0);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/ValueType.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\nimport \"./Helpers.sol\" as Helpers;\nimport \"./Math.sol\" as Math;\n\n/// @notice The signed 59.18-decimal fixed-point number representation, which can have up to 59 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type int256.\ntype SD59x18 is int256;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoInt256,\n Casting.intoSD1x18,\n Casting.intoUD2x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n MATHEMATICAL FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Math.abs,\n Math.avg,\n Math.ceil,\n Math.div,\n Math.exp,\n Math.exp2,\n Math.floor,\n Math.frac,\n Math.gm,\n Math.inv,\n Math.log10,\n Math.log2,\n Math.ln,\n Math.mul,\n Math.pow,\n Math.powu,\n Math.sqrt\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Helpers.add,\n Helpers.and,\n Helpers.eq,\n Helpers.gt,\n Helpers.gte,\n Helpers.isZero,\n Helpers.lshift,\n Helpers.lt,\n Helpers.lte,\n Helpers.mod,\n Helpers.neq,\n Helpers.not,\n Helpers.or,\n Helpers.rshift,\n Helpers.sub,\n Helpers.uncheckedAdd,\n Helpers.uncheckedSub,\n Helpers.uncheckedUnary,\n Helpers.xor\n} for SD59x18 global;\n\n/*//////////////////////////////////////////////////////////////////////////\n OPERATORS\n//////////////////////////////////////////////////////////////////////////*/\n\n// The global \"using for\" directive makes it possible to use these operators on the SD59x18 type.\nusing {\n Helpers.add as +,\n Helpers.and2 as &,\n Math.div as /,\n Helpers.eq as ==,\n Helpers.gt as >,\n Helpers.gte as >=,\n Helpers.lt as <,\n Helpers.lte as <=,\n Helpers.mod as %,\n Math.mul as *,\n Helpers.neq as !=,\n Helpers.not as ~,\n Helpers.or as |,\n Helpers.sub as -,\n Helpers.unary as -,\n Helpers.xor as ^\n} for SD59x18 global;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud2x18/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @dev Euler's number as a UD2x18 number.\nUD2x18 constant E = UD2x18.wrap(2_718281828459045235);\n\n/// @dev The maximum value a UD2x18 number can have.\nuint64 constant uMAX_UD2x18 = 18_446744073709551615;\nUD2x18 constant MAX_UD2x18 = UD2x18.wrap(uMAX_UD2x18);\n\n/// @dev PI as a UD2x18 number.\nUD2x18 constant PI = UD2x18.wrap(3_141592653589793238);\n\n/// @dev The unit number, which gives the decimal precision of UD2x18.\nuint256 constant uUNIT = 1e18;\nUD2x18 constant UNIT = UD2x18.wrap(1e18);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud2x18/ValueType.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Casting.sol\" as Casting;\n\n/// @notice The unsigned 2.18-decimal fixed-point number representation, which can have up to 2 digits and up to 18\n/// decimals. The values of this are bound by the minimum and the maximum values permitted by the underlying Solidity\n/// type uint64. This is useful when end users want to use uint64 to save gas, e.g. with tight variable packing in contract\n/// storage.\ntype UD2x18 is uint64;\n\n/*//////////////////////////////////////////////////////////////////////////\n CASTING\n//////////////////////////////////////////////////////////////////////////*/\n\nusing {\n Casting.intoSD1x18,\n Casting.intoSD59x18,\n Casting.intoUD60x18,\n Casting.intoUint256,\n Casting.intoUint128,\n Casting.intoUint40,\n Casting.unwrap\n} for UD2x18 global;\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd1x18/Casting.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as CastingErrors;\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD1x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of SD1x18 is a subset of SD59x18.\nfunction intoSD59x18(SD1x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(SD1x18.unwrap(x)));\n}\n\n/// @notice Casts an SD1x18 number into UD2x18.\n/// - x must be positive.\nfunction intoUD2x18(SD1x18 x) pure returns (UD2x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD2x18_Underflow(x);\n }\n result = UD2x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD1x18 x) pure returns (UD60x18 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD1x18 x) pure returns (uint256 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint256_Underflow(x);\n }\n result = uint256(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint128(SD1x18 x) pure returns (uint128 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint128_Underflow(x);\n }\n result = uint128(uint64(xInt));\n}\n\n/// @notice Casts an SD1x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD1x18 x) pure returns (uint40 result) {\n int64 xInt = SD1x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Underflow(x);\n }\n if (xInt > int64(uint64(Common.MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD1x18_ToUint40_Overflow(x);\n }\n result = uint40(uint64(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd1x18(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n\n/// @notice Unwraps an SD1x18 number into int64.\nfunction unwrap(SD1x18 x) pure returns (int64 result) {\n result = SD1x18.unwrap(x);\n}\n\n/// @notice Wraps an int64 number into SD1x18.\nfunction wrap(int64 x) pure returns (SD1x18 result) {\n result = SD1x18.wrap(x);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Casting.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"./Errors.sol\" as CastingErrors;\nimport { MAX_UINT128, MAX_UINT40 } from \"../Common.sol\";\nimport { uMAX_SD1x18, uMIN_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { uMAX_UD2x18 } from \"../ud2x18/Constants.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Casts an SD59x18 number into int256.\n/// @dev This is basically a functional alias for {unwrap}.\nfunction intoInt256(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Casts an SD59x18 number into SD1x18.\n/// @dev Requirements:\n/// - x must be greater than or equal to `uMIN_SD1x18`.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(SD59x18 x) pure returns (SD1x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < uMIN_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Underflow(x);\n }\n if (xInt > uMAX_SD1x18) {\n revert CastingErrors.PRBMath_SD59x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xInt));\n}\n\n/// @notice Casts an SD59x18 number into UD2x18.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UD2x18`.\nfunction intoUD2x18(SD59x18 x) pure returns (UD2x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Underflow(x);\n }\n if (xInt > int256(uint256(uMAX_UD2x18))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD2x18_Overflow(x);\n }\n result = UD2x18.wrap(uint64(uint256(xInt)));\n}\n\n/// @notice Casts an SD59x18 number into UD60x18.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUD60x18(SD59x18 x) pure returns (UD60x18 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUD60x18_Underflow(x);\n }\n result = UD60x18.wrap(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint256.\n/// @dev Requirements:\n/// - x must be positive.\nfunction intoUint256(SD59x18 x) pure returns (uint256 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint256_Underflow(x);\n }\n result = uint256(xInt);\n}\n\n/// @notice Casts an SD59x18 number into uint128.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `uMAX_UINT128`.\nfunction intoUint128(SD59x18 x) pure returns (uint128 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT128))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint128_Overflow(x);\n }\n result = uint128(uint256(xInt));\n}\n\n/// @notice Casts an SD59x18 number into uint40.\n/// @dev Requirements:\n/// - x must be positive.\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(SD59x18 x) pure returns (uint40 result) {\n int256 xInt = SD59x18.unwrap(x);\n if (xInt < 0) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Underflow(x);\n }\n if (xInt > int256(uint256(MAX_UINT40))) {\n revert CastingErrors.PRBMath_SD59x18_IntoUint40_Overflow(x);\n }\n result = uint40(uint256(xInt));\n}\n\n/// @notice Alias for {wrap}.\nfunction sd(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Alias for {wrap}.\nfunction sd59x18(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n\n/// @notice Unwraps an SD59x18 number into int256.\nfunction unwrap(SD59x18 x) pure returns (int256 result) {\n result = SD59x18.unwrap(x);\n}\n\n/// @notice Wraps an int256 number into SD59x18.\nfunction wrap(int256 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(x);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Helpers.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { wrap } from \"./Casting.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Implements the checked addition operation (+) in the SD59x18 type.\nfunction add(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() + y.unwrap());\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and(SD59x18 x, int256 bits) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & bits);\n}\n\n/// @notice Implements the AND (&) bitwise operation in the SD59x18 type.\nfunction and2(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n return wrap(x.unwrap() & y.unwrap());\n}\n\n/// @notice Implements the equal (=) operation in the SD59x18 type.\nfunction eq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() == y.unwrap();\n}\n\n/// @notice Implements the greater than operation (>) in the SD59x18 type.\nfunction gt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() > y.unwrap();\n}\n\n/// @notice Implements the greater than or equal to operation (>=) in the SD59x18 type.\nfunction gte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() >= y.unwrap();\n}\n\n/// @notice Implements a zero comparison check function in the SD59x18 type.\nfunction isZero(SD59x18 x) pure returns (bool result) {\n result = x.unwrap() == 0;\n}\n\n/// @notice Implements the left shift operation (<<) in the SD59x18 type.\nfunction lshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() << bits);\n}\n\n/// @notice Implements the lower than operation (<) in the SD59x18 type.\nfunction lt(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() < y.unwrap();\n}\n\n/// @notice Implements the lower than or equal to operation (<=) in the SD59x18 type.\nfunction lte(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() <= y.unwrap();\n}\n\n/// @notice Implements the unchecked modulo operation (%) in the SD59x18 type.\nfunction mod(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % y.unwrap());\n}\n\n/// @notice Implements the not equal operation (!=) in the SD59x18 type.\nfunction neq(SD59x18 x, SD59x18 y) pure returns (bool result) {\n result = x.unwrap() != y.unwrap();\n}\n\n/// @notice Implements the NOT (~) bitwise operation in the SD59x18 type.\nfunction not(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(~x.unwrap());\n}\n\n/// @notice Implements the OR (|) bitwise operation in the SD59x18 type.\nfunction or(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() | y.unwrap());\n}\n\n/// @notice Implements the right shift operation (>>) in the SD59x18 type.\nfunction rshift(SD59x18 x, uint256 bits) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() >> bits);\n}\n\n/// @notice Implements the checked subtraction operation (-) in the SD59x18 type.\nfunction sub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() - y.unwrap());\n}\n\n/// @notice Implements the checked unary minus operation (-) in the SD59x18 type.\nfunction unary(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(-x.unwrap());\n}\n\n/// @notice Implements the unchecked addition operation (+) in the SD59x18 type.\nfunction uncheckedAdd(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() + y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked subtraction operation (-) in the SD59x18 type.\nfunction uncheckedSub(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(x.unwrap() - y.unwrap());\n }\n}\n\n/// @notice Implements the unchecked unary minus operation (-) in the SD59x18 type.\nfunction uncheckedUnary(SD59x18 x) pure returns (SD59x18 result) {\n unchecked {\n result = wrap(-x.unwrap());\n }\n}\n\n/// @notice Implements the XOR (^) bitwise operation in the SD59x18 type.\nfunction xor(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() ^ y.unwrap());\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Math.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport {\n uEXP_MAX_INPUT,\n uEXP2_MAX_INPUT,\n uHALF_UNIT,\n uLOG2_10,\n uLOG2_E,\n uMAX_SD59x18,\n uMAX_WHOLE_SD59x18,\n uMIN_SD59x18,\n uMIN_WHOLE_SD59x18,\n UNIT,\n uUNIT,\n uUNIT_SQUARED,\n ZERO\n} from \"./Constants.sol\";\nimport { wrap } from \"./Helpers.sol\";\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Calculates the absolute value of x.\n///\n/// @dev Requirements:\n/// - x must be greater than `MIN_SD59x18`.\n///\n/// @param x The SD59x18 number for which to calculate the absolute value.\n/// @param result The absolute value of x as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction abs(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Abs_MinSD59x18();\n }\n result = xInt < 0 ? wrap(-xInt) : x;\n}\n\n/// @notice Calculates the arithmetic average of x and y.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The arithmetic average as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction avg(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n unchecked {\n // This operation is equivalent to `x / 2 + y / 2`, and it can never overflow.\n int256 sum = (xInt >> 1) + (yInt >> 1);\n\n if (sum < 0) {\n // If at least one of x and y is odd, add 1 to the result, because shifting negative numbers to the right\n // rounds toward negative infinity. The right part is equivalent to `sum + (x % 2 == 1 || y % 2 == 1)`.\n assembly (\"memory-safe\") {\n result := add(sum, and(or(xInt, yInt), 1))\n }\n } else {\n // Add 1 if both x and y are odd to account for the double 0.5 remainder truncated after shifting.\n result = wrap(sum + (xInt & yInt & 1));\n }\n }\n}\n\n/// @notice Yields the smallest whole number greater than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because every whole value has (1e18 - 1) fractional counterparts.\n/// See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be less than or equal to `MAX_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to ceil.\n/// @param result The smallest whole number greater than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ceil(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt > uMAX_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Ceil_Overflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt > 0) {\n resultInt += uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Divides two SD59x18 numbers, returning a new SD59x18 number.\n///\n/// @dev This is an extension of {Common.mulDiv} for signed numbers, which works by computing the signs and the absolute\n/// values separately.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv}.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The denominator must not be zero.\n/// - The result must fit in SD59x18.\n///\n/// @param x The numerator as an SD59x18 number.\n/// @param y The denominator as an SD59x18 number.\n/// @param result The quotient as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction div(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Div_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*UNIT÷y). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv(xAbs, uint256(uUNIT), yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Div_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Calculates the natural exponent of x using the following formula:\n///\n/// $$\n/// e^x = 2^{x * log_2{e}}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}.\n/// - x must be less than 133_084258667509499441.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n\n // This check prevents values greater than 192e18 from being passed to {exp2}.\n if (xInt > uEXP_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp_InputTooBig(x);\n }\n\n unchecked {\n // Inline the fixed-point multiplication to save gas.\n int256 doubleUnitProduct = xInt * uLOG2_E;\n result = exp2(wrap(doubleUnitProduct / uUNIT));\n }\n}\n\n/// @notice Calculates the binary exponent of x using the binary fraction method using the following formula:\n///\n/// $$\n/// 2^{-x} = \\frac{1}{2^x}\n/// $$\n///\n/// @dev See https://ethereum.stackexchange.com/q/79903/24693.\n///\n/// Notes:\n/// - If x is less than -59_794705707972522261, the result is zero.\n///\n/// Requirements:\n/// - x must be less than 192e18.\n/// - The result must fit in SD59x18.\n///\n/// @param x The exponent as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction exp2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n // The inverse of any number less than this is truncated to zero.\n if (xInt < -59_794705707972522261) {\n return ZERO;\n }\n\n unchecked {\n // Inline the fixed-point inversion to save gas.\n result = wrap(uUNIT_SQUARED / exp2(wrap(-xInt)).unwrap());\n }\n } else {\n // Numbers greater than or equal to 192e18 don't fit in the 192.64-bit format.\n if (xInt > uEXP2_MAX_INPUT) {\n revert Errors.PRBMath_SD59x18_Exp2_InputTooBig(x);\n }\n\n unchecked {\n // Convert x to the 192.64-bit fixed-point format.\n uint256 x_192x64 = uint256((xInt << 64) / uUNIT);\n\n // It is safe to cast the result to int256 due to the checks above.\n result = wrap(int256(Common.exp2(x_192x64)));\n }\n }\n}\n\n/// @notice Yields the greatest whole number less than or equal to x.\n///\n/// @dev Optimized for fractional value inputs, because for every whole value there are (1e18 - 1) fractional\n/// counterparts. See https://en.wikipedia.org/wiki/Floor_and_ceiling_functions.\n///\n/// Requirements:\n/// - x must be greater than or equal to `MIN_WHOLE_SD59x18`.\n///\n/// @param x The SD59x18 number to floor.\n/// @param result The greatest whole number less than or equal to x, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction floor(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < uMIN_WHOLE_SD59x18) {\n revert Errors.PRBMath_SD59x18_Floor_Underflow(x);\n }\n\n int256 remainder = xInt % uUNIT;\n if (remainder == 0) {\n result = x;\n } else {\n unchecked {\n // Solidity uses C fmod style, which returns a modulus with the same sign as x.\n int256 resultInt = xInt - remainder;\n if (xInt < 0) {\n resultInt -= uUNIT;\n }\n result = wrap(resultInt);\n }\n }\n}\n\n/// @notice Yields the excess beyond the floor of x for positive numbers and the part of the number to the right.\n/// of the radix point for negative numbers.\n/// @dev Based on the odd function definition. https://en.wikipedia.org/wiki/Fractional_part\n/// @param x The SD59x18 number to get the fractional part of.\n/// @param result The fractional part of x as an SD59x18 number.\nfunction frac(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(x.unwrap() % uUNIT);\n}\n\n/// @notice Calculates the geometric mean of x and y, i.e. $\\sqrt{x * y}$.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x * y must fit in SD59x18.\n/// - x * y must not be negative, since complex numbers are not supported.\n///\n/// @param x The first operand as an SD59x18 number.\n/// @param y The second operand as an SD59x18 number.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction gm(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == 0 || yInt == 0) {\n return ZERO;\n }\n\n unchecked {\n // Equivalent to `xy / x != y`. Checking for overflow this way is faster than letting Solidity do it.\n int256 xyInt = xInt * yInt;\n if (xyInt / xInt != yInt) {\n revert Errors.PRBMath_SD59x18_Gm_Overflow(x, y);\n }\n\n // The product must not be negative, since complex numbers are not supported.\n if (xyInt < 0) {\n revert Errors.PRBMath_SD59x18_Gm_NegativeProduct(x, y);\n }\n\n // We don't need to multiply the result by `UNIT` here because the x*y product picked up a factor of `UNIT`\n // during multiplication. See the comments in {Common.sqrt}.\n uint256 resultUint = Common.sqrt(uint256(xyInt));\n result = wrap(int256(resultUint));\n }\n}\n\n/// @notice Calculates the inverse of x.\n///\n/// @dev Notes:\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x must not be zero.\n///\n/// @param x The SD59x18 number for which to calculate the inverse.\n/// @return result The inverse as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction inv(SD59x18 x) pure returns (SD59x18 result) {\n result = wrap(uUNIT_SQUARED / x.unwrap());\n}\n\n/// @notice Calculates the natural logarithm of x using the following formula:\n///\n/// $$\n/// ln{x} = log_2{x} / log_2{e}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n/// - The precision isn't sufficiently fine-grained to return exactly `UNIT` when the input is `E`.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the natural logarithm.\n/// @return result The natural logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction ln(SD59x18 x) pure returns (SD59x18 result) {\n // Inline the fixed-point multiplication to save gas. This is overflow-safe because the maximum value that\n // {log2} can return is ~195_205294292027477728.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_E);\n}\n\n/// @notice Calculates the common logarithm of x using the following formula:\n///\n/// $$\n/// log_{10}{x} = log_2{x} / log_2{10}\n/// $$\n///\n/// However, if x is an exact power of ten, a hard coded value is returned.\n///\n/// @dev Notes:\n/// - Refer to the notes in {log2}.\n///\n/// Requirements:\n/// - Refer to the requirements in {log2}.\n///\n/// @param x The SD59x18 number for which to calculate the common logarithm.\n/// @return result The common logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log10(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n // Note that the `mul` in this block is the standard multiplication operation, not {SD59x18.mul}.\n // prettier-ignore\n assembly (\"memory-safe\") {\n switch x\n case 1 { result := mul(uUNIT, sub(0, 18)) }\n case 10 { result := mul(uUNIT, sub(1, 18)) }\n case 100 { result := mul(uUNIT, sub(2, 18)) }\n case 1000 { result := mul(uUNIT, sub(3, 18)) }\n case 10000 { result := mul(uUNIT, sub(4, 18)) }\n case 100000 { result := mul(uUNIT, sub(5, 18)) }\n case 1000000 { result := mul(uUNIT, sub(6, 18)) }\n case 10000000 { result := mul(uUNIT, sub(7, 18)) }\n case 100000000 { result := mul(uUNIT, sub(8, 18)) }\n case 1000000000 { result := mul(uUNIT, sub(9, 18)) }\n case 10000000000 { result := mul(uUNIT, sub(10, 18)) }\n case 100000000000 { result := mul(uUNIT, sub(11, 18)) }\n case 1000000000000 { result := mul(uUNIT, sub(12, 18)) }\n case 10000000000000 { result := mul(uUNIT, sub(13, 18)) }\n case 100000000000000 { result := mul(uUNIT, sub(14, 18)) }\n case 1000000000000000 { result := mul(uUNIT, sub(15, 18)) }\n case 10000000000000000 { result := mul(uUNIT, sub(16, 18)) }\n case 100000000000000000 { result := mul(uUNIT, sub(17, 18)) }\n case 1000000000000000000 { result := 0 }\n case 10000000000000000000 { result := uUNIT }\n case 100000000000000000000 { result := mul(uUNIT, 2) }\n case 1000000000000000000000 { result := mul(uUNIT, 3) }\n case 10000000000000000000000 { result := mul(uUNIT, 4) }\n case 100000000000000000000000 { result := mul(uUNIT, 5) }\n case 1000000000000000000000000 { result := mul(uUNIT, 6) }\n case 10000000000000000000000000 { result := mul(uUNIT, 7) }\n case 100000000000000000000000000 { result := mul(uUNIT, 8) }\n case 1000000000000000000000000000 { result := mul(uUNIT, 9) }\n case 10000000000000000000000000000 { result := mul(uUNIT, 10) }\n case 100000000000000000000000000000 { result := mul(uUNIT, 11) }\n case 1000000000000000000000000000000 { result := mul(uUNIT, 12) }\n case 10000000000000000000000000000000 { result := mul(uUNIT, 13) }\n case 100000000000000000000000000000000 { result := mul(uUNIT, 14) }\n case 1000000000000000000000000000000000 { result := mul(uUNIT, 15) }\n case 10000000000000000000000000000000000 { result := mul(uUNIT, 16) }\n case 100000000000000000000000000000000000 { result := mul(uUNIT, 17) }\n case 1000000000000000000000000000000000000 { result := mul(uUNIT, 18) }\n case 10000000000000000000000000000000000000 { result := mul(uUNIT, 19) }\n case 100000000000000000000000000000000000000 { result := mul(uUNIT, 20) }\n case 1000000000000000000000000000000000000000 { result := mul(uUNIT, 21) }\n case 10000000000000000000000000000000000000000 { result := mul(uUNIT, 22) }\n case 100000000000000000000000000000000000000000 { result := mul(uUNIT, 23) }\n case 1000000000000000000000000000000000000000000 { result := mul(uUNIT, 24) }\n case 10000000000000000000000000000000000000000000 { result := mul(uUNIT, 25) }\n case 100000000000000000000000000000000000000000000 { result := mul(uUNIT, 26) }\n case 1000000000000000000000000000000000000000000000 { result := mul(uUNIT, 27) }\n case 10000000000000000000000000000000000000000000000 { result := mul(uUNIT, 28) }\n case 100000000000000000000000000000000000000000000000 { result := mul(uUNIT, 29) }\n case 1000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 30) }\n case 10000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 31) }\n case 100000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 32) }\n case 1000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 33) }\n case 10000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 34) }\n case 100000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 35) }\n case 1000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 36) }\n case 10000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 37) }\n case 100000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 38) }\n case 1000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 39) }\n case 10000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 40) }\n case 100000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 41) }\n case 1000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 42) }\n case 10000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 43) }\n case 100000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 44) }\n case 1000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 45) }\n case 10000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 46) }\n case 100000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 47) }\n case 1000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 48) }\n case 10000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 49) }\n case 100000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 50) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 51) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 52) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 53) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 54) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 55) }\n case 100000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 56) }\n case 1000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 57) }\n case 10000000000000000000000000000000000000000000000000000000000000000000000000000 { result := mul(uUNIT, 58) }\n default { result := uMAX_SD59x18 }\n }\n\n if (result.unwrap() == uMAX_SD59x18) {\n unchecked {\n // Inline the fixed-point division to save gas.\n result = wrap(log2(x).unwrap() * uUNIT / uLOG2_10);\n }\n }\n}\n\n/// @notice Calculates the binary logarithm of x using the iterative approximation algorithm:\n///\n/// $$\n/// log_2{x} = n + log_2{y}, \\text{ where } y = x*2^{-n}, \\ y \\in [1, 2)\n/// $$\n///\n/// For $0 \\leq x \\lt 1$, the input is inverted:\n///\n/// $$\n/// log_2{x} = -log_2{\\frac{1}{x}}\n/// $$\n///\n/// @dev See https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation.\n///\n/// Notes:\n/// - Due to the lossy precision of the iterative approximation, the results are not perfectly accurate to the last decimal.\n///\n/// Requirements:\n/// - x must be greater than zero.\n///\n/// @param x The SD59x18 number for which to calculate the binary logarithm.\n/// @return result The binary logarithm as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction log2(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt <= 0) {\n revert Errors.PRBMath_SD59x18_Log_InputTooSmall(x);\n }\n\n unchecked {\n int256 sign;\n if (xInt >= uUNIT) {\n sign = 1;\n } else {\n sign = -1;\n // Inline the fixed-point inversion to save gas.\n xInt = uUNIT_SQUARED / xInt;\n }\n\n // Calculate the integer part of the logarithm.\n uint256 n = Common.msb(uint256(xInt / uUNIT));\n\n // This is the integer part of the logarithm as an SD59x18 number. The operation can't overflow\n // because n is at most 255, `UNIT` is 1e18, and the sign is either 1 or -1.\n int256 resultInt = int256(n) * uUNIT;\n\n // Calculate $y = x * 2^{-n}$.\n int256 y = xInt >> n;\n\n // If y is the unit number, the fractional part is zero.\n if (y == uUNIT) {\n return wrap(resultInt * sign);\n }\n\n // Calculate the fractional part via the iterative approximation.\n // The `delta >>= 1` part is equivalent to `delta /= 2`, but shifting bits is more gas efficient.\n int256 DOUBLE_UNIT = 2e18;\n for (int256 delta = uHALF_UNIT; delta > 0; delta >>= 1) {\n y = (y * y) / uUNIT;\n\n // Is y^2 >= 2e18 and so in the range [2e18, 4e18)?\n if (y >= DOUBLE_UNIT) {\n // Add the 2^{-m} factor to the logarithm.\n resultInt = resultInt + delta;\n\n // Halve y, which corresponds to z/2 in the Wikipedia article.\n y >>= 1;\n }\n }\n resultInt *= sign;\n result = wrap(resultInt);\n }\n}\n\n/// @notice Multiplies two SD59x18 numbers together, returning a new SD59x18 number.\n///\n/// @dev Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n///\n/// Requirements:\n/// - Refer to the requirements in {Common.mulDiv18}.\n/// - None of the inputs can be `MIN_SD59x18`.\n/// - The result must fit in SD59x18.\n///\n/// @param x The multiplicand as an SD59x18 number.\n/// @param y The multiplier as an SD59x18 number.\n/// @return result The product as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction mul(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n if (xInt == uMIN_SD59x18 || yInt == uMIN_SD59x18) {\n revert Errors.PRBMath_SD59x18_Mul_InputTooSmall();\n }\n\n // Get hold of the absolute values of x and y.\n uint256 xAbs;\n uint256 yAbs;\n unchecked {\n xAbs = xInt < 0 ? uint256(-xInt) : uint256(xInt);\n yAbs = yInt < 0 ? uint256(-yInt) : uint256(yInt);\n }\n\n // Compute the absolute value (x*y÷UNIT). The resulting value must fit in SD59x18.\n uint256 resultAbs = Common.mulDiv18(xAbs, yAbs);\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Mul_Overflow(x, y);\n }\n\n // Check if x and y have the same sign using two's complement representation. The left-most bit represents the sign (1 for\n // negative, 0 for positive or zero).\n bool sameSign = (xInt ^ yInt) > -1;\n\n // If the inputs have the same sign, the result should be positive. Otherwise, it should be negative.\n unchecked {\n result = wrap(sameSign ? int256(resultAbs) : -int256(resultAbs));\n }\n}\n\n/// @notice Raises x to the power of y using the following formula:\n///\n/// $$\n/// x^y = 2^{log_2{x} * y}\n/// $$\n///\n/// @dev Notes:\n/// - Refer to the notes in {exp2}, {log2}, and {mul}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {exp2}, {log2}, and {mul}.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y Exponent to raise x to, as an SD59x18 number\n/// @return result x raised to power y, as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction pow(SD59x18 x, SD59x18 y) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n int256 yInt = y.unwrap();\n\n // If both x and y are zero, the result is `UNIT`. If just x is zero, the result is always zero.\n if (xInt == 0) {\n return yInt == 0 ? UNIT : ZERO;\n }\n // If x is `UNIT`, the result is always `UNIT`.\n else if (xInt == uUNIT) {\n return UNIT;\n }\n\n // If y is zero, the result is always `UNIT`.\n if (yInt == 0) {\n return UNIT;\n }\n // If y is `UNIT`, the result is always x.\n else if (yInt == uUNIT) {\n return x;\n }\n\n // Calculate the result using the formula.\n result = exp2(mul(log2(x), y));\n}\n\n/// @notice Raises x (an SD59x18 number) to the power y (an unsigned basic integer) using the well-known\n/// algorithm \"exponentiation by squaring\".\n///\n/// @dev See https://en.wikipedia.org/wiki/Exponentiation_by_squaring.\n///\n/// Notes:\n/// - Refer to the notes in {Common.mulDiv18}.\n/// - Returns `UNIT` for 0^0.\n///\n/// Requirements:\n/// - Refer to the requirements in {abs} and {Common.mulDiv18}.\n/// - The result must fit in SD59x18.\n///\n/// @param x The base as an SD59x18 number.\n/// @param y The exponent as a uint256.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction powu(SD59x18 x, uint256 y) pure returns (SD59x18 result) {\n uint256 xAbs = uint256(abs(x).unwrap());\n\n // Calculate the first iteration of the loop in advance.\n uint256 resultAbs = y & 1 > 0 ? xAbs : uint256(uUNIT);\n\n // Equivalent to `for(y /= 2; y > 0; y /= 2)`.\n uint256 yAux = y;\n for (yAux >>= 1; yAux > 0; yAux >>= 1) {\n xAbs = Common.mulDiv18(xAbs, xAbs);\n\n // Equivalent to `y % 2 == 1`.\n if (yAux & 1 > 0) {\n resultAbs = Common.mulDiv18(resultAbs, xAbs);\n }\n }\n\n // The result must fit in SD59x18.\n if (resultAbs > uint256(uMAX_SD59x18)) {\n revert Errors.PRBMath_SD59x18_Powu_Overflow(x, y);\n }\n\n unchecked {\n // Is the base negative and the exponent odd? If yes, the result should be negative.\n int256 resultInt = int256(resultAbs);\n bool isNegative = x.unwrap() < 0 && y & 1 == 1;\n if (isNegative) {\n resultInt = -resultInt;\n }\n result = wrap(resultInt);\n }\n}\n\n/// @notice Calculates the square root of x using the Babylonian method.\n///\n/// @dev See https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method.\n///\n/// Notes:\n/// - Only the positive root is returned.\n/// - The result is rounded toward zero.\n///\n/// Requirements:\n/// - x cannot be negative, since complex numbers are not supported.\n/// - x must be less than `MAX_SD59x18 / UNIT`.\n///\n/// @param x The SD59x18 number for which to calculate the square root.\n/// @return result The result as an SD59x18 number.\n/// @custom:smtchecker abstract-function-nondet\nfunction sqrt(SD59x18 x) pure returns (SD59x18 result) {\n int256 xInt = x.unwrap();\n if (xInt < 0) {\n revert Errors.PRBMath_SD59x18_Sqrt_NegativeInput(x);\n }\n if (xInt > uMAX_SD59x18 / uUNIT) {\n revert Errors.PRBMath_SD59x18_Sqrt_Overflow(x);\n }\n\n unchecked {\n // Multiply x by `UNIT` to account for the factor of `UNIT` picked up when multiplying two SD59x18 numbers.\n // In this case, the two numbers are both the square root.\n uint256 resultUint = Common.sqrt(uint256(xInt * uUNIT));\n result = wrap(int256(resultUint));\n }\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud2x18/Casting.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport \"../Common.sol\" as Common;\nimport \"./Errors.sol\" as Errors;\nimport { uMAX_SD1x18 } from \"../sd1x18/Constants.sol\";\nimport { SD1x18 } from \"../sd1x18/ValueType.sol\";\nimport { SD59x18 } from \"../sd59x18/ValueType.sol\";\nimport { UD2x18 } from \"../ud2x18/ValueType.sol\";\nimport { UD60x18 } from \"../ud60x18/ValueType.sol\";\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Casts a UD2x18 number into SD1x18.\n/// - x must be less than or equal to `uMAX_SD1x18`.\nfunction intoSD1x18(UD2x18 x) pure returns (SD1x18 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(uMAX_SD1x18)) {\n revert Errors.PRBMath_UD2x18_IntoSD1x18_Overflow(x);\n }\n result = SD1x18.wrap(int64(xUint));\n}\n\n/// @notice Casts a UD2x18 number into SD59x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of SD59x18.\nfunction intoSD59x18(UD2x18 x) pure returns (SD59x18 result) {\n result = SD59x18.wrap(int256(uint256(UD2x18.unwrap(x))));\n}\n\n/// @notice Casts a UD2x18 number into UD60x18.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of UD60x18.\nfunction intoUD60x18(UD2x18 x) pure returns (UD60x18 result) {\n result = UD60x18.wrap(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint128.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint128.\nfunction intoUint128(UD2x18 x) pure returns (uint128 result) {\n result = uint128(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint256.\n/// @dev There is no overflow check because the domain of UD2x18 is a subset of uint256.\nfunction intoUint256(UD2x18 x) pure returns (uint256 result) {\n result = uint256(UD2x18.unwrap(x));\n}\n\n/// @notice Casts a UD2x18 number into uint40.\n/// @dev Requirements:\n/// - x must be less than or equal to `MAX_UINT40`.\nfunction intoUint40(UD2x18 x) pure returns (uint40 result) {\n uint64 xUint = UD2x18.unwrap(x);\n if (xUint > uint64(Common.MAX_UINT40)) {\n revert Errors.PRBMath_UD2x18_IntoUint40_Overflow(x);\n }\n result = uint40(xUint);\n}\n\n/// @notice Alias for {wrap}.\nfunction ud2x18(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n\n/// @notice Unwrap a UD2x18 number into uint64.\nfunction unwrap(UD2x18 x) pure returns (uint64 result) {\n result = UD2x18.unwrap(x);\n}\n\n/// @notice Wraps a uint64 number into UD2x18.\nfunction wrap(uint64 x) pure returns (UD2x18 result) {\n result = UD2x18.wrap(x);\n}\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd1x18/Errors.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD1x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD1x18_ToUD2x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD1x18_ToUD60x18_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint128.\nerror PRBMath_SD1x18_ToUint128_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint256.\nerror PRBMath_SD1x18_ToUint256_Underflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Overflow(SD1x18 x);\n\n/// @notice Thrown when trying to cast a SD1x18 number that doesn't fit in uint40.\nerror PRBMath_SD1x18_ToUint40_Underflow(SD1x18 x);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/sd59x18/Errors.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { SD59x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when taking the absolute value of `MIN_SD59x18`.\nerror PRBMath_SD59x18_Abs_MinSD59x18();\n\n/// @notice Thrown when ceiling a number overflows SD59x18.\nerror PRBMath_SD59x18_Ceil_Overflow(SD59x18 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format overflows SD59x18.\nerror PRBMath_SD59x18_Convert_Overflow(int256 x);\n\n/// @notice Thrown when converting a basic integer to the fixed-point format underflows SD59x18.\nerror PRBMath_SD59x18_Convert_Underflow(int256 x);\n\n/// @notice Thrown when dividing two numbers and one of them is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Div_InputTooSmall();\n\n/// @notice Thrown when dividing two numbers and one of the intermediary unsigned results overflows SD59x18.\nerror PRBMath_SD59x18_Div_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the natural exponent of a base greater than 133_084258667509499441.\nerror PRBMath_SD59x18_Exp_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when taking the binary exponent of a base greater than 192e18.\nerror PRBMath_SD59x18_Exp2_InputTooBig(SD59x18 x);\n\n/// @notice Thrown when flooring a number underflows SD59x18.\nerror PRBMath_SD59x18_Floor_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the geometric mean of two numbers and their product is negative.\nerror PRBMath_SD59x18_Gm_NegativeProduct(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when taking the geometric mean of two numbers and multiplying them overflows SD59x18.\nerror PRBMath_SD59x18_Gm_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in SD1x18.\nerror PRBMath_SD59x18_IntoSD1x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD2x18.\nerror PRBMath_SD59x18_IntoUD2x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in UD60x18.\nerror PRBMath_SD59x18_IntoUD60x18_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint128.\nerror PRBMath_SD59x18_IntoUint128_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint256.\nerror PRBMath_SD59x18_IntoUint256_Underflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Overflow(SD59x18 x);\n\n/// @notice Thrown when trying to cast a UD60x18 number that doesn't fit in uint40.\nerror PRBMath_SD59x18_IntoUint40_Underflow(SD59x18 x);\n\n/// @notice Thrown when taking the logarithm of a number less than or equal to zero.\nerror PRBMath_SD59x18_Log_InputTooSmall(SD59x18 x);\n\n/// @notice Thrown when multiplying two numbers and one of the inputs is `MIN_SD59x18`.\nerror PRBMath_SD59x18_Mul_InputTooSmall();\n\n/// @notice Thrown when multiplying two numbers and the intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Mul_Overflow(SD59x18 x, SD59x18 y);\n\n/// @notice Thrown when raising a number to a power and hte intermediary absolute result overflows SD59x18.\nerror PRBMath_SD59x18_Powu_Overflow(SD59x18 x, uint256 y);\n\n/// @notice Thrown when taking the square root of a negative number.\nerror PRBMath_SD59x18_Sqrt_NegativeInput(SD59x18 x);\n\n/// @notice Thrown when the calculating the square root overflows SD59x18.\nerror PRBMath_SD59x18_Sqrt_Overflow(SD59x18 x);\n"
},
"lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/ud2x18/Errors.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.19;\n\nimport { UD2x18 } from \"./ValueType.sol\";\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in SD1x18.\nerror PRBMath_UD2x18_IntoSD1x18_Overflow(UD2x18 x);\n\n/// @notice Thrown when trying to cast a UD2x18 number that doesn't fit in uint40.\nerror PRBMath_UD2x18_IntoUint40_Overflow(UD2x18 x);\n"
}
},
"settings": {
"remappings": [
"@prb/test/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/lib/prb-test/src/",
"bitwise/=lib/rain.flow/lib/rain.interpreter/src/lib/bitwise/",
"bytecode/=lib/rain.flow/lib/rain.interpreter/src/lib/bytecode/",
"caller/=lib/rain.flow/lib/rain.interpreter/src/lib/caller/",
"compile/=lib/rain.flow/lib/rain.interpreter/src/lib/compile/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"eval/=lib/rain.flow/lib/rain.interpreter/src/lib/eval/",
"extern/=lib/rain.flow/lib/rain.interpreter/src/lib/extern/",
"forge-std/=lib/forge-std/src/",
"integrity/=lib/rain.flow/lib/rain.interpreter/src/lib/integrity/",
"ns/=lib/rain.flow/lib/rain.interpreter/src/lib/ns/",
"op/=lib/rain.flow/lib/rain.interpreter/src/lib/op/",
"openzeppelin-contracts-upgradeable/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/rain.flow/lib/rain.factory/lib/openzeppelin-contracts/",
"openzeppelin/=lib/rain.flow/lib/openzeppelin-contracts-upgradeable/contracts/",
"parse/=lib/rain.flow/lib/rain.interpreter/src/lib/parse/",
"prb-math/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/src/",
"prb-test/=lib/rain.flow/lib/rain.interpreter/lib/prb-math/lib/prb-test/src/",
"rain.chainlink/=lib/rain.flow/lib/rain.interpreter/lib/rain.chainlink/src/",
"rain.datacontract/=lib/rain.flow/lib/rain.interpreter/lib/rain.datacontract/src/",
"rain.erc1820/=lib/rain.flow/lib/rain.interpreter/lib/rain.erc1820/src/",
"rain.extrospection/=lib/rain.flow/lib/rain.factory/lib/rain.extrospection/",
"rain.factory/=lib/rain.flow/lib/rain.factory/",
"rain.flow/=lib/rain.flow/",
"rain.interpreter/=lib/rain.flow/lib/rain.interpreter/",
"rain.lib.hash/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.memkv/lib/rain.lib.hash/src/",
"rain.lib.memkv/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.memkv/src/",
"rain.lib.typecast/=lib/rain.flow/lib/rain.interpreter/lib/rain.lib.typecast/src/",
"rain.math.fixedpoint/=lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/src/",
"rain.math.saturating/=lib/rain.flow/lib/rain.interpreter/lib/rain.math.fixedpoint/lib/rain.math.saturating/src/",
"rain.metadata/=lib/rain.flow/lib/rain.interpreter/lib/rain.metadata/src/",
"rain.solmem/=lib/rain.flow/lib/rain.interpreter/lib/rain.solmem/src/",
"sol.lib.binmaskflag/=lib/rain.flow/lib/rain.interpreter/lib/sol.lib.binmaskflag/src/",
"state/=lib/rain.flow/lib/rain.interpreter/src/lib/state/",
"uniswap/=lib/rain.flow/lib/rain.interpreter/src/lib/uniswap/",
"v2-core/=lib/rain.flow/lib/rain.interpreter/lib/v2-core/contracts/",
"v2-periphery/=lib/rain.flow/lib/rain.interpreter/lib/v2-periphery/contracts/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"viaIR": false,
"libraries": {}
}
}}
|
1 | 19,498,589 |
cca09afb3c3ec8d6f50057638f9c0c087b23abb0fbe0bc06b809a1d3bd05b42d
|
0d74c21201dd4314803691a678f72c2435daf840c2561119e0b14c26527760b8
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
ec81cf0af189cc0d31cefade268332b0ff58cf63
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,595 |
f03b107715984aceb468dee8d123e91463f6017fceb78a4e102a9f81695d26a1
|
ab25805b51a0108ed93da9250ed4964d876bfd87a45365f21b92216dfc42558e
|
d24b4b391f1aa1c006d86229eba7da1a6b521ee9
|
000000f20032b9e171844b00ea507e11960bd94a
|
9e5623879df9b8a3624cc1cbc51d9e403a65ccb3
|
3d602d80600a3d3981f3363d3d373d3d3d363d730d223d05e1cc4ac20de7fce86bc9bb8efb56f4d45af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730d223d05e1cc4ac20de7fce86bc9bb8efb56f4d45af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/clones/ERC1155SeaDropCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ERC1155SeaDropContractOffererCloneable\n} from \"./ERC1155SeaDropContractOffererCloneable.sol\";\n\n/**\n * @title ERC1155SeaDropCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable ERC1155 token contract that can mint as a\n * Seaport contract offerer.\n */\ncontract ERC1155SeaDropCloneable is ERC1155SeaDropContractOffererCloneable {\n /**\n * @notice Initialize the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * implementation code. Also contains SeaDrop\n * implementation code.\n * @param allowedSeaport The address of the Seaport contract allowed to\n * interact.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function initialize(\n address allowedConfigurer,\n address allowedSeaport,\n string memory name_,\n string memory symbol_,\n address initialOwner\n ) public initializer {\n // Initialize ownership.\n _initializeOwner(initialOwner);\n\n // Initialize ERC1155SeaDropContractOffererCloneable.\n __ERC1155SeaDropContractOffererCloneable_init(\n allowedConfigurer,\n allowedSeaport,\n name_,\n symbol_\n );\n }\n\n /**\n * @dev Auto-approve the conduit after mint or transfer.\n *\n * @custom:param from The address to transfer from.\n * @param to The address to transfer to.\n * @custom:param ids The token ids to transfer.\n * @custom:param amounts The quantities to transfer.\n * @custom:param data The data to pass if receiver is a contract.\n */\n function _afterTokenTransfer(\n address /* from */,\n address to,\n uint256[] memory /* ids */,\n uint256[] memory /* amounts */,\n bytes memory /* data */\n ) internal virtual override {\n // Auto-approve the conduit.\n if (to != address(0) && !isApprovedForAll(to, _CONDUIT)) {\n _setApprovalForAll(to, _CONDUIT, true);\n }\n }\n\n /**\n * @dev Override this function to return true if `_afterTokenTransfer` is\n * used. The is to help the compiler avoid producing dead bytecode.\n */\n function _useAfterTokenTransfer()\n internal\n view\n virtual\n override\n returns (bool)\n {\n return true;\n }\n\n /**\n * @notice Burns a token, restricted to the owner or approved operator,\n * and must have sufficient balance.\n *\n * @param from The address to burn from.\n * @param id The token id to burn.\n * @param amount The amount to burn.\n */\n function burn(address from, uint256 id, uint256 amount) external {\n // Burn the token.\n _burn(msg.sender, from, id, amount);\n }\n\n /**\n * @notice Burns a batch of tokens, restricted to the owner or\n * approved operator, and must have sufficient balance.\n *\n * @param from The address to burn from.\n * @param ids The token ids to burn.\n * @param amounts The amounts to burn per token id.\n */\n function batchBurn(\n address from,\n uint256[] calldata ids,\n uint256[] calldata amounts\n ) external {\n // Burn the tokens.\n _batchBurn(msg.sender, from, ids, amounts);\n }\n}\n"
},
"src/clones/ERC1155SeaDropContractOffererCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { IERC1155SeaDrop } from \"../interfaces/IERC1155SeaDrop.sol\";\n\nimport { ISeaDropToken } from \"../interfaces/ISeaDropToken.sol\";\n\nimport {\n ERC1155ContractMetadataCloneable\n} from \"./ERC1155ContractMetadataCloneable.sol\";\n\nimport {\n ERC1155SeaDropContractOffererStorage\n} from \"../lib/ERC1155SeaDropContractOffererStorage.sol\";\n\nimport {\n ERC1155SeaDropErrorsAndEvents\n} from \"../lib/ERC1155SeaDropErrorsAndEvents.sol\";\n\nimport { PublicDrop } from \"../lib//ERC1155SeaDropStructs.sol\";\n\nimport { AllowListData } from \"../lib/SeaDropStructs.sol\";\n\nimport {\n ERC1155ConduitPreapproved\n} from \"../lib/ERC1155ConduitPreapproved.sol\";\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\nimport { SpentItem } from \"seaport-types/src/lib/ConsiderationStructs.sol\";\n\nimport {\n ContractOffererInterface\n} from \"seaport-types/src/interfaces/ContractOffererInterface.sol\";\n\nimport {\n IERC165\n} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title ERC1155SeaDropContractOffererCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable ERC1155 token contract that can mint as a\n * Seaport contract offerer.\n */\ncontract ERC1155SeaDropContractOffererCloneable is\n ERC1155ContractMetadataCloneable,\n ERC1155SeaDropErrorsAndEvents\n{\n using ERC1155SeaDropContractOffererStorage for ERC1155SeaDropContractOffererStorage.Layout;\n\n /**\n * @notice Initialize the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * configure parameters. Also contains SeaDrop\n * implementation code.\n * @param allowedSeaport The address of the Seaport contract allowed to\n * interact.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function __ERC1155SeaDropContractOffererCloneable_init(\n address allowedConfigurer,\n address allowedSeaport,\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n // Set the allowed Seaport to interact with this contract.\n if (allowedSeaport == address(0)) {\n revert AllowedSeaportCannotBeZeroAddress();\n }\n ERC1155SeaDropContractOffererStorage.layout()._allowedSeaport[\n allowedSeaport\n ] = true;\n\n // Set the allowed Seaport enumeration.\n address[] memory enumeratedAllowedSeaport = new address[](1);\n enumeratedAllowedSeaport[0] = allowedSeaport;\n ERC1155SeaDropContractOffererStorage\n .layout()\n ._enumeratedAllowedSeaport = enumeratedAllowedSeaport;\n\n // Emit an event noting the contract deployment.\n emit SeaDropTokenDeployed(SEADROP_TOKEN_TYPE.ERC1155_CLONE);\n\n // Initialize ERC1155ContractMetadataCloneable.\n __ERC1155ContractMetadataCloneable_init(\n allowedConfigurer,\n name_,\n symbol_\n );\n }\n\n /**\n * @notice The fallback function is used as a dispatcher for SeaDrop\n * methods.\n */\n fallback(bytes calldata) external returns (bytes memory output) {\n // Get the function selector.\n bytes4 selector = msg.sig;\n\n // Get the rest of the msg data after the selector.\n bytes calldata data = msg.data[4:];\n\n // Determine if we should forward the call to the implementation\n // contract with SeaDrop logic.\n bool callSeaDropImplementation = selector ==\n ISeaDropToken.updateAllowedSeaport.selector ||\n selector == ISeaDropToken.updateDropURI.selector ||\n selector == ISeaDropToken.updateAllowList.selector ||\n selector == ISeaDropToken.updateCreatorPayouts.selector ||\n selector == ISeaDropToken.updatePayer.selector ||\n selector == ISeaDropToken.updateAllowedFeeRecipient.selector ||\n selector == ISeaDropToken.updateSigner.selector ||\n selector == IERC1155SeaDrop.updatePublicDrop.selector ||\n selector == ContractOffererInterface.previewOrder.selector ||\n selector == ContractOffererInterface.generateOrder.selector ||\n selector == ContractOffererInterface.getSeaportMetadata.selector ||\n selector == IERC1155SeaDrop.getPublicDrop.selector ||\n selector == IERC1155SeaDrop.getPublicDropIndexes.selector ||\n selector == ISeaDropToken.getAllowedSeaport.selector ||\n selector == ISeaDropToken.getCreatorPayouts.selector ||\n selector == ISeaDropToken.getAllowListMerkleRoot.selector ||\n selector == ISeaDropToken.getAllowedFeeRecipients.selector ||\n selector == ISeaDropToken.getSigners.selector ||\n selector == ISeaDropToken.getDigestIsUsed.selector ||\n selector == ISeaDropToken.getPayers.selector;\n\n // Determine if we should require only the owner or configurer calling.\n bool requireOnlyOwnerOrConfigurer = selector ==\n ISeaDropToken.updateAllowedSeaport.selector ||\n selector == ISeaDropToken.updateDropURI.selector ||\n selector == ISeaDropToken.updateAllowList.selector ||\n selector == ISeaDropToken.updateCreatorPayouts.selector ||\n selector == ISeaDropToken.updatePayer.selector ||\n selector == ISeaDropToken.updateAllowedFeeRecipient.selector ||\n selector == IERC1155SeaDrop.updatePublicDrop.selector;\n\n if (callSeaDropImplementation) {\n // For update calls, ensure the sender is only the owner\n // or configurer contract.\n if (requireOnlyOwnerOrConfigurer) {\n _onlyOwnerOrConfigurer();\n } else if (selector == ISeaDropToken.updateSigner.selector) {\n // For updateSigner, a signer can disallow themselves.\n // Get the signer parameter.\n address signer = address(bytes20(data[12:32]));\n // If the signer is not allowed, ensure sender is only owner\n // or configurer.\n if (\n msg.sender != signer ||\n (msg.sender == signer &&\n !ERC1155SeaDropContractOffererStorage\n .layout()\n ._allowedSigners[signer])\n ) {\n _onlyOwnerOrConfigurer();\n }\n }\n\n // Forward the call to the implementation contract.\n (bool success, bytes memory returnedData) = _CONFIGURER\n .delegatecall(msg.data);\n\n // Require that the call was successful.\n if (!success) {\n // Bubble up the revert reason.\n assembly {\n revert(add(32, returnedData), mload(returnedData))\n }\n }\n\n // If the call was to generateOrder, mint the tokens.\n if (selector == ContractOffererInterface.generateOrder.selector) {\n _mintOrder(data);\n }\n\n // Return the data from the delegate call.\n return returnedData;\n } else if (selector == IERC1155SeaDrop.getMintStats.selector) {\n // Get the minter and token id.\n (address minter, uint256 tokenId) = abi.decode(\n data,\n (address, uint256)\n );\n\n // Get the mint stats.\n (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n ) = _getMintStats(minter, tokenId);\n\n // Encode the return data.\n return\n abi.encode(\n minterNumMinted,\n minterNumMintedForTokenId,\n totalMintedForTokenId,\n maxSupply\n );\n } else if (selector == ContractOffererInterface.ratifyOrder.selector) {\n // This function is a no-op, nothing additional needs to happen here.\n // Utilize assembly to efficiently return the ratifyOrder magic value.\n assembly {\n mstore(0, 0xf4dd92ce)\n return(0x1c, 32)\n }\n } else if (selector == ISeaDropToken.configurer.selector) {\n // Return the configurer contract.\n return abi.encode(_CONFIGURER);\n } else if (selector == IERC1155SeaDrop.multiConfigureMint.selector) {\n // Ensure only the owner or configurer can call this function.\n _onlyOwnerOrConfigurer();\n\n // Mint the tokens.\n _multiConfigureMint(data);\n } else {\n // Revert if the function selector is not supported.\n revert UnsupportedFunctionSelector(selector);\n }\n }\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists in enforcing maxSupply, maxTotalMintableByWallet,\n * and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC1155Received() hooks.\n *\n * @param minter The minter address.\n * @param tokenId The token id to return the stats for.\n */\n function _getMintStats(\n address minter,\n uint256 tokenId\n )\n internal\n view\n returns (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n )\n {\n // Put the token supply on the stack.\n TokenSupply storage tokenSupply = _tokenSupply[tokenId];\n\n // Assign the return values.\n totalMintedForTokenId = tokenSupply.totalMinted;\n maxSupply = tokenSupply.maxSupply;\n minterNumMinted = _totalMintedByUser[minter];\n minterNumMintedForTokenId = _totalMintedByUserPerToken[minter][tokenId];\n }\n\n /**\n * @dev Handle ERC-1155 safeTransferFrom. If \"from\" is this contract,\n * the sender can only be Seaport or the conduit.\n *\n * @param from The address to transfer from.\n * @param to The address to transfer to.\n * @param id The token id to transfer.\n * @param amount The amount of tokens to transfer.\n * @param data The data to pass to the onERC1155Received hook.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual override {\n if (from == address(this)) {\n // Only Seaport or the conduit can use this function\n // when \"from\" is this contract.\n if (\n msg.sender != _CONDUIT &&\n !ERC1155SeaDropContractOffererStorage.layout()._allowedSeaport[\n msg.sender\n ]\n ) {\n revert InvalidCallerOnlyAllowedSeaport(msg.sender);\n }\n return;\n }\n\n ERC1155._safeTransfer(_by(), from, to, id, amount, data);\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n virtual\n override(ERC1155ContractMetadataCloneable)\n returns (bool)\n {\n return\n interfaceId == type(IERC1155SeaDrop).interfaceId ||\n interfaceId == type(ContractOffererInterface).interfaceId ||\n interfaceId == 0x2e778efc || // SIP-5 (getSeaportMetadata)\n // ERC1155ContractMetadata returns supportsInterface true for\n // IERC1155ContractMetadata, ERC-4906, ERC-2981\n // ERC1155A returns supportsInterface true for\n // ERC165, ERC1155, ERC1155MetadataURI\n ERC1155ContractMetadataCloneable.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Internal function to mint tokens during a generateOrder call\n * from Seaport.\n *\n * @param data The original transaction calldata, without the selector.\n */\n function _mintOrder(bytes calldata data) internal {\n // Decode fulfiller, minimumReceived, and context from calldata.\n (\n address fulfiller,\n SpentItem[] memory minimumReceived,\n ,\n bytes memory context\n ) = abi.decode(data, (address, SpentItem[], SpentItem[], bytes));\n\n // Assign the minter from context[22:42]. We validate context has the\n // correct minimum length in the implementation's `_decodeOrder`.\n address minter;\n assembly {\n minter := shr(96, mload(add(add(context, 0x20), 22)))\n }\n\n // If the minter is the zero address, set it to the fulfiller.\n if (minter == address(0)) {\n minter = fulfiller;\n }\n\n // Set the token ids and quantities.\n uint256 minimumReceivedLength = minimumReceived.length;\n uint256[] memory tokenIds = new uint256[](minimumReceivedLength);\n uint256[] memory quantities = new uint256[](minimumReceivedLength);\n for (uint256 i = 0; i < minimumReceivedLength; ) {\n tokenIds[i] = minimumReceived[i].identifier;\n quantities[i] = minimumReceived[i].amount;\n unchecked {\n ++i;\n }\n }\n\n // Mint the tokens.\n _batchMint(minter, tokenIds, quantities, \"\");\n }\n\n /**\n * @dev Internal function to mint tokens during a multiConfigureMint call\n * from the configurer contract.\n *\n * @param data The original transaction calldata, without the selector.\n */\n function _multiConfigureMint(bytes calldata data) internal {\n // Decode the calldata.\n (\n address recipient,\n uint256[] memory tokenIds,\n uint256[] memory amounts\n ) = abi.decode(data, (address, uint256[], uint256[]));\n\n _batchMint(recipient, tokenIds, amounts, \"\");\n }\n}\n"
},
"src/interfaces/IERC1155SeaDrop.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { ISeaDropToken } from \"./ISeaDropToken.sol\";\n\nimport { PublicDrop } from \"../lib/ERC1155SeaDropStructs.sol\";\n\n/**\n * @dev A helper interface to get and set parameters for ERC1155SeaDrop.\n * The token does not expose these methods as part of its external\n * interface to optimize contract size, but does implement them.\n */\ninterface IERC1155SeaDrop is ISeaDropToken {\n /**\n * @notice Update the SeaDrop public drop parameters at a given index.\n *\n * @param publicDrop The new public drop parameters.\n * @param index The public drop index.\n */\n function updatePublicDrop(\n PublicDrop calldata publicDrop,\n uint256 index\n ) external;\n\n /**\n * @notice Returns the public drop stage parameters at a given index.\n *\n * @param index The index of the public drop stage.\n */\n function getPublicDrop(\n uint256 index\n ) external view returns (PublicDrop memory);\n\n /**\n * @notice Returns the public drop indexes.\n */\n function getPublicDropIndexes() external view returns (uint256[] memory);\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, maxTotalMintableByWalletPerToken,\n * and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC1155Received() hooks.\n *\n * @param minter The minter address.\n * @param tokenId The token id to return stats for.\n */\n function getMintStats(\n address minter,\n uint256 tokenId\n )\n external\n view\n returns (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n );\n\n /**\n * @notice This function is only allowed to be called by the configurer\n * contract as a way to batch mints and configuration in one tx.\n *\n * @param recipient The address to receive the mints.\n * @param tokenIds The tokenIds to mint.\n * @param amounts The amounts to mint.\n */\n function multiConfigureMint(\n address recipient,\n uint256[] calldata tokenIds,\n uint256[] calldata amounts\n ) external;\n}\n"
},
"src/interfaces/ISeaDropToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\nimport { AllowListData, CreatorPayout } from \"../lib/SeaDropStructs.sol\";\n\n/**\n * @dev A helper base interface for IERC721SeaDrop and IERC1155SeaDrop.\n * The token does not expose these methods as part of its external\n * interface to optimize contract size, but does implement them.\n */\ninterface ISeaDropToken is ISeaDropTokenContractMetadata {\n /**\n * @notice Update the SeaDrop allowed Seaport contracts privileged to mint.\n * Only the owner can use this function.\n *\n * @param allowedSeaport The allowed Seaport addresses.\n */\n function updateAllowedSeaport(address[] calldata allowedSeaport) external;\n\n /**\n * @notice Update the SeaDrop allowed fee recipient.\n * Only the owner can use this function.\n *\n * @param feeRecipient The new fee recipient.\n * @param allowed Whether the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(\n address feeRecipient,\n bool allowed\n ) external;\n\n /**\n * @notice Update the SeaDrop creator payout addresses.\n * The total basis points must add up to exactly 10_000.\n * Only the owner can use this function.\n *\n * @param creatorPayouts The new creator payouts.\n */\n function updateCreatorPayouts(\n CreatorPayout[] calldata creatorPayouts\n ) external;\n\n /**\n * @notice Update the SeaDrop drop URI.\n * Only the owner can use this function.\n *\n * @param dropURI The new drop URI.\n */\n function updateDropURI(string calldata dropURI) external;\n\n /**\n * @notice Update the SeaDrop allow list data.\n * Only the owner can use this function.\n *\n * @param allowListData The new allow list data.\n */\n function updateAllowList(AllowListData calldata allowListData) external;\n\n /**\n * @notice Update the SeaDrop allowed payers.\n * Only the owner can use this function.\n *\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(address payer, bool allowed) external;\n\n /**\n * @notice Update the SeaDrop allowed signer.\n * Only the owner can use this function.\n * An allowed signer can also disallow themselves.\n *\n * @param signer The signer to update.\n * @param allowed Whether the signer is allowed.\n */\n function updateSigner(address signer, bool allowed) external;\n\n /**\n * @notice Get the SeaDrop allowed Seaport contracts privileged to mint.\n */\n function getAllowedSeaport() external view returns (address[] memory);\n\n /**\n * @notice Returns the SeaDrop creator payouts.\n */\n function getCreatorPayouts() external view returns (CreatorPayout[] memory);\n\n /**\n * @notice Returns the SeaDrop allow list merkle root.\n */\n function getAllowListMerkleRoot() external view returns (bytes32);\n\n /**\n * @notice Returns the SeaDrop allowed fee recipients.\n */\n function getAllowedFeeRecipients() external view returns (address[] memory);\n\n /**\n * @notice Returns the SeaDrop allowed signers.\n */\n function getSigners() external view returns (address[] memory);\n\n /**\n * @notice Returns if the signed digest has been used.\n *\n * @param digest The digest hash.\n */\n function getDigestIsUsed(bytes32 digest) external view returns (bool);\n\n /**\n * @notice Returns the SeaDrop allowed payers.\n */\n function getPayers() external view returns (address[] memory);\n\n /**\n * @notice Returns the configurer contract.\n */\n function configurer() external view returns (address);\n}\n"
},
"src/clones/ERC1155ContractMetadataCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n IERC1155ContractMetadata\n} from \"../interfaces/IERC1155ContractMetadata.sol\";\n\nimport {\n ERC1155ConduitPreapproved\n} from \"../lib/ERC1155ConduitPreapproved.sol\";\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\nimport { ERC2981 } from \"solady/src/tokens/ERC2981.sol\";\n\nimport { Ownable } from \"solady/src/auth/Ownable.sol\";\n\nimport {\n Initializable\n} from \"@openzeppelin-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\n/**\n * @title ERC1155ContractMetadataCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable token contract that extends ERC-1155\n * with additional metadata and ownership capabilities.\n */\ncontract ERC1155ContractMetadataCloneable is\n ERC1155ConduitPreapproved,\n ERC2981,\n Ownable,\n IERC1155ContractMetadata,\n Initializable\n{\n /// @notice A struct containing the token supply info per token id.\n mapping(uint256 => TokenSupply) _tokenSupply;\n\n /// @notice The total number of tokens minted by address.\n mapping(address => uint256) _totalMintedByUser;\n\n /// @notice The total number of tokens minted per token id by address.\n mapping(address => mapping(uint256 => uint256)) _totalMintedByUserPerToken;\n\n /// @notice The name of the token.\n string internal _name;\n\n /// @notice The symbol of the token.\n string internal _symbol;\n\n /// @notice The base URI for token metadata.\n string internal _baseURI;\n\n /// @notice The contract URI for contract metadata.\n string internal _contractURI;\n\n /// @notice The provenance hash for guaranteeing metadata order\n /// for random reveals.\n bytes32 internal _provenanceHash;\n\n /// @notice The allowed contract that can configure SeaDrop parameters.\n address internal _CONFIGURER;\n\n /**\n * @dev Reverts if the sender is not the owner or the allowed\n * configurer contract.\n *\n * This is used as a function instead of a modifier\n * to save contract space when used multiple times.\n */\n function _onlyOwnerOrConfigurer() internal view {\n if (msg.sender != _CONFIGURER && msg.sender != owner()) {\n revert Unauthorized();\n }\n }\n\n /**\n * @notice Deploy the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * configure parameters. Also contains SeaDrop\n * implementation code.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function __ERC1155ContractMetadataCloneable_init(\n address allowedConfigurer,\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n // Set the name of the token.\n _name = name_;\n\n // Set the symbol of the token.\n _symbol = symbol_;\n\n // Set the allowed configurer contract to interact with this contract.\n _CONFIGURER = allowedConfigurer;\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param newBaseURI The new base URI to set.\n */\n function setBaseURI(string calldata newBaseURI) external override {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the new base URI.\n _baseURI = newBaseURI;\n\n // Emit an event with the update.\n emit BatchMetadataUpdate(0, type(uint256).max);\n }\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external override {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the new contract URI.\n _contractURI = newContractURI;\n\n // Emit an event with the update.\n emit ContractURIUpdated(newContractURI);\n }\n\n /**\n * @notice Emit an event notifying metadata updates for\n * a range of token ids, according to EIP-4906.\n *\n * @param fromTokenId The start token id.\n * @param toTokenId The end token id.\n */\n function emitBatchMetadataUpdate(\n uint256 fromTokenId,\n uint256 toTokenId\n ) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Emit an event with the update.\n if (fromTokenId == toTokenId) {\n // If only one token is being updated, use the event\n // in the 1155 spec.\n emit URI(uri(fromTokenId), fromTokenId);\n } else {\n emit BatchMetadataUpdate(fromTokenId, toTokenId);\n }\n }\n\n /**\n * @notice Sets the max token supply and emits an event.\n *\n * @param tokenId The token id to set the max supply for.\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 tokenId, uint256 newMaxSupply) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Ensure the max supply does not exceed the maximum value of uint64,\n // a limit due to the storage of bit-packed variables in TokenSupply,\n if (newMaxSupply > 2 ** 64 - 1) {\n revert CannotExceedMaxSupplyOfUint64(newMaxSupply);\n }\n\n // Set the new max supply.\n _tokenSupply[tokenId].maxSupply = uint64(newMaxSupply);\n\n // Emit an event with the update.\n emit MaxSupplyUpdated(tokenId, newMaxSupply);\n }\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert if the provenance hash has already\n * been set, so be sure to carefully set it only once.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Keep track of the old provenance hash for emitting with the event.\n bytes32 oldProvenanceHash = _provenanceHash;\n\n // Revert if the provenance hash has already been set.\n if (oldProvenanceHash != bytes32(0)) {\n revert ProvenanceHashCannotBeSetAfterAlreadyBeingSet();\n }\n\n // Set the new provenance hash.\n _provenanceHash = newProvenanceHash;\n\n // Emit an event with the update.\n emit ProvenanceHashUpdated(oldProvenanceHash, newProvenanceHash);\n }\n\n /**\n * @notice Sets the default royalty information.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator of 10_000 basis points.\n */\n function setDefaultRoyalty(address receiver, uint96 feeNumerator) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the default royalty.\n // ERC2981 implementation ensures feeNumerator <= feeDenominator\n // and receiver != address(0).\n _setDefaultRoyalty(receiver, feeNumerator);\n\n // Emit an event with the updated params.\n emit RoyaltyInfoUpdated(receiver, feeNumerator);\n }\n\n /**\n * @notice Returns the name of the token.\n */\n function name() external view returns (string memory) {\n return _name;\n }\n\n /**\n * @notice Returns the symbol of the token.\n */\n function symbol() external view returns (string memory) {\n return _symbol;\n }\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view override returns (string memory) {\n return _baseURI;\n }\n\n /**\n * @notice Returns the contract URI for contract metadata.\n */\n function contractURI() external view override returns (string memory) {\n return _contractURI;\n }\n\n /**\n * @notice Returns the max token supply for a token id.\n */\n function maxSupply(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].maxSupply;\n }\n\n /**\n * @notice Returns the total supply for a token id.\n */\n function totalSupply(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].totalSupply;\n }\n\n /**\n * @notice Returns the total minted for a token id.\n */\n function totalMinted(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].totalMinted;\n }\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view override returns (bytes32) {\n return _provenanceHash;\n }\n\n /**\n * @notice Returns the URI for token metadata.\n *\n * This implementation returns the same URI for *all* token types.\n * It relies on the token type ID substitution mechanism defined\n * in the EIP to replace {id} with the token id.\n *\n * @custom:param tokenId The token id to get the URI for.\n */\n function uri(\n uint256 /* tokenId */\n ) public view virtual override returns (string memory) {\n // Return the base URI.\n return _baseURI;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC1155, ERC2981) returns (bool) {\n return\n interfaceId == type(IERC1155ContractMetadata).interfaceId ||\n interfaceId == 0x49064906 || // ERC-4906 (MetadataUpdate)\n ERC2981.supportsInterface(interfaceId) ||\n // ERC1155 returns supportsInterface true for\n // ERC165, ERC1155, ERC1155MetadataURI\n ERC1155.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Adds to the internal counters for a mint.\n *\n * @param to The address to mint to.\n * @param id The token id to mint.\n * @param amount The quantity to mint.\n * @param data The data to pass if receiver is a contract.\n */\n function _mint(\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual override {\n // Increment mint counts.\n _incrementMintCounts(to, id, amount);\n\n ERC1155._mint(to, id, amount, data);\n }\n\n /**\n * @dev Adds to the internal counters for a batch mint.\n *\n * @param to The address to mint to.\n * @param ids The token ids to mint.\n * @param amounts The quantities to mint.\n * @param data The data to pass if receiver is a contract.\n */\n function _batchMint(\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual override {\n // Put ids length on the stack to save MLOADs.\n uint256 idsLength = ids.length;\n\n for (uint256 i = 0; i < idsLength; ) {\n // Increment mint counts.\n _incrementMintCounts(to, ids[i], amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n\n ERC1155._batchMint(to, ids, amounts, data);\n }\n\n /**\n * @dev Subtracts from the internal counters for a burn.\n *\n * @param by The address calling the burn.\n * @param from The address to burn from.\n * @param id The token id to burn.\n * @param amount The amount to burn.\n */\n function _burn(\n address by,\n address from,\n uint256 id,\n uint256 amount\n ) internal virtual override {\n // Reduce the supply.\n _reduceSupplyOnBurn(id, amount);\n\n ERC1155._burn(by, from, id, amount);\n }\n\n /**\n * @dev Subtracts from the internal counters for a batch burn.\n *\n * @param by The address calling the burn.\n * @param from The address to burn from.\n * @param ids The token ids to burn.\n * @param amounts The amounts to burn.\n */\n function _batchBurn(\n address by,\n address from,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal virtual override {\n // Put ids length on the stack to save MLOADs.\n uint256 idsLength = ids.length;\n\n for (uint256 i = 0; i < idsLength; ) {\n // Reduce the supply.\n _reduceSupplyOnBurn(ids[i], amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n\n ERC1155._batchBurn(by, from, ids, amounts);\n }\n\n function _reduceSupplyOnBurn(uint256 id, uint256 amount) internal {\n // Get the current token supply.\n TokenSupply storage tokenSupply = _tokenSupply[id];\n\n // Reduce the totalSupply.\n unchecked {\n tokenSupply.totalSupply -= uint64(amount);\n }\n }\n\n /**\n * @dev Internal function to increment mint counts.\n *\n * Note that this function does not check if the mint exceeds\n * maxSupply, which should be validated before this function is called.\n *\n * @param to The address to mint to.\n * @param id The token id to mint.\n * @param amount The quantity to mint.\n */\n function _incrementMintCounts(\n address to,\n uint256 id,\n uint256 amount\n ) internal {\n // Get the current token supply.\n TokenSupply storage tokenSupply = _tokenSupply[id];\n\n if (tokenSupply.totalMinted + amount > tokenSupply.maxSupply) {\n revert MintExceedsMaxSupply(\n tokenSupply.totalMinted + amount,\n tokenSupply.maxSupply\n );\n }\n\n // Increment supply and number minted.\n // Can be unchecked because maxSupply cannot be set to exceed uint64.\n unchecked {\n tokenSupply.totalSupply += uint64(amount);\n tokenSupply.totalMinted += uint64(amount);\n\n // Increment total minted by user.\n _totalMintedByUser[to] += amount;\n\n // Increment total minted by user per token.\n _totalMintedByUserPerToken[to][id] += amount;\n }\n }\n}\n"
},
"src/lib/ERC1155SeaDropContractOffererStorage.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { PublicDrop } from \"./ERC1155SeaDropStructs.sol\";\n\nimport { CreatorPayout } from \"./SeaDropStructs.sol\";\n\nlibrary ERC1155SeaDropContractOffererStorage {\n struct Layout {\n /// @notice The allowed Seaport addresses that can mint.\n mapping(address => bool) _allowedSeaport;\n /// @notice The enumerated allowed Seaport addresses.\n address[] _enumeratedAllowedSeaport;\n /// @notice The public drop data.\n mapping(uint256 => PublicDrop) _publicDrops;\n /// @notice The enumerated public drop indexes.\n uint256[] _enumeratedPublicDropIndexes;\n /// @notice The creator payout addresses and basis points.\n CreatorPayout[] _creatorPayouts;\n /// @notice The allow list merkle root.\n bytes32 _allowListMerkleRoot;\n /// @notice The allowed fee recipients.\n mapping(address => bool) _allowedFeeRecipients;\n /// @notice The enumerated allowed fee recipients.\n address[] _enumeratedFeeRecipients;\n /// @notice The allowed server-side signers.\n mapping(address => bool) _allowedSigners;\n /// @notice The enumerated allowed signers.\n address[] _enumeratedSigners;\n /// @notice The used signature digests.\n mapping(bytes32 => bool) _usedDigests;\n /// @notice The allowed payers.\n mapping(address => bool) _allowedPayers;\n /// @notice The enumerated allowed payers.\n address[] _enumeratedPayers;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n bytes32(\n uint256(\n keccak256(\"contracts.storage.ERC1155SeaDropContractOfferer\")\n ) - 1\n );\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n"
},
"src/lib/ERC1155SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { PublicDrop } from \"./ERC1155SeaDropStructs.sol\";\n\nimport { SeaDropErrorsAndEvents } from \"./SeaDropErrorsAndEvents.sol\";\n\ninterface ERC1155SeaDropErrorsAndEvents is SeaDropErrorsAndEvents {\n /**\n * @dev Revert with an error if an empty PublicDrop is provided\n * for an already-empty public drop.\n */\n error PublicDropStageNotPresent();\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the\n * max minted per wallet for a certain token id.\n */\n error MintQuantityExceedsMaxMintedPerWalletForTokenId(\n uint256 tokenId,\n uint256 total,\n uint256 allowed\n );\n\n /**\n * @dev Revert with an error if the target token id to mint is not within\n * the drop stage range.\n */\n error TokenIdNotWithinDropStageRange(\n uint256 tokenId,\n uint256 startTokenId,\n uint256 endTokenId\n );\n\n /**\n * @notice Revert with an error if the number of maxSupplyAmounts doesn't\n * match the number of maxSupplyTokenIds.\n */\n error MaxSupplyMismatch();\n\n /**\n * @notice Revert with an error if the number of mint tokenIds doesn't\n * match the number of mint amounts.\n */\n error MintAmountsMismatch();\n\n /**\n * @notice Revert with an error if the mint order offer contains\n * a duplicate tokenId.\n */\n error OfferContainsDuplicateTokenId(uint256 tokenId);\n\n /**\n * @dev Revert if the fromTokenId is greater than the toTokenId.\n */\n error InvalidFromAndToTokenId(uint256 fromTokenId, uint256 toTokenId);\n\n /**\n * @notice Revert with an error if the number of publicDropIndexes doesn't\n * match the number of publicDrops.\n */\n error PublicDropsMismatch();\n\n /**\n * @dev An event with updated public drop data.\n */\n event PublicDropUpdated(PublicDrop publicDrop, uint256 index);\n}\n"
},
"src/lib/ERC1155SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { AllowListData, CreatorPayout } from \"./SeaDropStructs.sol\";\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in two storage slots.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n * @param paymentToken The payment token address. Null for\n * native token.\n * @param fromTokenId The start token id for the stage.\n * @param toTokenId The end token id for the stage.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param maxTotalMintableByWalletPerToken Maximum total number of mints a user\n * is allowed for the token id. (The limit for\n * this field is 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n */\nstruct PublicDrop {\n // slot 1\n uint80 startPrice; // 80/512 bits\n uint80 endPrice; // 160/512 bits\n uint40 startTime; // 200/512 bits\n uint40 endTime; // 240/512 bits\n bool restrictFeeRecipients; // 248/512 bits\n // uint8 unused;\n\n // slot 2\n address paymentToken; // 408/512 bits\n uint24 fromTokenId; // 432/512 bits\n uint24 toTokenId; // 456/512 bits\n uint16 maxTotalMintableByWallet; // 472/512 bits\n uint16 maxTotalMintableByWalletPerToken; // 488/512 bits\n uint16 feeBps; // 504/512 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n *\n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token for the mint. Null for\n * native token.\n * @param fromTokenId The start token id for the stage.\n * @param toTokenId The end token id for the stage.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param maxTotalMintableByWalletPerToken Maximum total number of mints a user\n * is allowed for the token id.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 startPrice;\n uint256 endPrice;\n uint256 startTime;\n uint256 endTime;\n address paymentToken;\n uint256 fromTokenId;\n uint256 toTokenId;\n uint256 maxTotalMintableByWallet;\n uint256 maxTotalMintableByWalletPerToken;\n uint256 maxTokenSupplyForStage;\n uint256 dropStageIndex; // non-zero\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @dev Struct containing internal SeaDrop implementation logic\n * mint details to avoid stack too deep.\n *\n * @param feeRecipient The fee recipient.\n * @param payer The payer of the mint.\n * @param minter The mint recipient.\n * @param tokenIds The tokenIds to mint.\n * @param quantities The number of tokens to mint per tokenId.\n * @param withEffects Whether to apply state changes of the mint.\n */\nstruct MintDetails {\n address feeRecipient;\n address payer;\n address minter;\n uint256[] tokenIds;\n uint256[] quantities;\n bool withEffects;\n}\n\n/**\n * @notice A struct to configure multiple contract options in one transaction.\n */\nstruct MultiConfigureStruct {\n uint256[] maxSupplyTokenIds;\n uint256[] maxSupplyAmounts;\n string baseURI;\n string contractURI;\n PublicDrop[] publicDrops;\n uint256[] publicDropsIndexes;\n string dropURI;\n AllowListData allowListData;\n CreatorPayout[] creatorPayouts;\n bytes32 provenanceHash;\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n address[] allowedPayers;\n address[] disallowedPayers;\n // Server-signed\n address[] allowedSigners;\n address[] disallowedSigners;\n // ERC-2981\n address royaltyReceiver;\n uint96 royaltyBps;\n // Mint\n address mintRecipient;\n uint256[] mintTokenIds;\n uint256[] mintAmounts;\n}\n"
},
"src/lib/SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\n/**\n * @notice A struct defining a creator payout address and basis points.\n *\n * @param payoutAddress The payout address.\n * @param basisPoints The basis points to pay out to the creator.\n * The total creator payouts must equal 10_000 bps.\n */\nstruct CreatorPayout {\n address payoutAddress;\n uint16 basisPoints;\n}\n\n/**\n * @notice A struct defining allow list data (for minting an allow list).\n *\n * @param merkleRoot The merkle root for the allow list.\n * @param publicKeyURIs If the allowListURI is encrypted, a list of URIs\n * pointing to the public keys. Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\nstruct AllowListData {\n bytes32 merkleRoot;\n string[] publicKeyURIs;\n string allowListURI;\n}\n"
},
"src/lib/ERC1155ConduitPreapproved.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\n/**\n * @title ERC1155ConduitPreapproved\n * @notice Solady's ERC1155 with the OpenSea conduit preapproved.\n */\nabstract contract ERC1155ConduitPreapproved is ERC1155 {\n /// @dev The canonical OpenSea conduit.\n address internal constant _CONDUIT =\n 0x1E0049783F008A0085193E00003D00cd54003c71;\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual override {\n _safeTransfer(_by(), from, to, id, amount, data);\n }\n\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) public virtual override {\n _safeBatchTransfer(_by(), from, to, ids, amounts, data);\n }\n\n function isApprovedForAll(\n address owner,\n address operator\n ) public view virtual override returns (bool) {\n if (operator == _CONDUIT) return true;\n return ERC1155.isApprovedForAll(owner, operator);\n }\n\n function _by() internal view returns (address result) {\n assembly {\n // `msg.sender == _CONDUIT ? address(0) : msg.sender`.\n result := mul(iszero(eq(caller(), _CONDUIT)), caller())\n }\n }\n}\n"
},
"lib/solady/src/tokens/ERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple ERC1155 implementation.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC1155.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC1155/ERC1155.sol)\n///\n/// @dev Note:\n/// The ERC1155 standard allows for self-approvals.\n/// For performance, this implementation WILL NOT revert for such actions.\n/// Please add any checks with overrides if desired.\nabstract contract ERC1155 {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The lengths of the input arrays are not the same.\n error ArrayLengthsMismatch();\n\n /// @dev Cannot mint or transfer to the zero address.\n error TransferToZeroAddress();\n\n /// @dev The recipient's balance has overflowed.\n error AccountBalanceOverflow();\n\n /// @dev Insufficient balance.\n error InsufficientBalance();\n\n /// @dev Only the token owner or an approved account can manage the tokens.\n error NotOwnerNorApproved();\n\n /// @dev Cannot safely transfer to a contract that does not implement\n /// the ERC1155Receiver interface.\n error TransferToNonERC1155ReceiverImplementer();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EVENTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Emitted when `amount` of token `id` is transferred\n /// from `from` to `to` by `operator`.\n event TransferSingle(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256 id,\n uint256 amount\n );\n\n /// @dev Emitted when `amounts` of token `ids` are transferred\n /// from `from` to `to` by `operator`.\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] amounts\n );\n\n /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.\n event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);\n\n /// @dev Emitted when the Uniform Resource Identifier (URI) for token `id`\n /// is updated to `value`. This event is not used in the base contract.\n /// You may need to emit this event depending on your URI logic.\n ///\n /// See: https://eips.ethereum.org/EIPS/eip-1155#metadata\n event URI(string value, uint256 indexed id);\n\n /// @dev `keccak256(bytes(\"TransferSingle(address,address,address,uint256,uint256)\"))`.\n uint256 private constant _TRANSFER_SINGLE_EVENT_SIGNATURE =\n 0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62;\n\n /// @dev `keccak256(bytes(\"TransferBatch(address,address,address,uint256[],uint256[])\"))`.\n uint256 private constant _TRANSFER_BATCH_EVENT_SIGNATURE =\n 0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb;\n\n /// @dev `keccak256(bytes(\"ApprovalForAll(address,address,bool)\"))`.\n uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =\n 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The `ownerSlotSeed` of a given owner is given by.\n /// ```\n /// let ownerSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner))\n /// ```\n ///\n /// The balance slot of `owner` is given by.\n /// ```\n /// mstore(0x20, ownerSlotSeed)\n /// mstore(0x00, id)\n /// let balanceSlot := keccak256(0x00, 0x40)\n /// ```\n ///\n /// The operator approval slot of `owner` is given by.\n /// ```\n /// mstore(0x20, ownerSlotSeed)\n /// mstore(0x00, operator)\n /// let operatorApprovalSlot := keccak256(0x0c, 0x34)\n /// ```\n uint256 private constant _ERC1155_MASTER_SLOT_SEED = 0x9a31110384e0b0c9;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC1155 METADATA */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the URI for token `id`.\n ///\n /// You can either return the same templated URI for all token IDs,\n /// (e.g. \"https://example.com/api/{id}.json\"),\n /// or return a unique URI for each `id`.\n ///\n /// See: https://eips.ethereum.org/EIPS/eip-1155#metadata\n function uri(uint256 id) public view virtual returns (string memory);\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC1155 */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the amount of `id` owned by `owner`.\n function balanceOf(address owner, uint256 id) public view virtual returns (uint256 result) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, owner)\n mstore(0x00, id)\n result := sload(keccak256(0x00, 0x40))\n }\n }\n\n /// @dev Returns whether `operator` is approved to manage the tokens of `owner`.\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n returns (bool result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, owner)\n mstore(0x00, operator)\n result := sload(keccak256(0x0c, 0x34))\n }\n }\n\n /// @dev Sets whether `operator` is approved to manage the tokens of the caller.\n ///\n /// Emits a {ApprovalForAll} event.\n function setApprovalForAll(address operator, bool isApproved) public virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Convert to 0 or 1.\n isApproved := iszero(iszero(isApproved))\n // Update the `isApproved` for (`msg.sender`, `operator`).\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, caller())\n mstore(0x00, operator)\n sstore(keccak256(0x0c, 0x34), isApproved)\n // Emit the {ApprovalForAll} event.\n mstore(0x00, isApproved)\n // forgefmt: disable-next-line\n log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), shr(96, shl(96, operator)))\n }\n }\n\n /// @dev Transfers `amount` of `id` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - If the caller is not `from`,\n /// it must be approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from))\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to))\n mstore(0x20, fromSlotSeed)\n // Clear the upper 96 bits.\n from := shr(96, fromSlotSeed)\n to := shr(96, toSlotSeed)\n // Revert if `to` is the zero address.\n if iszero(to) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // If the caller is not `from`, do the authorization check.\n if iszero(eq(caller(), from)) {\n mstore(0x00, caller())\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), from, to)\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Do the {onERC1155Received} check if `to` is a smart contract.\n if extcodesize(to) {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155Received(address,address,uint256,uint256,bytes)`.\n mstore(m, 0xf23a6e61)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), from)\n mstore(add(m, 0x60), id)\n mstore(add(m, 0x80), amount)\n mstore(add(m, 0xa0), 0xa0)\n calldatacopy(add(m, 0xc0), sub(data.offset, 0x20), add(0x20, data.length))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, data.length), m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xf23a6e61))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n }\n\n /// @dev Transfers `amounts` of `ids` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - `ids` and `amounts` must have the same length.\n /// - If the caller is not `from`,\n /// it must be approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) public virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(ids.length, amounts.length)) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from))\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to))\n mstore(0x20, fromSlotSeed)\n // Clear the upper 96 bits.\n from := shr(96, fromSlotSeed)\n to := shr(96, toSlotSeed)\n // Revert if `to` is the zero address.\n if iszero(to) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // If the caller is not `from`, do the authorization check.\n if iszero(eq(caller(), from)) {\n mstore(0x00, caller())\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, ids.length)\n for { let i := 0 } iszero(eq(i, end)) { i := add(i, 0x20) } {\n let amount := calldataload(add(amounts.offset, i))\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x20, fromSlotSeed)\n mstore(0x00, calldataload(add(ids.offset, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, ids.length))\n let o := add(m, 0x40)\n calldatacopy(o, sub(ids.offset, 0x20), n)\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, n))\n o := add(o, n)\n n := add(0x20, shl(5, amounts.length))\n calldatacopy(o, sub(amounts.offset, 0x20), n)\n n := sub(add(o, n), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), from, to)\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransferCalldata(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Do the {onERC1155BatchReceived} check if `to` is a smart contract.\n if extcodesize(to) {\n let m := mload(0x40)\n // Prepare the calldata.\n // `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`.\n mstore(m, 0xbc197c81)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), from)\n // Copy the `ids`.\n mstore(add(m, 0x60), 0xa0)\n let n := add(0x20, shl(5, ids.length))\n let o := add(m, 0xc0)\n calldatacopy(o, sub(ids.offset, 0x20), n)\n // Copy the `amounts`.\n let s := add(0xa0, n)\n mstore(add(m, 0x80), s)\n o := add(o, n)\n n := add(0x20, shl(5, amounts.length))\n calldatacopy(o, sub(amounts.offset, 0x20), n)\n // Copy the `data`.\n mstore(add(m, 0xa0), add(s, n))\n o := add(o, n)\n n := add(0x20, data.length)\n calldatacopy(o, sub(data.offset, 0x20), n)\n n := sub(add(o, n), add(m, 0x1c))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), n, m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xbc197c81))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n }\n\n /// @dev Returns the amounts of `ids` for `owners.\n ///\n /// Requirements:\n /// - `owners` and `ids` must have the same length.\n function balanceOfBatch(address[] calldata owners, uint256[] calldata ids)\n public\n view\n virtual\n returns (uint256[] memory balances)\n {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(ids.length, owners.length)) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n balances := mload(0x40)\n mstore(balances, ids.length)\n let o := add(balances, 0x20)\n let end := shl(5, ids.length)\n mstore(0x40, add(end, o))\n // Loop through all the `ids` and load the balances.\n for { let i := 0 } iszero(eq(i, end)) { i := add(i, 0x20) } {\n let owner := calldataload(add(owners.offset, i))\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner)))\n mstore(0x00, calldataload(add(ids.offset, i)))\n mstore(add(o, i), sload(keccak256(0x00, 0x40)))\n }\n }\n }\n\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\n /// See: https://eips.ethereum.org/EIPS/eip-165\n /// This function call must use less than 30000 gas.\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := shr(224, interfaceId)\n // ERC165: 0x01ffc9a7, ERC1155: 0xd9b67a26, ERC1155MetadataURI: 0x0e89341c.\n result := or(or(eq(s, 0x01ffc9a7), eq(s, 0xd9b67a26)), eq(s, 0x0e89341c))\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL MINT FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Mints `amount` of `id` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(address(0), to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, to)\n mstore(0x00, id)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x00, id)\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), 0, shr(96, to_))\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(address(0), to, _single(id), _single(amount), data);\n }\n if (_hasCode(to)) _checkOnERC1155Received(address(0), to, id, amount, data);\n }\n\n /// @dev Mints `amounts` of `ids` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `ids` and `amounts` must have the same length.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function _batchMint(\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(address(0), to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // Loop through all the `ids` and update the balances.\n {\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_))\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Increase and store the updated balance of `to`.\n {\n mstore(0x00, mload(add(ids, i)))\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), 0, shr(96, to_))\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(address(0), to, ids, amounts, data);\n }\n if (_hasCode(to)) _checkOnERC1155BatchReceived(address(0), to, ids, amounts, data);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL BURN FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Equivalent to `_burn(address(0), from, id, amount)`.\n function _burn(address from, uint256 id, uint256 amount) internal virtual {\n _burn(address(0), from, id, amount);\n }\n\n /// @dev Destroys `amount` of `id` from `from`.\n ///\n /// Requirements:\n /// - `from` must have at least `amount` of `id`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n ///\n /// Emits a {Transfer} event.\n function _burn(address by, address from, uint256 id, uint256 amount) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, address(0), _single(id), _single(amount), \"\");\n }\n /// @solidity memory-safe-assembly\n assembly {\n let from_ := shl(96, from)\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n if iszero(or(iszero(shl(96, by)), eq(shl(96, by), from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Decrease and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Emit a {TransferSingle} event.\n mstore(0x00, id)\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), 0)\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, address(0), _single(id), _single(amount), \"\");\n }\n }\n\n /// @dev Equivalent to `_batchBurn(address(0), from, ids, amounts)`.\n function _batchBurn(address from, uint256[] memory ids, uint256[] memory amounts)\n internal\n virtual\n {\n _batchBurn(address(0), from, ids, amounts);\n }\n\n /// @dev Destroys `amounts` of `ids` from `from`.\n ///\n /// Requirements:\n /// - `ids` and `amounts` must have the same length.\n /// - `from` must have at least `amounts` of `ids`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n ///\n /// Emits a {TransferBatch} event.\n function _batchBurn(address by, address from, uint256[] memory ids, uint256[] memory amounts)\n internal\n virtual\n {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, address(0), ids, amounts, \"\");\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let from_ := shl(96, from)\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Decrease and store the updated balance of `to`.\n {\n mstore(0x00, mload(add(ids, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), 0)\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, address(0), ids, amounts, \"\");\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL APPROVAL FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Approve or remove the `operator` as an operator for `by`,\n /// without authorization checks.\n ///\n /// Emits a {ApprovalForAll} event.\n function _setApprovalForAll(address by, address operator, bool isApproved) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Convert to 0 or 1.\n isApproved := iszero(iszero(isApproved))\n // Update the `isApproved` for (`by`, `operator`).\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, by)\n mstore(0x00, operator)\n sstore(keccak256(0x0c, 0x34), isApproved)\n // Emit the {ApprovalForAll} event.\n mstore(0x00, isApproved)\n let m := shr(96, not(0))\n log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, and(m, by), and(m, operator))\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL TRANSFER FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Equivalent to `_safeTransfer(address(0), from, to, id, amount, data)`.\n function _safeTransfer(address from, address to, uint256 id, uint256 amount, bytes memory data)\n internal\n virtual\n {\n _safeTransfer(address(0), from, to, id, amount, data);\n }\n\n /// @dev Transfers `amount` of `id` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function _safeTransfer(\n address by,\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let from_ := shl(96, from)\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_))\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x20, amount)\n // forgefmt: disable-next-line\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_))\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n if (_hasCode(to)) _checkOnERC1155Received(from, to, id, amount, data);\n }\n\n /// @dev Equivalent to `_safeBatchTransfer(address(0), from, to, ids, amounts, data)`.\n function _safeBatchTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _safeBatchTransfer(address(0), from, to, ids, amounts, data);\n }\n\n /// @dev Transfers `amounts` of `ids` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `ids` and `amounts` must have the same length.\n /// - `from` must have at least `amounts` of `ids`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function _safeBatchTransfer(\n address by,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let from_ := shl(96, from)\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, from_)\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, to_)\n mstore(0x20, fromSlotSeed)\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x20, fromSlotSeed)\n mstore(0x00, mload(add(ids, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_))\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, ids, amounts, data);\n }\n if (_hasCode(to)) _checkOnERC1155BatchReceived(from, to, ids, amounts, data);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* HOOKS FOR OVERRIDING */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Override this function to return true if `_beforeTokenTransfer` is used.\n /// The is to help the compiler avoid producing dead bytecode.\n function _useBeforeTokenTransfer() internal view virtual returns (bool) {\n return false;\n }\n\n /// @dev Hook that is called before any token transfer.\n /// This includes minting and burning, as well as batched variants.\n ///\n /// The same hook is called on both single and batched variants.\n /// For single transfers, the length of the `id` and `amount` arrays are 1.\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n\n /// @dev Override this function to return true if `_afterTokenTransfer` is used.\n /// The is to help the compiler avoid producing dead bytecode.\n function _useAfterTokenTransfer() internal view virtual returns (bool) {\n return false;\n }\n\n /// @dev Hook that is called after any token transfer.\n /// This includes minting and burning, as well as batched variants.\n ///\n /// The same hook is called on both single and batched variants.\n /// For single transfers, the length of the `id` and `amount` arrays are 1.\n function _afterTokenTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PRIVATE HELPERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Helper for calling the `_afterTokenTransfer` hook.\n /// The is to help the compiler avoid producing dead bytecode.\n function _afterTokenTransferCalldata(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) private {\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, ids, amounts, data);\n }\n }\n\n /// @dev Returns if `a` has bytecode of non-zero length.\n function _hasCode(address a) private view returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := extcodesize(a) // Can handle dirty upper bits.\n }\n }\n\n /// @dev Perform a call to invoke {IERC1155Receiver-onERC1155Received} on `to`.\n /// Reverts if the target does not support the function correctly.\n function _checkOnERC1155Received(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) private {\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155Received(address,address,uint256,uint256,bytes)`.\n mstore(m, 0xf23a6e61)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), shr(96, shl(96, from)))\n mstore(add(m, 0x60), id)\n mstore(add(m, 0x80), amount)\n mstore(add(m, 0xa0), 0xa0)\n let n := mload(data)\n mstore(add(m, 0xc0), n)\n if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xe0), n)) }\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, n), m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xf23a6e61))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Perform a call to invoke {IERC1155Receiver-onERC1155BatchReceived} on `to`.\n /// Reverts if the target does not support the function correctly.\n function _checkOnERC1155BatchReceived(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) private {\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`.\n mstore(m, 0xbc197c81)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), shr(96, shl(96, from)))\n // Copy the `ids`.\n mstore(add(m, 0x60), 0xa0)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0xc0)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n let s := add(0xa0, returndatasize())\n mstore(add(m, 0x80), s)\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n // Copy the `data`.\n mstore(add(m, 0xa0), add(s, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, mload(data))\n pop(staticcall(gas(), 4, data, n, o, n))\n n := sub(add(o, returndatasize()), add(m, 0x1c))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), n, m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xbc197c81))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Returns `x` in an array with a single element.\n function _single(uint256 x) private pure returns (uint256[] memory result) {\n assembly {\n result := mload(0x40)\n mstore(0x40, add(result, 0x40))\n mstore(result, 1)\n mstore(add(result, 0x20), x)\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/lib/ConsiderationStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {\n BasicOrderType,\n ItemType,\n OrderType,\n Side\n} from \"./ConsiderationEnums.sol\";\n\nimport {\n CalldataPointer,\n MemoryPointer\n} from \"../helpers/PointerLibraries.sol\";\n\n/**\n * @dev An order contains eleven components: an offerer, a zone (or account that\n * can cancel the order or restrict who can fulfill the order depending on\n * the type), the order type (specifying partial fill support as well as\n * restricted order status), the start and end time, a hash that will be\n * provided to the zone when validating restricted orders, a salt, a key\n * corresponding to a given conduit, a counter, and an arbitrary number of\n * offer items that can be spent along with consideration items that must\n * be received by their respective recipient.\n */\nstruct OrderComponents {\n address offerer;\n address zone;\n OfferItem[] offer;\n ConsiderationItem[] consideration;\n OrderType orderType;\n uint256 startTime;\n uint256 endTime;\n bytes32 zoneHash;\n uint256 salt;\n bytes32 conduitKey;\n uint256 counter;\n}\n\n/**\n * @dev An offer item has five components: an item type (ETH or other native\n * tokens, ERC20, ERC721, and ERC1155, as well as criteria-based ERC721 and\n * ERC1155), a token address, a dual-purpose \"identifierOrCriteria\"\n * component that will either represent a tokenId or a merkle root\n * depending on the item type, and a start and end amount that support\n * increasing or decreasing amounts over the duration of the respective\n * order.\n */\nstruct OfferItem {\n ItemType itemType;\n address token;\n uint256 identifierOrCriteria;\n uint256 startAmount;\n uint256 endAmount;\n}\n\n/**\n * @dev A consideration item has the same five components as an offer item and\n * an additional sixth component designating the required recipient of the\n * item.\n */\nstruct ConsiderationItem {\n ItemType itemType;\n address token;\n uint256 identifierOrCriteria;\n uint256 startAmount;\n uint256 endAmount;\n address payable recipient;\n}\n\n/**\n * @dev A spent item is translated from a utilized offer item and has four\n * components: an item type (ETH or other native tokens, ERC20, ERC721, and\n * ERC1155), a token address, a tokenId, and an amount.\n */\nstruct SpentItem {\n ItemType itemType;\n address token;\n uint256 identifier;\n uint256 amount;\n}\n\n/**\n * @dev A received item is translated from a utilized consideration item and has\n * the same four components as a spent item, as well as an additional fifth\n * component designating the required recipient of the item.\n */\nstruct ReceivedItem {\n ItemType itemType;\n address token;\n uint256 identifier;\n uint256 amount;\n address payable recipient;\n}\n\n/**\n * @dev For basic orders involving ETH / native / ERC20 <=> ERC721 / ERC1155\n * matching, a group of six functions may be called that only requires a\n * subset of the usual order arguments. Note the use of a \"basicOrderType\"\n * enum; this represents both the usual order type as well as the \"route\"\n * of the basic order (a simple derivation function for the basic order\n * type is `basicOrderType = orderType + (4 * basicOrderRoute)`.)\n */\nstruct BasicOrderParameters {\n // calldata offset\n address considerationToken; // 0x24\n uint256 considerationIdentifier; // 0x44\n uint256 considerationAmount; // 0x64\n address payable offerer; // 0x84\n address zone; // 0xa4\n address offerToken; // 0xc4\n uint256 offerIdentifier; // 0xe4\n uint256 offerAmount; // 0x104\n BasicOrderType basicOrderType; // 0x124\n uint256 startTime; // 0x144\n uint256 endTime; // 0x164\n bytes32 zoneHash; // 0x184\n uint256 salt; // 0x1a4\n bytes32 offererConduitKey; // 0x1c4\n bytes32 fulfillerConduitKey; // 0x1e4\n uint256 totalOriginalAdditionalRecipients; // 0x204\n AdditionalRecipient[] additionalRecipients; // 0x224\n bytes signature; // 0x244\n // Total length, excluding dynamic array data: 0x264 (580)\n}\n\n/**\n * @dev Basic orders can supply any number of additional recipients, with the\n * implied assumption that they are supplied from the offered ETH (or other\n * native token) or ERC20 token for the order.\n */\nstruct AdditionalRecipient {\n uint256 amount;\n address payable recipient;\n}\n\n/**\n * @dev The full set of order components, with the exception of the counter,\n * must be supplied when fulfilling more sophisticated orders or groups of\n * orders. The total number of original consideration items must also be\n * supplied, as the caller may specify additional consideration items.\n */\nstruct OrderParameters {\n address offerer; // 0x00\n address zone; // 0x20\n OfferItem[] offer; // 0x40\n ConsiderationItem[] consideration; // 0x60\n OrderType orderType; // 0x80\n uint256 startTime; // 0xa0\n uint256 endTime; // 0xc0\n bytes32 zoneHash; // 0xe0\n uint256 salt; // 0x100\n bytes32 conduitKey; // 0x120\n uint256 totalOriginalConsiderationItems; // 0x140\n // offer.length // 0x160\n}\n\n/**\n * @dev Orders require a signature in addition to the other order parameters.\n */\nstruct Order {\n OrderParameters parameters;\n bytes signature;\n}\n\n/**\n * @dev Advanced orders include a numerator (i.e. a fraction to attempt to fill)\n * and a denominator (the total size of the order) in addition to the\n * signature and other order parameters. It also supports an optional field\n * for supplying extra data; this data will be provided to the zone if the\n * order type is restricted and the zone is not the caller, or will be\n * provided to the offerer as context for contract order types.\n */\nstruct AdvancedOrder {\n OrderParameters parameters;\n uint120 numerator;\n uint120 denominator;\n bytes signature;\n bytes extraData;\n}\n\n/**\n * @dev Orders can be validated (either explicitly via `validate`, or as a\n * consequence of a full or partial fill), specifically cancelled (they can\n * also be cancelled in bulk via incrementing a per-zone counter), and\n * partially or fully filled (with the fraction filled represented by a\n * numerator and denominator).\n */\nstruct OrderStatus {\n bool isValidated;\n bool isCancelled;\n uint120 numerator;\n uint120 denominator;\n}\n\n/**\n * @dev A criteria resolver specifies an order, side (offer vs. consideration),\n * and item index. It then provides a chosen identifier (i.e. tokenId)\n * alongside a merkle proof demonstrating the identifier meets the required\n * criteria.\n */\nstruct CriteriaResolver {\n uint256 orderIndex;\n Side side;\n uint256 index;\n uint256 identifier;\n bytes32[] criteriaProof;\n}\n\n/**\n * @dev A fulfillment is applied to a group of orders. It decrements a series of\n * offer and consideration items, then generates a single execution\n * element. A given fulfillment can be applied to as many offer and\n * consideration items as desired, but must contain at least one offer and\n * at least one consideration that match. The fulfillment must also remain\n * consistent on all key parameters across all offer items (same offerer,\n * token, type, tokenId, and conduit preference) as well as across all\n * consideration items (token, type, tokenId, and recipient).\n */\nstruct Fulfillment {\n FulfillmentComponent[] offerComponents;\n FulfillmentComponent[] considerationComponents;\n}\n\n/**\n * @dev Each fulfillment component contains one index referencing a specific\n * order and another referencing a specific offer or consideration item.\n */\nstruct FulfillmentComponent {\n uint256 orderIndex;\n uint256 itemIndex;\n}\n\n/**\n * @dev An execution is triggered once all consideration items have been zeroed\n * out. It sends the item in question from the offerer to the item's\n * recipient, optionally sourcing approvals from either this contract\n * directly or from the offerer's chosen conduit if one is specified. An\n * execution is not provided as an argument, but rather is derived via\n * orders, criteria resolvers, and fulfillments (where the total number of\n * executions will be less than or equal to the total number of indicated\n * fulfillments) and returned as part of `matchOrders`.\n */\nstruct Execution {\n ReceivedItem item;\n address offerer;\n bytes32 conduitKey;\n}\n\n/**\n * @dev Restricted orders are validated post-execution by calling validateOrder\n * on the zone. This struct provides context about the order fulfillment\n * and any supplied extraData, as well as all order hashes fulfilled in a\n * call to a match or fulfillAvailable method.\n */\nstruct ZoneParameters {\n bytes32 orderHash;\n address fulfiller;\n address offerer;\n SpentItem[] offer;\n ReceivedItem[] consideration;\n bytes extraData;\n bytes32[] orderHashes;\n uint256 startTime;\n uint256 endTime;\n bytes32 zoneHash;\n}\n\n/**\n * @dev Zones and contract offerers can communicate which schemas they implement\n * along with any associated metadata related to each schema.\n */\nstruct Schema {\n uint256 id;\n bytes metadata;\n}\n\nusing StructPointers for OrderComponents global;\nusing StructPointers for OfferItem global;\nusing StructPointers for ConsiderationItem global;\nusing StructPointers for SpentItem global;\nusing StructPointers for ReceivedItem global;\nusing StructPointers for BasicOrderParameters global;\nusing StructPointers for AdditionalRecipient global;\nusing StructPointers for OrderParameters global;\nusing StructPointers for Order global;\nusing StructPointers for AdvancedOrder global;\nusing StructPointers for OrderStatus global;\nusing StructPointers for CriteriaResolver global;\nusing StructPointers for Fulfillment global;\nusing StructPointers for FulfillmentComponent global;\nusing StructPointers for Execution global;\nusing StructPointers for ZoneParameters global;\n\n/**\n * @dev This library provides a set of functions for converting structs to\n * pointers.\n */\nlibrary StructPointers {\n /**\n * @dev Get a MemoryPointer from OrderComponents.\n *\n * @param obj The OrderComponents object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderComponents memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderComponents.\n *\n * @param obj The OrderComponents object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderComponents calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OfferItem.\n *\n * @param obj The OfferItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OfferItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OfferItem.\n *\n * @param obj The OfferItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OfferItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ConsiderationItem.\n *\n * @param obj The ConsiderationItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ConsiderationItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ConsiderationItem.\n *\n * @param obj The ConsiderationItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ConsiderationItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from SpentItem.\n *\n * @param obj The SpentItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n SpentItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from SpentItem.\n *\n * @param obj The SpentItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n SpentItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ReceivedItem.\n *\n * @param obj The ReceivedItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ReceivedItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ReceivedItem.\n *\n * @param obj The ReceivedItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ReceivedItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from BasicOrderParameters.\n *\n * @param obj The BasicOrderParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n BasicOrderParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from BasicOrderParameters.\n *\n * @param obj The BasicOrderParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n BasicOrderParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from AdditionalRecipient.\n *\n * @param obj The AdditionalRecipient object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n AdditionalRecipient memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from AdditionalRecipient.\n *\n * @param obj The AdditionalRecipient object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n AdditionalRecipient calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OrderParameters.\n *\n * @param obj The OrderParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderParameters.\n *\n * @param obj The OrderParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Order.\n *\n * @param obj The Order object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Order memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Order.\n *\n * @param obj The Order object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Order calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from AdvancedOrder.\n *\n * @param obj The AdvancedOrder object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n AdvancedOrder memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from AdvancedOrder.\n *\n * @param obj The AdvancedOrder object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n AdvancedOrder calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OrderStatus.\n *\n * @param obj The OrderStatus object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderStatus memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderStatus.\n *\n * @param obj The OrderStatus object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderStatus calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from CriteriaResolver.\n *\n * @param obj The CriteriaResolver object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n CriteriaResolver memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from CriteriaResolver.\n *\n * @param obj The CriteriaResolver object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n CriteriaResolver calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Fulfillment.\n *\n * @param obj The Fulfillment object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Fulfillment memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Fulfillment.\n *\n * @param obj The Fulfillment object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Fulfillment calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from FulfillmentComponent.\n *\n * @param obj The FulfillmentComponent object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n FulfillmentComponent memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from FulfillmentComponent.\n *\n * @param obj The FulfillmentComponent object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n FulfillmentComponent calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Execution.\n *\n * @param obj The Execution object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Execution memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Execution.\n *\n * @param obj The Execution object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Execution calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ZoneParameters.\n *\n * @param obj The ZoneParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ZoneParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ZoneParameters.\n *\n * @param obj The ZoneParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ZoneParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/interfaces/ContractOffererInterface.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {ReceivedItem, Schema, SpentItem} from \"../lib/ConsiderationStructs.sol\";\nimport {IERC165} from \"../interfaces/IERC165.sol\";\n\n/**\n * @title ContractOffererInterface\n * @notice Contains the minimum interfaces needed to interact with a contract\n * offerer.\n */\ninterface ContractOffererInterface is IERC165 {\n /**\n * @dev Generates an order with the specified minimum and maximum spent\n * items, and optional context (supplied as extraData).\n *\n * @param fulfiller The address of the fulfiller.\n * @param minimumReceived The minimum items that the caller is willing to\n * receive.\n * @param maximumSpent The maximum items the caller is willing to spend.\n * @param context Additional context of the order.\n *\n * @return offer A tuple containing the offer items.\n * @return consideration A tuple containing the consideration items.\n */\n function generateOrder(\n address fulfiller,\n SpentItem[] calldata minimumReceived,\n SpentItem[] calldata maximumSpent,\n bytes calldata context // encoded based on the schemaID\n ) external returns (SpentItem[] memory offer, ReceivedItem[] memory consideration);\n\n /**\n * @dev Ratifies an order with the specified offer, consideration, and\n * optional context (supplied as extraData).\n *\n * @param offer The offer items.\n * @param consideration The consideration items.\n * @param context Additional context of the order.\n * @param orderHashes The hashes to ratify.\n * @param contractNonce The nonce of the contract.\n *\n * @return ratifyOrderMagicValue The magic value returned by the contract\n * offerer.\n */\n function ratifyOrder(\n SpentItem[] calldata offer,\n ReceivedItem[] calldata consideration,\n bytes calldata context, // encoded based on the schemaID\n bytes32[] calldata orderHashes,\n uint256 contractNonce\n ) external returns (bytes4 ratifyOrderMagicValue);\n\n /**\n * @dev View function to preview an order generated in response to a minimum\n * set of received items, maximum set of spent items, and context\n * (supplied as extraData).\n *\n * @param caller The address of the caller (e.g. Seaport).\n * @param fulfiller The address of the fulfiller (e.g. the account\n * calling Seaport).\n * @param minimumReceived The minimum items that the caller is willing to\n * receive.\n * @param maximumSpent The maximum items the caller is willing to spend.\n * @param context Additional context of the order.\n *\n * @return offer A tuple containing the offer items.\n * @return consideration A tuple containing the consideration items.\n */\n function previewOrder(\n address caller,\n address fulfiller,\n SpentItem[] calldata minimumReceived,\n SpentItem[] calldata maximumSpent,\n bytes calldata context // encoded based on the schemaID\n ) external view returns (SpentItem[] memory offer, ReceivedItem[] memory consideration);\n\n /**\n * @dev Gets the metadata for this contract offerer.\n *\n * @return name The name of the contract offerer.\n * @return schemas The schemas supported by the contract offerer.\n */\n function getSeaportMetadata() external view returns (string memory name, Schema[] memory schemas); // map to Seaport Improvement Proposal IDs\n\n function supportsInterface(bytes4 interfaceId) external view override returns (bool);\n\n // Additional functions and/or events based on implemented schemaIDs\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.19;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"src/interfaces/ISeaDropTokenContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\ninterface ISeaDropTokenContractMetadata {\n /**\n * @dev Emit an event for token metadata reveals/updates,\n * according to EIP-4906.\n *\n * @param _fromTokenId The start token id.\n * @param _toTokenId The end token id.\n */\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n\n /**\n * @dev Emit an event when the URI for the collection-level metadata\n * is updated.\n */\n event ContractURIUpdated(string newContractURI);\n\n /**\n * @dev Emit an event with the previous and new provenance hash after\n * being updated.\n */\n event ProvenanceHashUpdated(bytes32 previousHash, bytes32 newHash);\n\n /**\n * @dev Emit an event when the EIP-2981 royalty info is updated.\n */\n event RoyaltyInfoUpdated(address receiver, uint256 basisPoints);\n\n /**\n * @notice Throw if the max supply exceeds uint64, a limit\n * due to the storage of bit-packed variables.\n */\n error CannotExceedMaxSupplyOfUint64(uint256 got);\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after the mint has started.\n */\n error ProvenanceHashCannotBeSetAfterMintStarted();\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after it has already been set.\n */\n error ProvenanceHashCannotBeSetAfterAlreadyBeingSet();\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param tokenURI The new base URI to set.\n */\n function setBaseURI(string calldata tokenURI) external;\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external;\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external;\n\n /**\n * @notice Sets the default royalty information.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator of\n * 10_000 basis points.\n */\n function setDefaultRoyalty(address receiver, uint96 feeNumerator) external;\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view returns (string memory);\n\n /**\n * @notice Returns the contract URI.\n */\n function contractURI() external view returns (string memory);\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view returns (bytes32);\n}\n"
},
"src/interfaces/IERC1155ContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\ninterface IERC1155ContractMetadata is ISeaDropTokenContractMetadata {\n /**\n * @dev A struct representing the supply info for a token id,\n * packed into one storage slot.\n *\n * @param maxSupply The max supply for the token id.\n * @param totalSupply The total token supply for the token id.\n * Subtracted when an item is burned.\n * @param totalMinted The total number of tokens minted for the token id.\n */\n struct TokenSupply {\n uint64 maxSupply; // 64/256 bits\n uint64 totalSupply; // 128/256 bits\n uint64 totalMinted; // 192/256 bits\n }\n\n /**\n * @dev Emit an event when the max token supply for a token id is updated.\n */\n event MaxSupplyUpdated(uint256 tokenId, uint256 newMaxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @notice Sets the max supply for a token id and emits an event.\n *\n * @param tokenId The token id to set the max supply for.\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 tokenId, uint256 newMaxSupply) external;\n\n /**\n * @notice Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @notice Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @notice Returns the max token supply for a token id.\n */\n function maxSupply(uint256 tokenId) external view returns (uint256);\n\n /**\n * @notice Returns the total supply for a token id.\n */\n function totalSupply(uint256 tokenId) external view returns (uint256);\n\n /**\n * @notice Returns the total minted for a token id.\n */\n function totalMinted(uint256 tokenId) external view returns (uint256);\n}\n"
},
"lib/solady/src/tokens/ERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple ERC2981 NFT Royalty Standard implementation.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC2981.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/common/ERC2981.sol)\nabstract contract ERC2981 {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The royalty fee numerator exceeds the fee denominator.\n error RoyaltyOverflow();\n\n /// @dev The royalty receiver cannot be the zero address.\n error RoyaltyReceiverIsZeroAddress();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The default royalty info is given by:\n /// ```\n /// let packed := sload(_ERC2981_MASTER_SLOT_SEED)\n /// let receiver := shr(96, packed)\n /// let royaltyFraction := xor(packed, shl(96, receiver))\n /// ```\n ///\n /// The per token royalty info is given by.\n /// ```\n /// mstore(0x00, tokenId)\n /// mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n /// let packed := sload(keccak256(0x00, 0x40))\n /// let receiver := shr(96, packed)\n /// let royaltyFraction := xor(packed, shl(96, receiver))\n /// ```\n uint256 private constant _ERC2981_MASTER_SLOT_SEED = 0xaa4ec00224afccfdb7;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC2981 */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Checks that `_feeDenominator` is non-zero.\n constructor() {\n require(_feeDenominator() != 0, \"Fee denominator cannot be zero.\");\n }\n\n /// @dev Returns the denominator for the royalty amount.\n /// Defaults to 10000, which represents fees in basis points.\n /// Override this function to return a custom amount if needed.\n function _feeDenominator() internal pure virtual returns (uint96) {\n return 10000;\n }\n\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\n /// See: https://eips.ethereum.org/EIPS/eip-165\n /// This function call must use less than 30000 gas.\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := shr(224, interfaceId)\n // ERC165: 0x01ffc9a7, ERC2981: 0x2a55205a.\n result := or(eq(s, 0x01ffc9a7), eq(s, 0x2a55205a))\n }\n }\n\n /// @dev Returns the `receiver` and `royaltyAmount` for `tokenId` sold at `salePrice`.\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n public\n view\n virtual\n returns (address receiver, uint256 royaltyAmount)\n {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n let packed := sload(keccak256(0x00, 0x40))\n receiver := shr(96, packed)\n if iszero(receiver) {\n packed := sload(mload(0x20))\n receiver := shr(96, packed)\n }\n let x := salePrice\n let y := xor(packed, shl(96, receiver)) // `feeNumerator`.\n // Overflow check, equivalent to `require(y == 0 || x <= type(uint256).max / y)`.\n // Out-of-gas revert. Should not be triggered in practice, but included for safety.\n returndatacopy(returndatasize(), returndatasize(), mul(y, gt(x, div(not(0), y))))\n royaltyAmount := div(mul(x, y), feeDenominator)\n }\n }\n\n /// @dev Sets the default royalty `receiver` and `feeNumerator`.\n ///\n /// Requirements:\n /// - `receiver` must not be the zero address.\n /// - `feeNumerator` must not be greater than the fee denominator.\n function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n feeNumerator := shr(160, shl(160, feeNumerator))\n if gt(feeNumerator, feeDenominator) {\n mstore(0x00, 0x350a88b3) // `RoyaltyOverflow()`.\n revert(0x1c, 0x04)\n }\n let packed := shl(96, receiver)\n if iszero(packed) {\n mstore(0x00, 0xb4457eaa) // `RoyaltyReceiverIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n sstore(_ERC2981_MASTER_SLOT_SEED, or(packed, feeNumerator))\n }\n }\n\n /// @dev Sets the default royalty `receiver` and `feeNumerator` to zero.\n function _deleteDefaultRoyalty() internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n sstore(_ERC2981_MASTER_SLOT_SEED, 0)\n }\n }\n\n /// @dev Sets the royalty `receiver` and `feeNumerator` for `tokenId`.\n ///\n /// Requirements:\n /// - `receiver` must not be the zero address.\n /// - `feeNumerator` must not be greater than the fee denominator.\n function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator)\n internal\n virtual\n {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n feeNumerator := shr(160, shl(160, feeNumerator))\n if gt(feeNumerator, feeDenominator) {\n mstore(0x00, 0x350a88b3) // `RoyaltyOverflow()`.\n revert(0x1c, 0x04)\n }\n let packed := shl(96, receiver)\n if iszero(packed) {\n mstore(0x00, 0xb4457eaa) // `RoyaltyReceiverIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n sstore(keccak256(0x00, 0x40), or(packed, feeNumerator))\n }\n }\n\n /// @dev Sets the royalty `receiver` and `feeNumerator` for `tokenId` to zero.\n function _resetTokenRoyalty(uint256 tokenId) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n sstore(keccak256(0x00, 0x40), 0)\n }\n }\n}\n"
},
"lib/solady/src/auth/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple single owner authorization mixin.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)\n/// @dev While the ownable portion follows\n/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,\n/// the nomenclature for the 2-step ownership handover may be unique to this codebase.\nabstract contract Ownable {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The caller is not authorized to call the function.\n error Unauthorized();\n\n /// @dev The `newOwner` cannot be the zero address.\n error NewOwnerIsZeroAddress();\n\n /// @dev The `pendingOwner` does not have a valid handover request.\n error NoHandoverRequest();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EVENTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\n /// This event is intentionally kept the same as OpenZeppelin's Ownable to be\n /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),\n /// despite it not being as lightweight as a single argument event.\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\n\n /// @dev An ownership handover to `pendingOwner` has been requested.\n event OwnershipHandoverRequested(address indexed pendingOwner);\n\n /// @dev The ownership handover to `pendingOwner` has been canceled.\n event OwnershipHandoverCanceled(address indexed pendingOwner);\n\n /// @dev `keccak256(bytes(\"OwnershipTransferred(address,address)\"))`.\n uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =\n 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverRequested(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =\n 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverCanceled(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =\n 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The owner slot is given by: `not(_OWNER_SLOT_NOT)`.\n /// It is intentionally chosen to be a high value\n /// to avoid collision with lower slots.\n /// The choice of manual storage layout is to enable compatibility\n /// with both regular and upgradeable contracts.\n uint256 private constant _OWNER_SLOT_NOT = 0x8b78c6d8;\n\n /// The ownership handover slot of `newOwner` is given by:\n /// ```\n /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))\n /// let handoverSlot := keccak256(0x00, 0x20)\n /// ```\n /// It stores the expiry timestamp of the two-step ownership handover.\n uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Initializes the owner directly without authorization guard.\n /// This function must be called upon initialization,\n /// regardless of whether the contract is upgradeable or not.\n /// This is to enable generalization to both regular and upgradeable contracts,\n /// and to save gas in case the initial owner is not the caller.\n /// For performance reasons, this function will not check if there\n /// is an existing owner.\n function _initializeOwner(address newOwner) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Store the new value.\n sstore(not(_OWNER_SLOT_NOT), newOwner)\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\n }\n }\n\n /// @dev Sets the owner directly without authorization guard.\n function _setOwner(address newOwner) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := not(_OWNER_SLOT_NOT)\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\n // Store the new value.\n sstore(ownerSlot, newOwner)\n }\n }\n\n /// @dev Throws if the sender is not the owner.\n function _checkOwner() internal view virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // If the caller is not the stored owner, revert.\n if iszero(eq(caller(), sload(not(_OWNER_SLOT_NOT)))) {\n mstore(0x00, 0x82b42900) // `Unauthorized()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC UPDATE FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Allows the owner to transfer the ownership to `newOwner`.\n function transferOwnership(address newOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(shl(96, newOwner)) {\n mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n }\n _setOwner(newOwner);\n }\n\n /// @dev Allows the owner to renounce their ownership.\n function renounceOwnership() public payable virtual onlyOwner {\n _setOwner(address(0));\n }\n\n /// @dev Request a two-step ownership handover to the caller.\n /// The request will automatically expire in 48 hours (172800 seconds) by default.\n function requestOwnershipHandover() public payable virtual {\n unchecked {\n uint256 expires = block.timestamp + ownershipHandoverValidFor();\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to `expires`.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), expires)\n // Emit the {OwnershipHandoverRequested} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())\n }\n }\n }\n\n /// @dev Cancels the two-step ownership handover to the caller, if any.\n function cancelOwnershipHandover() public payable virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), 0)\n // Emit the {OwnershipHandoverCanceled} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())\n }\n }\n\n /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.\n /// Reverts if there is no existing ownership handover requested by `pendingOwner`.\n function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n let handoverSlot := keccak256(0x0c, 0x20)\n // If the handover does not exist, or has expired.\n if gt(timestamp(), sload(handoverSlot)) {\n mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.\n revert(0x1c, 0x04)\n }\n // Set the handover slot to 0.\n sstore(handoverSlot, 0)\n }\n _setOwner(pendingOwner);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC READ FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the owner of the contract.\n function owner() public view virtual returns (address result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := sload(not(_OWNER_SLOT_NOT))\n }\n }\n\n /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\n function ownershipHandoverExpiresAt(address pendingOwner)\n public\n view\n virtual\n returns (uint256 result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute the handover slot.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n // Load the handover slot.\n result := sload(keccak256(0x0c, 0x20))\n }\n }\n\n /// @dev Returns how long a two-step ownership handover is valid for in seconds.\n function ownershipHandoverValidFor() public view virtual returns (uint64) {\n return 48 * 3600;\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* MODIFIERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Marks a function as only callable by the owner.\n modifier onlyOwner() virtual {\n _checkOwner();\n _;\n }\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.19;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (address(this).code.length == 0 && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
},
"src/lib/SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { CreatorPayout, PublicDrop } from \"./ERC721SeaDropStructs.sol\";\n\ninterface SeaDropErrorsAndEvents {\n /**\n * @notice The SeaDrop token types, emitted as part of\n * `event SeaDropTokenDeployed`.\n */\n enum SEADROP_TOKEN_TYPE {\n ERC721_STANDARD,\n ERC721_CLONE,\n ERC721_UPGRADEABLE,\n ERC1155_STANDARD,\n ERC1155_CLONE,\n ERC1155_UPGRADEABLE\n }\n\n /**\n * @notice An event to signify that a SeaDrop token contract was deployed.\n */\n event SeaDropTokenDeployed(SEADROP_TOKEN_TYPE tokenType);\n\n /**\n * @notice Revert with an error if the function selector is not supported.\n */\n error UnsupportedFunctionSelector(bytes4 selector);\n\n /**\n * @dev Revert with an error if the drop stage is not active.\n */\n error NotActive(\n uint256 currentTimestamp,\n uint256 startTimestamp,\n uint256 endTimestamp\n );\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max allowed\n * to be minted per wallet.\n */\n error MintQuantityExceedsMaxMintedPerWallet(uint256 total, uint256 allowed);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply for the stage.\n * Note: The `maxTokenSupplyForStage` for public mint is\n * always `type(uint).max`.\n */\n error MintQuantityExceedsMaxTokenSupplyForStage(\n uint256 total,\n uint256 maxTokenSupplyForStage\n );\n\n /**\n * @dev Revert if the fee recipient is the zero address.\n */\n error FeeRecipientCannotBeZeroAddress();\n\n /**\n * @dev Revert if the fee recipient is not already included.\n */\n error FeeRecipientNotPresent();\n\n /**\n * @dev Revert if the fee basis points is greater than 10_000.\n */\n error InvalidFeeBps(uint256 feeBps);\n\n /**\n * @dev Revert if the fee recipient is already included.\n */\n error DuplicateFeeRecipient();\n\n /**\n * @dev Revert if the fee recipient is restricted and not allowed.\n */\n error FeeRecipientNotAllowed(address got);\n\n /**\n * @dev Revert if the creator payout address is the zero address.\n */\n error CreatorPayoutAddressCannotBeZeroAddress();\n\n /**\n * @dev Revert if the creator payouts are not set.\n */\n error CreatorPayoutsNotSet();\n\n /**\n * @dev Revert if the creator payout basis points are zero.\n */\n error CreatorPayoutBasisPointsCannotBeZero();\n\n /**\n * @dev Revert if the total basis points for the creator payouts\n * don't equal exactly 10_000.\n */\n error InvalidCreatorPayoutTotalBasisPoints(\n uint256 totalReceivedBasisPoints\n );\n\n /**\n * @dev Revert if the creator payout basis points don't add up to 10_000.\n */\n error InvalidCreatorPayoutBasisPoints(uint256 totalReceivedBasisPoints);\n\n /**\n * @dev Revert with an error if the allow list proof is invalid.\n */\n error InvalidProof();\n\n /**\n * @dev Revert if a supplied signer address is the zero address.\n */\n error SignerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if a signer is not included in\n * the enumeration when removing.\n */\n error SignerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is not included in\n * the enumeration when removing.\n */\n error PayerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is already included in mapping\n * when adding.\n */\n error DuplicatePayer();\n\n /**\n * @dev Revert with an error if a signer is already included in mapping\n * when adding.\n */\n error DuplicateSigner();\n\n /**\n * @dev Revert with an error if the payer is not allowed. The minter must\n * pay for their own mint.\n */\n error PayerNotAllowed(address got);\n\n /**\n * @dev Revert if a supplied payer address is the zero address.\n */\n error PayerCannotBeZeroAddress();\n\n /**\n * @dev Revert if the start time is greater than the end time.\n */\n error InvalidStartAndEndTime(uint256 startTime, uint256 endTime);\n\n /**\n * @dev Revert with an error if the signer payment token is not the same.\n */\n error InvalidSignedPaymentToken(address got, address want);\n\n /**\n * @dev Revert with an error if supplied signed mint price is less than\n * the minimum specified.\n */\n error InvalidSignedMintPrice(\n address paymentToken,\n uint256 got,\n uint256 minimum\n );\n\n /**\n * @dev Revert with an error if supplied signed maxTotalMintableByWallet\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTotalMintableByWallet(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed\n * maxTotalMintableByWalletPerToken is greater than the maximum\n * specified.\n */\n error InvalidSignedMaxTotalMintableByWalletPerToken(\n uint256 got,\n uint256 maximum\n );\n\n /**\n * @dev Revert with an error if the fromTokenId is not within range.\n */\n error InvalidSignedFromTokenId(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if the toTokenId is not within range.\n */\n error InvalidSignedToTokenId(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed start time is less than\n * the minimum specified.\n */\n error InvalidSignedStartTime(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if supplied signed end time is greater than\n * the maximum specified.\n */\n error InvalidSignedEndTime(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed maxTokenSupplyForStage\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTokenSupplyForStage(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed feeBps is greater than\n * the maximum specified, or less than the minimum.\n */\n error InvalidSignedFeeBps(uint256 got, uint256 minimumOrMaximum);\n\n /**\n * @dev Revert with an error if signed mint did not specify to restrict\n * fee recipients.\n */\n error SignedMintsMustRestrictFeeRecipients();\n\n /**\n * @dev Revert with an error if a signature for a signed mint has already\n * been used.\n */\n error SignatureAlreadyUsed();\n\n /**\n * @dev Revert with an error if the contract has no balance to withdraw.\n */\n error NoBalanceToWithdraw();\n\n /**\n * @dev Revert with an error if the caller is not an allowed Seaport.\n */\n error InvalidCallerOnlyAllowedSeaport(address caller);\n\n /**\n * @dev Revert with an error if the order does not have the ERC1155 magic\n * consideration item to signify a consecutive mint.\n */\n error MustSpecifyERC1155ConsiderationItemForSeaDropMint();\n\n /**\n * @dev Revert with an error if the extra data version is not supported.\n */\n error UnsupportedExtraDataVersion(uint8 version);\n\n /**\n * @dev Revert with an error if the extra data encoding is not supported.\n */\n error InvalidExtraDataEncoding(uint8 version);\n\n /**\n * @dev Revert with an error if the provided substandard is not supported.\n */\n error InvalidSubstandard(uint8 substandard);\n\n /**\n * @dev Revert with an error if the implementation contract is called without\n * delegatecall.\n */\n error OnlyDelegateCalled();\n\n /**\n * @dev Revert with an error if the provided allowed Seaport is the\n * zero address.\n */\n error AllowedSeaportCannotBeZeroAddress();\n\n /**\n * @dev Emit an event when allowed Seaport contracts are updated.\n */\n event AllowedSeaportUpdated(address[] allowedSeaport);\n\n /**\n * @dev An event with details of a SeaDrop mint, for analytical purposes.\n *\n * @param payer The address who payed for the tx.\n * @param dropStageIndex The drop stage index. Items minted through\n * public mint have dropStageIndex of 0\n */\n event SeaDropMint(address payer, uint256 dropStageIndex);\n\n /**\n * @dev An event with updated allow list data.\n *\n * @param previousMerkleRoot The previous allow list merkle root.\n * @param newMerkleRoot The new allow list merkle root.\n * @param publicKeyURI If the allow list is encrypted, the public key\n * URIs that can decrypt the list.\n * Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\n event AllowListUpdated(\n bytes32 indexed previousMerkleRoot,\n bytes32 indexed newMerkleRoot,\n string[] publicKeyURI,\n string allowListURI\n );\n\n /**\n * @dev An event with updated drop URI.\n */\n event DropURIUpdated(string newDropURI);\n\n /**\n * @dev An event with the updated creator payout address.\n */\n event CreatorPayoutsUpdated(CreatorPayout[] creatorPayouts);\n\n /**\n * @dev An event with the updated allowed fee recipient.\n */\n event AllowedFeeRecipientUpdated(\n address indexed feeRecipient,\n bool indexed allowed\n );\n\n /**\n * @dev An event with the updated signer.\n */\n event SignerUpdated(address indexed signer, bool indexed allowed);\n\n /**\n * @dev An event with the updated payer.\n */\n event PayerUpdated(address indexed payer, bool indexed allowed);\n}\n"
},
"lib/seaport/lib/seaport-types/src/lib/ConsiderationEnums.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nenum OrderType {\n // 0: no partial fills, anyone can execute\n FULL_OPEN,\n\n // 1: partial fills supported, anyone can execute\n PARTIAL_OPEN,\n\n // 2: no partial fills, only offerer or zone can execute\n FULL_RESTRICTED,\n\n // 3: partial fills supported, only offerer or zone can execute\n PARTIAL_RESTRICTED,\n\n // 4: contract order type\n CONTRACT\n}\n\nenum BasicOrderType {\n // 0: no partial fills, anyone can execute\n ETH_TO_ERC721_FULL_OPEN,\n\n // 1: partial fills supported, anyone can execute\n ETH_TO_ERC721_PARTIAL_OPEN,\n\n // 2: no partial fills, only offerer or zone can execute\n ETH_TO_ERC721_FULL_RESTRICTED,\n\n // 3: partial fills supported, only offerer or zone can execute\n ETH_TO_ERC721_PARTIAL_RESTRICTED,\n\n // 4: no partial fills, anyone can execute\n ETH_TO_ERC1155_FULL_OPEN,\n\n // 5: partial fills supported, anyone can execute\n ETH_TO_ERC1155_PARTIAL_OPEN,\n\n // 6: no partial fills, only offerer or zone can execute\n ETH_TO_ERC1155_FULL_RESTRICTED,\n\n // 7: partial fills supported, only offerer or zone can execute\n ETH_TO_ERC1155_PARTIAL_RESTRICTED,\n\n // 8: no partial fills, anyone can execute\n ERC20_TO_ERC721_FULL_OPEN,\n\n // 9: partial fills supported, anyone can execute\n ERC20_TO_ERC721_PARTIAL_OPEN,\n\n // 10: no partial fills, only offerer or zone can execute\n ERC20_TO_ERC721_FULL_RESTRICTED,\n\n // 11: partial fills supported, only offerer or zone can execute\n ERC20_TO_ERC721_PARTIAL_RESTRICTED,\n\n // 12: no partial fills, anyone can execute\n ERC20_TO_ERC1155_FULL_OPEN,\n\n // 13: partial fills supported, anyone can execute\n ERC20_TO_ERC1155_PARTIAL_OPEN,\n\n // 14: no partial fills, only offerer or zone can execute\n ERC20_TO_ERC1155_FULL_RESTRICTED,\n\n // 15: partial fills supported, only offerer or zone can execute\n ERC20_TO_ERC1155_PARTIAL_RESTRICTED,\n\n // 16: no partial fills, anyone can execute\n ERC721_TO_ERC20_FULL_OPEN,\n\n // 17: partial fills supported, anyone can execute\n ERC721_TO_ERC20_PARTIAL_OPEN,\n\n // 18: no partial fills, only offerer or zone can execute\n ERC721_TO_ERC20_FULL_RESTRICTED,\n\n // 19: partial fills supported, only offerer or zone can execute\n ERC721_TO_ERC20_PARTIAL_RESTRICTED,\n\n // 20: no partial fills, anyone can execute\n ERC1155_TO_ERC20_FULL_OPEN,\n\n // 21: partial fills supported, anyone can execute\n ERC1155_TO_ERC20_PARTIAL_OPEN,\n\n // 22: no partial fills, only offerer or zone can execute\n ERC1155_TO_ERC20_FULL_RESTRICTED,\n\n // 23: partial fills supported, only offerer or zone can execute\n ERC1155_TO_ERC20_PARTIAL_RESTRICTED\n}\n\nenum BasicOrderRouteType {\n // 0: provide Ether (or other native token) to receive offered ERC721 item.\n ETH_TO_ERC721,\n\n // 1: provide Ether (or other native token) to receive offered ERC1155 item.\n ETH_TO_ERC1155,\n\n // 2: provide ERC20 item to receive offered ERC721 item.\n ERC20_TO_ERC721,\n\n // 3: provide ERC20 item to receive offered ERC1155 item.\n ERC20_TO_ERC1155,\n\n // 4: provide ERC721 item to receive offered ERC20 item.\n ERC721_TO_ERC20,\n\n // 5: provide ERC1155 item to receive offered ERC20 item.\n ERC1155_TO_ERC20\n}\n\nenum ItemType {\n // 0: ETH on mainnet, MATIC on polygon, etc.\n NATIVE,\n\n // 1: ERC20 items (ERC777 and ERC20 analogues could also technically work)\n ERC20,\n\n // 2: ERC721 items\n ERC721,\n\n // 3: ERC1155 items\n ERC1155,\n\n // 4: ERC721 items where a number of tokenIds are supported\n ERC721_WITH_CRITERIA,\n\n // 5: ERC1155 items where a number of ids are supported\n ERC1155_WITH_CRITERIA\n}\n\nenum Side {\n // 0: Items that can be spent\n OFFER,\n\n // 1: Items that must be received\n CONSIDERATION\n}\n"
},
"lib/seaport/lib/seaport-types/src/helpers/PointerLibraries.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ntype CalldataPointer is uint256;\n\ntype ReturndataPointer is uint256;\n\ntype MemoryPointer is uint256;\n\nusing CalldataPointerLib for CalldataPointer global;\nusing MemoryPointerLib for MemoryPointer global;\nusing ReturndataPointerLib for ReturndataPointer global;\n\nusing CalldataReaders for CalldataPointer global;\nusing ReturndataReaders for ReturndataPointer global;\nusing MemoryReaders for MemoryPointer global;\nusing MemoryWriters for MemoryPointer global;\n\nCalldataPointer constant CalldataStart = CalldataPointer.wrap(0x04);\nMemoryPointer constant FreeMemoryPPtr = MemoryPointer.wrap(0x40);\nuint256 constant IdentityPrecompileAddress = 0x4;\nuint256 constant OffsetOrLengthMask = 0xffffffff;\nuint256 constant _OneWord = 0x20;\nuint256 constant _FreeMemoryPointerSlot = 0x40;\n\n/// @dev Allocates `size` bytes in memory by increasing the free memory pointer\n/// and returns the memory pointer to the first byte of the allocated region.\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction malloc(uint256 size) pure returns (MemoryPointer mPtr) {\n assembly {\n mPtr := mload(_FreeMemoryPointerSlot)\n mstore(_FreeMemoryPointerSlot, add(mPtr, size))\n }\n}\n\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction getFreeMemoryPointer() pure returns (MemoryPointer mPtr) {\n mPtr = FreeMemoryPPtr.readMemoryPointer();\n}\n\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction setFreeMemoryPointer(MemoryPointer mPtr) pure {\n FreeMemoryPPtr.write(mPtr);\n}\n\nlibrary CalldataPointerLib {\n function lt(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(CalldataPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n /// @dev Resolves an offset stored at `cdPtr + headOffset` to a calldata.\n /// pointer `cdPtr` must point to some parent object with a dynamic\n /// type's head stored at `cdPtr + headOffset`.\n function pptr(\n CalldataPointer cdPtr,\n uint256 headOffset\n ) internal pure returns (CalldataPointer cdPtrChild) {\n cdPtrChild = cdPtr.offset(\n cdPtr.offset(headOffset).readUint256() & OffsetOrLengthMask\n );\n }\n\n /// @dev Resolves an offset stored at `cdPtr` to a calldata pointer.\n /// `cdPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n CalldataPointer cdPtr\n ) internal pure returns (CalldataPointer cdPtrChild) {\n cdPtrChild = cdPtr.offset(cdPtr.readUint256() & OffsetOrLengthMask);\n }\n\n /// @dev Returns the calldata pointer one word after `cdPtr`.\n function next(\n CalldataPointer cdPtr\n ) internal pure returns (CalldataPointer cdPtrNext) {\n assembly {\n cdPtrNext := add(cdPtr, _OneWord)\n }\n }\n\n /// @dev Returns the calldata pointer `_offset` bytes after `cdPtr`.\n function offset(\n CalldataPointer cdPtr,\n uint256 _offset\n ) internal pure returns (CalldataPointer cdPtrNext) {\n assembly {\n cdPtrNext := add(cdPtr, _offset)\n }\n }\n\n /// @dev Copies `size` bytes from calldata starting at `src` to memory at\n /// `dst`.\n function copy(\n CalldataPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal pure {\n assembly {\n calldatacopy(dst, src, size)\n }\n }\n}\n\nlibrary ReturndataPointerLib {\n function lt(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(ReturndataPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n /// @dev Resolves an offset stored at `rdPtr + headOffset` to a returndata\n /// pointer. `rdPtr` must point to some parent object with a dynamic\n /// type's head stored at `rdPtr + headOffset`.\n function pptr(\n ReturndataPointer rdPtr,\n uint256 headOffset\n ) internal pure returns (ReturndataPointer rdPtrChild) {\n rdPtrChild = rdPtr.offset(\n rdPtr.offset(headOffset).readUint256() & OffsetOrLengthMask\n );\n }\n\n /// @dev Resolves an offset stored at `rdPtr` to a returndata pointer.\n /// `rdPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n ReturndataPointer rdPtr\n ) internal pure returns (ReturndataPointer rdPtrChild) {\n rdPtrChild = rdPtr.offset(rdPtr.readUint256() & OffsetOrLengthMask);\n }\n\n /// @dev Returns the returndata pointer one word after `cdPtr`.\n function next(\n ReturndataPointer rdPtr\n ) internal pure returns (ReturndataPointer rdPtrNext) {\n assembly {\n rdPtrNext := add(rdPtr, _OneWord)\n }\n }\n\n /// @dev Returns the returndata pointer `_offset` bytes after `cdPtr`.\n function offset(\n ReturndataPointer rdPtr,\n uint256 _offset\n ) internal pure returns (ReturndataPointer rdPtrNext) {\n assembly {\n rdPtrNext := add(rdPtr, _offset)\n }\n }\n\n /// @dev Copies `size` bytes from returndata starting at `src` to memory at\n /// `dst`.\n function copy(\n ReturndataPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal pure {\n assembly {\n returndatacopy(dst, src, size)\n }\n }\n}\n\nlibrary MemoryPointerLib {\n function copy(\n MemoryPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal view {\n assembly {\n let success := staticcall(\n gas(),\n IdentityPrecompileAddress,\n src,\n size,\n dst,\n size\n )\n if or(iszero(returndatasize()), iszero(success)) {\n revert(0, 0)\n }\n }\n }\n\n function lt(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(MemoryPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n function hash(\n MemoryPointer ptr,\n uint256 length\n ) internal pure returns (bytes32 _hash) {\n assembly {\n _hash := keccak256(ptr, length)\n }\n }\n\n /// @dev Returns the memory pointer one word after `mPtr`.\n function next(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer mPtrNext) {\n assembly {\n mPtrNext := add(mPtr, _OneWord)\n }\n }\n\n /// @dev Returns the memory pointer `_offset` bytes after `mPtr`.\n function offset(\n MemoryPointer mPtr,\n uint256 _offset\n ) internal pure returns (MemoryPointer mPtrNext) {\n assembly {\n mPtrNext := add(mPtr, _offset)\n }\n }\n\n /// @dev Resolves a pointer at `mPtr + headOffset` to a memory\n /// pointer. `mPtr` must point to some parent object with a dynamic\n /// type's pointer stored at `mPtr + headOffset`.\n function pptr(\n MemoryPointer mPtr,\n uint256 headOffset\n ) internal pure returns (MemoryPointer mPtrChild) {\n mPtrChild = mPtr.offset(headOffset).readMemoryPointer();\n }\n\n /// @dev Resolves a pointer stored at `mPtr` to a memory pointer.\n /// `mPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer mPtrChild) {\n mPtrChild = mPtr.readMemoryPointer();\n }\n}\n\nlibrary CalldataReaders {\n /// @dev Reads the value at `cdPtr` and applies a mask to return only the\n /// last 4 bytes.\n function readMaskedUint256(\n CalldataPointer cdPtr\n ) internal pure returns (uint256 value) {\n value = cdPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `cdPtr` in calldata.\n function readBool(\n CalldataPointer cdPtr\n ) internal pure returns (bool value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the address at `cdPtr` in calldata.\n function readAddress(\n CalldataPointer cdPtr\n ) internal pure returns (address value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes1 at `cdPtr` in calldata.\n function readBytes1(\n CalldataPointer cdPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes2 at `cdPtr` in calldata.\n function readBytes2(\n CalldataPointer cdPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes3 at `cdPtr` in calldata.\n function readBytes3(\n CalldataPointer cdPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes4 at `cdPtr` in calldata.\n function readBytes4(\n CalldataPointer cdPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes5 at `cdPtr` in calldata.\n function readBytes5(\n CalldataPointer cdPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes6 at `cdPtr` in calldata.\n function readBytes6(\n CalldataPointer cdPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes7 at `cdPtr` in calldata.\n function readBytes7(\n CalldataPointer cdPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes8 at `cdPtr` in calldata.\n function readBytes8(\n CalldataPointer cdPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes9 at `cdPtr` in calldata.\n function readBytes9(\n CalldataPointer cdPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes10 at `cdPtr` in calldata.\n function readBytes10(\n CalldataPointer cdPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes11 at `cdPtr` in calldata.\n function readBytes11(\n CalldataPointer cdPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes12 at `cdPtr` in calldata.\n function readBytes12(\n CalldataPointer cdPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes13 at `cdPtr` in calldata.\n function readBytes13(\n CalldataPointer cdPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes14 at `cdPtr` in calldata.\n function readBytes14(\n CalldataPointer cdPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes15 at `cdPtr` in calldata.\n function readBytes15(\n CalldataPointer cdPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes16 at `cdPtr` in calldata.\n function readBytes16(\n CalldataPointer cdPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes17 at `cdPtr` in calldata.\n function readBytes17(\n CalldataPointer cdPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes18 at `cdPtr` in calldata.\n function readBytes18(\n CalldataPointer cdPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes19 at `cdPtr` in calldata.\n function readBytes19(\n CalldataPointer cdPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes20 at `cdPtr` in calldata.\n function readBytes20(\n CalldataPointer cdPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes21 at `cdPtr` in calldata.\n function readBytes21(\n CalldataPointer cdPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes22 at `cdPtr` in calldata.\n function readBytes22(\n CalldataPointer cdPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes23 at `cdPtr` in calldata.\n function readBytes23(\n CalldataPointer cdPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes24 at `cdPtr` in calldata.\n function readBytes24(\n CalldataPointer cdPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes25 at `cdPtr` in calldata.\n function readBytes25(\n CalldataPointer cdPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes26 at `cdPtr` in calldata.\n function readBytes26(\n CalldataPointer cdPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes27 at `cdPtr` in calldata.\n function readBytes27(\n CalldataPointer cdPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes28 at `cdPtr` in calldata.\n function readBytes28(\n CalldataPointer cdPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes29 at `cdPtr` in calldata.\n function readBytes29(\n CalldataPointer cdPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes30 at `cdPtr` in calldata.\n function readBytes30(\n CalldataPointer cdPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes31 at `cdPtr` in calldata.\n function readBytes31(\n CalldataPointer cdPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes32 at `cdPtr` in calldata.\n function readBytes32(\n CalldataPointer cdPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint8 at `cdPtr` in calldata.\n function readUint8(\n CalldataPointer cdPtr\n ) internal pure returns (uint8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint16 at `cdPtr` in calldata.\n function readUint16(\n CalldataPointer cdPtr\n ) internal pure returns (uint16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint24 at `cdPtr` in calldata.\n function readUint24(\n CalldataPointer cdPtr\n ) internal pure returns (uint24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint32 at `cdPtr` in calldata.\n function readUint32(\n CalldataPointer cdPtr\n ) internal pure returns (uint32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint40 at `cdPtr` in calldata.\n function readUint40(\n CalldataPointer cdPtr\n ) internal pure returns (uint40 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint48 at `cdPtr` in calldata.\n function readUint48(\n CalldataPointer cdPtr\n ) internal pure returns (uint48 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint56 at `cdPtr` in calldata.\n function readUint56(\n CalldataPointer cdPtr\n ) internal pure returns (uint56 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint64 at `cdPtr` in calldata.\n function readUint64(\n CalldataPointer cdPtr\n ) internal pure returns (uint64 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint72 at `cdPtr` in calldata.\n function readUint72(\n CalldataPointer cdPtr\n ) internal pure returns (uint72 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint80 at `cdPtr` in calldata.\n function readUint80(\n CalldataPointer cdPtr\n ) internal pure returns (uint80 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint88 at `cdPtr` in calldata.\n function readUint88(\n CalldataPointer cdPtr\n ) internal pure returns (uint88 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint96 at `cdPtr` in calldata.\n function readUint96(\n CalldataPointer cdPtr\n ) internal pure returns (uint96 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint104 at `cdPtr` in calldata.\n function readUint104(\n CalldataPointer cdPtr\n ) internal pure returns (uint104 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint112 at `cdPtr` in calldata.\n function readUint112(\n CalldataPointer cdPtr\n ) internal pure returns (uint112 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint120 at `cdPtr` in calldata.\n function readUint120(\n CalldataPointer cdPtr\n ) internal pure returns (uint120 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint128 at `cdPtr` in calldata.\n function readUint128(\n CalldataPointer cdPtr\n ) internal pure returns (uint128 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint136 at `cdPtr` in calldata.\n function readUint136(\n CalldataPointer cdPtr\n ) internal pure returns (uint136 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint144 at `cdPtr` in calldata.\n function readUint144(\n CalldataPointer cdPtr\n ) internal pure returns (uint144 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint152 at `cdPtr` in calldata.\n function readUint152(\n CalldataPointer cdPtr\n ) internal pure returns (uint152 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint160 at `cdPtr` in calldata.\n function readUint160(\n CalldataPointer cdPtr\n ) internal pure returns (uint160 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint168 at `cdPtr` in calldata.\n function readUint168(\n CalldataPointer cdPtr\n ) internal pure returns (uint168 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint176 at `cdPtr` in calldata.\n function readUint176(\n CalldataPointer cdPtr\n ) internal pure returns (uint176 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint184 at `cdPtr` in calldata.\n function readUint184(\n CalldataPointer cdPtr\n ) internal pure returns (uint184 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint192 at `cdPtr` in calldata.\n function readUint192(\n CalldataPointer cdPtr\n ) internal pure returns (uint192 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint200 at `cdPtr` in calldata.\n function readUint200(\n CalldataPointer cdPtr\n ) internal pure returns (uint200 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint208 at `cdPtr` in calldata.\n function readUint208(\n CalldataPointer cdPtr\n ) internal pure returns (uint208 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint216 at `cdPtr` in calldata.\n function readUint216(\n CalldataPointer cdPtr\n ) internal pure returns (uint216 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint224 at `cdPtr` in calldata.\n function readUint224(\n CalldataPointer cdPtr\n ) internal pure returns (uint224 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint232 at `cdPtr` in calldata.\n function readUint232(\n CalldataPointer cdPtr\n ) internal pure returns (uint232 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint240 at `cdPtr` in calldata.\n function readUint240(\n CalldataPointer cdPtr\n ) internal pure returns (uint240 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint248 at `cdPtr` in calldata.\n function readUint248(\n CalldataPointer cdPtr\n ) internal pure returns (uint248 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint256 at `cdPtr` in calldata.\n function readUint256(\n CalldataPointer cdPtr\n ) internal pure returns (uint256 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int8 at `cdPtr` in calldata.\n function readInt8(\n CalldataPointer cdPtr\n ) internal pure returns (int8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int16 at `cdPtr` in calldata.\n function readInt16(\n CalldataPointer cdPtr\n ) internal pure returns (int16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int24 at `cdPtr` in calldata.\n function readInt24(\n CalldataPointer cdPtr\n ) internal pure returns (int24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int32 at `cdPtr` in calldata.\n function readInt32(\n CalldataPointer cdPtr\n ) internal pure returns (int32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int40 at `cdPtr` in calldata.\n function readInt40(\n CalldataPointer cdPtr\n ) internal pure returns (int40 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int48 at `cdPtr` in calldata.\n function readInt48(\n CalldataPointer cdPtr\n ) internal pure returns (int48 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int56 at `cdPtr` in calldata.\n function readInt56(\n CalldataPointer cdPtr\n ) internal pure returns (int56 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int64 at `cdPtr` in calldata.\n function readInt64(\n CalldataPointer cdPtr\n ) internal pure returns (int64 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int72 at `cdPtr` in calldata.\n function readInt72(\n CalldataPointer cdPtr\n ) internal pure returns (int72 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int80 at `cdPtr` in calldata.\n function readInt80(\n CalldataPointer cdPtr\n ) internal pure returns (int80 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int88 at `cdPtr` in calldata.\n function readInt88(\n CalldataPointer cdPtr\n ) internal pure returns (int88 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int96 at `cdPtr` in calldata.\n function readInt96(\n CalldataPointer cdPtr\n ) internal pure returns (int96 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int104 at `cdPtr` in calldata.\n function readInt104(\n CalldataPointer cdPtr\n ) internal pure returns (int104 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int112 at `cdPtr` in calldata.\n function readInt112(\n CalldataPointer cdPtr\n ) internal pure returns (int112 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int120 at `cdPtr` in calldata.\n function readInt120(\n CalldataPointer cdPtr\n ) internal pure returns (int120 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int128 at `cdPtr` in calldata.\n function readInt128(\n CalldataPointer cdPtr\n ) internal pure returns (int128 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int136 at `cdPtr` in calldata.\n function readInt136(\n CalldataPointer cdPtr\n ) internal pure returns (int136 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int144 at `cdPtr` in calldata.\n function readInt144(\n CalldataPointer cdPtr\n ) internal pure returns (int144 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int152 at `cdPtr` in calldata.\n function readInt152(\n CalldataPointer cdPtr\n ) internal pure returns (int152 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int160 at `cdPtr` in calldata.\n function readInt160(\n CalldataPointer cdPtr\n ) internal pure returns (int160 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int168 at `cdPtr` in calldata.\n function readInt168(\n CalldataPointer cdPtr\n ) internal pure returns (int168 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int176 at `cdPtr` in calldata.\n function readInt176(\n CalldataPointer cdPtr\n ) internal pure returns (int176 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int184 at `cdPtr` in calldata.\n function readInt184(\n CalldataPointer cdPtr\n ) internal pure returns (int184 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int192 at `cdPtr` in calldata.\n function readInt192(\n CalldataPointer cdPtr\n ) internal pure returns (int192 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int200 at `cdPtr` in calldata.\n function readInt200(\n CalldataPointer cdPtr\n ) internal pure returns (int200 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int208 at `cdPtr` in calldata.\n function readInt208(\n CalldataPointer cdPtr\n ) internal pure returns (int208 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int216 at `cdPtr` in calldata.\n function readInt216(\n CalldataPointer cdPtr\n ) internal pure returns (int216 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int224 at `cdPtr` in calldata.\n function readInt224(\n CalldataPointer cdPtr\n ) internal pure returns (int224 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int232 at `cdPtr` in calldata.\n function readInt232(\n CalldataPointer cdPtr\n ) internal pure returns (int232 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int240 at `cdPtr` in calldata.\n function readInt240(\n CalldataPointer cdPtr\n ) internal pure returns (int240 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int248 at `cdPtr` in calldata.\n function readInt248(\n CalldataPointer cdPtr\n ) internal pure returns (int248 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int256 at `cdPtr` in calldata.\n function readInt256(\n CalldataPointer cdPtr\n ) internal pure returns (int256 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n}\n\nlibrary ReturndataReaders {\n /// @dev Reads value at `rdPtr` & applies a mask to return only last 4 bytes\n function readMaskedUint256(\n ReturndataPointer rdPtr\n ) internal pure returns (uint256 value) {\n value = rdPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `rdPtr` in returndata.\n function readBool(\n ReturndataPointer rdPtr\n ) internal pure returns (bool value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the address at `rdPtr` in returndata.\n function readAddress(\n ReturndataPointer rdPtr\n ) internal pure returns (address value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes1 at `rdPtr` in returndata.\n function readBytes1(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes2 at `rdPtr` in returndata.\n function readBytes2(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes3 at `rdPtr` in returndata.\n function readBytes3(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes4 at `rdPtr` in returndata.\n function readBytes4(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes5 at `rdPtr` in returndata.\n function readBytes5(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes6 at `rdPtr` in returndata.\n function readBytes6(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes7 at `rdPtr` in returndata.\n function readBytes7(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes8 at `rdPtr` in returndata.\n function readBytes8(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes9 at `rdPtr` in returndata.\n function readBytes9(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes10 at `rdPtr` in returndata.\n function readBytes10(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes11 at `rdPtr` in returndata.\n function readBytes11(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes12 at `rdPtr` in returndata.\n function readBytes12(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes13 at `rdPtr` in returndata.\n function readBytes13(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes14 at `rdPtr` in returndata.\n function readBytes14(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes15 at `rdPtr` in returndata.\n function readBytes15(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes16 at `rdPtr` in returndata.\n function readBytes16(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes17 at `rdPtr` in returndata.\n function readBytes17(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes18 at `rdPtr` in returndata.\n function readBytes18(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes19 at `rdPtr` in returndata.\n function readBytes19(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes20 at `rdPtr` in returndata.\n function readBytes20(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes21 at `rdPtr` in returndata.\n function readBytes21(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes22 at `rdPtr` in returndata.\n function readBytes22(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes23 at `rdPtr` in returndata.\n function readBytes23(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes24 at `rdPtr` in returndata.\n function readBytes24(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes25 at `rdPtr` in returndata.\n function readBytes25(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes26 at `rdPtr` in returndata.\n function readBytes26(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes27 at `rdPtr` in returndata.\n function readBytes27(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes28 at `rdPtr` in returndata.\n function readBytes28(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes29 at `rdPtr` in returndata.\n function readBytes29(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes30 at `rdPtr` in returndata.\n function readBytes30(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes31 at `rdPtr` in returndata.\n function readBytes31(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes32 at `rdPtr` in returndata.\n function readBytes32(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint8 at `rdPtr` in returndata.\n function readUint8(\n ReturndataPointer rdPtr\n ) internal pure returns (uint8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint16 at `rdPtr` in returndata.\n function readUint16(\n ReturndataPointer rdPtr\n ) internal pure returns (uint16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint24 at `rdPtr` in returndata.\n function readUint24(\n ReturndataPointer rdPtr\n ) internal pure returns (uint24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint32 at `rdPtr` in returndata.\n function readUint32(\n ReturndataPointer rdPtr\n ) internal pure returns (uint32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint40 at `rdPtr` in returndata.\n function readUint40(\n ReturndataPointer rdPtr\n ) internal pure returns (uint40 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint48 at `rdPtr` in returndata.\n function readUint48(\n ReturndataPointer rdPtr\n ) internal pure returns (uint48 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint56 at `rdPtr` in returndata.\n function readUint56(\n ReturndataPointer rdPtr\n ) internal pure returns (uint56 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint64 at `rdPtr` in returndata.\n function readUint64(\n ReturndataPointer rdPtr\n ) internal pure returns (uint64 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint72 at `rdPtr` in returndata.\n function readUint72(\n ReturndataPointer rdPtr\n ) internal pure returns (uint72 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint80 at `rdPtr` in returndata.\n function readUint80(\n ReturndataPointer rdPtr\n ) internal pure returns (uint80 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint88 at `rdPtr` in returndata.\n function readUint88(\n ReturndataPointer rdPtr\n ) internal pure returns (uint88 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint96 at `rdPtr` in returndata.\n function readUint96(\n ReturndataPointer rdPtr\n ) internal pure returns (uint96 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint104 at `rdPtr` in returndata.\n function readUint104(\n ReturndataPointer rdPtr\n ) internal pure returns (uint104 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint112 at `rdPtr` in returndata.\n function readUint112(\n ReturndataPointer rdPtr\n ) internal pure returns (uint112 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint120 at `rdPtr` in returndata.\n function readUint120(\n ReturndataPointer rdPtr\n ) internal pure returns (uint120 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint128 at `rdPtr` in returndata.\n function readUint128(\n ReturndataPointer rdPtr\n ) internal pure returns (uint128 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint136 at `rdPtr` in returndata.\n function readUint136(\n ReturndataPointer rdPtr\n ) internal pure returns (uint136 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint144 at `rdPtr` in returndata.\n function readUint144(\n ReturndataPointer rdPtr\n ) internal pure returns (uint144 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint152 at `rdPtr` in returndata.\n function readUint152(\n ReturndataPointer rdPtr\n ) internal pure returns (uint152 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint160 at `rdPtr` in returndata.\n function readUint160(\n ReturndataPointer rdPtr\n ) internal pure returns (uint160 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint168 at `rdPtr` in returndata.\n function readUint168(\n ReturndataPointer rdPtr\n ) internal pure returns (uint168 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint176 at `rdPtr` in returndata.\n function readUint176(\n ReturndataPointer rdPtr\n ) internal pure returns (uint176 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint184 at `rdPtr` in returndata.\n function readUint184(\n ReturndataPointer rdPtr\n ) internal pure returns (uint184 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint192 at `rdPtr` in returndata.\n function readUint192(\n ReturndataPointer rdPtr\n ) internal pure returns (uint192 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint200 at `rdPtr` in returndata.\n function readUint200(\n ReturndataPointer rdPtr\n ) internal pure returns (uint200 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint208 at `rdPtr` in returndata.\n function readUint208(\n ReturndataPointer rdPtr\n ) internal pure returns (uint208 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint216 at `rdPtr` in returndata.\n function readUint216(\n ReturndataPointer rdPtr\n ) internal pure returns (uint216 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint224 at `rdPtr` in returndata.\n function readUint224(\n ReturndataPointer rdPtr\n ) internal pure returns (uint224 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint232 at `rdPtr` in returndata.\n function readUint232(\n ReturndataPointer rdPtr\n ) internal pure returns (uint232 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint240 at `rdPtr` in returndata.\n function readUint240(\n ReturndataPointer rdPtr\n ) internal pure returns (uint240 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint248 at `rdPtr` in returndata.\n function readUint248(\n ReturndataPointer rdPtr\n ) internal pure returns (uint248 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint256 at `rdPtr` in returndata.\n function readUint256(\n ReturndataPointer rdPtr\n ) internal pure returns (uint256 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int8 at `rdPtr` in returndata.\n function readInt8(\n ReturndataPointer rdPtr\n ) internal pure returns (int8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int16 at `rdPtr` in returndata.\n function readInt16(\n ReturndataPointer rdPtr\n ) internal pure returns (int16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int24 at `rdPtr` in returndata.\n function readInt24(\n ReturndataPointer rdPtr\n ) internal pure returns (int24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int32 at `rdPtr` in returndata.\n function readInt32(\n ReturndataPointer rdPtr\n ) internal pure returns (int32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int40 at `rdPtr` in returndata.\n function readInt40(\n ReturndataPointer rdPtr\n ) internal pure returns (int40 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int48 at `rdPtr` in returndata.\n function readInt48(\n ReturndataPointer rdPtr\n ) internal pure returns (int48 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int56 at `rdPtr` in returndata.\n function readInt56(\n ReturndataPointer rdPtr\n ) internal pure returns (int56 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int64 at `rdPtr` in returndata.\n function readInt64(\n ReturndataPointer rdPtr\n ) internal pure returns (int64 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int72 at `rdPtr` in returndata.\n function readInt72(\n ReturndataPointer rdPtr\n ) internal pure returns (int72 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int80 at `rdPtr` in returndata.\n function readInt80(\n ReturndataPointer rdPtr\n ) internal pure returns (int80 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int88 at `rdPtr` in returndata.\n function readInt88(\n ReturndataPointer rdPtr\n ) internal pure returns (int88 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int96 at `rdPtr` in returndata.\n function readInt96(\n ReturndataPointer rdPtr\n ) internal pure returns (int96 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int104 at `rdPtr` in returndata.\n function readInt104(\n ReturndataPointer rdPtr\n ) internal pure returns (int104 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int112 at `rdPtr` in returndata.\n function readInt112(\n ReturndataPointer rdPtr\n ) internal pure returns (int112 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int120 at `rdPtr` in returndata.\n function readInt120(\n ReturndataPointer rdPtr\n ) internal pure returns (int120 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int128 at `rdPtr` in returndata.\n function readInt128(\n ReturndataPointer rdPtr\n ) internal pure returns (int128 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int136 at `rdPtr` in returndata.\n function readInt136(\n ReturndataPointer rdPtr\n ) internal pure returns (int136 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int144 at `rdPtr` in returndata.\n function readInt144(\n ReturndataPointer rdPtr\n ) internal pure returns (int144 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int152 at `rdPtr` in returndata.\n function readInt152(\n ReturndataPointer rdPtr\n ) internal pure returns (int152 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int160 at `rdPtr` in returndata.\n function readInt160(\n ReturndataPointer rdPtr\n ) internal pure returns (int160 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int168 at `rdPtr` in returndata.\n function readInt168(\n ReturndataPointer rdPtr\n ) internal pure returns (int168 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int176 at `rdPtr` in returndata.\n function readInt176(\n ReturndataPointer rdPtr\n ) internal pure returns (int176 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int184 at `rdPtr` in returndata.\n function readInt184(\n ReturndataPointer rdPtr\n ) internal pure returns (int184 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int192 at `rdPtr` in returndata.\n function readInt192(\n ReturndataPointer rdPtr\n ) internal pure returns (int192 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int200 at `rdPtr` in returndata.\n function readInt200(\n ReturndataPointer rdPtr\n ) internal pure returns (int200 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int208 at `rdPtr` in returndata.\n function readInt208(\n ReturndataPointer rdPtr\n ) internal pure returns (int208 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int216 at `rdPtr` in returndata.\n function readInt216(\n ReturndataPointer rdPtr\n ) internal pure returns (int216 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int224 at `rdPtr` in returndata.\n function readInt224(\n ReturndataPointer rdPtr\n ) internal pure returns (int224 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int232 at `rdPtr` in returndata.\n function readInt232(\n ReturndataPointer rdPtr\n ) internal pure returns (int232 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int240 at `rdPtr` in returndata.\n function readInt240(\n ReturndataPointer rdPtr\n ) internal pure returns (int240 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int248 at `rdPtr` in returndata.\n function readInt248(\n ReturndataPointer rdPtr\n ) internal pure returns (int248 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int256 at `rdPtr` in returndata.\n function readInt256(\n ReturndataPointer rdPtr\n ) internal pure returns (int256 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n}\n\nlibrary MemoryReaders {\n /// @dev Reads the memory pointer at `mPtr` in memory.\n function readMemoryPointer(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads value at `mPtr` & applies a mask to return only last 4 bytes\n function readMaskedUint256(\n MemoryPointer mPtr\n ) internal pure returns (uint256 value) {\n value = mPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `mPtr` in memory.\n function readBool(MemoryPointer mPtr) internal pure returns (bool value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the address at `mPtr` in memory.\n function readAddress(\n MemoryPointer mPtr\n ) internal pure returns (address value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes1 at `mPtr` in memory.\n function readBytes1(\n MemoryPointer mPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes2 at `mPtr` in memory.\n function readBytes2(\n MemoryPointer mPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes3 at `mPtr` in memory.\n function readBytes3(\n MemoryPointer mPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes4 at `mPtr` in memory.\n function readBytes4(\n MemoryPointer mPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes5 at `mPtr` in memory.\n function readBytes5(\n MemoryPointer mPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes6 at `mPtr` in memory.\n function readBytes6(\n MemoryPointer mPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes7 at `mPtr` in memory.\n function readBytes7(\n MemoryPointer mPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes8 at `mPtr` in memory.\n function readBytes8(\n MemoryPointer mPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes9 at `mPtr` in memory.\n function readBytes9(\n MemoryPointer mPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes10 at `mPtr` in memory.\n function readBytes10(\n MemoryPointer mPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes11 at `mPtr` in memory.\n function readBytes11(\n MemoryPointer mPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes12 at `mPtr` in memory.\n function readBytes12(\n MemoryPointer mPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes13 at `mPtr` in memory.\n function readBytes13(\n MemoryPointer mPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes14 at `mPtr` in memory.\n function readBytes14(\n MemoryPointer mPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes15 at `mPtr` in memory.\n function readBytes15(\n MemoryPointer mPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes16 at `mPtr` in memory.\n function readBytes16(\n MemoryPointer mPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes17 at `mPtr` in memory.\n function readBytes17(\n MemoryPointer mPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes18 at `mPtr` in memory.\n function readBytes18(\n MemoryPointer mPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes19 at `mPtr` in memory.\n function readBytes19(\n MemoryPointer mPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes20 at `mPtr` in memory.\n function readBytes20(\n MemoryPointer mPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes21 at `mPtr` in memory.\n function readBytes21(\n MemoryPointer mPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes22 at `mPtr` in memory.\n function readBytes22(\n MemoryPointer mPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes23 at `mPtr` in memory.\n function readBytes23(\n MemoryPointer mPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes24 at `mPtr` in memory.\n function readBytes24(\n MemoryPointer mPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes25 at `mPtr` in memory.\n function readBytes25(\n MemoryPointer mPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes26 at `mPtr` in memory.\n function readBytes26(\n MemoryPointer mPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes27 at `mPtr` in memory.\n function readBytes27(\n MemoryPointer mPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes28 at `mPtr` in memory.\n function readBytes28(\n MemoryPointer mPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes29 at `mPtr` in memory.\n function readBytes29(\n MemoryPointer mPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes30 at `mPtr` in memory.\n function readBytes30(\n MemoryPointer mPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes31 at `mPtr` in memory.\n function readBytes31(\n MemoryPointer mPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes32 at `mPtr` in memory.\n function readBytes32(\n MemoryPointer mPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint8 at `mPtr` in memory.\n function readUint8(MemoryPointer mPtr) internal pure returns (uint8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint16 at `mPtr` in memory.\n function readUint16(\n MemoryPointer mPtr\n ) internal pure returns (uint16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint24 at `mPtr` in memory.\n function readUint24(\n MemoryPointer mPtr\n ) internal pure returns (uint24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint32 at `mPtr` in memory.\n function readUint32(\n MemoryPointer mPtr\n ) internal pure returns (uint32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint40 at `mPtr` in memory.\n function readUint40(\n MemoryPointer mPtr\n ) internal pure returns (uint40 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint48 at `mPtr` in memory.\n function readUint48(\n MemoryPointer mPtr\n ) internal pure returns (uint48 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint56 at `mPtr` in memory.\n function readUint56(\n MemoryPointer mPtr\n ) internal pure returns (uint56 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint64 at `mPtr` in memory.\n function readUint64(\n MemoryPointer mPtr\n ) internal pure returns (uint64 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint72 at `mPtr` in memory.\n function readUint72(\n MemoryPointer mPtr\n ) internal pure returns (uint72 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint80 at `mPtr` in memory.\n function readUint80(\n MemoryPointer mPtr\n ) internal pure returns (uint80 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint88 at `mPtr` in memory.\n function readUint88(\n MemoryPointer mPtr\n ) internal pure returns (uint88 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint96 at `mPtr` in memory.\n function readUint96(\n MemoryPointer mPtr\n ) internal pure returns (uint96 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint104 at `mPtr` in memory.\n function readUint104(\n MemoryPointer mPtr\n ) internal pure returns (uint104 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint112 at `mPtr` in memory.\n function readUint112(\n MemoryPointer mPtr\n ) internal pure returns (uint112 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint120 at `mPtr` in memory.\n function readUint120(\n MemoryPointer mPtr\n ) internal pure returns (uint120 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint128 at `mPtr` in memory.\n function readUint128(\n MemoryPointer mPtr\n ) internal pure returns (uint128 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint136 at `mPtr` in memory.\n function readUint136(\n MemoryPointer mPtr\n ) internal pure returns (uint136 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint144 at `mPtr` in memory.\n function readUint144(\n MemoryPointer mPtr\n ) internal pure returns (uint144 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint152 at `mPtr` in memory.\n function readUint152(\n MemoryPointer mPtr\n ) internal pure returns (uint152 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint160 at `mPtr` in memory.\n function readUint160(\n MemoryPointer mPtr\n ) internal pure returns (uint160 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint168 at `mPtr` in memory.\n function readUint168(\n MemoryPointer mPtr\n ) internal pure returns (uint168 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint176 at `mPtr` in memory.\n function readUint176(\n MemoryPointer mPtr\n ) internal pure returns (uint176 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint184 at `mPtr` in memory.\n function readUint184(\n MemoryPointer mPtr\n ) internal pure returns (uint184 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint192 at `mPtr` in memory.\n function readUint192(\n MemoryPointer mPtr\n ) internal pure returns (uint192 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint200 at `mPtr` in memory.\n function readUint200(\n MemoryPointer mPtr\n ) internal pure returns (uint200 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint208 at `mPtr` in memory.\n function readUint208(\n MemoryPointer mPtr\n ) internal pure returns (uint208 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint216 at `mPtr` in memory.\n function readUint216(\n MemoryPointer mPtr\n ) internal pure returns (uint216 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint224 at `mPtr` in memory.\n function readUint224(\n MemoryPointer mPtr\n ) internal pure returns (uint224 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint232 at `mPtr` in memory.\n function readUint232(\n MemoryPointer mPtr\n ) internal pure returns (uint232 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint240 at `mPtr` in memory.\n function readUint240(\n MemoryPointer mPtr\n ) internal pure returns (uint240 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint248 at `mPtr` in memory.\n function readUint248(\n MemoryPointer mPtr\n ) internal pure returns (uint248 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint256 at `mPtr` in memory.\n function readUint256(\n MemoryPointer mPtr\n ) internal pure returns (uint256 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int8 at `mPtr` in memory.\n function readInt8(MemoryPointer mPtr) internal pure returns (int8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int16 at `mPtr` in memory.\n function readInt16(MemoryPointer mPtr) internal pure returns (int16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int24 at `mPtr` in memory.\n function readInt24(MemoryPointer mPtr) internal pure returns (int24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int32 at `mPtr` in memory.\n function readInt32(MemoryPointer mPtr) internal pure returns (int32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int40 at `mPtr` in memory.\n function readInt40(MemoryPointer mPtr) internal pure returns (int40 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int48 at `mPtr` in memory.\n function readInt48(MemoryPointer mPtr) internal pure returns (int48 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int56 at `mPtr` in memory.\n function readInt56(MemoryPointer mPtr) internal pure returns (int56 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int64 at `mPtr` in memory.\n function readInt64(MemoryPointer mPtr) internal pure returns (int64 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int72 at `mPtr` in memory.\n function readInt72(MemoryPointer mPtr) internal pure returns (int72 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int80 at `mPtr` in memory.\n function readInt80(MemoryPointer mPtr) internal pure returns (int80 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int88 at `mPtr` in memory.\n function readInt88(MemoryPointer mPtr) internal pure returns (int88 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int96 at `mPtr` in memory.\n function readInt96(MemoryPointer mPtr) internal pure returns (int96 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int104 at `mPtr` in memory.\n function readInt104(\n MemoryPointer mPtr\n ) internal pure returns (int104 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int112 at `mPtr` in memory.\n function readInt112(\n MemoryPointer mPtr\n ) internal pure returns (int112 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int120 at `mPtr` in memory.\n function readInt120(\n MemoryPointer mPtr\n ) internal pure returns (int120 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int128 at `mPtr` in memory.\n function readInt128(\n MemoryPointer mPtr\n ) internal pure returns (int128 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int136 at `mPtr` in memory.\n function readInt136(\n MemoryPointer mPtr\n ) internal pure returns (int136 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int144 at `mPtr` in memory.\n function readInt144(\n MemoryPointer mPtr\n ) internal pure returns (int144 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int152 at `mPtr` in memory.\n function readInt152(\n MemoryPointer mPtr\n ) internal pure returns (int152 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int160 at `mPtr` in memory.\n function readInt160(\n MemoryPointer mPtr\n ) internal pure returns (int160 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int168 at `mPtr` in memory.\n function readInt168(\n MemoryPointer mPtr\n ) internal pure returns (int168 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int176 at `mPtr` in memory.\n function readInt176(\n MemoryPointer mPtr\n ) internal pure returns (int176 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int184 at `mPtr` in memory.\n function readInt184(\n MemoryPointer mPtr\n ) internal pure returns (int184 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int192 at `mPtr` in memory.\n function readInt192(\n MemoryPointer mPtr\n ) internal pure returns (int192 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int200 at `mPtr` in memory.\n function readInt200(\n MemoryPointer mPtr\n ) internal pure returns (int200 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int208 at `mPtr` in memory.\n function readInt208(\n MemoryPointer mPtr\n ) internal pure returns (int208 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int216 at `mPtr` in memory.\n function readInt216(\n MemoryPointer mPtr\n ) internal pure returns (int216 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int224 at `mPtr` in memory.\n function readInt224(\n MemoryPointer mPtr\n ) internal pure returns (int224 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int232 at `mPtr` in memory.\n function readInt232(\n MemoryPointer mPtr\n ) internal pure returns (int232 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int240 at `mPtr` in memory.\n function readInt240(\n MemoryPointer mPtr\n ) internal pure returns (int240 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int248 at `mPtr` in memory.\n function readInt248(\n MemoryPointer mPtr\n ) internal pure returns (int248 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int256 at `mPtr` in memory.\n function readInt256(\n MemoryPointer mPtr\n ) internal pure returns (int256 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n}\n\nlibrary MemoryWriters {\n /// @dev Writes `valuePtr` to memory at `mPtr`.\n function write(MemoryPointer mPtr, MemoryPointer valuePtr) internal pure {\n assembly {\n mstore(mPtr, valuePtr)\n }\n }\n\n /// @dev Writes a boolean `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, bool value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes an address `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, address value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes a bytes32 `value` to `mPtr` in memory.\n /// Separate name to disambiguate literal write parameters.\n function writeBytes32(MemoryPointer mPtr, bytes32 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes a uint256 `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, uint256 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes an int256 `value` to `mPtr` in memory.\n /// Separate name to disambiguate literal write parameters.\n function writeInt(MemoryPointer mPtr, int256 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.7;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.19;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(target.code.length > 0, \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
},
"src/lib/ERC721SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { AllowListData, CreatorPayout } from \"./SeaDropStructs.sol\";\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in two storage slots.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token address. Null for\n * native token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct PublicDrop {\n uint80 startPrice; // 80/512 bits\n uint80 endPrice; // 160/512 bits\n uint40 startTime; // 200/512 bits\n uint40 endTime; // 240/512 bits\n address paymentToken; // 400/512 bits\n uint16 maxTotalMintableByWallet; // 416/512 bits\n uint16 feeBps; // 432/512 bits\n bool restrictFeeRecipients; // 440/512 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n *\n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token for the mint. Null for\n * native token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 startPrice;\n uint256 endPrice;\n uint256 startTime;\n uint256 endTime;\n address paymentToken;\n uint256 maxTotalMintableByWallet;\n uint256 maxTokenSupplyForStage;\n uint256 dropStageIndex; // non-zero\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @dev Struct containing internal SeaDrop implementation logic\n * mint details to avoid stack too deep.\n *\n * @param feeRecipient The fee recipient.\n * @param payer The payer of the mint.\n * @param minter The mint recipient.\n * @param quantity The number of tokens to mint.\n * @param withEffects Whether to apply state changes of the mint.\n */\nstruct MintDetails {\n address feeRecipient;\n address payer;\n address minter;\n uint256 quantity;\n bool withEffects;\n}\n\n/**\n * @notice A struct to configure multiple contract options in one transaction.\n */\nstruct MultiConfigureStruct {\n uint256 maxSupply;\n string baseURI;\n string contractURI;\n PublicDrop publicDrop;\n string dropURI;\n AllowListData allowListData;\n CreatorPayout[] creatorPayouts;\n bytes32 provenanceHash;\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n address[] allowedPayers;\n address[] disallowedPayers;\n // Server-signed\n address[] allowedSigners;\n address[] disallowedSigners;\n // ERC-2981\n address royaltyReceiver;\n uint96 royaltyBps;\n // Mint\n address mintRecipient;\n uint256 mintQuantity;\n}\n"
}
},
"settings": {
"remappings": [
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"ERC721A/=lib/ERC721A/contracts/",
"ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin-upgradeable/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@rari-capital/solmate/=lib/seaport/lib/solmate/",
"murky/=lib/murky/src/",
"create2-scripts/=lib/create2-helpers/script/",
"seadrop/=src/",
"seaport-sol/=lib/seaport/lib/seaport-sol/",
"seaport-types/=lib/seaport/lib/seaport-types/",
"seaport-core/=lib/seaport/lib/seaport-core/",
"seaport-test-utils/=lib/seaport/test/foundry/utils/",
"solady/=lib/solady/"
],
"optimizer": {
"enabled": true,
"runs": 99999999
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"libraries": {}
}
}}
|
1 | 19,498,597 |
b80f983b3d124b0fa40766d16a1161af7e552168269f220a04f9b6236cad7bfa
|
0b2d6e5a824ac8f281664a26c2483e48809734b8958e93124b5f34a27f842368
|
9846ccad919446c1cce8a1aabfe0a88443c4d3fb
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
e3accdee8eea889d6847ed33b835bb509c37f97a
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,599 |
086c6f8dd3902bdb0e3fd43a7e94c017bf181c0ad1a7ff4e616d1753b8e95098
|
b286da2589bbc7c017c1cfdaa966a26ef3962e39cbba9f8c6fc8f502a2e7eca6
|
7c6f33092f2bd73d4db744670eda088a32f75f45
|
000000008924d42d98026c656545c3c1fb3ad31c
|
35e124b11f2e260b66a4e2e6e11ec36b76ee304c
|
3d602d80600a3d3981f3363d3d373d3d3d363d73391a04311e0bfc913ef6fa784773307c826104f05af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73391a04311e0bfc913ef6fa784773307c826104f05af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"lib/ERC721A/contracts/IERC721A.sol": {
"content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v4.2.2\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\n/**\n * @dev Interface of ERC721A.\n */\ninterface IERC721A {\n /**\n * The caller must own the token or be an approved operator.\n */\n error ApprovalCallerNotOwnerNorApproved();\n\n /**\n * The token does not exist.\n */\n error ApprovalQueryForNonexistentToken();\n\n /**\n * Cannot query the balance for the zero address.\n */\n error BalanceQueryForZeroAddress();\n\n /**\n * Cannot mint to the zero address.\n */\n error MintToZeroAddress();\n\n /**\n * The quantity of tokens minted must be more than zero.\n */\n error MintZeroQuantity();\n\n /**\n * The token does not exist.\n */\n error OwnerQueryForNonexistentToken();\n\n /**\n * The caller must own the token or be an approved operator.\n */\n error TransferCallerNotOwnerNorApproved();\n\n /**\n * The token must be owned by `from`.\n */\n error TransferFromIncorrectOwner();\n\n /**\n * Cannot safely transfer to a contract that does not implement the\n * ERC721Receiver interface.\n */\n error TransferToNonERC721ReceiverImplementer();\n\n /**\n * Cannot transfer to the zero address.\n */\n error TransferToZeroAddress();\n\n /**\n * The token does not exist.\n */\n error URIQueryForNonexistentToken();\n\n /**\n * The `quantity` minted with ERC2309 exceeds the safety limit.\n */\n error MintERC2309QuantityExceedsLimit();\n\n /**\n * The `extraData` cannot be set on an unintialized ownership slot.\n */\n error OwnershipNotInitializedForExtraData();\n\n // =============================================================\n // STRUCTS\n // =============================================================\n\n struct TokenOwnership {\n // The address of the owner.\n address addr;\n // Stores the start time of ownership with minimal overhead for tokenomics.\n uint64 startTimestamp;\n // Whether the token has been burned.\n bool burned;\n // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.\n uint24 extraData;\n }\n\n // =============================================================\n // TOKEN COUNTERS\n // =============================================================\n\n /**\n * @dev Returns the total number of tokens in existence.\n * Burned tokens will reduce the count.\n * To get the total number of tokens minted, please see {_totalMinted}.\n */\n function totalSupply() external view returns (uint256);\n\n // =============================================================\n // IERC165\n // =============================================================\n\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n\n // =============================================================\n // IERC721\n // =============================================================\n\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables\n * (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in `owner`'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`,\n * checking first that contract recipients are aware of the ERC721 protocol\n * to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move\n * this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom}\n * whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n // =============================================================\n // IERC721Metadata\n // =============================================================\n\n /**\n * @dev Returns the token collection name.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId) external view returns (string memory);\n\n // =============================================================\n // IERC2309\n // =============================================================\n\n /**\n * @dev Emitted when tokens in `fromTokenId` to `toTokenId`\n * (inclusive) is transferred from `from` to `to`, as defined in the\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.\n *\n * See {_mintERC2309} for more details.\n */\n event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);\n}\n"
},
"lib/openzeppelin-contracts/contracts/interfaces/IERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981 is IERC165 {\n /**\n * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n */\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n external\n view\n returns (address receiver, uint256 royaltyAmount);\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initialized`\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Internal function that returns the initialized version. Returns `_initializing`\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/security/ReentrancyGuardUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n function __ReentrancyGuard_init() internal onlyInitializing {\n __ReentrancyGuard_init_unchained();\n }\n\n function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
},
"lib/operator-filter-registry/src/IOperatorFilterRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IOperatorFilterRegistry {\n /**\n * @notice Returns true if operator is not filtered for a given token, either by address or codeHash. Also returns\n * true if supplied registrant address is not registered.\n */\n function isOperatorAllowed(address registrant, address operator) external view returns (bool);\n\n /**\n * @notice Registers an address with the registry. May be called by address itself or by EIP-173 owner.\n */\n function register(address registrant) external;\n\n /**\n * @notice Registers an address with the registry and \"subscribes\" to another address's filtered operators and codeHashes.\n */\n function registerAndSubscribe(address registrant, address subscription) external;\n\n /**\n * @notice Registers an address with the registry and copies the filtered operators and codeHashes from another\n * address without subscribing.\n */\n function registerAndCopyEntries(address registrant, address registrantToCopy) external;\n\n /**\n * @notice Unregisters an address with the registry and removes its subscription. May be called by address itself or by EIP-173 owner.\n * Note that this does not remove any filtered addresses or codeHashes.\n * Also note that any subscriptions to this registrant will still be active and follow the existing filtered addresses and codehashes.\n */\n function unregister(address addr) external;\n\n /**\n * @notice Update an operator address for a registered address - when filtered is true, the operator is filtered.\n */\n function updateOperator(address registrant, address operator, bool filtered) external;\n\n /**\n * @notice Update multiple operators for a registered address - when filtered is true, the operators will be filtered. Reverts on duplicates.\n */\n function updateOperators(address registrant, address[] calldata operators, bool filtered) external;\n\n /**\n * @notice Update a codeHash for a registered address - when filtered is true, the codeHash is filtered.\n */\n function updateCodeHash(address registrant, bytes32 codehash, bool filtered) external;\n\n /**\n * @notice Update multiple codeHashes for a registered address - when filtered is true, the codeHashes will be filtered. Reverts on duplicates.\n */\n function updateCodeHashes(address registrant, bytes32[] calldata codeHashes, bool filtered) external;\n\n /**\n * @notice Subscribe an address to another registrant's filtered operators and codeHashes. Will remove previous\n * subscription if present.\n * Note that accounts with subscriptions may go on to subscribe to other accounts - in this case,\n * subscriptions will not be forwarded. Instead the former subscription's existing entries will still be\n * used.\n */\n function subscribe(address registrant, address registrantToSubscribe) external;\n\n /**\n * @notice Unsubscribe an address from its current subscribed registrant, and optionally copy its filtered operators and codeHashes.\n */\n function unsubscribe(address registrant, bool copyExistingEntries) external;\n\n /**\n * @notice Get the subscription address of a given registrant, if any.\n */\n function subscriptionOf(address addr) external returns (address registrant);\n\n /**\n * @notice Get the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscribers(address registrant) external returns (address[] memory);\n\n /**\n * @notice Get the subscriber at a given index in the set of addresses subscribed to a given registrant.\n * Note that order is not guaranteed as updates are made.\n */\n function subscriberAt(address registrant, uint256 index) external returns (address);\n\n /**\n * @notice Copy filtered operators and codeHashes from a different registrantToCopy to addr.\n */\n function copyEntriesOf(address registrant, address registrantToCopy) external;\n\n /**\n * @notice Returns true if operator is filtered by a given address or its subscription.\n */\n function isOperatorFiltered(address registrant, address operator) external returns (bool);\n\n /**\n * @notice Returns true if the hash of an address's code is filtered by a given address or its subscription.\n */\n function isCodeHashOfFiltered(address registrant, address operatorWithCode) external returns (bool);\n\n /**\n * @notice Returns true if a codeHash is filtered by a given address or its subscription.\n */\n function isCodeHashFiltered(address registrant, bytes32 codeHash) external returns (bool);\n\n /**\n * @notice Returns a list of filtered operators for a given address or its subscription.\n */\n function filteredOperators(address addr) external returns (address[] memory);\n\n /**\n * @notice Returns the set of filtered codeHashes for a given address or its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashes(address addr) external returns (bytes32[] memory);\n\n /**\n * @notice Returns the filtered operator at the given index of the set of filtered operators for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredOperatorAt(address registrant, uint256 index) external returns (address);\n\n /**\n * @notice Returns the filtered codeHash at the given index of the list of filtered codeHashes for a given address or\n * its subscription.\n * Note that order is not guaranteed as updates are made.\n */\n function filteredCodeHashAt(address registrant, uint256 index) external returns (bytes32);\n\n /**\n * @notice Returns true if an address has registered\n */\n function isRegistered(address addr) external returns (bool);\n\n /**\n * @dev Convenience method to compute the code hash of an arbitrary contract\n */\n function codeHashOf(address addr) external returns (bytes32);\n}\n"
},
"lib/operator-filter-registry/src/lib/Constants.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.17;\n\naddress constant CANONICAL_OPERATOR_FILTER_REGISTRY_ADDRESS = 0x000000000000AAeB6D7670E522A718067333cd4E;\naddress constant CANONICAL_CORI_SUBSCRIPTION = 0x3cc6CddA760b79bAfa08dF41ECFA224f810dCeB6;\n"
},
"lib/operator-filter-registry/src/upgradeable/DefaultOperatorFiltererUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {OperatorFiltererUpgradeable} from \"./OperatorFiltererUpgradeable.sol\";\nimport {CANONICAL_CORI_SUBSCRIPTION} from \"../lib/Constants.sol\";\n\n/**\n * @title DefaultOperatorFiltererUpgradeable\n * @notice Inherits from OperatorFiltererUpgradeable and automatically subscribes to the default OpenSea subscription\n * when the init function is called.\n */\nabstract contract DefaultOperatorFiltererUpgradeable is OperatorFiltererUpgradeable {\n /// @dev The upgradeable initialize function that should be called when the contract is being deployed.\n function __DefaultOperatorFilterer_init() internal onlyInitializing {\n OperatorFiltererUpgradeable.__OperatorFilterer_init(CANONICAL_CORI_SUBSCRIPTION, true);\n }\n}\n"
},
"lib/operator-filter-registry/src/upgradeable/OperatorFiltererUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {IOperatorFilterRegistry} from \"../IOperatorFilterRegistry.sol\";\nimport {Initializable} from \"../../../../lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\n/**\n * @title OperatorFiltererUpgradeable\n * @notice Abstract contract whose constructor automatically registers and optionally subscribes to or copies another\n * registrant's entries in the OperatorFilterRegistry when the init function is called.\n * @dev This smart contract is meant to be inherited by token contracts so they can use the following:\n * - `onlyAllowedOperator` modifier for `transferFrom` and `safeTransferFrom` methods.\n * - `onlyAllowedOperatorApproval` modifier for `approve` and `setApprovalForAll` methods.\n */\nabstract contract OperatorFiltererUpgradeable is Initializable {\n /// @notice Emitted when an operator is not allowed.\n error OperatorNotAllowed(address operator);\n\n IOperatorFilterRegistry constant OPERATOR_FILTER_REGISTRY =\n IOperatorFilterRegistry(0x000000000000AAeB6D7670E522A718067333cd4E);\n\n /// @dev The upgradeable initialize function that should be called when the contract is being upgraded.\n function __OperatorFilterer_init(address subscriptionOrRegistrantToCopy, bool subscribe)\n internal\n onlyInitializing\n {\n // If an inheriting token contract is deployed to a network without the registry deployed, the modifier\n // will not revert, but the contract will need to be registered with the registry once it is deployed in\n // order for the modifier to filter addresses.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n if (!OPERATOR_FILTER_REGISTRY.isRegistered(address(this))) {\n if (subscribe) {\n OPERATOR_FILTER_REGISTRY.registerAndSubscribe(address(this), subscriptionOrRegistrantToCopy);\n } else {\n if (subscriptionOrRegistrantToCopy != address(0)) {\n OPERATOR_FILTER_REGISTRY.registerAndCopyEntries(address(this), subscriptionOrRegistrantToCopy);\n } else {\n OPERATOR_FILTER_REGISTRY.register(address(this));\n }\n }\n }\n }\n }\n\n /**\n * @dev A helper modifier to check if the operator is allowed.\n */\n modifier onlyAllowedOperator(address from) virtual {\n // Allow spending tokens from addresses with balance\n // Note that this still allows listings and marketplaces with escrow to transfer tokens if transferred\n // from an EOA.\n if (from != msg.sender) {\n _checkFilterOperator(msg.sender);\n }\n _;\n }\n\n /**\n * @dev A helper modifier to check if the operator approval is allowed.\n */\n modifier onlyAllowedOperatorApproval(address operator) virtual {\n _checkFilterOperator(operator);\n _;\n }\n\n /**\n * @dev A helper function to check if the operator is allowed.\n */\n function _checkFilterOperator(address operator) internal view virtual {\n // Check registry code length to facilitate testing in environments without a deployed registry.\n if (address(OPERATOR_FILTER_REGISTRY).code.length > 0) {\n // under normal circumstances, this function will revert rather than return false, but inheriting or\n // upgraded contracts may specify their own OperatorFilterRegistry implementations, which may behave\n // differently\n if (!OPERATOR_FILTER_REGISTRY.isOperatorAllowed(address(this), operator)) {\n revert OperatorNotAllowed(operator);\n }\n }\n }\n}\n"
},
"lib/utility-contracts/src/ConstructorInitializable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\n/**\n * @author emo.eth\n * @notice Abstract smart contract that provides an onlyUninitialized modifier which only allows calling when\n * from within a constructor of some sort, whether directly instantiating an inherting contract,\n * or when delegatecalling from a proxy\n */\nabstract contract ConstructorInitializable {\n error AlreadyInitialized();\n\n modifier onlyConstructor() {\n if (address(this).code.length != 0) {\n revert AlreadyInitialized();\n }\n _;\n }\n}\n"
},
"lib/utility-contracts/src/TwoStepOwnable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.4;\n\nimport {ConstructorInitializable} from \"./ConstructorInitializable.sol\";\n\n/**\n@notice A two-step extension of Ownable, where the new owner must claim ownership of the contract after owner initiates transfer\nOwner can cancel the transfer at any point before the new owner claims ownership.\nHelpful in guarding against transferring ownership to an address that is unable to act as the Owner.\n*/\nabstract contract TwoStepOwnable is ConstructorInitializable {\n address private _owner;\n\n event OwnershipTransferred(\n address indexed previousOwner,\n address indexed newOwner\n );\n\n address internal potentialOwner;\n\n event PotentialOwnerUpdated(address newPotentialAdministrator);\n\n error NewOwnerIsZeroAddress();\n error NotNextOwner();\n error OnlyOwner();\n\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n constructor() {\n _initialize();\n }\n\n function _initialize() private onlyConstructor {\n _transferOwnership(msg.sender);\n }\n\n ///@notice Initiate ownership transfer to newPotentialOwner. Note: new owner will have to manually acceptOwnership\n ///@param newPotentialOwner address of potential new owner\n function transferOwnership(address newPotentialOwner)\n public\n virtual\n onlyOwner\n {\n if (newPotentialOwner == address(0)) {\n revert NewOwnerIsZeroAddress();\n }\n potentialOwner = newPotentialOwner;\n emit PotentialOwnerUpdated(newPotentialOwner);\n }\n\n ///@notice Claim ownership of smart contract, after the current owner has initiated the process with transferOwnership\n function acceptOwnership() public virtual {\n address _potentialOwner = potentialOwner;\n if (msg.sender != _potentialOwner) {\n revert NotNextOwner();\n }\n delete potentialOwner;\n emit PotentialOwnerUpdated(address(0));\n _transferOwnership(_potentialOwner);\n }\n\n ///@notice cancel ownership transfer\n function cancelOwnershipTransfer() public virtual onlyOwner {\n delete potentialOwner;\n emit PotentialOwnerUpdated(address(0));\n }\n\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (_owner != msg.sender) {\n revert OnlyOwner();\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"src/clones/ERC721ACloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// ERC721A Contracts v4.2.2\n// Creator: Chiru Labs\n\npragma solidity ^0.8.4;\n\nimport { IERC721A } from \"ERC721A/IERC721A.sol\";\n\nimport {\n Initializable\n} from \"openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @dev Interface of ERC721 token receiver.\n */\ninterface ERC721A__IERC721Receiver {\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n\n/**\n * @title ERC721A\n *\n * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)\n * Non-Fungible Token Standard, including the Metadata extension.\n * Optimized for lower gas during batch mints.\n *\n * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)\n * starting from `_startTokenId()`.\n *\n * Assumptions:\n *\n * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.\n * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).\n */\ncontract ERC721ACloneable is IERC721A, Initializable {\n // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).\n struct TokenApprovalRef {\n address value;\n }\n\n // =============================================================\n // CONSTANTS\n // =============================================================\n\n // Mask of an entry in packed address data.\n uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;\n\n // The bit position of `numberMinted` in packed address data.\n uint256 private constant _BITPOS_NUMBER_MINTED = 64;\n\n // The bit position of `numberBurned` in packed address data.\n uint256 private constant _BITPOS_NUMBER_BURNED = 128;\n\n // The bit position of `aux` in packed address data.\n uint256 private constant _BITPOS_AUX = 192;\n\n // Mask of all 256 bits in packed address data except the 64 bits for `aux`.\n uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;\n\n // The bit position of `startTimestamp` in packed ownership.\n uint256 private constant _BITPOS_START_TIMESTAMP = 160;\n\n // The bit mask of the `burned` bit in packed ownership.\n uint256 private constant _BITMASK_BURNED = 1 << 224;\n\n // The bit position of the `nextInitialized` bit in packed ownership.\n uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;\n\n // The bit mask of the `nextInitialized` bit in packed ownership.\n uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;\n\n // The bit position of `extraData` in packed ownership.\n uint256 private constant _BITPOS_EXTRA_DATA = 232;\n\n // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.\n uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;\n\n // The mask of the lower 160 bits for addresses.\n uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;\n\n // The maximum `quantity` that can be minted with {_mintERC2309}.\n // This limit is to prevent overflows on the address data entries.\n // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}\n // is required to cause an overflow, which is unrealistic.\n uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;\n\n // The `Transfer` event signature is given by:\n // `keccak256(bytes(\"Transfer(address,address,uint256)\"))`.\n bytes32 private constant _TRANSFER_EVENT_SIGNATURE =\n 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;\n\n // =============================================================\n // STORAGE\n // =============================================================\n\n // The next token ID to be minted.\n uint256 private _currentIndex;\n\n // The number of tokens burned.\n uint256 private _burnCounter;\n\n // Token name\n string private _name;\n\n // Token symbol\n string private _symbol;\n\n // Mapping from token ID to ownership details\n // An empty struct value does not necessarily mean the token is unowned.\n // See {_packedOwnershipOf} implementation for details.\n //\n // Bits Layout:\n // - [0..159] `addr`\n // - [160..223] `startTimestamp`\n // - [224] `burned`\n // - [225] `nextInitialized`\n // - [232..255] `extraData`\n mapping(uint256 => uint256) private _packedOwnerships;\n\n // Mapping owner address to address data.\n //\n // Bits Layout:\n // - [0..63] `balance`\n // - [64..127] `numberMinted`\n // - [128..191] `numberBurned`\n // - [192..255] `aux`\n mapping(address => uint256) private _packedAddressData;\n\n // Mapping from token ID to approved address.\n mapping(uint256 => TokenApprovalRef) private _tokenApprovals;\n\n // Mapping from owner to operator approvals\n mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n // =============================================================\n // CONSTRUCTOR\n // =============================================================\n\n function __ERC721ACloneable__init(\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n _name = name_;\n _symbol = symbol_;\n _currentIndex = _startTokenId();\n }\n\n // =============================================================\n // TOKEN COUNTING OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the starting token ID.\n * To change the starting token ID, please override this function.\n */\n function _startTokenId() internal view virtual returns (uint256) {\n return 0;\n }\n\n /**\n * @dev Returns the next token ID to be minted.\n */\n function _nextTokenId() internal view virtual returns (uint256) {\n return _currentIndex;\n }\n\n /**\n * @dev Returns the total number of tokens in existence.\n * Burned tokens will reduce the count.\n * To get the total number of tokens minted, please see {_totalMinted}.\n */\n function totalSupply() public view virtual override returns (uint256) {\n // Counter underflow is impossible as _burnCounter cannot be incremented\n // more than `_currentIndex - _startTokenId()` times.\n unchecked {\n return _currentIndex - _burnCounter - _startTokenId();\n }\n }\n\n /**\n * @dev Returns the total amount of tokens minted in the contract.\n */\n function _totalMinted() internal view virtual returns (uint256) {\n // Counter underflow is impossible as `_currentIndex` does not decrement,\n // and it is initialized to `_startTokenId()`.\n unchecked {\n return _currentIndex - _startTokenId();\n }\n }\n\n /**\n * @dev Returns the total number of tokens burned.\n */\n function _totalBurned() internal view virtual returns (uint256) {\n return _burnCounter;\n }\n\n // =============================================================\n // ADDRESS DATA OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the number of tokens in `owner`'s account.\n */\n function balanceOf(address owner)\n public\n view\n virtual\n override\n returns (uint256)\n {\n if (owner == address(0)) revert BalanceQueryForZeroAddress();\n return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the number of tokens minted by `owner`.\n */\n function _numberMinted(address owner) internal view returns (uint256) {\n return\n (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) &\n _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the number of tokens burned by or on behalf of `owner`.\n */\n function _numberBurned(address owner) internal view returns (uint256) {\n return\n (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) &\n _BITMASK_ADDRESS_DATA_ENTRY;\n }\n\n /**\n * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\n */\n function _getAux(address owner) internal view returns (uint64) {\n return uint64(_packedAddressData[owner] >> _BITPOS_AUX);\n }\n\n /**\n * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).\n * If there are multiple variables, please pack them into a uint64.\n */\n function _setAux(address owner, uint64 aux) internal virtual {\n uint256 packed = _packedAddressData[owner];\n uint256 auxCasted;\n // Cast `aux` with assembly to avoid redundant masking.\n assembly {\n auxCasted := aux\n }\n packed =\n (packed & _BITMASK_AUX_COMPLEMENT) |\n (auxCasted << _BITPOS_AUX);\n _packedAddressData[owner] = packed;\n }\n\n // =============================================================\n // IERC165\n // =============================================================\n\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30000 gas.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override\n returns (bool)\n {\n // The interface IDs are constants representing the first 4 bytes\n // of the XOR of all function selectors in the interface.\n // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)\n // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)\n return\n interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.\n interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.\n interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.\n }\n\n // =============================================================\n // IERC721Metadata\n // =============================================================\n\n /**\n * @dev Returns the token collection name.\n */\n function name() public view virtual override returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the token collection symbol.\n */\n function symbol() public view virtual override returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n string memory baseURI = _baseURI();\n return\n bytes(baseURI).length != 0\n ? string(abi.encodePacked(baseURI, _toString(tokenId)))\n : \"\";\n }\n\n /**\n * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n * by default, it can be overridden in child contracts.\n */\n function _baseURI() internal view virtual returns (string memory) {\n return \"\";\n }\n\n // =============================================================\n // OWNERSHIPS OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n return address(uint160(_packedOwnershipOf(tokenId)));\n }\n\n /**\n * @dev Gas spent here starts off proportional to the maximum mint batch size.\n * It gradually moves to O(1) as tokens get transferred around over time.\n */\n function _ownershipOf(uint256 tokenId)\n internal\n view\n virtual\n returns (TokenOwnership memory)\n {\n return _unpackedOwnership(_packedOwnershipOf(tokenId));\n }\n\n /**\n * @dev Returns the unpacked `TokenOwnership` struct at `index`.\n */\n function _ownershipAt(uint256 index)\n internal\n view\n virtual\n returns (TokenOwnership memory)\n {\n return _unpackedOwnership(_packedOwnerships[index]);\n }\n\n /**\n * @dev Initializes the ownership slot minted at `index` for efficiency purposes.\n */\n function _initializeOwnershipAt(uint256 index) internal virtual {\n if (_packedOwnerships[index] == 0) {\n _packedOwnerships[index] = _packedOwnershipOf(index);\n }\n }\n\n /**\n * Returns the packed ownership data of `tokenId`.\n */\n function _packedOwnershipOf(uint256 tokenId)\n private\n view\n returns (uint256)\n {\n uint256 curr = tokenId;\n\n unchecked {\n if (_startTokenId() <= curr) {\n if (curr < _currentIndex) {\n uint256 packed = _packedOwnerships[curr];\n // If not burned.\n if (packed & _BITMASK_BURNED == 0) {\n // Invariant:\n // There will always be an initialized ownership slot\n // (i.e. `ownership.addr != address(0) && ownership.burned == false`)\n // before an unintialized ownership slot\n // (i.e. `ownership.addr == address(0) && ownership.burned == false`)\n // Hence, `curr` will not underflow.\n //\n // We can directly compare the packed value.\n // If the address is zero, packed will be zero.\n while (packed == 0) {\n packed = _packedOwnerships[--curr];\n }\n return packed;\n }\n }\n }\n }\n revert OwnerQueryForNonexistentToken();\n }\n\n /**\n * @dev Returns the unpacked `TokenOwnership` struct from `packed`.\n */\n function _unpackedOwnership(uint256 packed)\n private\n pure\n returns (TokenOwnership memory ownership)\n {\n ownership.addr = address(uint160(packed));\n ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);\n ownership.burned = packed & _BITMASK_BURNED != 0;\n ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);\n }\n\n /**\n * @dev Packs ownership data into a single uint256.\n */\n function _packOwnershipData(address owner, uint256 flags)\n private\n view\n returns (uint256 result)\n {\n assembly {\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.\n owner := and(owner, _BITMASK_ADDRESS)\n // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.\n result := or(\n owner,\n or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags)\n )\n }\n }\n\n /**\n * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.\n */\n function _nextInitializedFlag(uint256 quantity)\n private\n pure\n returns (uint256 result)\n {\n // For branchless setting of the `nextInitialized` flag.\n assembly {\n // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.\n result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))\n }\n }\n\n // =============================================================\n // APPROVAL OPERATIONS\n // =============================================================\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) public virtual override {\n address owner = ownerOf(tokenId);\n\n if (_msgSenderERC721A() != owner) {\n if (!isApprovedForAll(owner, _msgSenderERC721A())) {\n revert ApprovalCallerNotOwnerNorApproved();\n }\n }\n\n _tokenApprovals[tokenId].value = to;\n emit Approval(owner, to, tokenId);\n }\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId)\n public\n view\n virtual\n override\n returns (address)\n {\n if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();\n\n return _tokenApprovals[tokenId].value;\n }\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved)\n public\n virtual\n override\n {\n _operatorApprovals[_msgSenderERC721A()][operator] = approved;\n emit ApprovalForAll(_msgSenderERC721A(), operator, approved);\n }\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n override\n returns (bool)\n {\n return _operatorApprovals[owner][operator];\n }\n\n /**\n * @dev Returns whether `tokenId` exists.\n *\n * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n *\n * Tokens start existing when they are minted. See {_mint}.\n */\n function _exists(uint256 tokenId) internal view virtual returns (bool) {\n return\n _startTokenId() <= tokenId &&\n tokenId < _currentIndex && // If within bounds,\n _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.\n }\n\n /**\n * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.\n */\n function _isSenderApprovedOrOwner(\n address approvedAddress,\n address owner,\n address msgSender\n ) private pure returns (bool result) {\n assembly {\n // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.\n owner := and(owner, _BITMASK_ADDRESS)\n // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.\n msgSender := and(msgSender, _BITMASK_ADDRESS)\n // `msgSender == owner || msgSender == approvedAddress`.\n result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))\n }\n }\n\n /**\n * @dev Returns the storage slot and value for the approved address of `tokenId`.\n */\n function _getApprovedSlotAndAddress(uint256 tokenId)\n private\n view\n returns (uint256 approvedAddressSlot, address approvedAddress)\n {\n TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];\n // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.\n assembly {\n approvedAddressSlot := tokenApproval.slot\n approvedAddress := sload(approvedAddressSlot)\n }\n }\n\n // =============================================================\n // TRANSFER OPERATIONS\n // =============================================================\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\n\n if (address(uint160(prevOwnershipPacked)) != from)\n revert TransferFromIncorrectOwner();\n\n (\n uint256 approvedAddressSlot,\n address approvedAddress\n ) = _getApprovedSlotAndAddress(tokenId);\n\n // The nested ifs save around 20+ gas over a compound boolean condition.\n if (\n !_isSenderApprovedOrOwner(\n approvedAddress,\n from,\n _msgSenderERC721A()\n )\n ) {\n if (!isApprovedForAll(from, _msgSenderERC721A()))\n revert TransferCallerNotOwnerNorApproved();\n }\n\n if (to == address(0)) revert TransferToZeroAddress();\n\n _beforeTokenTransfers(from, to, tokenId, 1);\n\n // Clear approvals from the previous owner.\n assembly {\n if approvedAddress {\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\n sstore(approvedAddressSlot, 0)\n }\n }\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\n unchecked {\n // We can directly increment and decrement the balances.\n --_packedAddressData[from]; // Updates: `balance -= 1`.\n ++_packedAddressData[to]; // Updates: `balance += 1`.\n\n // Updates:\n // - `address` to the next owner.\n // - `startTimestamp` to the timestamp of transfering.\n // - `burned` to `false`.\n // - `nextInitialized` to `true`.\n _packedOwnerships[tokenId] = _packOwnershipData(\n to,\n _BITMASK_NEXT_INITIALIZED |\n _nextExtraData(from, to, prevOwnershipPacked)\n );\n\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\n if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {\n uint256 nextTokenId = tokenId + 1;\n // If the next slot's address is zero and not burned (i.e. packed value is zero).\n if (_packedOwnerships[nextTokenId] == 0) {\n // If the next slot is within bounds.\n if (nextTokenId != _currentIndex) {\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\n }\n }\n }\n }\n\n emit Transfer(from, to, tokenId);\n _afterTokenTransfers(from, to, tokenId, 1);\n }\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public virtual override {\n safeTransferFrom(from, to, tokenId, \"\");\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) public virtual override {\n transferFrom(from, to, tokenId);\n if (to.code.length != 0) {\n if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n }\n }\n\n /**\n * @dev Hook that is called before a set of serially-ordered token IDs\n * are about to be transferred. This includes minting.\n * And also called before burning one token.\n *\n * `startTokenId` - the first token ID to be transferred.\n * `quantity` - the amount to be transferred.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _beforeTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Hook that is called after a set of serially-ordered token IDs\n * have been transferred. This includes minting.\n * And also called after one token has been burned.\n *\n * `startTokenId` - the first token ID to be transferred.\n * `quantity` - the amount to be transferred.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been\n * transferred to `to`.\n * - When `from` is zero, `tokenId` has been minted for `to`.\n * - When `to` is zero, `tokenId` has been burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _afterTokenTransfers(\n address from,\n address to,\n uint256 startTokenId,\n uint256 quantity\n ) internal virtual {}\n\n /**\n * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.\n *\n * `from` - Previous owner of the given token ID.\n * `to` - Target address that will receive the token.\n * `tokenId` - Token ID to be transferred.\n * `_data` - Optional data to send along with the call.\n *\n * Returns whether the call correctly returned the expected magic value.\n */\n function _checkContractOnERC721Received(\n address from,\n address to,\n uint256 tokenId,\n bytes memory _data\n ) private returns (bool) {\n try\n ERC721A__IERC721Receiver(to).onERC721Received(\n _msgSenderERC721A(),\n from,\n tokenId,\n _data\n )\n returns (bytes4 retval) {\n return\n retval ==\n ERC721A__IERC721Receiver(to).onERC721Received.selector;\n } catch (bytes memory reason) {\n if (reason.length == 0) {\n revert TransferToNonERC721ReceiverImplementer();\n } else {\n assembly {\n revert(add(32, reason), mload(reason))\n }\n }\n }\n }\n\n // =============================================================\n // MINT OPERATIONS\n // =============================================================\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {Transfer} event for each mint.\n */\n function _mint(address to, uint256 quantity) internal virtual {\n uint256 startTokenId = _currentIndex;\n if (quantity == 0) revert MintZeroQuantity();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are incredibly unrealistic.\n // `balance` and `numberMinted` have a maximum limit of 2**64.\n // `tokenId` has a maximum limit of 2**256.\n unchecked {\n // Updates:\n // - `balance += quantity`.\n // - `numberMinted += quantity`.\n //\n // We can directly add to the `balance` and `numberMinted`.\n _packedAddressData[to] +=\n quantity *\n ((1 << _BITPOS_NUMBER_MINTED) | 1);\n\n // Updates:\n // - `address` to the owner.\n // - `startTimestamp` to the timestamp of minting.\n // - `burned` to `false`.\n // - `nextInitialized` to `quantity == 1`.\n _packedOwnerships[startTokenId] = _packOwnershipData(\n to,\n _nextInitializedFlag(quantity) |\n _nextExtraData(address(0), to, 0)\n );\n\n uint256 toMasked;\n uint256 end = startTokenId + quantity;\n\n // Use assembly to loop and emit the `Transfer` event for gas savings.\n // The duplicated `log4` removes an extra check and reduces stack juggling.\n // The assembly, together with the surrounding Solidity code, have been\n // delicately arranged to nudge the compiler into producing optimized opcodes.\n assembly {\n // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.\n toMasked := and(to, _BITMASK_ADDRESS)\n // Emit the `Transfer` event.\n log4(\n 0, // Start of data (0, since no data).\n 0, // End of data (0, since no data).\n _TRANSFER_EVENT_SIGNATURE, // Signature.\n 0, // `address(0)`.\n toMasked, // `to`.\n startTokenId // `tokenId`.\n )\n\n // The `iszero(eq(,))` check ensures that large values of `quantity`\n // that overflows uint256 will make the loop run out of gas.\n // The compiler will optimize the `iszero` away for performance.\n for {\n let tokenId := add(startTokenId, 1)\n } iszero(eq(tokenId, end)) {\n tokenId := add(tokenId, 1)\n } {\n // Emit the `Transfer` event. Similar to above.\n log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)\n }\n }\n if (toMasked == 0) revert MintToZeroAddress();\n\n _currentIndex = end;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Mints `quantity` tokens and transfers them to `to`.\n *\n * This function is intended for efficient minting only during contract creation.\n *\n * It emits only one {ConsecutiveTransfer} as defined in\n * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),\n * instead of a sequence of {Transfer} event(s).\n *\n * Calling this function outside of contract creation WILL make your contract\n * non-compliant with the ERC721 standard.\n * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309\n * {ConsecutiveTransfer} event is only permissible during contract creation.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - `quantity` must be greater than 0.\n *\n * Emits a {ConsecutiveTransfer} event.\n */\n function _mintERC2309(address to, uint256 quantity) internal virtual {\n uint256 startTokenId = _currentIndex;\n if (to == address(0)) revert MintToZeroAddress();\n if (quantity == 0) revert MintZeroQuantity();\n if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT)\n revert MintERC2309QuantityExceedsLimit();\n\n _beforeTokenTransfers(address(0), to, startTokenId, quantity);\n\n // Overflows are unrealistic due to the above check for `quantity` to be below the limit.\n unchecked {\n // Updates:\n // - `balance += quantity`.\n // - `numberMinted += quantity`.\n //\n // We can directly add to the `balance` and `numberMinted`.\n _packedAddressData[to] +=\n quantity *\n ((1 << _BITPOS_NUMBER_MINTED) | 1);\n\n // Updates:\n // - `address` to the owner.\n // - `startTimestamp` to the timestamp of minting.\n // - `burned` to `false`.\n // - `nextInitialized` to `quantity == 1`.\n _packedOwnerships[startTokenId] = _packOwnershipData(\n to,\n _nextInitializedFlag(quantity) |\n _nextExtraData(address(0), to, 0)\n );\n\n emit ConsecutiveTransfer(\n startTokenId,\n startTokenId + quantity - 1,\n address(0),\n to\n );\n\n _currentIndex = startTokenId + quantity;\n }\n _afterTokenTransfers(address(0), to, startTokenId, quantity);\n }\n\n /**\n * @dev Safely mints `quantity` tokens and transfers them to `to`.\n *\n * Requirements:\n *\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.\n * - `quantity` must be greater than 0.\n *\n * See {_mint}.\n *\n * Emits a {Transfer} event for each mint.\n */\n function _safeMint(\n address to,\n uint256 quantity,\n bytes memory _data\n ) internal virtual {\n _mint(to, quantity);\n\n unchecked {\n if (to.code.length != 0) {\n uint256 end = _currentIndex;\n uint256 index = end - quantity;\n do {\n if (\n !_checkContractOnERC721Received(\n address(0),\n to,\n index++,\n _data\n )\n ) {\n revert TransferToNonERC721ReceiverImplementer();\n }\n } while (index < end);\n // Reentrancy protection.\n if (_currentIndex != end) revert();\n }\n }\n }\n\n /**\n * @dev Equivalent to `_safeMint(to, quantity, '')`.\n */\n function _safeMint(address to, uint256 quantity) internal virtual {\n _safeMint(to, quantity, \"\");\n }\n\n // =============================================================\n // BURN OPERATIONS\n // =============================================================\n\n /**\n * @dev Equivalent to `_burn(tokenId, false)`.\n */\n function _burn(uint256 tokenId) internal virtual {\n _burn(tokenId, false);\n }\n\n /**\n * @dev Destroys `tokenId`.\n * The approval is cleared when the token is burned.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n *\n * Emits a {Transfer} event.\n */\n function _burn(uint256 tokenId, bool approvalCheck) internal virtual {\n uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);\n\n address from = address(uint160(prevOwnershipPacked));\n\n (\n uint256 approvedAddressSlot,\n address approvedAddress\n ) = _getApprovedSlotAndAddress(tokenId);\n\n if (approvalCheck) {\n // The nested ifs save around 20+ gas over a compound boolean condition.\n if (\n !_isSenderApprovedOrOwner(\n approvedAddress,\n from,\n _msgSenderERC721A()\n )\n ) {\n if (!isApprovedForAll(from, _msgSenderERC721A()))\n revert TransferCallerNotOwnerNorApproved();\n }\n }\n\n _beforeTokenTransfers(from, address(0), tokenId, 1);\n\n // Clear approvals from the previous owner.\n assembly {\n if approvedAddress {\n // This is equivalent to `delete _tokenApprovals[tokenId]`.\n sstore(approvedAddressSlot, 0)\n }\n }\n\n // Underflow of the sender's balance is impossible because we check for\n // ownership above and the recipient's balance can't realistically overflow.\n // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.\n unchecked {\n // Updates:\n // - `balance -= 1`.\n // - `numberBurned += 1`.\n //\n // We can directly decrement the balance, and increment the number burned.\n // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.\n _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;\n\n // Updates:\n // - `address` to the last owner.\n // - `startTimestamp` to the timestamp of burning.\n // - `burned` to `true`.\n // - `nextInitialized` to `true`.\n _packedOwnerships[tokenId] = _packOwnershipData(\n from,\n (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) |\n _nextExtraData(from, address(0), prevOwnershipPacked)\n );\n\n // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .\n if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {\n uint256 nextTokenId = tokenId + 1;\n // If the next slot's address is zero and not burned (i.e. packed value is zero).\n if (_packedOwnerships[nextTokenId] == 0) {\n // If the next slot is within bounds.\n if (nextTokenId != _currentIndex) {\n // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.\n _packedOwnerships[nextTokenId] = prevOwnershipPacked;\n }\n }\n }\n }\n\n emit Transfer(from, address(0), tokenId);\n _afterTokenTransfers(from, address(0), tokenId, 1);\n\n // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.\n unchecked {\n _burnCounter++;\n }\n }\n\n // =============================================================\n // EXTRA DATA OPERATIONS\n // =============================================================\n\n /**\n * @dev Directly sets the extra data for the ownership data `index`.\n */\n function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {\n uint256 packed = _packedOwnerships[index];\n if (packed == 0) revert OwnershipNotInitializedForExtraData();\n uint256 extraDataCasted;\n // Cast `extraData` with assembly to avoid redundant masking.\n assembly {\n extraDataCasted := extraData\n }\n packed =\n (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) |\n (extraDataCasted << _BITPOS_EXTRA_DATA);\n _packedOwnerships[index] = packed;\n }\n\n /**\n * @dev Called during each token transfer to set the 24bit `extraData` field.\n * Intended to be overridden by the cosumer contract.\n *\n * `previousExtraData` - the value of `extraData` before transfer.\n *\n * Calling conditions:\n *\n * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be\n * transferred to `to`.\n * - When `from` is zero, `tokenId` will be minted for `to`.\n * - When `to` is zero, `tokenId` will be burned by `from`.\n * - `from` and `to` are never both zero.\n */\n function _extraData(\n address from,\n address to,\n uint24 previousExtraData\n ) internal view virtual returns (uint24) {}\n\n /**\n * @dev Returns the next extra data for the packed ownership data.\n * The returned result is shifted into position.\n */\n function _nextExtraData(\n address from,\n address to,\n uint256 prevOwnershipPacked\n ) private view returns (uint256) {\n uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);\n return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;\n }\n\n // =============================================================\n // OTHER OPERATIONS\n // =============================================================\n\n /**\n * @dev Returns the message sender (defaults to `msg.sender`).\n *\n * If you are writing GSN compatible contracts, you need to override this function.\n */\n function _msgSenderERC721A() internal view virtual returns (address) {\n return msg.sender;\n }\n\n /**\n * @dev Converts a uint256 to its ASCII string decimal representation.\n */\n function _toString(uint256 value)\n internal\n pure\n virtual\n returns (string memory str)\n {\n assembly {\n // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\n // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\n // We will need 1 word for the trailing zeros padding, 1 word for the length,\n // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.\n let m := add(mload(0x40), 0xa0)\n // Update the free memory pointer to allocate.\n mstore(0x40, m)\n // Assign the `str` to the end.\n str := sub(m, 0x20)\n // Zeroize the slot after the string.\n mstore(str, 0)\n\n // Cache the end of the memory to calculate the length later.\n let end := str\n\n // We write the string from rightmost digit to leftmost digit.\n // The following is essentially a do-while loop that also handles the zero case.\n // prettier-ignore\n for { let temp := value } 1 {} {\n str := sub(str, 1)\n // Write the character to the pointer.\n // The ASCII index of the '0' character is 48.\n mstore8(str, add(48, mod(temp, 10)))\n // Keep dividing `temp` until zero.\n temp := div(temp, 10)\n // prettier-ignore\n if iszero(temp) { break }\n }\n\n let length := sub(end, str)\n // Move the pointer 32 bytes leftwards to make room for the length.\n str := sub(str, 0x20)\n // Store the length.\n mstore(str, length)\n }\n }\n}\n"
},
"src/clones/ERC721ContractMetadataCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"../interfaces/ISeaDropTokenContractMetadata.sol\";\n\nimport { ERC721ACloneable } from \"./ERC721ACloneable.sol\";\n\nimport { TwoStepOwnable } from \"utility-contracts/TwoStepOwnable.sol\";\n\nimport { IERC2981 } from \"openzeppelin-contracts/interfaces/IERC2981.sol\";\n\nimport {\n IERC165\n} from \"openzeppelin-contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title ERC721ContractMetadataCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @notice ERC721ContractMetadata is a token contract that extends ERC721A\n * with additional metadata and ownership capabilities.\n */\ncontract ERC721ContractMetadataCloneable is\n ERC721ACloneable,\n TwoStepOwnable,\n ISeaDropTokenContractMetadata\n{\n /// @notice Track the max supply.\n uint256 _maxSupply;\n\n /// @notice Track the base URI for token metadata.\n string _tokenBaseURI;\n\n /// @notice Track the contract URI for contract metadata.\n string _contractURI;\n\n /// @notice Track the provenance hash for guaranteeing metadata order\n /// for random reveals.\n bytes32 _provenanceHash;\n\n /// @notice Track the royalty info: address to receive royalties, and\n /// royalty basis points.\n RoyaltyInfo _royaltyInfo;\n\n /**\n * @dev Reverts if the sender is not the owner or the contract itself.\n * This function is inlined instead of being a modifier\n * to save contract space from being inlined N times.\n */\n function _onlyOwnerOrSelf() internal view {\n if (\n _cast(msg.sender == owner()) | _cast(msg.sender == address(this)) ==\n 0\n ) {\n revert OnlyOwner();\n }\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param newBaseURI The new base URI to set.\n */\n function setBaseURI(string calldata newBaseURI) external override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Set the new base URI.\n _tokenBaseURI = newBaseURI;\n\n // Emit an event with the update.\n if (totalSupply() != 0) {\n emit BatchMetadataUpdate(1, _nextTokenId() - 1);\n }\n }\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Set the new contract URI.\n _contractURI = newContractURI;\n\n // Emit an event with the update.\n emit ContractURIUpdated(newContractURI);\n }\n\n /**\n * @notice Emit an event notifying metadata updates for\n * a range of token ids, according to EIP-4906.\n *\n * @param fromTokenId The start token id.\n * @param toTokenId The end token id.\n */\n function emitBatchMetadataUpdate(uint256 fromTokenId, uint256 toTokenId)\n external\n {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Emit an event with the update.\n emit BatchMetadataUpdate(fromTokenId, toTokenId);\n }\n\n /**\n * @notice Sets the max token supply and emits an event.\n *\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 newMaxSupply) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the max supply does not exceed the maximum value of uint64.\n if (newMaxSupply > 2**64 - 1) {\n revert CannotExceedMaxSupplyOfUint64(newMaxSupply);\n }\n\n // Set the new max supply.\n _maxSupply = newMaxSupply;\n\n // Emit an event with the update.\n emit MaxSupplyUpdated(newMaxSupply);\n }\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Revert if any items have been minted.\n if (_totalMinted() > 0) {\n revert ProvenanceHashCannotBeSetAfterMintStarted();\n }\n\n // Keep track of the old provenance hash for emitting with the event.\n bytes32 oldProvenanceHash = _provenanceHash;\n\n // Set the new provenance hash.\n _provenanceHash = newProvenanceHash;\n\n // Emit an event with the update.\n emit ProvenanceHashUpdated(oldProvenanceHash, newProvenanceHash);\n }\n\n /**\n * @notice Sets the address and basis points for royalties.\n *\n * @param newInfo The struct to configure royalties.\n */\n function setRoyaltyInfo(RoyaltyInfo calldata newInfo) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Revert if the new royalty address is the zero address.\n if (newInfo.royaltyAddress == address(0)) {\n revert RoyaltyAddressCannotBeZeroAddress();\n }\n\n // Revert if the new basis points is greater than 10_000.\n if (newInfo.royaltyBps > 10_000) {\n revert InvalidRoyaltyBasisPoints(newInfo.royaltyBps);\n }\n\n // Set the new royalty info.\n _royaltyInfo = newInfo;\n\n // Emit an event with the updated params.\n emit RoyaltyInfoUpdated(newInfo.royaltyAddress, newInfo.royaltyBps);\n }\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view override returns (string memory) {\n return _baseURI();\n }\n\n /**\n * @notice Returns the base URI for the contract, which ERC721A uses\n * to return tokenURI.\n */\n function _baseURI() internal view virtual override returns (string memory) {\n return _tokenBaseURI;\n }\n\n /**\n * @notice Returns the contract URI for contract metadata.\n */\n function contractURI() external view override returns (string memory) {\n return _contractURI;\n }\n\n /**\n * @notice Returns the max token supply.\n */\n function maxSupply() public view returns (uint256) {\n return _maxSupply;\n }\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view override returns (bytes32) {\n return _provenanceHash;\n }\n\n /**\n * @notice Returns the address that receives royalties.\n */\n function royaltyAddress() external view returns (address) {\n return _royaltyInfo.royaltyAddress;\n }\n\n /**\n * @notice Returns the royalty basis points out of 10_000.\n */\n function royaltyBasisPoints() external view returns (uint256) {\n return _royaltyInfo.royaltyBps;\n }\n\n /**\n * @notice Called with the sale price to determine how much royalty\n * is owed and to whom.\n *\n * @ param _tokenId The NFT asset queried for royalty information.\n * @param _salePrice The sale price of the NFT asset specified by\n * _tokenId.\n *\n * @return receiver Address of who should be sent the royalty payment.\n * @return royaltyAmount The royalty payment amount for _salePrice.\n */\n function royaltyInfo(\n uint256,\n /* _tokenId */\n uint256 _salePrice\n ) external view returns (address receiver, uint256 royaltyAmount) {\n // Put the royalty info on the stack for more efficient access.\n RoyaltyInfo storage info = _royaltyInfo;\n\n // Set the royalty amount to the sale price times the royalty basis\n // points divided by 10_000.\n royaltyAmount = (_salePrice * info.royaltyBps) / 10_000;\n\n // Set the receiver of the royalty.\n receiver = info.royaltyAddress;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, ERC721ACloneable)\n returns (bool)\n {\n return\n interfaceId == type(IERC2981).interfaceId ||\n interfaceId == 0x49064906 || // ERC-4906\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Internal pure function to cast a `bool` value to a `uint256` value.\n *\n * @param b The `bool` value to cast.\n *\n * @return u The `uint256` value.\n */\n function _cast(bool b) internal pure returns (uint256 u) {\n assembly {\n u := b\n }\n }\n}\n"
},
"src/clones/ERC721SeaDropCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ERC721ContractMetadataCloneable,\n ISeaDropTokenContractMetadata\n} from \"./ERC721ContractMetadataCloneable.sol\";\n\nimport {\n INonFungibleSeaDropToken\n} from \"../interfaces/INonFungibleSeaDropToken.sol\";\n\nimport { ISeaDrop } from \"../interfaces/ISeaDrop.sol\";\n\nimport {\n AllowListData,\n PublicDrop,\n TokenGatedDropStage,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\nimport {\n ERC721SeaDropStructsErrorsAndEvents\n} from \"../lib/ERC721SeaDropStructsErrorsAndEvents.sol\";\n\nimport { ERC721ACloneable } from \"./ERC721ACloneable.sol\";\n\nimport {\n ReentrancyGuardUpgradeable\n} from \"openzeppelin-contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\n\nimport {\n IERC165\n} from \"openzeppelin-contracts/utils/introspection/IERC165.sol\";\n\nimport {\n DefaultOperatorFiltererUpgradeable\n} from \"operator-filter-registry/upgradeable/DefaultOperatorFiltererUpgradeable.sol\";\n\n/**\n * @title ERC721SeaDrop\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @notice ERC721SeaDrop is a token contract that contains methods\n * to properly interact with SeaDrop.\n */\ncontract ERC721SeaDropCloneable is\n ERC721ContractMetadataCloneable,\n INonFungibleSeaDropToken,\n ERC721SeaDropStructsErrorsAndEvents,\n ReentrancyGuardUpgradeable,\n DefaultOperatorFiltererUpgradeable\n{\n /// @notice Track the allowed SeaDrop addresses.\n mapping(address => bool) internal _allowedSeaDrop;\n\n /// @notice Track the enumerated allowed SeaDrop addresses.\n address[] internal _enumeratedAllowedSeaDrop;\n\n /**\n * @dev Reverts if not an allowed SeaDrop contract.\n * This function is inlined instead of being a modifier\n * to save contract space from being inlined N times.\n *\n * @param seaDrop The SeaDrop address to check if allowed.\n */\n function _onlyAllowedSeaDrop(address seaDrop) internal view {\n if (_allowedSeaDrop[seaDrop] != true) {\n revert OnlyAllowedSeaDrop();\n }\n }\n\n /**\n * @notice Deploy the token contract with its name, symbol,\n * and allowed SeaDrop addresses.\n */\n function initialize(\n string calldata __name,\n string calldata __symbol,\n address[] calldata allowedSeaDrop,\n address initialOwner\n ) public initializer {\n __ERC721ACloneable__init(__name, __symbol);\n __ReentrancyGuard_init();\n __DefaultOperatorFilterer_init();\n _updateAllowedSeaDrop(allowedSeaDrop);\n _transferOwnership(initialOwner);\n emit SeaDropTokenDeployed();\n }\n\n /**\n * @notice Update the allowed SeaDrop contracts.\n * Only the owner or administrator can use this function.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function updateAllowedSeaDrop(address[] calldata allowedSeaDrop)\n external\n virtual\n override\n onlyOwner\n {\n _updateAllowedSeaDrop(allowedSeaDrop);\n }\n\n /**\n * @notice Internal function to update the allowed SeaDrop contracts.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function _updateAllowedSeaDrop(address[] calldata allowedSeaDrop) internal {\n // Put the length on the stack for more efficient access.\n uint256 enumeratedAllowedSeaDropLength = _enumeratedAllowedSeaDrop\n .length;\n uint256 allowedSeaDropLength = allowedSeaDrop.length;\n\n // Reset the old mapping.\n for (uint256 i = 0; i < enumeratedAllowedSeaDropLength; ) {\n _allowedSeaDrop[_enumeratedAllowedSeaDrop[i]] = false;\n unchecked {\n ++i;\n }\n }\n\n // Set the new mapping for allowed SeaDrop contracts.\n for (uint256 i = 0; i < allowedSeaDropLength; ) {\n _allowedSeaDrop[allowedSeaDrop[i]] = true;\n unchecked {\n ++i;\n }\n }\n\n // Set the enumeration.\n _enumeratedAllowedSeaDrop = allowedSeaDrop;\n\n // Emit an event for the update.\n emit AllowedSeaDropUpdated(allowedSeaDrop);\n }\n\n /**\n * @dev Overrides the `_startTokenId` function from ERC721A\n * to start at token id `1`.\n *\n * This is to avoid future possible problems since `0` is usually\n * used to signal values that have not been set or have been removed.\n */\n function _startTokenId() internal view virtual override returns (uint256) {\n return 1;\n }\n\n /**\n * @dev Overrides the `tokenURI()` function from ERC721A\n * to return just the base URI if it is implied to not be a directory.\n *\n * This is to help with ERC721 contracts in which the same token URI\n * is desired for each token, such as when the tokenURI is 'unrevealed'.\n */\n function tokenURI(uint256 tokenId)\n public\n view\n virtual\n override\n returns (string memory)\n {\n if (!_exists(tokenId)) revert URIQueryForNonexistentToken();\n\n string memory baseURI = _baseURI();\n\n // Exit early if the baseURI is empty.\n if (bytes(baseURI).length == 0) {\n return \"\";\n }\n\n // Check if the last character in baseURI is a slash.\n if (bytes(baseURI)[bytes(baseURI).length - 1] != bytes(\"/\")[0]) {\n return baseURI;\n }\n\n return string(abi.encodePacked(baseURI, _toString(tokenId)));\n }\n\n /**\n * @notice Mint tokens, restricted to the SeaDrop contract.\n *\n * @dev NOTE: If a token registers itself with multiple SeaDrop\n * contracts, the implementation of this function should guard\n * against reentrancy. If the implementing token uses\n * _safeMint(), or a feeRecipient with a malicious receive() hook\n * is specified, the token or fee recipients may be able to execute\n * another mint in the same transaction via a separate SeaDrop\n * contract.\n * This is dangerous if an implementing token does not correctly\n * update the minterNumMinted and currentTotalSupply values before\n * transferring minted tokens, as SeaDrop references these values\n * to enforce token limits on a per-wallet and per-stage basis.\n *\n * ERC721A tracks these values automatically, but this note and\n * nonReentrant modifier are left here to encourage best-practices\n * when referencing this contract.\n *\n * @param minter The address to mint to.\n * @param quantity The number of tokens to mint.\n */\n function mintSeaDrop(address minter, uint256 quantity)\n external\n virtual\n override\n nonReentrant\n {\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(msg.sender);\n\n // Extra safety check to ensure the max supply is not exceeded.\n if (_totalMinted() + quantity > maxSupply()) {\n revert MintQuantityExceedsMaxSupply(\n _totalMinted() + quantity,\n maxSupply()\n );\n }\n\n // Mint the quantity of tokens to the minter.\n _safeMint(minter, quantity);\n }\n\n /**\n * @notice Update the public drop data for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(\n address seaDropImpl,\n PublicDrop calldata publicDrop\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the public drop data on SeaDrop.\n ISeaDrop(seaDropImpl).updatePublicDrop(publicDrop);\n }\n\n /**\n * @notice Update the allow list data for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowListData The allow list data.\n */\n function updateAllowList(\n address seaDropImpl,\n AllowListData calldata allowListData\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the allow list on SeaDrop.\n ISeaDrop(seaDropImpl).updateAllowList(allowListData);\n }\n\n /**\n * @notice Update the token gated drop stage data for this nft contract\n * on SeaDrop.\n * Only the owner can use this function.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during the\n * `dropStage` time period.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowedNftToken The allowed nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address seaDropImpl,\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the token gated drop stage.\n ISeaDrop(seaDropImpl).updateTokenGatedDrop(allowedNftToken, dropStage);\n }\n\n /**\n * @notice Update the drop URI for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param dropURI The new drop URI.\n */\n function updateDropURI(address seaDropImpl, string calldata dropURI)\n external\n virtual\n override\n {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the drop URI.\n ISeaDrop(seaDropImpl).updateDropURI(dropURI);\n }\n\n /**\n * @notice Update the creator payout address for this nft contract on\n * SeaDrop.\n * Only the owner can set the creator payout address.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payoutAddress The new payout address.\n */\n function updateCreatorPayoutAddress(\n address seaDropImpl,\n address payoutAddress\n ) external {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the creator payout address.\n ISeaDrop(seaDropImpl).updateCreatorPayoutAddress(payoutAddress);\n }\n\n /**\n * @notice Update the allowed fee recipient for this nft contract\n * on SeaDrop.\n * Only the owner can set the allowed fee recipient.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param feeRecipient The new fee recipient.\n * @param allowed If the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(\n address seaDropImpl,\n address feeRecipient,\n bool allowed\n ) external virtual {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the allowed fee recipient.\n ISeaDrop(seaDropImpl).updateAllowedFeeRecipient(feeRecipient, allowed);\n }\n\n /**\n * @notice Update the server-side signers for this nft contract\n * on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters to\n * enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address seaDropImpl,\n address signer,\n SignedMintValidationParams memory signedMintValidationParams\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the signer.\n ISeaDrop(seaDropImpl).updateSignedMintValidationParams(\n signer,\n signedMintValidationParams\n );\n }\n\n /**\n * @notice Update the allowed payers for this nft contract on SeaDrop.\n * Only the owner can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(\n address seaDropImpl,\n address payer,\n bool allowed\n ) external virtual override {\n // Ensure the sender is only the owner or contract itself.\n _onlyOwnerOrSelf();\n\n // Ensure the SeaDrop is allowed.\n _onlyAllowedSeaDrop(seaDropImpl);\n\n // Update the payer.\n ISeaDrop(seaDropImpl).updatePayer(payer, allowed);\n }\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC721Received() hooks.\n *\n * @param minter The minter address.\n */\n function getMintStats(address minter)\n external\n view\n override\n returns (\n uint256 minterNumMinted,\n uint256 currentTotalSupply,\n uint256 maxSupply\n )\n {\n minterNumMinted = _numberMinted(minter);\n currentTotalSupply = _totalMinted();\n maxSupply = _maxSupply;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(bytes4 interfaceId)\n public\n view\n virtual\n override(IERC165, ERC721ContractMetadataCloneable)\n returns (bool)\n {\n return\n interfaceId == type(INonFungibleSeaDropToken).interfaceId ||\n interfaceId == type(ISeaDropTokenContractMetadata).interfaceId ||\n // ERC721ContractMetadata returns supportsInterface true for\n // EIP-2981\n // ERC721A returns supportsInterface true for\n // ERC165, ERC721, ERC721Metadata\n super.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom}\n * for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n * - The `operator` must be allowed.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool approved)\n public\n override\n onlyAllowedOperatorApproval(operator)\n {\n super.setApprovalForAll(operator, approved);\n }\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the\n * zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n * - The `operator` mut be allowed.\n *\n * Emits an {Approval} event.\n */\n function approve(address operator, uint256 tokenId)\n public\n override\n onlyAllowedOperatorApproval(operator)\n {\n super.approve(operator, tokenId);\n }\n\n /**\n * @dev Transfers `tokenId` from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - The operator must be allowed.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.transferFrom(from, to, tokenId);\n }\n\n /**\n * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId);\n }\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token\n * by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement\n * {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n * - The operator must be allowed.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes memory data\n ) public override onlyAllowedOperator(from) {\n super.safeTransferFrom(from, to, tokenId, data);\n }\n\n /**\n * @notice Configure multiple properties at a time.\n *\n * Note: The individual configure methods should be used\n * to unset or reset any properties to zero, as this method\n * will ignore zero-value properties in the config struct.\n *\n * @param config The configuration struct.\n */\n function multiConfigure(MultiConfigureStruct calldata config)\n external\n onlyOwner\n {\n if (config.maxSupply > 0) {\n this.setMaxSupply(config.maxSupply);\n }\n if (bytes(config.baseURI).length != 0) {\n this.setBaseURI(config.baseURI);\n }\n if (bytes(config.contractURI).length != 0) {\n this.setContractURI(config.contractURI);\n }\n if (\n _cast(config.publicDrop.startTime != 0) |\n _cast(config.publicDrop.endTime != 0) ==\n 1\n ) {\n this.updatePublicDrop(config.seaDropImpl, config.publicDrop);\n }\n if (bytes(config.dropURI).length != 0) {\n this.updateDropURI(config.seaDropImpl, config.dropURI);\n }\n if (config.allowListData.merkleRoot != bytes32(0)) {\n this.updateAllowList(config.seaDropImpl, config.allowListData);\n }\n if (config.creatorPayoutAddress != address(0)) {\n this.updateCreatorPayoutAddress(\n config.seaDropImpl,\n config.creatorPayoutAddress\n );\n }\n if (config.provenanceHash != bytes32(0)) {\n this.setProvenanceHash(config.provenanceHash);\n }\n if (config.allowedFeeRecipients.length > 0) {\n for (uint256 i = 0; i < config.allowedFeeRecipients.length; ) {\n this.updateAllowedFeeRecipient(\n config.seaDropImpl,\n config.allowedFeeRecipients[i],\n true\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedFeeRecipients.length > 0) {\n for (uint256 i = 0; i < config.disallowedFeeRecipients.length; ) {\n this.updateAllowedFeeRecipient(\n config.seaDropImpl,\n config.disallowedFeeRecipients[i],\n false\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.allowedPayers.length > 0) {\n for (uint256 i = 0; i < config.allowedPayers.length; ) {\n this.updatePayer(\n config.seaDropImpl,\n config.allowedPayers[i],\n true\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedPayers.length > 0) {\n for (uint256 i = 0; i < config.disallowedPayers.length; ) {\n this.updatePayer(\n config.seaDropImpl,\n config.disallowedPayers[i],\n false\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.tokenGatedDropStages.length > 0) {\n if (\n config.tokenGatedDropStages.length !=\n config.tokenGatedAllowedNftTokens.length\n ) {\n revert TokenGatedMismatch();\n }\n for (uint256 i = 0; i < config.tokenGatedDropStages.length; ) {\n this.updateTokenGatedDrop(\n config.seaDropImpl,\n config.tokenGatedAllowedNftTokens[i],\n config.tokenGatedDropStages[i]\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedTokenGatedAllowedNftTokens.length > 0) {\n for (\n uint256 i = 0;\n i < config.disallowedTokenGatedAllowedNftTokens.length;\n\n ) {\n TokenGatedDropStage memory emptyStage;\n this.updateTokenGatedDrop(\n config.seaDropImpl,\n config.disallowedTokenGatedAllowedNftTokens[i],\n emptyStage\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.signedMintValidationParams.length > 0) {\n if (\n config.signedMintValidationParams.length !=\n config.signers.length\n ) {\n revert SignersMismatch();\n }\n for (\n uint256 i = 0;\n i < config.signedMintValidationParams.length;\n\n ) {\n this.updateSignedMintValidationParams(\n config.seaDropImpl,\n config.signers[i],\n config.signedMintValidationParams[i]\n );\n unchecked {\n ++i;\n }\n }\n }\n if (config.disallowedSigners.length > 0) {\n for (uint256 i = 0; i < config.disallowedSigners.length; ) {\n SignedMintValidationParams memory emptyParams;\n this.updateSignedMintValidationParams(\n config.seaDropImpl,\n config.disallowedSigners[i],\n emptyParams\n );\n unchecked {\n ++i;\n }\n }\n }\n }\n}\n"
},
"src/interfaces/INonFungibleSeaDropToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\nimport {\n AllowListData,\n PublicDrop,\n TokenGatedDropStage,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\ninterface INonFungibleSeaDropToken is ISeaDropTokenContractMetadata {\n /**\n * @dev Revert with an error if a contract is not an allowed\n * SeaDrop address.\n */\n error OnlyAllowedSeaDrop();\n\n /**\n * @dev Emit an event when allowed SeaDrop contracts are updated.\n */\n event AllowedSeaDropUpdated(address[] allowedSeaDrop);\n\n /**\n * @notice Update the allowed SeaDrop contracts.\n * Only the owner or administrator can use this function.\n *\n * @param allowedSeaDrop The allowed SeaDrop addresses.\n */\n function updateAllowedSeaDrop(address[] calldata allowedSeaDrop) external;\n\n /**\n * @notice Mint tokens, restricted to the SeaDrop contract.\n *\n * @dev NOTE: If a token registers itself with multiple SeaDrop\n * contracts, the implementation of this function should guard\n * against reentrancy. If the implementing token uses\n * _safeMint(), or a feeRecipient with a malicious receive() hook\n * is specified, the token or fee recipients may be able to execute\n * another mint in the same transaction via a separate SeaDrop\n * contract.\n * This is dangerous if an implementing token does not correctly\n * update the minterNumMinted and currentTotalSupply values before\n * transferring minted tokens, as SeaDrop references these values\n * to enforce token limits on a per-wallet and per-stage basis.\n *\n * @param minter The address to mint to.\n * @param quantity The number of tokens to mint.\n */\n function mintSeaDrop(address minter, uint256 quantity) external;\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC721Received() hooks.\n *\n * @param minter The minter address.\n */\n function getMintStats(address minter)\n external\n view\n returns (\n uint256 minterNumMinted,\n uint256 currentTotalSupply,\n uint256 maxSupply\n );\n\n /**\n * @notice Update the public drop data for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * The administrator can only update `feeBps`.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(\n address seaDropImpl,\n PublicDrop calldata publicDrop\n ) external;\n\n /**\n * @notice Update the allow list data for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowListData The allow list data.\n */\n function updateAllowList(\n address seaDropImpl,\n AllowListData calldata allowListData\n ) external;\n\n /**\n * @notice Update the token gated drop stage data for this nft contract\n * on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * The administrator, when present, must first set `feeBps`.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during the\n * `dropStage` time period.\n *\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param allowedNftToken The allowed nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address seaDropImpl,\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external;\n\n /**\n * @notice Update the drop URI for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param dropURI The new drop URI.\n */\n function updateDropURI(address seaDropImpl, string calldata dropURI)\n external;\n\n /**\n * @notice Update the creator payout address for this nft contract on\n * SeaDrop.\n * Only the owner can set the creator payout address.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payoutAddress The new payout address.\n */\n function updateCreatorPayoutAddress(\n address seaDropImpl,\n address payoutAddress\n ) external;\n\n /**\n * @notice Update the allowed fee recipient for this nft contract\n * on SeaDrop.\n * Only the administrator can set the allowed fee recipient.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param feeRecipient The new fee recipient.\n */\n function updateAllowedFeeRecipient(\n address seaDropImpl,\n address feeRecipient,\n bool allowed\n ) external;\n\n /**\n * @notice Update the server-side signers for this nft contract\n * on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters\n * to enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address seaDropImpl,\n address signer,\n SignedMintValidationParams memory signedMintValidationParams\n ) external;\n\n /**\n * @notice Update the allowed payers for this nft contract on SeaDrop.\n * Only the owner or administrator can use this function.\n *\n * @param seaDropImpl The allowed SeaDrop contract.\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(\n address seaDropImpl,\n address payer,\n bool allowed\n ) external;\n}\n"
},
"src/interfaces/ISeaDrop.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n AllowListData,\n MintParams,\n PublicDrop,\n TokenGatedDropStage,\n TokenGatedMintParams,\n SignedMintValidationParams\n} from \"../lib/SeaDropStructs.sol\";\n\nimport { SeaDropErrorsAndEvents } from \"../lib/SeaDropErrorsAndEvents.sol\";\n\ninterface ISeaDrop is SeaDropErrorsAndEvents {\n /**\n * @notice Mint a public drop.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n */\n function mintPublic(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity\n ) external payable;\n\n /**\n * @notice Mint from an allow list.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n * @param mintParams The mint parameters.\n * @param proof The proof for the leaf of the allow list.\n */\n function mintAllowList(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity,\n MintParams calldata mintParams,\n bytes32[] calldata proof\n ) external payable;\n\n /**\n * @notice Mint with a server-side signature.\n * Note that a signature can only be used once.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param quantity The number of tokens to mint.\n * @param mintParams The mint parameters.\n * @param salt The sale for the signed mint.\n * @param signature The server-side signature, must be an allowed\n * signer.\n */\n function mintSigned(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n uint256 quantity,\n MintParams calldata mintParams,\n uint256 salt,\n bytes calldata signature\n ) external payable;\n\n /**\n * @notice Mint as an allowed token holder.\n * This will mark the token id as redeemed and will revert if the\n * same token id is attempted to be redeemed twice.\n *\n * @param nftContract The nft contract to mint.\n * @param feeRecipient The fee recipient.\n * @param minterIfNotPayer The mint recipient if different than the payer.\n * @param mintParams The token gated mint params.\n */\n function mintAllowedTokenHolder(\n address nftContract,\n address feeRecipient,\n address minterIfNotPayer,\n TokenGatedMintParams calldata mintParams\n ) external payable;\n\n /**\n * @notice Emits an event to notify update of the drop URI.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param dropURI The new drop URI.\n */\n function updateDropURI(string calldata dropURI) external;\n\n /**\n * @notice Updates the public drop data for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param publicDrop The public drop data.\n */\n function updatePublicDrop(PublicDrop calldata publicDrop) external;\n\n /**\n * @notice Updates the allow list merkle root for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param allowListData The allow list data.\n */\n function updateAllowList(AllowListData calldata allowListData) external;\n\n /**\n * @notice Updates the token gated drop stage for the nft contract\n * and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * Note: If two INonFungibleSeaDropToken tokens are doing\n * simultaneous token gated drop promotions for each other,\n * they can be minted by the same actor until\n * `maxTokenSupplyForStage` is reached. Please ensure the\n * `allowedNftToken` is not running an active drop during\n * the `dropStage` time period.\n *\n * @param allowedNftToken The token gated nft token.\n * @param dropStage The token gated drop stage data.\n */\n function updateTokenGatedDrop(\n address allowedNftToken,\n TokenGatedDropStage calldata dropStage\n ) external;\n\n /**\n * @notice Updates the creator payout address and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param payoutAddress The creator payout address.\n */\n function updateCreatorPayoutAddress(address payoutAddress) external;\n\n /**\n * @notice Updates the allowed fee recipient and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param feeRecipient The fee recipient.\n * @param allowed If the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(address feeRecipient, bool allowed)\n external;\n\n /**\n * @notice Updates the allowed server-side signers and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param signer The signer to update.\n * @param signedMintValidationParams Minimum and maximum parameters\n * to enforce for signed mints.\n */\n function updateSignedMintValidationParams(\n address signer,\n SignedMintValidationParams calldata signedMintValidationParams\n ) external;\n\n /**\n * @notice Updates the allowed payer and emits an event.\n *\n * This method assume msg.sender is an nft contract and its\n * ERC165 interface id matches INonFungibleSeaDropToken.\n *\n * Note: Be sure only authorized users can call this from\n * token contracts that implement INonFungibleSeaDropToken.\n *\n * @param payer The payer to add or remove.\n * @param allowed Whether to add or remove the payer.\n */\n function updatePayer(address payer, bool allowed) external;\n\n /**\n * @notice Returns the public drop data for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getPublicDrop(address nftContract)\n external\n view\n returns (PublicDrop memory);\n\n /**\n * @notice Returns the creator payout address for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getCreatorPayoutAddress(address nftContract)\n external\n view\n returns (address);\n\n /**\n * @notice Returns the allow list merkle root for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getAllowListMerkleRoot(address nftContract)\n external\n view\n returns (bytes32);\n\n /**\n * @notice Returns if the specified fee recipient is allowed\n * for the nft contract.\n *\n * @param nftContract The nft contract.\n * @param feeRecipient The fee recipient.\n */\n function getFeeRecipientIsAllowed(address nftContract, address feeRecipient)\n external\n view\n returns (bool);\n\n /**\n * @notice Returns an enumeration of allowed fee recipients for an\n * nft contract when fee recipients are enforced\n *\n * @param nftContract The nft contract.\n */\n function getAllowedFeeRecipients(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the server-side signers for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getSigners(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the struct of SignedMintValidationParams for a signer.\n *\n * @param nftContract The nft contract.\n * @param signer The signer.\n */\n function getSignedMintValidationParams(address nftContract, address signer)\n external\n view\n returns (SignedMintValidationParams memory);\n\n /**\n * @notice Returns the payers for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getPayers(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns if the specified payer is allowed\n * for the nft contract.\n *\n * @param nftContract The nft contract.\n * @param payer The payer.\n */\n function getPayerIsAllowed(address nftContract, address payer)\n external\n view\n returns (bool);\n\n /**\n * @notice Returns the allowed token gated drop tokens for the nft contract.\n *\n * @param nftContract The nft contract.\n */\n function getTokenGatedAllowedTokens(address nftContract)\n external\n view\n returns (address[] memory);\n\n /**\n * @notice Returns the token gated drop data for the nft contract\n * and token gated nft.\n *\n * @param nftContract The nft contract.\n * @param allowedNftToken The token gated nft token.\n */\n function getTokenGatedDrop(address nftContract, address allowedNftToken)\n external\n view\n returns (TokenGatedDropStage memory);\n\n /**\n * @notice Returns whether the token id for a token gated drop has been\n * redeemed.\n *\n * @param nftContract The nft contract.\n * @param allowedNftToken The token gated nft token.\n * @param allowedNftTokenId The token gated nft token id to check.\n */\n function getAllowedNftTokenIdIsRedeemed(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n ) external view returns (bool);\n}\n"
},
"src/interfaces/ISeaDropTokenContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport { IERC2981 } from \"openzeppelin-contracts/interfaces/IERC2981.sol\";\n\ninterface ISeaDropTokenContractMetadata is IERC2981 {\n /**\n * @notice Throw if the max supply exceeds uint64, a limit\n * due to the storage of bit-packed variables in ERC721A.\n */\n error CannotExceedMaxSupplyOfUint64(uint256 newMaxSupply);\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after the mint has started.\n */\n error ProvenanceHashCannotBeSetAfterMintStarted();\n\n /**\n * @dev Revert if the royalty basis points is greater than 10_000.\n */\n error InvalidRoyaltyBasisPoints(uint256 basisPoints);\n\n /**\n * @dev Revert if the royalty address is being set to the zero address.\n */\n error RoyaltyAddressCannotBeZeroAddress();\n\n /**\n * @dev Emit an event for token metadata reveals/updates,\n * according to EIP-4906.\n *\n * @param _fromTokenId The start token id.\n * @param _toTokenId The end token id.\n */\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n\n /**\n * @dev Emit an event when the URI for the collection-level metadata\n * is updated.\n */\n event ContractURIUpdated(string newContractURI);\n\n /**\n * @dev Emit an event when the max token supply is updated.\n */\n event MaxSupplyUpdated(uint256 newMaxSupply);\n\n /**\n * @dev Emit an event with the previous and new provenance hash after\n * being updated.\n */\n event ProvenanceHashUpdated(bytes32 previousHash, bytes32 newHash);\n\n /**\n * @dev Emit an event when the royalties info is updated.\n */\n event RoyaltyInfoUpdated(address receiver, uint256 bps);\n\n /**\n * @notice A struct defining royalty info for the contract.\n */\n struct RoyaltyInfo {\n address royaltyAddress;\n uint96 royaltyBps;\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param tokenURI The new base URI to set.\n */\n function setBaseURI(string calldata tokenURI) external;\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external;\n\n /**\n * @notice Sets the max supply and emits an event.\n *\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 newMaxSupply) external;\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external;\n\n /**\n * @notice Sets the address and basis points for royalties.\n *\n * @param newInfo The struct to configure royalties.\n */\n function setRoyaltyInfo(RoyaltyInfo calldata newInfo) external;\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view returns (string memory);\n\n /**\n * @notice Returns the contract URI.\n */\n function contractURI() external view returns (string memory);\n\n /**\n * @notice Returns the max token supply.\n */\n function maxSupply() external view returns (uint256);\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view returns (bytes32);\n\n /**\n * @notice Returns the address that receives royalties.\n */\n function royaltyAddress() external view returns (address);\n\n /**\n * @notice Returns the royalty basis points out of 10_000.\n */\n function royaltyBasisPoints() external view returns (uint256);\n}\n"
},
"src/lib/ERC721SeaDropStructsErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport {\n AllowListData,\n PublicDrop,\n SignedMintValidationParams,\n TokenGatedDropStage\n} from \"./SeaDropStructs.sol\";\n\ninterface ERC721SeaDropStructsErrorsAndEvents {\n /**\n * @notice Revert with an error if mint exceeds the max supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @notice Revert with an error if the number of token gated \n * allowedNftTokens doesn't match the length of supplied\n * drop stages.\n */\n error TokenGatedMismatch();\n\n /**\n * @notice Revert with an error if the number of signers doesn't match\n * the length of supplied signedMintValidationParams\n */\n error SignersMismatch();\n\n /**\n * @notice An event to signify that a SeaDrop token contract was deployed.\n */\n event SeaDropTokenDeployed();\n\n /**\n * @notice A struct to configure multiple contract options at a time.\n */\n struct MultiConfigureStruct {\n uint256 maxSupply;\n string baseURI;\n string contractURI;\n address seaDropImpl;\n PublicDrop publicDrop;\n string dropURI;\n AllowListData allowListData;\n address creatorPayoutAddress;\n bytes32 provenanceHash;\n\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n\n address[] allowedPayers;\n address[] disallowedPayers;\n\n // Token-gated\n address[] tokenGatedAllowedNftTokens;\n TokenGatedDropStage[] tokenGatedDropStages;\n address[] disallowedTokenGatedAllowedNftTokens;\n\n // Server-signed\n address[] signers;\n SignedMintValidationParams[] signedMintValidationParams;\n address[] disallowedSigners;\n }\n}"
},
"src/lib/SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\nimport { PublicDrop, TokenGatedDropStage, SignedMintValidationParams } from \"./SeaDropStructs.sol\";\n\ninterface SeaDropErrorsAndEvents {\n /**\n * @dev Revert with an error if the drop stage is not active.\n */\n error NotActive(\n uint256 currentTimestamp,\n uint256 startTimestamp,\n uint256 endTimestamp\n );\n\n /**\n * @dev Revert with an error if the mint quantity is zero.\n */\n error MintQuantityCannotBeZero();\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max allowed\n * to be minted per wallet.\n */\n error MintQuantityExceedsMaxMintedPerWallet(uint256 total, uint256 allowed);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply for the stage.\n * Note: The `maxTokenSupplyForStage` for public mint is\n * always `type(uint).max`.\n */\n error MintQuantityExceedsMaxTokenSupplyForStage(\n uint256 total, \n uint256 maxTokenSupplyForStage\n );\n \n /**\n * @dev Revert if the fee recipient is the zero address.\n */\n error FeeRecipientCannotBeZeroAddress();\n\n /**\n * @dev Revert if the fee recipient is not already included.\n */\n error FeeRecipientNotPresent();\n\n /**\n * @dev Revert if the fee basis points is greater than 10_000.\n */\n error InvalidFeeBps(uint256 feeBps);\n\n /**\n * @dev Revert if the fee recipient is already included.\n */\n error DuplicateFeeRecipient();\n\n /**\n * @dev Revert if the fee recipient is restricted and not allowed.\n */\n error FeeRecipientNotAllowed();\n\n /**\n * @dev Revert if the creator payout address is the zero address.\n */\n error CreatorPayoutAddressCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if the received payment is incorrect.\n */\n error IncorrectPayment(uint256 got, uint256 want);\n\n /**\n * @dev Revert with an error if the allow list proof is invalid.\n */\n error InvalidProof();\n\n /**\n * @dev Revert if a supplied signer address is the zero address.\n */\n error SignerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if signer's signature is invalid.\n */\n error InvalidSignature(address recoveredSigner);\n\n /**\n * @dev Revert with an error if a signer is not included in\n * the enumeration when removing.\n */\n error SignerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is not included in\n * the enumeration when removing.\n */\n error PayerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is already included in mapping\n * when adding.\n * Note: only applies when adding a single payer, as duplicates in\n * enumeration can be removed with updatePayer.\n */\n error DuplicatePayer();\n\n /**\n * @dev Revert with an error if the payer is not allowed. The minter must\n * pay for their own mint.\n */\n error PayerNotAllowed();\n\n /**\n * @dev Revert if a supplied payer address is the zero address.\n */\n error PayerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if the sender does not\n * match the INonFungibleSeaDropToken interface.\n */\n error OnlyINonFungibleSeaDropToken(address sender);\n\n /**\n * @dev Revert with an error if the sender of a token gated supplied\n * drop stage redeem is not the owner of the token.\n */\n error TokenGatedNotTokenOwner(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n );\n\n /**\n * @dev Revert with an error if the token id has already been used to\n * redeem a token gated drop stage.\n */\n error TokenGatedTokenIdAlreadyRedeemed(\n address nftContract,\n address allowedNftToken,\n uint256 allowedNftTokenId\n );\n\n /**\n * @dev Revert with an error if an empty TokenGatedDropStage is provided\n * for an already-empty TokenGatedDropStage.\n */\n error TokenGatedDropStageNotPresent();\n\n /**\n * @dev Revert with an error if an allowedNftToken is set to\n * the zero address.\n */\n error TokenGatedDropAllowedNftTokenCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if an allowedNftToken is set to\n * the drop token itself.\n */\n error TokenGatedDropAllowedNftTokenCannotBeDropToken();\n\n\n /**\n * @dev Revert with an error if supplied signed mint price is less than\n * the minimum specified.\n */\n error InvalidSignedMintPrice(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if supplied signed maxTotalMintableByWallet\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTotalMintableByWallet(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed start time is less than\n * the minimum specified.\n */\n error InvalidSignedStartTime(uint256 got, uint256 minimum);\n \n /**\n * @dev Revert with an error if supplied signed end time is greater than\n * the maximum specified.\n */\n error InvalidSignedEndTime(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed maxTokenSupplyForStage\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTokenSupplyForStage(uint256 got, uint256 maximum);\n \n /**\n * @dev Revert with an error if supplied signed feeBps is greater than\n * the maximum specified, or less than the minimum.\n */\n error InvalidSignedFeeBps(uint256 got, uint256 minimumOrMaximum);\n\n /**\n * @dev Revert with an error if signed mint did not specify to restrict\n * fee recipients.\n */\n error SignedMintsMustRestrictFeeRecipients();\n\n /**\n * @dev Revert with an error if a signature for a signed mint has already\n * been used.\n */\n error SignatureAlreadyUsed();\n\n /**\n * @dev An event with details of a SeaDrop mint, for analytical purposes.\n * \n * @param nftContract The nft contract.\n * @param minter The mint recipient.\n * @param feeRecipient The fee recipient.\n * @param payer The address who payed for the tx.\n * @param quantityMinted The number of tokens minted.\n * @param unitMintPrice The amount paid for each token.\n * @param feeBps The fee out of 10_000 basis points collected.\n * @param dropStageIndex The drop stage index. Items minted\n * through mintPublic() have\n * dropStageIndex of 0.\n */\n event SeaDropMint(\n address indexed nftContract,\n address indexed minter,\n address indexed feeRecipient,\n address payer,\n uint256 quantityMinted,\n uint256 unitMintPrice,\n uint256 feeBps,\n uint256 dropStageIndex\n );\n\n /**\n * @dev An event with updated public drop data for an nft contract.\n */\n event PublicDropUpdated(\n address indexed nftContract,\n PublicDrop publicDrop\n );\n\n /**\n * @dev An event with updated token gated drop stage data\n * for an nft contract.\n */\n event TokenGatedDropStageUpdated(\n address indexed nftContract,\n address indexed allowedNftToken,\n TokenGatedDropStage dropStage\n );\n\n /**\n * @dev An event with updated allow list data for an nft contract.\n * \n * @param nftContract The nft contract.\n * @param previousMerkleRoot The previous allow list merkle root.\n * @param newMerkleRoot The new allow list merkle root.\n * @param publicKeyURI If the allow list is encrypted, the public key\n * URIs that can decrypt the list.\n * Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\n event AllowListUpdated(\n address indexed nftContract,\n bytes32 indexed previousMerkleRoot,\n bytes32 indexed newMerkleRoot,\n string[] publicKeyURI,\n string allowListURI\n );\n\n /**\n * @dev An event with updated drop URI for an nft contract.\n */\n event DropURIUpdated(address indexed nftContract, string newDropURI);\n\n /**\n * @dev An event with the updated creator payout address for an nft\n * contract.\n */\n event CreatorPayoutAddressUpdated(\n address indexed nftContract,\n address indexed newPayoutAddress\n );\n\n /**\n * @dev An event with the updated allowed fee recipient for an nft\n * contract.\n */\n event AllowedFeeRecipientUpdated(\n address indexed nftContract,\n address indexed feeRecipient,\n bool indexed allowed\n );\n\n /**\n * @dev An event with the updated validation parameters for server-side\n * signers.\n */\n event SignedMintValidationParamsUpdated(\n address indexed nftContract,\n address indexed signer,\n SignedMintValidationParams signedMintValidationParams\n ); \n\n /**\n * @dev An event with the updated payer for an nft contract.\n */\n event PayerUpdated(\n address indexed nftContract,\n address indexed payer,\n bool indexed allowed\n );\n}\n"
},
"src/lib/SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.17;\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in one storage slot.\n * \n * @param mintPrice The mint price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param startTime The start time, ensure this is not zero.\n * @param endTIme The end time, ensure this is not zero.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct PublicDrop {\n uint80 mintPrice; // 80/256 bits\n uint48 startTime; // 128/256 bits\n uint48 endTime; // 176/256 bits\n uint16 maxTotalMintableByWallet; // 224/256 bits\n uint16 feeBps; // 240/256 bits\n bool restrictFeeRecipients; // 248/256 bits\n}\n\n/**\n * @notice A struct defining token gated drop stage data.\n * Designed to fit efficiently in one storage slot.\n * \n * @param mintPrice The mint price per token. (Up to 1.2m \n * of native token, e.g.: ETH, MATIC)\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be \n * non-zero since the public mint emits\n * with index zero.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct TokenGatedDropStage {\n uint80 mintPrice; // 80/256 bits\n uint16 maxTotalMintableByWallet; // 96/256 bits\n uint48 startTime; // 144/256 bits\n uint48 endTime; // 192/256 bits\n uint8 dropStageIndex; // non-zero. 200/256 bits\n uint32 maxTokenSupplyForStage; // 232/256 bits\n uint16 feeBps; // 248/256 bits\n bool restrictFeeRecipients; // 256/256 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n * \n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n * \n * @param mintPrice The mint price per token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 mintPrice; \n uint256 maxTotalMintableByWallet;\n uint256 startTime;\n uint256 endTime;\n uint256 dropStageIndex; // non-zero\n uint256 maxTokenSupplyForStage;\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @notice A struct defining token gated mint params.\n * \n * @param allowedNftToken The allowed nft token contract address.\n * @param allowedNftTokenIds The token ids to redeem.\n */\nstruct TokenGatedMintParams {\n address allowedNftToken;\n uint256[] allowedNftTokenIds;\n}\n\n/**\n * @notice A struct defining allow list data (for minting an allow list).\n * \n * @param merkleRoot The merkle root for the allow list.\n * @param publicKeyURIs If the allowListURI is encrypted, a list of URIs\n * pointing to the public keys. Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\nstruct AllowListData {\n bytes32 merkleRoot;\n string[] publicKeyURIs;\n string allowListURI;\n}\n\n/**\n * @notice A struct defining minimum and maximum parameters to validate for \n * signed mints, to minimize negative effects of a compromised signer.\n *\n * @param minMintPrice The minimum mint price allowed.\n * @param maxMaxTotalMintableByWallet The maximum total number of mints allowed\n * by a wallet.\n * @param minStartTime The minimum start time allowed.\n * @param maxEndTime The maximum end time allowed.\n * @param maxMaxTokenSupplyForStage The maximum token supply allowed.\n * @param minFeeBps The minimum fee allowed.\n * @param maxFeeBps The maximum fee allowed.\n */\nstruct SignedMintValidationParams {\n uint80 minMintPrice; // 80/256 bits\n uint24 maxMaxTotalMintableByWallet; // 104/256 bits\n uint40 minStartTime; // 144/256 bits\n uint40 maxEndTime; // 184/256 bits\n uint40 maxMaxTokenSupplyForStage; // 224/256 bits\n uint16 minFeeBps; // 240/256 bits\n uint16 maxFeeBps; // 256/256 bits\n}"
}
},
"settings": {
"remappings": [
"ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
"ERC721A/=lib/ERC721A/contracts/",
"create2-helpers/=lib/create2-helpers/src/",
"create2-scripts/=lib/create2-helpers/script/",
"ds-test/=lib/ds-test/src/",
"erc4626-tests/=lib/operator-filter-registry/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"murky/=lib/murky/src/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
"operator-filter-registry/=lib/operator-filter-registry/src/",
"seadrop/=src/",
"solmate/=lib/solmate/src/",
"utility-contracts/=lib/utility-contracts/src/"
],
"optimizer": {
"enabled": true,
"runs": 1000000
},
"metadata": {
"bytecodeHash": "none"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
}}
|
1 | 19,498,600 |
e62c29272f1c2f91d109986f4f7d5abf5efb6df8b36280a55355a6fcd36cd81a
|
fc55f5ebb4ce4b1df5dcc213fe775edd2ef1ec351e8183ecbdac16e338268806
|
a9a0b8a5e1adca0caccc63a168f053cd3be30808
|
01cd62ed13d0b666e2a10d13879a763dfd1dab99
|
ee3f29df0beba1d55ce02e0004ea6531e5bc7349
|
3d602d80600a3d3981f3363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
| |
1 | 19,498,600 |
e62c29272f1c2f91d109986f4f7d5abf5efb6df8b36280a55355a6fcd36cd81a
|
61dd9b332abfe9bd01adf259dd3e6f7c73919835b7c9ec5aea1b8b9aaa34cb14
|
e41e59b5ed5e5540014d830969c027115ca8fccb
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
d73ed788efade2649891ce9a0dc5eb6d99975d9e
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,602 |
c6f8dec819b75f28fdca12af481c593adca3f7b0b255020129e9e2c9174d7617
|
a179851d389136b2c837f442123875df37a953b83ab2fd65c0a7abc82577c717
|
20bbf99bdea419f3e4379d8014d56049a1637e66
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
1d7af8da371e9bbd5b5bd9e5c5fea8f3aaa2d151
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,498,602 |
c6f8dec819b75f28fdca12af481c593adca3f7b0b255020129e9e2c9174d7617
|
0cce02719094b287d4bb6a845f20997b85983118cf9089bf6ff2f4335a5da8e2
|
b3388a3eee7ac4c7ea20928f0badc8640e5cece4
|
1e68238ce926dec62b3fbc99ab06eb1d85ce0270
|
5556add2c1fd9076a5ec5daaffce1e8f7cadefa1
|
3d602d80600a3d3981f3363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/contracts/ConsensusLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Consensus Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ConsensusLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n error NotImplemented();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ConsensusLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ConsensusLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract\n /// @param _stakingContract Address of the Staking Contract\n function initCLD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32) external payable {\n revert NotImplemented();\n /*\n uint256 balance = address(this).balance; // this has taken into account msg.value\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee;\n\n if (balance >= 32 ether) {\n // withdrawing a healthy & exited validator\n globalFee = ((balance - 32 ether) * stakingContract.getGlobalFee()) / BASIS_POINTS;\n } else if (balance <= 16 ether) {\n // withdrawing from what looks like skimming\n globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n }\n\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(withdrawer, operator, balance - globalFee, operatorFee, globalFee - operatorFee);\n */\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
},
"src/contracts/libs/DispatchersStorageLib.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\nlibrary DispatchersStorageLib {\n function getUint256(bytes32 position) internal view returns (uint256 data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setUint256(bytes32 position, uint256 data) internal {\n assembly {\n sstore(position, data)\n }\n }\n\n function getAddress(bytes32 position) internal view returns (address data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setAddress(bytes32 position, address data) internal {\n assembly {\n sstore(position, data)\n }\n }\n}\n"
},
"src/contracts/interfaces/IStakingContractFeeDetails.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IStakingContractFeeDetails {\n function getWithdrawerFromPublicKeyRoot(bytes32 _publicKeyRoot) external view returns (address);\n\n function getTreasury() external view returns (address);\n\n function getOperatorFeeRecipient(bytes32 pubKeyRoot) external view returns (address);\n\n function getGlobalFee() external view returns (uint256);\n\n function getOperatorFee() external view returns (uint256);\n}\n"
},
"src/contracts/interfaces/IFeeDispatcher.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IFeeDispatcher {\n function dispatch(bytes32 _publicKeyRoot) external payable;\n\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address);\n}\n"
},
"src/contracts/FeeRecipient.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./interfaces/IFeeDispatcher.sol\";\n\ncontract FeeRecipient {\n /// @notice Constructor replay prevention\n bool internal initialized;\n /// @notice Address where funds are sent to be dispatched\n IFeeDispatcher internal dispatcher;\n /// @notice Public Key root assigned to this receiver\n bytes32 internal publicKeyRoot;\n\n error AlreadyInitialized();\n\n /// @notice Initializes the receiver\n /// @param _dispatcher Address that will handle the fee dispatching\n /// @param _publicKeyRoot Public Key root assigned to this receiver\n function init(address _dispatcher, bytes32 _publicKeyRoot) external {\n if (initialized) {\n revert AlreadyInitialized();\n }\n initialized = true;\n dispatcher = IFeeDispatcher(_dispatcher);\n publicKeyRoot = _publicKeyRoot;\n }\n\n /// @notice Empty calldata fallback\n receive() external payable {}\n\n /// @notice Non-empty calldata fallback\n fallback() external payable {}\n\n /// @notice Triggers a withdrawal by sending its funds + its public key root to the dispatcher\n /// @dev Can be called by any wallet as recipients are not parameters\n function withdraw() external {\n dispatcher.dispatch{value: address(this).balance}(publicKeyRoot);\n }\n\n /// @notice Retrieve the assigned public key root\n function getPublicKeyRoot() external view returns (bytes32) {\n return publicKeyRoot;\n }\n\n /// @notice retrieve the assigned withdrawer\n function getWithdrawer() external view returns (address) {\n return dispatcher.getWithdrawer(publicKeyRoot);\n }\n}\n"
},
"src/contracts/ExecutionLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Execution Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ExecutionLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ExecutionLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ExecutionLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract and the public key in storage\n /// @param _stakingContract Address of the Staking Contract\n function initELD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32 _publicKeyRoot) external payable {\n uint256 balance = address(this).balance;\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(\n withdrawer,\n operator,\n _publicKeyRoot,\n balance - globalFee,\n operatorFee,\n globalFee - operatorFee\n );\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}}
|
1 | 19,498,602 |
c6f8dec819b75f28fdca12af481c593adca3f7b0b255020129e9e2c9174d7617
|
32dad05ba2fa2a2a1a3b9360334714326719cbcdb1fa4b43565bcb7bc1ee69a9
|
df4967f952ee02d5bc224510d37ad758a13a9eee
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
33a2b44052d4572c4cc3f1514e3acb6991b067bb
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,498,603 |
f0551284ee313b1070389a4699c5d3934c8dac615910e0523f0b621e485853d8
|
e7dc4f5cd3ee24540b60a5be87183109ddd82e58e015a784fa57d6e2eb3a2d08
|
faf34daecf2f91417908f0550cde3eb027481ca5
|
faf34daecf2f91417908f0550cde3eb027481ca5
|
345774c06854472233e333f48aca22f686faae18
|
6080604052604051620011ec380380620011ec8339810160408190526200002691620004b2565b6200003133620001cd565b8651620000469060039060208a01906200033c565b5085516200005c9060049060208901906200033c565b506005805460ff191660ff87161790556200008a620000836000546001600160a01b031690565b856200021d565b600780546001600160a01b0319166001600160a01b0385169081179091556318e02bd9620000c06000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b1580156200010257600080fd5b505af115801562000117573d6000803e3d6000fd5b50506007805460ff60a01b1916600160a01b17905550309050620001436000546001600160a01b031690565b6001600160a01b03167f56358b41df5fa59f5639228f0930994cbdde383c8a8fd74e06c04e1deebe3562600180604051620001809291906200056b565b60405180910390a36040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015620001bf573d6000803e3d6000fd5b505050505050505062000610565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038216620002785760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b62000294816006546200032760201b620005951790919060201c565b6006556001600160a01b038216600090815260016020908152604090912054620002c99183906200059562000327821b17901c565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906200031b9085815260200190565b60405180910390a35050565b600062000335828462000598565b9392505050565b8280546200034a90620005bd565b90600052602060002090601f0160209004810192826200036e5760008555620003b9565b82601f106200038957805160ff1916838001178555620003b9565b82800160010185558215620003b9579182015b82811115620003b95782518255916020019190600101906200039c565b50620003c7929150620003cb565b5090565b5b80821115620003c75760008155600101620003cc565b80516001600160a01b0381168114620003fa57600080fd5b919050565b600082601f83011262000410578081fd5b81516001600160401b03808211156200042d576200042d620005fa565b604051601f8301601f19908116603f01168101908282118183101715620004585762000458620005fa565b8160405283815260209250868385880101111562000474578485fd5b8491505b8382101562000497578582018301518183018401529082019062000478565b83821115620004a857848385830101525b9695505050505050565b600080600080600080600060e0888a031215620004cd578283fd5b87516001600160401b0380821115620004e4578485fd5b620004f28b838c01620003ff565b985060208a015191508082111562000508578485fd5b50620005178a828b01620003ff565b965050604088015160ff811681146200052e578384fd5b606089015190955093506200054660808901620003e2565b92506200055660a08901620003e2565b915060c0880151905092959891949750929550565b60408101600884106200058e57634e487b7160e01b600052602160045260246000fd5b9281526020015290565b60008219821115620005b857634e487b7160e01b81526011600452602481fd5b500190565b600181811c90821680620005d257607f821691505b60208210811415620005f457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b610bcc80620006206000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c806370a08231116100a2578063a457c2d711610071578063a457c2d714610247578063a9059cbb1461025a578063dd62ed3e1461026d578063f2fde38b146102a6578063ffa1ad74146102b957600080fd5b806370a08231146101fd578063715018a6146102265780638da5cb5b1461022e57806395d89b411461023f57600080fd5b806323b872dd116100e957806323b872dd14610183578063241ec3be14610196578063313ce567146101aa57806339509351146101bf578063407133d2146101d257600080fd5b806306fdde031461011b578063095ea7b31461013957806318160ddd1461015c5780631f46b1c61461016e575b600080fd5b6101236102c1565b6040516101309190610a3c565b60405180910390f35b61014c6101473660046109f3565b610353565b6040519015158152602001610130565b6006545b604051908152602001610130565b61018161017c366004610a1c565b610369565b005b61014c6101913660046109b8565b6103ba565b60075461014c90600160a01b900460ff1681565b60055460405160ff9091168152602001610130565b61014c6101cd3660046109f3565b610423565b6007546101e5906001600160a01b031681565b6040516001600160a01b039091168152602001610130565b61016061020b36600461096c565b6001600160a01b031660009081526001602052604090205490565b610181610459565b6000546001600160a01b03166101e5565b61012361048f565b61014c6102553660046109f3565b61049e565b61014c6102683660046109f3565b6104ed565b61016061027b366004610986565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6101816102b436600461096c565b6104fa565b610160600181565b6060600380546102d090610ae8565b80601f01602080910402602001604051908101604052809291908181526020018280546102fc90610ae8565b80156103495780601f1061031e57610100808354040283529160200191610349565b820191906000526020600020905b81548152906001019060200180831161032c57829003601f168201915b5050505050905090565b60006103603384846105a8565b50600192915050565b6000546001600160a01b0316331461039c5760405162461bcd60e51b815260040161039390610a8f565b60405180910390fd5b60078054911515600160a01b0260ff60a01b19909216919091179055565b60006103c78484846106cd565b610419843361041485604051806060016040528060288152602001610b4a602891396001600160a01b038a16600090815260026020908152604080832033845290915290205491906108d4565b6105a8565b5060019392505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490916103609185906104149086610595565b6000546001600160a01b031633146104835760405162461bcd60e51b815260040161039390610a8f565b61048d6000610900565b565b6060600480546102d090610ae8565b6000610360338461041485604051806060016040528060258152602001610b72602591393360009081526002602090815260408083206001600160a01b038d16845290915290205491906108d4565b60006103603384846106cd565b6000546001600160a01b031633146105245760405162461bcd60e51b815260040161039390610a8f565b6001600160a01b0381166105895760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610393565b61059281610900565b50565b60006105a18284610ac4565b9392505050565b6001600160a01b03831661060a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610393565b6001600160a01b03821661066b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610393565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166107315760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610393565b6001600160a01b0382166107935760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610393565b600754600160a01b900460ff16156108145760075460405163090ec10b60e31b81526001600160a01b03858116600483015284811660248301526044820184905290911690634876085890606401600060405180830381600087803b1580156107fb57600080fd5b505af115801561080f573d6000803e3d6000fd5b505050505b61085181604051806060016040528060268152602001610b24602691396001600160a01b03861660009081526001602052604090205491906108d4565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546108809082610595565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906106c09085815260200190565b600081848411156108f85760405162461bcd60e51b81526004016103939190610a3c565b505050900390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461096757600080fd5b919050565b60006020828403121561097d578081fd5b6105a182610950565b60008060408385031215610998578081fd5b6109a183610950565b91506109af60208401610950565b90509250929050565b6000806000606084860312156109cc578081fd5b6109d584610950565b92506109e360208501610950565b9150604084013590509250925092565b60008060408385031215610a05578182fd5b610a0e83610950565b946020939093013593505050565b600060208284031215610a2d578081fd5b813580151581146105a1578182fd5b6000602080835283518082850152825b81811015610a6857858101830151858201604001528201610a4c565b81811115610a795783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610ae357634e487b7160e01b81526011600452602481fd5b500190565b600181811c90821680610afc57607f821691505b60208210811415610b1d57634e487b7160e01b600052602260045260246000fd5b5091905056fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220a315ed57d3f9b893d48f5e4b53c7434cc9edcf752c48558caa894249076b0dcc64736f6c6343000804003300000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000052b7d2dcc80cd2e4000000000000000000000000000000f4f071eb637b64fc78c9ea87dace4445d119ca350000000000000000000000004b04213c2774f77e60702880654206b116d00508000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000000005476f6c656d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005474f4c454d000000000000000000000000000000000000000000000000000000
|
608060405234801561001057600080fd5b50600436106101165760003560e01c806370a08231116100a2578063a457c2d711610071578063a457c2d714610247578063a9059cbb1461025a578063dd62ed3e1461026d578063f2fde38b146102a6578063ffa1ad74146102b957600080fd5b806370a08231146101fd578063715018a6146102265780638da5cb5b1461022e57806395d89b411461023f57600080fd5b806323b872dd116100e957806323b872dd14610183578063241ec3be14610196578063313ce567146101aa57806339509351146101bf578063407133d2146101d257600080fd5b806306fdde031461011b578063095ea7b31461013957806318160ddd1461015c5780631f46b1c61461016e575b600080fd5b6101236102c1565b6040516101309190610a3c565b60405180910390f35b61014c6101473660046109f3565b610353565b6040519015158152602001610130565b6006545b604051908152602001610130565b61018161017c366004610a1c565b610369565b005b61014c6101913660046109b8565b6103ba565b60075461014c90600160a01b900460ff1681565b60055460405160ff9091168152602001610130565b61014c6101cd3660046109f3565b610423565b6007546101e5906001600160a01b031681565b6040516001600160a01b039091168152602001610130565b61016061020b36600461096c565b6001600160a01b031660009081526001602052604090205490565b610181610459565b6000546001600160a01b03166101e5565b61012361048f565b61014c6102553660046109f3565b61049e565b61014c6102683660046109f3565b6104ed565b61016061027b366004610986565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6101816102b436600461096c565b6104fa565b610160600181565b6060600380546102d090610ae8565b80601f01602080910402602001604051908101604052809291908181526020018280546102fc90610ae8565b80156103495780601f1061031e57610100808354040283529160200191610349565b820191906000526020600020905b81548152906001019060200180831161032c57829003601f168201915b5050505050905090565b60006103603384846105a8565b50600192915050565b6000546001600160a01b0316331461039c5760405162461bcd60e51b815260040161039390610a8f565b60405180910390fd5b60078054911515600160a01b0260ff60a01b19909216919091179055565b60006103c78484846106cd565b610419843361041485604051806060016040528060288152602001610b4a602891396001600160a01b038a16600090815260026020908152604080832033845290915290205491906108d4565b6105a8565b5060019392505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490916103609185906104149086610595565b6000546001600160a01b031633146104835760405162461bcd60e51b815260040161039390610a8f565b61048d6000610900565b565b6060600480546102d090610ae8565b6000610360338461041485604051806060016040528060258152602001610b72602591393360009081526002602090815260408083206001600160a01b038d16845290915290205491906108d4565b60006103603384846106cd565b6000546001600160a01b031633146105245760405162461bcd60e51b815260040161039390610a8f565b6001600160a01b0381166105895760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610393565b61059281610900565b50565b60006105a18284610ac4565b9392505050565b6001600160a01b03831661060a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610393565b6001600160a01b03821661066b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610393565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166107315760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610393565b6001600160a01b0382166107935760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610393565b600754600160a01b900460ff16156108145760075460405163090ec10b60e31b81526001600160a01b03858116600483015284811660248301526044820184905290911690634876085890606401600060405180830381600087803b1580156107fb57600080fd5b505af115801561080f573d6000803e3d6000fd5b505050505b61085181604051806060016040528060268152602001610b24602691396001600160a01b03861660009081526001602052604090205491906108d4565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546108809082610595565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906106c09085815260200190565b600081848411156108f85760405162461bcd60e51b81526004016103939190610a3c565b505050900390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461096757600080fd5b919050565b60006020828403121561097d578081fd5b6105a182610950565b60008060408385031215610998578081fd5b6109a183610950565b91506109af60208401610950565b90509250929050565b6000806000606084860312156109cc578081fd5b6109d584610950565b92506109e360208501610950565b9150604084013590509250925092565b60008060408385031215610a05578182fd5b610a0e83610950565b946020939093013593505050565b600060208284031215610a2d578081fd5b813580151581146105a1578182fd5b6000602080835283518082850152825b81811015610a6857858101830151858201604001528201610a4c565b81811115610a795783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610ae357634e487b7160e01b81526011600452602481fd5b500190565b600181811c90821680610afc57607f821691505b60208210811415610b1d57634e487b7160e01b600052602260045260246000fd5b5091905056fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220a315ed57d3f9b893d48f5e4b53c7434cc9edcf752c48558caa894249076b0dcc64736f6c63430008040033
|
/**
*Submitted for verification at BscScan.com on 2021-11-21
*/
// Dependency file: @openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// Dependency file: @openzeppelin/contracts/utils/Context.sol
// pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// Dependency file: @openzeppelin/contracts/access/Ownable.sol
// pragma solidity ^0.8.0;
// import "@openzeppelin/contracts/utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// Dependency file: @openzeppelin/contracts/utils/math/SafeMath.sol
// pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// Dependency file: contracts/interfaces/IPinkAntiBot.sol
// pragma solidity >=0.5.0;
interface IPinkAntiBot {
function setTokenOwner(address owner) external;
function onPreTransferCheck(
address from,
address to,
uint256 amount
) external;
}
// Dependency file: contracts/BaseToken.sol
// pragma solidity =0.8.4;
enum TokenType {
standard,
antiBotStandard,
liquidityGenerator,
antiBotLiquidityGenerator,
baby,
antiBotBaby,
buybackBaby,
antiBotBuybackBaby
}
abstract contract BaseToken {
event TokenCreated(
address indexed owner,
address indexed token,
TokenType tokenType,
uint256 version
);
}
// Root file: contracts/standard/AntiBotStandardToken.sol
pragma solidity =0.8.4;
// import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// import "@openzeppelin/contracts/access/Ownable.sol";
// import "@openzeppelin/contracts/utils/math/SafeMath.sol";
// import "contracts/interfaces/IPinkAntiBot.sol";
// import "contracts/BaseToken.sol";
contract AntiBotStandardToken is IERC20, Ownable, BaseToken {
using SafeMath for uint256;
uint256 public constant VERSION = 1;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _totalSupply;
IPinkAntiBot public pinkAntiBot;
bool public enableAntiBot;
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_,
uint256 totalSupply_,
address pinkAntiBot_,
address serviceFeeReceiver_,
uint256 serviceFee_
) payable {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
_mint(owner(), totalSupply_);
pinkAntiBot = IPinkAntiBot(pinkAntiBot_);
pinkAntiBot.setTokenOwner(owner());
enableAntiBot = true;
emit TokenCreated(
owner(),
address(this),
TokenType.antiBotStandard,
VERSION
);
payable(serviceFeeReceiver_).transfer(serviceFee_);
}
function setEnableAntiBot(bool _enable) external onlyOwner {
enableAntiBot = _enable;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account)
public
view
virtual
override
returns (uint256)
{
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount)
public
virtual
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender)
public
view
virtual
override
returns (uint256)
{
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount)
public
virtual
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].add(addedValue)
);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
"ERC20: decreased allowance below zero"
)
);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if (enableAntiBot) {
pinkAntiBot.onPreTransferCheck(sender, recipient, amount);
}
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(
amount,
"ERC20: transfer amount exceeds balance"
);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(
amount,
"ERC20: burn amount exceeds balance"
);
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal virtual {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
|
1 | 19,498,603 |
f0551284ee313b1070389a4699c5d3934c8dac615910e0523f0b621e485853d8
|
57f066c539dacb5ddb0997ff4225c84f674ee896a3afe687990a8b9d3ae3d017
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
ea326505b3f6e54d2c19e0ef433b9e6f922cd216
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,605 |
21c4abf5a7b88fa8faaa85439a169eab8dc9de76500d5d5bb9141970821188dc
|
f070044ee169335ab514bdb1aa4f163158eb1109bad2e637da055a465eb80439
|
ddb3cc4dc30ce0fcd9bbfc2a5f389b8c40aa023a
|
46950ba8946d7be4594399bcf203fb53e1fd7d37
|
3da74a562c11e5bb602176e2ff5c590ce8cae4b3
|
3d602d80600a3d3981f3363d3d373d3d3d363d73bfac0f451e63d2d639b05bbea3e72318ac5abc095af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73bfac0f451e63d2d639b05bbea3e72318ac5abc095af43d82803e903d91602b57fd5bf3
| |
1 | 19,498,607 |
3c863bdc0904ae8b749822816536f0d36f537072b1f2576ea50adf05c29bfa62
|
ddcde1ea9f5cf55736ee97c31406b53339179876ad34c7ca552ca7dca4a93b17
|
69838d02400aa379f1e496caee0927d14231bff4
|
69838d02400aa379f1e496caee0927d14231bff4
|
730d3ad397172996f478f6ec7acfa2ccd139a62c
|
6080604052670de0b6b3a764000060025566b1a2bc2ec500006003556004805460ff191690557f6e75382374384e10a7b62f6203157aa9e99f78d5213223f5ac9a4d92c9ed5d716007557f6e75382374384e10a7b62f6266005ed5a21c0da4330e4df10986a5d4ea19b6756008557f6e75382374384e10a7b62f6275685a1a7ba2ec89d03aaf46ee28682d66a044bc60095534801561009d57600080fd5b50600080546001600160a01b031916331781556007546008546100be911890565b60405163e2d73ccd60e01b81523060048201529091506001600160a01b0382169063e2d73ccd90602401600060405180830381600087803b15801561010257600080fd5b505af1158015610116573d6000803e3d6000fd5b50505050506103648061012a6000396000f3fe6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030b565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b600060208284031215610304578081fd5b5035919050565b60008282101561032957634e487b7160e01b81526011600452602481fd5b50039056fea2646970667358221220329aa5c6335f8f0910faa13beca8f327a48fe5a58162aacc8c57f60eca0c960664736f6c63430008040033
|
6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030b565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b600060208284031215610304578081fd5b5035919050565b60008282101561032957634e487b7160e01b81526011600452602481fd5b50039056fea2646970667358221220329aa5c6335f8f0910faa13beca8f327a48fe5a58162aacc8c57f60eca0c960664736f6c63430008040033
| |
1 | 19,498,608 |
cde37f77f4ef427d5977a8f360c32ab366f637ed741515859447f8f9f6e5e8ff
|
73705b317e73e3920c7d060d28df9b9cb09d6ee13c8f8be8678a2748241e8af6
|
b71703b338ac88184695bf23b92026c773ae09e0
|
b71703b338ac88184695bf23b92026c773ae09e0
|
6639cbcfd178d6b23800937b0de0741bc16a8f8c
|
608060405234801562000010575f80fd5b50604051620031b4380380620031b483398181016040528101906200003691906200030f565b620000566200004a6200008a60201b60201c565b6200009160201b60201c565b8260019081620000679190620005d4565b508160029081620000799190620005d4565b5080600481905550505050620006b8565b5f33905090565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620001b3826200016b565b810181811067ffffffffffffffff82111715620001d557620001d46200017b565b5b80604052505050565b5f620001e962000152565b9050620001f78282620001a8565b919050565b5f67ffffffffffffffff8211156200021957620002186200017b565b5b62000224826200016b565b9050602081019050919050565b5f5b838110156200025057808201518184015260208101905062000233565b5f8484015250505050565b5f620002716200026b84620001fc565b620001de565b90508281526020810184848401111562000290576200028f62000167565b5b6200029d84828562000231565b509392505050565b5f82601f830112620002bc57620002bb62000163565b5b8151620002ce8482602086016200025b565b91505092915050565b5f819050919050565b620002eb81620002d7565b8114620002f6575f80fd5b50565b5f815190506200030981620002e0565b92915050565b5f805f606084860312156200032957620003286200015b565b5b5f84015167ffffffffffffffff8111156200034957620003486200015f565b5b6200035786828701620002a5565b935050602084015167ffffffffffffffff8111156200037b576200037a6200015f565b5b6200038986828701620002a5565b92505060406200039c86828701620002f9565b9150509250925092565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680620003f557607f821691505b6020821081036200040b576200040a620003b0565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026200046f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8262000432565b6200047b868362000432565b95508019841693508086168417925050509392505050565b5f819050919050565b5f620004bc620004b6620004b084620002d7565b62000493565b620002d7565b9050919050565b5f819050919050565b620004d7836200049c565b620004ef620004e682620004c3565b8484546200043e565b825550505050565b5f90565b62000505620004f7565b62000512818484620004cc565b505050565b5b8181101562000539576200052d5f82620004fb565b60018101905062000518565b5050565b601f8211156200058857620005528162000411565b6200055d8462000423565b810160208510156200056d578190505b620005856200057c8562000423565b83018262000517565b50505b505050565b5f82821c905092915050565b5f620005aa5f19846008026200058d565b1980831691505092915050565b5f620005c4838362000599565b9150826002028217905092915050565b620005df82620003a6565b67ffffffffffffffff811115620005fb57620005fa6200017b565b5b620006078254620003dd565b620006148282856200053d565b5f60209050601f8311600181146200064a575f841562000635578287015190505b620006418582620005b7565b865550620006b0565b601f1984166200065a8662000411565b5f5b8281101562000683578489015182556001820191506020850194506020810190506200065c565b86831015620006a357848901516200069f601f89168262000599565b8355505b6001600288020188555050505b505050505050565b612aee80620006c65f395ff3fe60806040526004361061013f575f3560e01c806370a08231116100b5578063a0712d681161006e578063a0712d6814610405578063a457c2d714610421578063a5500c301461045d578063a9059cbb14610485578063dd62ed3e146104c1578063f2fde38b146104fd5761013f565b806370a082311461031b578063715018a61461035757806381f4f3991461036d5780638da5cb5b1461039557806395d89b41146103bf5780639dc29fac146103e95761013f565b80631ee59f20116101075780631ee59f201461020b57806323b872dd14610235578063313ce56714610271578063395093511461029b578063616da87c146102d75780636a2eff37146102f35761013f565b806301e336671461014357806306fdde031461015f578063095ea7b31461018957806318160ddd146101c55780631b9a91a4146101ef575b5f80fd5b61015d60048036038101906101589190611d0c565b610525565b005b34801561016a575f80fd5b506101736106f7565b6040516101809190611de6565b60405180910390f35b348015610194575f80fd5b506101af60048036038101906101aa9190611e06565b610787565b6040516101bc9190611e5e565b60405180910390f35b3480156101d0575f80fd5b506101d96107a4565b6040516101e69190611e86565b60405180910390f35b61020960048036038101906102049190611eda565b6107ad565b005b348015610216575f80fd5b5061021f6108cf565b60405161022c9190611f27565b60405180910390f35b348015610240575f80fd5b5061025b60048036038101906102569190611d0c565b6108f4565b6040516102689190611e5e565b60405180910390f35b34801561027c575f80fd5b50610285610a37565b6040516102929190611f5b565b60405180910390f35b3480156102a6575f80fd5b506102c160048036038101906102bc9190611e06565b610a3b565b6040516102ce9190611e5e565b60405180910390f35b6102f160048036038101906102ec91906120b4565b610ae2565b005b3480156102fe575f80fd5b5061031960048036038101906103149190612120565b610b7f565b005b348015610326575f80fd5b50610341600480360381019061033c9190612120565b610c3e565b60405161034e9190611e86565b60405180910390f35b348015610362575f80fd5b5061036b610cdd565b005b348015610378575f80fd5b50610393600480360381019061038e9190612120565b610d64565b005b3480156103a0575f80fd5b506103a9610e23565b6040516103b69190611f27565b60405180910390f35b3480156103ca575f80fd5b506103d3610e4a565b6040516103e09190611de6565b60405180910390f35b61040360048036038101906103fe9190611e06565b610eda565b005b61041f600480360381019061041a919061214b565b610f64565b005b34801561042c575f80fd5b5061044760048036038101906104429190611e06565b610ff9565b6040516104549190611e5e565b60405180910390f35b348015610468575f80fd5b50610483600480360381019061047e919061214b565b6110df565b005b348015610490575f80fd5b506104ab60048036038101906104a69190611e06565b611165565b6040516104b89190611e5e565b60405180910390f35b3480156104cc575f80fd5b506104e760048036038101906104e29190612176565b611182565b6040516104f49190611e86565b60405180910390f35b348015610508575f80fd5b50610523600480360381019061051e9190612120565b611204565b005b61052d6112fa565b73ffffffffffffffffffffffffffffffffffffffff1661054b610e23565b73ffffffffffffffffffffffffffffffffffffffff16146105a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610598906121fe565b60405180910390fd5b5f8273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105db9190611f27565b602060405180830381865afa1580156105f6573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061061a9190612230565b90505f8203610627578091505b5f821180156106365750818110155b610675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066c906122a5565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85846040518363ffffffff1660e01b81526004016106b09291906122c3565b6020604051808303815f875af11580156106cc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106f09190612314565b5050505050565b6060600180546107069061236c565b80601f01602080910402602001604051908101604052809291908181526020018280546107329061236c565b801561077d5780601f106107545761010080835404028352916020019161077d565b820191905f5260205f20905b81548152906001019060200180831161076057829003601f168201915b5050505050905090565b5f61079a6107936112fa565b8484611301565b6001905092915050565b5f600354905090565b6107b56112fa565b73ffffffffffffffffffffffffffffffffffffffff166107d3610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610829576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610820906121fe565b60405180910390fd5b5f4790505f8203610838578091505b5f821180156108475750818110155b610886576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087d906123e6565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff166108fc8390811502906040515f60405180830381858888f193505050501580156108c9573d5f803e3d5ffd5b50505050565b60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146109f5576109548484846114c4565b5f60085f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f61099b6112fa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490506109eb856109e36112fa565b858403611301565b6001915050610a30565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2790612474565b60405180910390fd5b9392505050565b5f90565b5f610ad8610a476112fa565b848460085f610a546112fa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054610ad391906124bf565b611301565b6001905092915050565b5f5b8251811015610b7957828181518110610b0057610aff6124f2565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610b649190611e86565b60405180910390a38080600101915050610ae4565b50505050565b610b876112fa565b73ffffffffffffffffffffffffffffffffffffffff16610ba5610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610bfb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf2906121fe565b60405180910390fd5b8060055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f60065f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16610c97576004549050610cd8565b60075f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490505b919050565b610ce56112fa565b73ffffffffffffffffffffffffffffffffffffffff16610d03610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610d59576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d50906121fe565b60405180910390fd5b610d625f61180a565b565b610d6c6112fa565b73ffffffffffffffffffffffffffffffffffffffff16610d8a610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610de0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd7906121fe565b60405180910390fd5b8060055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060028054610e599061236c565b80601f0160208091040260200160405190810160405280929190818152602001828054610e859061236c565b8015610ed05780601f10610ea757610100808354040283529160200191610ed0565b820191905f5260205f20905b815481529060010190602001808311610eb357829003601f168201915b5050505050905090565b610ee26112fa565b73ffffffffffffffffffffffffffffffffffffffff16610f00610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610f56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4d906121fe565b60405180910390fd5b610f6082826118cb565b5050565b610f6c6112fa565b73ffffffffffffffffffffffffffffffffffffffff16610f8a610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610fe0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd7906121fe565b60405180910390fd5b5f610fe9610e23565b9050610ff58183611ad7565b5050565b5f8060085f6110066112fa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050828110156110c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b79061258f565b60405180910390fd5b6110d46110cb6112fa565b85858403611301565b600191505092915050565b6110e76112fa565b73ffffffffffffffffffffffffffffffffffffffff16611105610e23565b73ffffffffffffffffffffffffffffffffffffffff161461115b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611152906121fe565b60405180910390fd5b8060048190555050565b5f6111786111716112fa565b84846114c4565b6001905092915050565b5f60085f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b61120c6112fa565b73ffffffffffffffffffffffffffffffffffffffff1661122a610e23565b73ffffffffffffffffffffffffffffffffffffffff1614611280576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611277906121fe565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036112ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112e59061261d565b60405180910390fd5b6112f78161180a565b50565b5f33905090565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361136f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611366906126ab565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036113dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d490612739565b60405180910390fd5b8060085f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114b79190611e86565b60405180910390a3505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611532576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611529906127c7565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036115a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159790612855565b60405180910390fd5b60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361162f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162690612474565b60405180910390fd5b5f60075f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050818110156116b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116aa906128e3565b60405180910390fd5b81810360075f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508160075f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461174391906124bf565b92505081905550600160065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516117fc9190611e86565b60405180910390a350505050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611939576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193090612971565b60405180910390fd5b5f60075f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050818110156119bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b4906129ff565b60405180910390fd5b81810360075f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508160035f828254611a129190612a1d565b925050819055505f60065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611aca9190611e86565b60405180910390a3505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611b45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3c90612a9a565b60405180910390fd5b8060035f828254611b5691906124bf565b925050819055508060075f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f828254611ba991906124bf565b92505081905550600160065f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff165f73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051611c629190611e86565b60405180910390a35050565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f611ca882611c7f565b9050919050565b611cb881611c9e565b8114611cc2575f80fd5b50565b5f81359050611cd381611caf565b92915050565b5f819050919050565b611ceb81611cd9565b8114611cf5575f80fd5b50565b5f81359050611d0681611ce2565b92915050565b5f805f60608486031215611d2357611d22611c77565b5b5f611d3086828701611cc5565b9350506020611d4186828701611cc5565b9250506040611d5286828701611cf8565b9150509250925092565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015611d93578082015181840152602081019050611d78565b5f8484015250505050565b5f601f19601f8301169050919050565b5f611db882611d5c565b611dc28185611d66565b9350611dd2818560208601611d76565b611ddb81611d9e565b840191505092915050565b5f6020820190508181035f830152611dfe8184611dae565b905092915050565b5f8060408385031215611e1c57611e1b611c77565b5b5f611e2985828601611cc5565b9250506020611e3a85828601611cf8565b9150509250929050565b5f8115159050919050565b611e5881611e44565b82525050565b5f602082019050611e715f830184611e4f565b92915050565b611e8081611cd9565b82525050565b5f602082019050611e995f830184611e77565b92915050565b5f611ea982611c7f565b9050919050565b611eb981611e9f565b8114611ec3575f80fd5b50565b5f81359050611ed481611eb0565b92915050565b5f8060408385031215611ef057611eef611c77565b5b5f611efd85828601611ec6565b9250506020611f0e85828601611cf8565b9150509250929050565b611f2181611c9e565b82525050565b5f602082019050611f3a5f830184611f18565b92915050565b5f60ff82169050919050565b611f5581611f40565b82525050565b5f602082019050611f6e5f830184611f4c565b92915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b611fae82611d9e565b810181811067ffffffffffffffff82111715611fcd57611fcc611f78565b5b80604052505050565b5f611fdf611c6e565b9050611feb8282611fa5565b919050565b5f67ffffffffffffffff82111561200a57612009611f78565b5b602082029050602081019050919050565b5f80fd5b5f61203161202c84611ff0565b611fd6565b905080838252602082019050602084028301858111156120545761205361201b565b5b835b8181101561207d57806120698882611cc5565b845260208401935050602081019050612056565b5050509392505050565b5f82601f83011261209b5761209a611f74565b5b81356120ab84826020860161201f565b91505092915050565b5f805f606084860312156120cb576120ca611c77565b5b5f6120d886828701611cc5565b935050602084013567ffffffffffffffff8111156120f9576120f8611c7b565b5b61210586828701612087565b925050604061211686828701611cf8565b9150509250925092565b5f6020828403121561213557612134611c77565b5b5f61214284828501611cc5565b91505092915050565b5f602082840312156121605761215f611c77565b5b5f61216d84828501611cf8565b91505092915050565b5f806040838503121561218c5761218b611c77565b5b5f61219985828601611cc5565b92505060206121aa85828601611cc5565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725f82015250565b5f6121e8602083611d66565b91506121f3826121b4565b602082019050919050565b5f6020820190508181035f830152612215816121dc565b9050919050565b5f8151905061222a81611ce2565b92915050565b5f6020828403121561224557612244611c77565b5b5f6122528482850161221c565b91505092915050565b7f62616420616d6f756e74000000000000000000000000000000000000000000005f82015250565b5f61228f600a83611d66565b915061229a8261225b565b602082019050919050565b5f6020820190508181035f8301526122bc81612283565b9050919050565b5f6040820190506122d65f830185611f18565b6122e36020830184611e77565b9392505050565b6122f381611e44565b81146122fd575f80fd5b50565b5f8151905061230e816122ea565b92915050565b5f6020828403121561232957612328611c77565b5b5f61233684828501612300565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061238357607f821691505b6020821081036123965761239561233f565b5b50919050565b7f6e6f2062616c616e6365000000000000000000000000000000000000000000005f82015250565b5f6123d0600a83611d66565b91506123db8261239c565b602082019050919050565b5f6020820190508181035f8301526123fd816123c4565b9050919050565b7f4572726f723a20546f6b656e2063616e206f6e6c7920626520747261646564205f8201527f6f6e204f70656e64616f2e697300000000000000000000000000000000000000602082015250565b5f61245e602d83611d66565b915061246982612404565b604082019050919050565b5f6020820190508181035f83015261248b81612452565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6124c982611cd9565b91506124d483611cd9565b92508282019050808211156124ec576124eb612492565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f775f8201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b5f612579602583611d66565b91506125848261251f565b604082019050919050565b5f6020820190508181035f8301526125a68161256d565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b5f612607602683611d66565b9150612612826125ad565b604082019050919050565b5f6020820190508181035f830152612634816125fb565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f206164645f8201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b5f612695602483611d66565b91506126a08261263b565b604082019050919050565b5f6020820190508181035f8301526126c281612689565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f2061646472655f8201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b5f612723602283611d66565b915061272e826126c9565b604082019050919050565b5f6020820190508181035f83015261275081612717565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f2061645f8201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b5f6127b1602583611d66565b91506127bc82612757565b604082019050919050565b5f6020820190508181035f8301526127de816127a5565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f20616464725f8201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b5f61283f602383611d66565b915061284a826127e5565b604082019050919050565b5f6020820190508181035f83015261286c81612833565b9050919050565b7f45524332303a207472616e7366657220616d6f756e74206578636565647320625f8201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b5f6128cd602683611d66565b91506128d882612873565b604082019050919050565b5f6020820190508181035f8301526128fa816128c1565b9050919050565b7f45524332303a206275726e2066726f6d20746865207a65726f206164647265735f8201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b5f61295b602183611d66565b915061296682612901565b604082019050919050565b5f6020820190508181035f8301526129888161294f565b9050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e5f8201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b5f6129e9602283611d66565b91506129f48261298f565b604082019050919050565b5f6020820190508181035f830152612a16816129dd565b9050919050565b5f612a2782611cd9565b9150612a3283611cd9565b9250828203905081811115612a4a57612a49612492565b5b92915050565b7f45524332303a206d696e7420746f20746865207a65726f2061646472657373005f82015250565b5f612a84601f83611d66565b9150612a8f82612a50565b602082019050919050565b5f6020820190508181035f830152612ab181612a78565b905091905056fea264697066735822122044bed58d00aef6e6c091efaec842ed74899b0c5517a7101e0eb2947982f78d2b64736f6c63430008180033000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000c8000000000000000000000000000000000000000000000000000000000000001a436c61696d20243230304b206174204554483230306b2e636f6d000000000000000000000000000000000000000000000000000000000000000000000000001a436c61696d20243230304b206174204554483230306b2e636f6d000000000000
|
60806040526004361061013f575f3560e01c806370a08231116100b5578063a0712d681161006e578063a0712d6814610405578063a457c2d714610421578063a5500c301461045d578063a9059cbb14610485578063dd62ed3e146104c1578063f2fde38b146104fd5761013f565b806370a082311461031b578063715018a61461035757806381f4f3991461036d5780638da5cb5b1461039557806395d89b41146103bf5780639dc29fac146103e95761013f565b80631ee59f20116101075780631ee59f201461020b57806323b872dd14610235578063313ce56714610271578063395093511461029b578063616da87c146102d75780636a2eff37146102f35761013f565b806301e336671461014357806306fdde031461015f578063095ea7b31461018957806318160ddd146101c55780631b9a91a4146101ef575b5f80fd5b61015d60048036038101906101589190611d0c565b610525565b005b34801561016a575f80fd5b506101736106f7565b6040516101809190611de6565b60405180910390f35b348015610194575f80fd5b506101af60048036038101906101aa9190611e06565b610787565b6040516101bc9190611e5e565b60405180910390f35b3480156101d0575f80fd5b506101d96107a4565b6040516101e69190611e86565b60405180910390f35b61020960048036038101906102049190611eda565b6107ad565b005b348015610216575f80fd5b5061021f6108cf565b60405161022c9190611f27565b60405180910390f35b348015610240575f80fd5b5061025b60048036038101906102569190611d0c565b6108f4565b6040516102689190611e5e565b60405180910390f35b34801561027c575f80fd5b50610285610a37565b6040516102929190611f5b565b60405180910390f35b3480156102a6575f80fd5b506102c160048036038101906102bc9190611e06565b610a3b565b6040516102ce9190611e5e565b60405180910390f35b6102f160048036038101906102ec91906120b4565b610ae2565b005b3480156102fe575f80fd5b5061031960048036038101906103149190612120565b610b7f565b005b348015610326575f80fd5b50610341600480360381019061033c9190612120565b610c3e565b60405161034e9190611e86565b60405180910390f35b348015610362575f80fd5b5061036b610cdd565b005b348015610378575f80fd5b50610393600480360381019061038e9190612120565b610d64565b005b3480156103a0575f80fd5b506103a9610e23565b6040516103b69190611f27565b60405180910390f35b3480156103ca575f80fd5b506103d3610e4a565b6040516103e09190611de6565b60405180910390f35b61040360048036038101906103fe9190611e06565b610eda565b005b61041f600480360381019061041a919061214b565b610f64565b005b34801561042c575f80fd5b5061044760048036038101906104429190611e06565b610ff9565b6040516104549190611e5e565b60405180910390f35b348015610468575f80fd5b50610483600480360381019061047e919061214b565b6110df565b005b348015610490575f80fd5b506104ab60048036038101906104a69190611e06565b611165565b6040516104b89190611e5e565b60405180910390f35b3480156104cc575f80fd5b506104e760048036038101906104e29190612176565b611182565b6040516104f49190611e86565b60405180910390f35b348015610508575f80fd5b50610523600480360381019061051e9190612120565b611204565b005b61052d6112fa565b73ffffffffffffffffffffffffffffffffffffffff1661054b610e23565b73ffffffffffffffffffffffffffffffffffffffff16146105a1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610598906121fe565b60405180910390fd5b5f8273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016105db9190611f27565b602060405180830381865afa1580156105f6573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061061a9190612230565b90505f8203610627578091505b5f821180156106365750818110155b610675576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161066c906122a5565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85846040518363ffffffff1660e01b81526004016106b09291906122c3565b6020604051808303815f875af11580156106cc573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906106f09190612314565b5050505050565b6060600180546107069061236c565b80601f01602080910402602001604051908101604052809291908181526020018280546107329061236c565b801561077d5780601f106107545761010080835404028352916020019161077d565b820191905f5260205f20905b81548152906001019060200180831161076057829003601f168201915b5050505050905090565b5f61079a6107936112fa565b8484611301565b6001905092915050565b5f600354905090565b6107b56112fa565b73ffffffffffffffffffffffffffffffffffffffff166107d3610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610829576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610820906121fe565b60405180910390fd5b5f4790505f8203610838578091505b5f821180156108475750818110155b610886576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161087d906123e6565b60405180910390fd5b8273ffffffffffffffffffffffffffffffffffffffff166108fc8390811502906040515f60405180830381858888f193505050501580156108c9573d5f803e3d5ffd5b50505050565b60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16146109f5576109548484846114c4565b5f60085f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f61099b6112fa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490506109eb856109e36112fa565b858403611301565b6001915050610a30565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a2790612474565b60405180910390fd5b9392505050565b5f90565b5f610ad8610a476112fa565b848460085f610a546112fa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054610ad391906124bf565b611301565b6001905092915050565b5f5b8251811015610b7957828181518110610b0057610aff6124f2565b5b602002602001015173ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610b649190611e86565b60405180910390a38080600101915050610ae4565b50505050565b610b876112fa565b73ffffffffffffffffffffffffffffffffffffffff16610ba5610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610bfb576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf2906121fe565b60405180910390fd5b8060055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f60065f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff16610c97576004549050610cd8565b60075f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205490505b919050565b610ce56112fa565b73ffffffffffffffffffffffffffffffffffffffff16610d03610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610d59576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d50906121fe565b60405180910390fd5b610d625f61180a565b565b610d6c6112fa565b73ffffffffffffffffffffffffffffffffffffffff16610d8a610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610de0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd7906121fe565b60405180910390fd5b8060055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b606060028054610e599061236c565b80601f0160208091040260200160405190810160405280929190818152602001828054610e859061236c565b8015610ed05780601f10610ea757610100808354040283529160200191610ed0565b820191905f5260205f20905b815481529060010190602001808311610eb357829003601f168201915b5050505050905090565b610ee26112fa565b73ffffffffffffffffffffffffffffffffffffffff16610f00610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610f56576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4d906121fe565b60405180910390fd5b610f6082826118cb565b5050565b610f6c6112fa565b73ffffffffffffffffffffffffffffffffffffffff16610f8a610e23565b73ffffffffffffffffffffffffffffffffffffffff1614610fe0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fd7906121fe565b60405180910390fd5b5f610fe9610e23565b9050610ff58183611ad7565b5050565b5f8060085f6110066112fa565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050828110156110c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110b79061258f565b60405180910390fd5b6110d46110cb6112fa565b85858403611301565b600191505092915050565b6110e76112fa565b73ffffffffffffffffffffffffffffffffffffffff16611105610e23565b73ffffffffffffffffffffffffffffffffffffffff161461115b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611152906121fe565b60405180910390fd5b8060048190555050565b5f6111786111716112fa565b84846114c4565b6001905092915050565b5f60085f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b61120c6112fa565b73ffffffffffffffffffffffffffffffffffffffff1661122a610e23565b73ffffffffffffffffffffffffffffffffffffffff1614611280576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611277906121fe565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036112ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112e59061261d565b60405180910390fd5b6112f78161180a565b50565b5f33905090565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361136f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611366906126ab565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036113dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113d490612739565b60405180910390fd5b8060085f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040516114b79190611e86565b60405180910390a3505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611532576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611529906127c7565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036115a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159790612855565b60405180910390fd5b60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361162f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161162690612474565b60405180910390fd5b5f60075f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050818110156116b3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116aa906128e3565b60405180910390fd5b81810360075f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508160075f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825461174391906124bf565b92505081905550600160065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040516117fc9190611e86565b60405180910390a350505050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611939576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193090612971565b60405180910390fd5b5f60075f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050818110156119bd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119b4906129ff565b60405180910390fd5b81810360075f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508160035f828254611a129190612a1d565b925050819055505f60065f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055505f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051611aca9190611e86565b60405180910390a3505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603611b45576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b3c90612a9a565b60405180910390fd5b8060035f828254611b5691906124bf565b925050819055508060075f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f828254611ba991906124bf565b92505081905550600160065f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff165f73ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051611c629190611e86565b60405180910390a35050565b5f604051905090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f611ca882611c7f565b9050919050565b611cb881611c9e565b8114611cc2575f80fd5b50565b5f81359050611cd381611caf565b92915050565b5f819050919050565b611ceb81611cd9565b8114611cf5575f80fd5b50565b5f81359050611d0681611ce2565b92915050565b5f805f60608486031215611d2357611d22611c77565b5b5f611d3086828701611cc5565b9350506020611d4186828701611cc5565b9250506040611d5286828701611cf8565b9150509250925092565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015611d93578082015181840152602081019050611d78565b5f8484015250505050565b5f601f19601f8301169050919050565b5f611db882611d5c565b611dc28185611d66565b9350611dd2818560208601611d76565b611ddb81611d9e565b840191505092915050565b5f6020820190508181035f830152611dfe8184611dae565b905092915050565b5f8060408385031215611e1c57611e1b611c77565b5b5f611e2985828601611cc5565b9250506020611e3a85828601611cf8565b9150509250929050565b5f8115159050919050565b611e5881611e44565b82525050565b5f602082019050611e715f830184611e4f565b92915050565b611e8081611cd9565b82525050565b5f602082019050611e995f830184611e77565b92915050565b5f611ea982611c7f565b9050919050565b611eb981611e9f565b8114611ec3575f80fd5b50565b5f81359050611ed481611eb0565b92915050565b5f8060408385031215611ef057611eef611c77565b5b5f611efd85828601611ec6565b9250506020611f0e85828601611cf8565b9150509250929050565b611f2181611c9e565b82525050565b5f602082019050611f3a5f830184611f18565b92915050565b5f60ff82169050919050565b611f5581611f40565b82525050565b5f602082019050611f6e5f830184611f4c565b92915050565b5f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b611fae82611d9e565b810181811067ffffffffffffffff82111715611fcd57611fcc611f78565b5b80604052505050565b5f611fdf611c6e565b9050611feb8282611fa5565b919050565b5f67ffffffffffffffff82111561200a57612009611f78565b5b602082029050602081019050919050565b5f80fd5b5f61203161202c84611ff0565b611fd6565b905080838252602082019050602084028301858111156120545761205361201b565b5b835b8181101561207d57806120698882611cc5565b845260208401935050602081019050612056565b5050509392505050565b5f82601f83011261209b5761209a611f74565b5b81356120ab84826020860161201f565b91505092915050565b5f805f606084860312156120cb576120ca611c77565b5b5f6120d886828701611cc5565b935050602084013567ffffffffffffffff8111156120f9576120f8611c7b565b5b61210586828701612087565b925050604061211686828701611cf8565b9150509250925092565b5f6020828403121561213557612134611c77565b5b5f61214284828501611cc5565b91505092915050565b5f602082840312156121605761215f611c77565b5b5f61216d84828501611cf8565b91505092915050565b5f806040838503121561218c5761218b611c77565b5b5f61219985828601611cc5565b92505060206121aa85828601611cc5565b9150509250929050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65725f82015250565b5f6121e8602083611d66565b91506121f3826121b4565b602082019050919050565b5f6020820190508181035f830152612215816121dc565b9050919050565b5f8151905061222a81611ce2565b92915050565b5f6020828403121561224557612244611c77565b5b5f6122528482850161221c565b91505092915050565b7f62616420616d6f756e74000000000000000000000000000000000000000000005f82015250565b5f61228f600a83611d66565b915061229a8261225b565b602082019050919050565b5f6020820190508181035f8301526122bc81612283565b9050919050565b5f6040820190506122d65f830185611f18565b6122e36020830184611e77565b9392505050565b6122f381611e44565b81146122fd575f80fd5b50565b5f8151905061230e816122ea565b92915050565b5f6020828403121561232957612328611c77565b5b5f61233684828501612300565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061238357607f821691505b6020821081036123965761239561233f565b5b50919050565b7f6e6f2062616c616e6365000000000000000000000000000000000000000000005f82015250565b5f6123d0600a83611d66565b91506123db8261239c565b602082019050919050565b5f6020820190508181035f8301526123fd816123c4565b9050919050565b7f4572726f723a20546f6b656e2063616e206f6e6c7920626520747261646564205f8201527f6f6e204f70656e64616f2e697300000000000000000000000000000000000000602082015250565b5f61245e602d83611d66565b915061246982612404565b604082019050919050565b5f6020820190508181035f83015261248b81612452565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6124c982611cd9565b91506124d483611cd9565b92508282019050808211156124ec576124eb612492565b5b92915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f775f8201527f207a65726f000000000000000000000000000000000000000000000000000000602082015250565b5f612579602583611d66565b91506125848261251f565b604082019050919050565b5f6020820190508181035f8301526125a68161256d565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f20615f8201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b5f612607602683611d66565b9150612612826125ad565b604082019050919050565b5f6020820190508181035f830152612634816125fb565b9050919050565b7f45524332303a20617070726f76652066726f6d20746865207a65726f206164645f8201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b5f612695602483611d66565b91506126a08261263b565b604082019050919050565b5f6020820190508181035f8301526126c281612689565b9050919050565b7f45524332303a20617070726f766520746f20746865207a65726f2061646472655f8201527f7373000000000000000000000000000000000000000000000000000000000000602082015250565b5f612723602283611d66565b915061272e826126c9565b604082019050919050565b5f6020820190508181035f83015261275081612717565b9050919050565b7f45524332303a207472616e736665722066726f6d20746865207a65726f2061645f8201527f6472657373000000000000000000000000000000000000000000000000000000602082015250565b5f6127b1602583611d66565b91506127bc82612757565b604082019050919050565b5f6020820190508181035f8301526127de816127a5565b9050919050565b7f45524332303a207472616e7366657220746f20746865207a65726f20616464725f8201527f6573730000000000000000000000000000000000000000000000000000000000602082015250565b5f61283f602383611d66565b915061284a826127e5565b604082019050919050565b5f6020820190508181035f83015261286c81612833565b9050919050565b7f45524332303a207472616e7366657220616d6f756e74206578636565647320625f8201527f616c616e63650000000000000000000000000000000000000000000000000000602082015250565b5f6128cd602683611d66565b91506128d882612873565b604082019050919050565b5f6020820190508181035f8301526128fa816128c1565b9050919050565b7f45524332303a206275726e2066726f6d20746865207a65726f206164647265735f8201527f7300000000000000000000000000000000000000000000000000000000000000602082015250565b5f61295b602183611d66565b915061296682612901565b604082019050919050565b5f6020820190508181035f8301526129888161294f565b9050919050565b7f45524332303a206275726e20616d6f756e7420657863656564732062616c616e5f8201527f6365000000000000000000000000000000000000000000000000000000000000602082015250565b5f6129e9602283611d66565b91506129f48261298f565b604082019050919050565b5f6020820190508181035f830152612a16816129dd565b9050919050565b5f612a2782611cd9565b9150612a3283611cd9565b9250828203905081811115612a4a57612a49612492565b5b92915050565b7f45524332303a206d696e7420746f20746865207a65726f2061646472657373005f82015250565b5f612a84601f83611d66565b9150612a8f82612a50565b602082019050919050565b5f6020820190508181035f830152612ab181612a78565b905091905056fea264697066735822122044bed58d00aef6e6c091efaec842ed74899b0c5517a7101e0eb2947982f78d2b64736f6c63430008180033
| |
1 | 19,498,619 |
093422bc29da4ddedfedf0de37a4c3e199aee86a979f7d5a67f4a6f63b5905a1
|
9eb5e51422f1a21376903745d5c2bb069ad02412b9c91fac39d1dba9e73db16a
|
d7bdff042c48ed3d5dd527301e8001d5860ae717
|
d7bdff042c48ed3d5dd527301e8001d5860ae717
|
3a5475f23341723709eac54afc22faab8a21e23a
|
61054d80600a3d393df35f5f355f1a8060f0141561042857565b610100565b610258565b6102dc565b6103ee565b610496565b610360560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b6103a55600000000000000000000005b806021013560f01c80826025015f375f5f825f5f73111111125421ca6dc452d289314280a0f8842a655af11561054657816005013560901c826003013560f01c3560601c7f70a08231000000000000000000000000000000000000000000000000000000005f523060045260205f60245f5f855af11561054657505f51034681035f52505f51826023013560f01c808360250185015f3760205f825e805f528201602601830191504682033560f81c5f828160020285013560f01c5246018181111561049e57506002026002019050015f5180515f525f5f825f5f73111111125421ca6dc452d289314280a0f8842a655af115610546578246013560f01c3560601c7f70a08231000000000000000000000000000000000000000000000000000000005f523060045260205f60245f5f855af11561054657505f51836013013560901c1015610546575090508035801561054b575f1a565b7f095ea7b3000000000000000000000000000000000000000000000000000000005f5273111111125421ca6dc452d289314280a0f8842a656004528046013560f01c3560601c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6024525f5f60445f5f855af150506003018035801561054b575f1a565b7f095ea7b3000000000000000000000000000000000000000000000000000000005f527387870bca3f3fd6335c3f4ce8392d69350b4fa4e26004528046013560f01c3560601c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6024525f5f60445f5f855af150506003018035801561054b575f1a565b7fa9059cbb000000000000000000000000000000000000000000000000000000005f5233600452806015013560245246013560601c5f5f60445f5f855af11561054657005b73ba12222222228d8ba445958a75a0704d566bf2c83314156105465773d7bdff042c48ed3d5dd527301e8001d5860ae71732141561054657610164355f1a610164010180355f1a565b7fa9059cbb000000000000000000000000000000000000000000000000000000005f523360045260e4356024525f5f60645f5f60a4355af1005b80601b1461044e5773d7bdff042c48ed3d5dd527301e8001d5860ae71733141561054657565b7387870bca3f3fd6335c3f4ce8392d69350b4fa4e23314156105465773d7bdff042c48ed3d5dd527301e8001d5860ae717321415610546575f60c4355f1a60c4010180355f1a565b465f5260205ff35b828160020285013560f01c5246018181111561049e57506002026002019050015f5180515f525f5f825f5f73111111125421ca6dc452d289314280a0f8842a655af115610546578246013560f01c3560601c7f70a08231000000000000000000000000000000000000000000000000000000005f523060045260205f60245f5f855af11561054657505f51836013013560901c1015610546575090508035801561054b575f1a565b600380fd5b00
|
5f5f355f1a8060f0141561042857565b610100565b610258565b6102dc565b6103ee565b610496565b610360560000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005b6103a55600000000000000000000005b806021013560f01c80826025015f375f5f825f5f73111111125421ca6dc452d289314280a0f8842a655af11561054657816005013560901c826003013560f01c3560601c7f70a08231000000000000000000000000000000000000000000000000000000005f523060045260205f60245f5f855af11561054657505f51034681035f52505f51826023013560f01c808360250185015f3760205f825e805f528201602601830191504682033560f81c5f828160020285013560f01c5246018181111561049e57506002026002019050015f5180515f525f5f825f5f73111111125421ca6dc452d289314280a0f8842a655af115610546578246013560f01c3560601c7f70a08231000000000000000000000000000000000000000000000000000000005f523060045260205f60245f5f855af11561054657505f51836013013560901c1015610546575090508035801561054b575f1a565b7f095ea7b3000000000000000000000000000000000000000000000000000000005f5273111111125421ca6dc452d289314280a0f8842a656004528046013560f01c3560601c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6024525f5f60445f5f855af150506003018035801561054b575f1a565b7f095ea7b3000000000000000000000000000000000000000000000000000000005f527387870bca3f3fd6335c3f4ce8392d69350b4fa4e26004528046013560f01c3560601c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6024525f5f60445f5f855af150506003018035801561054b575f1a565b7fa9059cbb000000000000000000000000000000000000000000000000000000005f5233600452806015013560245246013560601c5f5f60445f5f855af11561054657005b73ba12222222228d8ba445958a75a0704d566bf2c83314156105465773d7bdff042c48ed3d5dd527301e8001d5860ae71732141561054657610164355f1a610164010180355f1a565b7fa9059cbb000000000000000000000000000000000000000000000000000000005f523360045260e4356024525f5f60645f5f60a4355af1005b80601b1461044e5773d7bdff042c48ed3d5dd527301e8001d5860ae71733141561054657565b7387870bca3f3fd6335c3f4ce8392d69350b4fa4e23314156105465773d7bdff042c48ed3d5dd527301e8001d5860ae717321415610546575f60c4355f1a60c4010180355f1a565b465f5260205ff35b828160020285013560f01c5246018181111561049e57506002026002019050015f5180515f525f5f825f5f73111111125421ca6dc452d289314280a0f8842a655af115610546578246013560f01c3560601c7f70a08231000000000000000000000000000000000000000000000000000000005f523060045260205f60245f5f855af11561054657505f51836013013560901c1015610546575090508035801561054b575f1a565b600380fd5b00
| |
1 | 19,498,622 |
3ee20101c595772724ee95accd33fc71042f9102261f26166b1653820a88771d
|
a2d12303c66ed5c8227a6a0c3f599775a7d22e1cd6f3e7ba2e069bc466b320e3
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
30967dc216926e704fc051b2b25564721f4b0282
|
60806040523480156200001157600080fd5b50604051620008d4380380620008d48339810160408190526200003491620002b4565b7fc95dbb57fc82aaa5d8e58ffb65cff40b4b5c1fdd2d50da43d760cea45ea2304f60001b816200006f828260200151620000c660201b60201c565b60208101516040517fbea766d03fa1efd3f81cc8634d08320bc62bb0ed9234ac59bbaafa5893fb6b1391620000a89133913091620003c2565b60405180910390a18051620000bd906200010d565b505050620004d8565b80516020820120828114620000fd5760405163074fe10f60e41b815260048101849052602481018290526044015b60405180910390fd5b6200010882620001a4565b505050565b60408051600080825260208201818152828401938490526331a66b6560e01b90935291829182916001600160a01b038616916331a66b65916200015591906044820162000431565b6060604051808303816000875af115801562000175573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200019b919062000468565b50505050505050565b620001af81620001d4565b620001d15780604051630c89984b60e31b8152600401620000f49190620004bc565b50565b6000600882511015620001e957506000919050565b50600801516001600160401b031667ff0a89c674ee78741490565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156200023f576200023f62000204565b60405290565b604051601f8201601f191681016001600160401b038111828210171562000270576200027062000204565b604052919050565b6001600160a01b0381168114620001d157600080fd5b60005b83811015620002ab57818101518382015260200162000291565b50506000910152565b60006020808385031215620002c857600080fd5b82516001600160401b0380821115620002e057600080fd5b9084019060408287031215620002f557600080fd5b620002ff6200021a565b82516200030c8162000278565b815282840151828111156200032057600080fd5b80840193505086601f8401126200033657600080fd5b8251828111156200034b576200034b62000204565b6200035f601f8201601f1916860162000245565b925080835287858286010111156200037657600080fd5b62000387818685018787016200028e565b5092830152509392505050565b60008151808452620003ae8160208601602086016200028e565b601f01601f19169290920160200192915050565b60018060a01b0384168152826020820152606060408201526000620003eb606083018462000394565b95945050505050565b600081518084526020808501945080840160005b83811015620004265781518752958201959082019060010162000408565b509495945050505050565b6060815260006060820152608060208201526000620004546080830185620003f4565b8281036040840152620003eb8185620003f4565b6000806000606084860312156200047e57600080fd5b83516200048b8162000278565b60208501519093506200049e8162000278565b6040850151909250620004b18162000278565b809150509250925092565b602081526000620004d1602083018462000394565b9392505050565b6103ec80620004e86000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80630fbe133c14610030575b600080fd5b61004361003e3660046102e8565b61006c565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b60008373ffffffffffffffffffffffffffffffffffffffff163b6000036100bf576040517ff432283200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006100ca8561021c565b6040805133815273ffffffffffffffffffffffffffffffffffffffff888116602083015283168183015290519192507f274b5f356634f32a865af65bdc3d8205939d9413d75e1f367652e4f3b24d0c3a919081900360600190a16040517f439fab910000000000000000000000000000000000000000000000000000000081527fe0e57eda3f08f2a93bbe980d3df7f9c315eac41181f58b865a13d917fe769fc39073ffffffffffffffffffffffffffffffffffffffff83169063439fab919061019a9088908890600401610386565b6020604051808303816000875af11580156101b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101dd91906103d3565b14610214576040517f19b991a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f0905073ffffffffffffffffffffffffffffffffffffffff81166102e3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015260640160405180910390fd5b919050565b6000806000604084860312156102fd57600080fd5b833573ffffffffffffffffffffffffffffffffffffffff8116811461032157600080fd5b9250602084013567ffffffffffffffff8082111561033e57600080fd5b818601915086601f83011261035257600080fd5b81358181111561036157600080fd5b87602082850101111561037357600080fd5b6020830194508093505050509250925092565b60208152816020820152818360408301376000818301604090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101919050565b6000602082840312156103e557600080fd5b5051919050560000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d039bc83136011e3b6017cda4d4d597865b13bed000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001b6ff0a89c674ee7874a500590180cd543d4fc33010fd2b2873178a60606d85e85006be0650874b7c0523c78eec73698afadfb9b4094eda244415039b3feebd7777efecd7af48eacc938bae79999834331a75b9959ad06a508f7986d175044258742e1a451ad2e24060a64c8e964fa819b21d1da1e39cb0864d9120e0f697dbc5e810e5c8fa84cea6a5d254bac4acd042ac70ce0ccfe389d1fb186934af97f22d6824d5be54219f29dca93802c2b92788a59294f39d363a83bce00df149c56d6c5951d9a9c58fc44c4b92a0e4068a046e402a148100ad3d84fed617afbb3a5306dc19ba07a977d59f9f2075310e62b8ce302114b7e0de0f2439accbc43a0324e44175e043d24fba922af26e86b7641e802f68cd2c65db529e4ad89b2cf0416eb08d00d8c53c359e3996a01c8e9acd10b86677c255ff743b6440e76cf77279de8f2faf6a5c3efee0f203591531806ce0c329af8fe662c58dfb57cd39e2920d7fff863351fc8fb550d5de117e4e9a41a155dd4fe8c4e4fb0c15d06b685589f13438a9f6c2877d7a4baf779f2943be01011bffe5ffb4a3ff2cde02706170706c69636174696f6e2f6a736f6e03676465666c6174650462656e00000000000000000000
|
608060405234801561001057600080fd5b506004361061002b5760003560e01c80630fbe133c14610030575b600080fd5b61004361003e3660046102e8565b61006c565b60405173ffffffffffffffffffffffffffffffffffffffff909116815260200160405180910390f35b60008373ffffffffffffffffffffffffffffffffffffffff163b6000036100bf576040517ff432283200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006100ca8561021c565b6040805133815273ffffffffffffffffffffffffffffffffffffffff888116602083015283168183015290519192507f274b5f356634f32a865af65bdc3d8205939d9413d75e1f367652e4f3b24d0c3a919081900360600190a16040517f439fab910000000000000000000000000000000000000000000000000000000081527fe0e57eda3f08f2a93bbe980d3df7f9c315eac41181f58b865a13d917fe769fc39073ffffffffffffffffffffffffffffffffffffffff83169063439fab919061019a9088908890600401610386565b6020604051808303816000875af11580156101b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101dd91906103d3565b14610214576040517f19b991a800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b949350505050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f0905073ffffffffffffffffffffffffffffffffffffffff81166102e3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601660248201527f455243313136373a20637265617465206661696c656400000000000000000000604482015260640160405180910390fd5b919050565b6000806000604084860312156102fd57600080fd5b833573ffffffffffffffffffffffffffffffffffffffff8116811461032157600080fd5b9250602084013567ffffffffffffffff8082111561033e57600080fd5b818601915086601f83011261035257600080fd5b81358181111561036157600080fd5b87602082850101111561037357600080fd5b6020830194508093505050509250925092565b60208152816020820152818360408301376000818301604090810191909152601f9092017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0160101919050565b6000602082840312156103e557600080fd5b505191905056
|
{{
"language": "Solidity",
"sources": {
"lib/openzeppelin-contracts/contracts/proxy/Clones.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/Clones.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for\n * deploying minimal proxy contracts, also known as \"clones\".\n *\n * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies\n * > a minimal bytecode implementation that delegates all calls to a known, fixed address.\n *\n * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`\n * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the\n * deterministic method.\n *\n * _Available since v3.4._\n */\nlibrary Clones {\n /**\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n *\n * This function uses the create opcode, which should never revert.\n */\n function clone(address implementation) internal returns (address instance) {\n /// @solidity memory-safe-assembly\n assembly {\n // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes\n // of the `implementation` address with the bytecode before the address.\n mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))\n // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.\n mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))\n instance := create(0, 0x09, 0x37)\n }\n require(instance != address(0), \"ERC1167: create failed\");\n }\n\n /**\n * @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.\n *\n * This function uses the create2 opcode and a `salt` to deterministically deploy\n * the clone. Using the same `implementation` and `salt` multiple time will revert, since\n * the clones cannot be deployed twice at the same address.\n */\n function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {\n /// @solidity memory-safe-assembly\n assembly {\n // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes\n // of the `implementation` address with the bytecode before the address.\n mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))\n // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.\n mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))\n instance := create2(0, 0x09, 0x37, salt)\n }\n require(instance != address(0), \"ERC1167: create2 failed\");\n }\n\n /**\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n */\n function predictDeterministicAddress(\n address implementation,\n bytes32 salt,\n address deployer\n ) internal pure returns (address predicted) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(add(ptr, 0x38), deployer)\n mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)\n mstore(add(ptr, 0x14), implementation)\n mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)\n mstore(add(ptr, 0x58), salt)\n mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))\n predicted := keccak256(add(ptr, 0x43), 0x55)\n }\n }\n\n /**\n * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.\n */\n function predictDeterministicAddress(\n address implementation,\n bytes32 salt\n ) internal view returns (address predicted) {\n return predictDeterministicAddress(implementation, salt, address(this));\n }\n}\n"
},
"lib/rain.interpreter/lib/rain.metadata/src/IMetaV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// Thrown when hashed metadata does NOT match the expected hash.\n/// @param expectedHash The hash expected by the `IMetaV1` contract.\n/// @param actualHash The hash of the metadata seen by the `IMetaV1` contract.\nerror UnexpectedMetaHash(bytes32 expectedHash, bytes32 actualHash);\n\n/// Thrown when some bytes are expected to be rain meta and are not.\n/// @param unmeta the bytes that are not meta.\nerror NotRainMetaV1(bytes unmeta);\n\n/// @dev Randomly generated magic number with first bytes oned out.\n/// https://github.com/rainprotocol/specs/blob/main/metadata-v1.md\nuint64 constant META_MAGIC_NUMBER_V1 = 0xff0a89c674ee7874;\n\n/// @title IMetaV1\ninterface IMetaV1 {\n /// An onchain wrapper to carry arbitrary Rain metadata. Assigns the sender\n /// to the metadata so that tooling can easily drop/ignore data from unknown\n /// sources. As metadata is about something, the subject MUST be provided.\n /// @param sender The msg.sender.\n /// @param subject The entity that the metadata is about. MAY be the address\n /// of the emitting contract (as `uint256`) OR anything else. The\n /// interpretation of the subject is context specific, so will often be a\n /// hash of some data/thing that this metadata is about.\n /// @param meta Rain metadata V1 compliant metadata bytes.\n /// https://github.com/rainprotocol/specs/blob/main/metadata-v1.md\n event MetaV1(address sender, uint256 subject, bytes meta);\n}\n"
},
"lib/rain.interpreter/lib/rain.metadata/src/LibMeta.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IMetaV1.sol\";\n\n/// @title LibMeta\n/// @notice Need a place to put data that can be handled offchain like ABIs that\n/// IS NOT etherscan.\nlibrary LibMeta {\n /// Returns true if the metadata bytes are prefixed by the Rain meta magic\n /// number. DOES NOT attempt to validate the body of the metadata as offchain\n /// tooling will be required for this.\n /// @param meta_ The data that may be rain metadata.\n /// @return True if `meta_` is metadata, false otherwise.\n function isRainMetaV1(bytes memory meta_) internal pure returns (bool) {\n if (meta_.length < 8) return false;\n uint256 mask_ = type(uint64).max;\n uint256 magicNumber_ = META_MAGIC_NUMBER_V1;\n assembly (\"memory-safe\") {\n magicNumber_ := and(mload(add(meta_, 8)), mask_)\n }\n return magicNumber_ == META_MAGIC_NUMBER_V1;\n }\n\n /// Reverts if the provided `meta_` is NOT metadata according to\n /// `isRainMetaV1`.\n /// @param meta_ The metadata bytes to check.\n function checkMetaUnhashed(bytes memory meta_) internal pure {\n if (!isRainMetaV1(meta_)) {\n revert NotRainMetaV1(meta_);\n }\n }\n\n /// Reverts if the provided `meta_` is NOT metadata according to\n /// `isRainMetaV1` OR it does not match the expected hash of its data.\n /// @param meta_ The metadata to check.\n function checkMetaHashed(bytes32 expectedHash_, bytes memory meta_) internal pure {\n bytes32 actualHash_ = keccak256(meta_);\n if (expectedHash_ != actualHash_) {\n revert UnexpectedMetaHash(expectedHash_, actualHash_);\n }\n checkMetaUnhashed(meta_);\n }\n}\n"
},
"lib/rain.interpreter/src/abstract/DeployerDiscoverableMetaV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"rain.metadata/IMetaV1.sol\";\nimport \"rain.metadata/LibMeta.sol\";\nimport \"../lib/caller/LibDeployerDiscoverable.sol\";\n\n/// Construction config for `DeployerDiscoverableMetaV1`.\n/// @param deployer Deployer the calling contract will be discoverable under.\n/// @param meta MetaV1 data to emit before touching the deployer.\nstruct DeployerDiscoverableMetaV1ConstructionConfig {\n address deployer;\n bytes meta;\n}\n\n/// @title DeployerDiscoverableMetaV1\n/// @notice Upon construction, checks metadata against a known hash, emits it\n/// then touches the deployer (deploy an empty expression). This allows indexers\n/// to discover the metadata of the `DeployerDiscoverableMetaV1` contract by\n/// indexing the deployer. In this way the deployer acts as a pseudo-registry by\n/// virtue of it being a natural hub for interactions with calling contracts.\nabstract contract DeployerDiscoverableMetaV1 is IMetaV1 {\n constructor(bytes32 metaHash, DeployerDiscoverableMetaV1ConstructionConfig memory config) {\n LibMeta.checkMetaHashed(metaHash, config.meta);\n emit MetaV1(msg.sender, uint256(uint160(address(this))), config.meta);\n LibDeployerDiscoverable.touchDeployerV1(config.deployer);\n }\n}\n"
},
"lib/rain.interpreter/src/interface/IExpressionDeployerV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterV1.sol\";\n\nstring constant IERC1820_NAME_IEXPRESSION_DEPLOYER_V1 = \"IExpressionDeployerV1\";\n\n/// @title IExpressionDeployerV1\n/// @notice Companion to `IInterpreterV1` responsible for onchain static code\n/// analysis and deploying expressions. Each `IExpressionDeployerV1` is tightly\n/// coupled at the bytecode level to some interpreter that it knows how to\n/// analyse and deploy expressions for. The expression deployer can perform an\n/// integrity check \"dry run\" of candidate source code for the intepreter. The\n/// critical analysis/transformation includes:\n///\n/// - Enforcement of no out of bounds memory reads/writes\n/// - Calculation of memory required to eval the stack with a single allocation\n/// - Replacing index based opcodes with absolute interpreter function pointers\n/// - Enforcement that all opcodes and operands used exist and are valid\n///\n/// This analysis is highly sensitive to the specific implementation and position\n/// of all opcodes and function pointers as compiled into the interpreter. This\n/// is what makes the coupling between an interpreter and expression deployer\n/// so tight. Ideally all responsibilities would be handled by a single contract\n/// but this introduces code size issues quickly by roughly doubling the compiled\n/// logic of each opcode (half for the integrity check and half for evaluation).\n///\n/// Interpreters MUST assume that expression deployers are malicious and fail\n/// gracefully if the integrity check is corrupt/bypassed and/or function\n/// pointers are incorrect, etc. i.e. the interpreter MUST always return a stack\n/// from `eval` in a read only way or error. I.e. it is the expression deployer's\n/// responsibility to do everything it can to prevent undefined behaviour in the\n/// interpreter, and the interpreter's responsibility to handle the expression\n/// deployer completely failing to do so.\ninterface IExpressionDeployerV1 {\n /// This is the literal InterpreterOpMeta bytes to be used offchain to make\n /// sense of the opcodes in this interpreter deployment, as a human. For\n /// formats like json that make heavy use of boilerplate, repetition and\n /// whitespace, some kind of compression is recommended.\n /// @param sender The `msg.sender` providing the op meta.\n /// @param opMeta The raw binary data of the op meta. Maybe compressed data\n /// etc. and is intended for offchain consumption.\n event DISpair(address sender, address deployer, address interpreter, address store, bytes opMeta);\n\n /// Expressions are expected to be deployed onchain as immutable contract\n /// code with a first class address like any other contract or account.\n /// Technically this is optional in the sense that all the tools required to\n /// eval some expression and define all its opcodes are available as\n /// libraries.\n ///\n /// In practise there are enough advantages to deploying the sources directly\n /// onchain as contract data and loading them from the interpreter at eval:\n ///\n /// - Loading and storing binary data is gas efficient as immutable contract\n /// data\n /// - Expressions need to be immutable between their deploy time integrity\n /// check and runtime evaluation\n /// - Passing the address of an expression through calldata to an interpreter\n /// is cheaper than passing an entire expression through calldata\n /// - Conceptually a very simple approach, even if implementations like\n /// SSTORE2 are subtle under the hood\n ///\n /// The expression deployer MUST perform an integrity check of the source\n /// code before it puts the expression onchain at a known address. The\n /// integrity check MUST at a minimum (it is free to do additional static\n /// analysis) calculate the memory required to be allocated for the stack in\n /// total, and that no out of bounds memory reads/writes occur within this\n /// stack. A simple example of an invalid source would be one that pushes one\n /// value to the stack then attempts to pops two values, clearly we cannot\n /// remove more values than we added. The `IExpressionDeployerV1` MUST revert\n /// in the case of any integrity failure, all integrity checks MUST pass in\n /// order for the deployment to complete.\n ///\n /// Once the integrity check is complete the `IExpressionDeployerV1` MUST do\n /// any additional processing required by its paired interpreter.\n /// For example, the `IExpressionDeployerV1` MAY NEED to replace the indexed\n /// opcodes in the `ExpressionConfig` sources with real function pointers\n /// from the corresponding interpreter.\n ///\n /// @param sources Sources verbatim. These sources MUST be provided in their\n /// sequential/index opcode form as the deployment process will need to index\n /// into BOTH the integrity check and the final runtime function pointers.\n /// This will be emitted in an event for offchain processing to use the\n /// indexed opcode sources. The first N sources are considered entrypoints\n /// and will be integrity checked by the expression deployer against a\n /// starting stack height of 0. Non-entrypoint sources MAY be provided for\n /// internal use such as the `call` opcode but will NOT be integrity checked\n /// UNLESS entered by an opcode in an entrypoint.\n /// @param constants Constants verbatim. Constants are provided alongside\n /// sources rather than inline as it allows us to avoid variable length\n /// opcodes and can be more memory efficient if the same constant is\n /// referenced several times from the sources.\n /// @param minOutputs The first N sources on the state config are entrypoints\n /// to the expression where N is the length of the `minOutputs` array. Each\n /// item in the `minOutputs` array specifies the number of outputs that MUST\n /// be present on the final stack for an evaluation of each entrypoint. The\n /// minimum output for some entrypoint MAY be zero if the expectation is that\n /// the expression only applies checks and error logic. Non-entrypoint\n /// sources MUST NOT have a minimum outputs length specified.\n /// @return interpreter The interpreter the deployer believes it is qualified\n /// to perform integrity checks on behalf of.\n /// @return store The interpreter store the deployer believes is compatible\n /// with the interpreter.\n /// @return expression The address of the deployed onchain expression. MUST\n /// be valid according to all integrity checks the deployer is aware of.\n function deployExpression(bytes[] memory sources, uint256[] memory constants, uint256[] memory minOutputs)\n external\n returns (IInterpreterV1 interpreter, IInterpreterStoreV1 store, address expression);\n}\n"
},
"lib/rain.interpreter/src/interface/IInterpreterStoreV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterV1.sol\";\n\n/// A fully qualified namespace includes the interpreter's own namespacing logic\n/// IN ADDITION to the calling contract's requested `StateNamespace`. Typically\n/// this involves hashing the `msg.sender` into the `StateNamespace` so that each\n/// caller operates within its own disjoint state universe. Intepreters MUST NOT\n/// allow either the caller nor any expression/word to modify this directly on\n/// pain of potential key collisions on writes to the interpreter's own storage.\ntype FullyQualifiedNamespace is uint256;\n\nIInterpreterStoreV1 constant NO_STORE = IInterpreterStoreV1(address(0));\n\n/// @title IInterpreterStoreV1\n/// @notice Tracks state changes on behalf of an interpreter. A single store can\n/// handle state changes for many calling contracts, many interpreters and many\n/// expressions. The store is responsible for ensuring that applying these state\n/// changes is safe from key collisions with calls to `set` from different\n/// `msg.sender` callers. I.e. it MUST NOT be possible for a caller to modify the\n/// state changes associated with some other caller.\n///\n/// The store defines the shape of its own state changes, which is opaque to the\n/// calling contract. For example, some store may treat the list of state changes\n/// as a pairwise key/value set, and some other store may treat it as a literal\n/// list to be stored as-is.\n///\n/// Each interpreter decides for itself which store to use based on the\n/// compatibility of its own opcodes.\n///\n/// The store MUST assume the state changes have been corrupted by the calling\n/// contract due to bugs or malicious intent, and enforce state isolation between\n/// callers despite arbitrarily invalid state changes. The store MUST revert if\n/// it can detect invalid state changes, such as a key/value list having an odd\n/// number of items, but this MAY NOT be possible if the corruption is\n/// undetectable.\ninterface IInterpreterStoreV1 {\n /// Mutates the interpreter store in bulk. The bulk values are provided in\n /// the form of a `uint256[]` which can be treated e.g. as pairwise keys and\n /// values to be stored in a Solidity mapping. The `IInterpreterStoreV1`\n /// defines the meaning of the `uint256[]` for its own storage logic.\n ///\n /// @param namespace The unqualified namespace for the set that MUST be\n /// fully qualified by the `IInterpreterStoreV1` to prevent key collisions\n /// between callers. The fully qualified namespace forms a compound key with\n /// the keys for each value to set.\n /// @param kvs The list of changes to apply to the store's internal state.\n function set(StateNamespace namespace, uint256[] calldata kvs) external;\n\n /// Given a fully qualified namespace and key, return the associated value.\n /// Ostensibly the interpreter can use this to implement opcodes that read\n /// previously set values. The interpreter MUST apply the same qualification\n /// logic as the store that it uses to guarantee consistent round tripping of\n /// data and prevent malicious behaviours. Technically also allows onchain\n /// reads of any set value from any contract, not just interpreters, but in\n /// this case readers MUST be aware and handle inconsistencies between get\n /// and set while the state changes are still in memory in the calling\n /// context and haven't yet been persisted to the store.\n ///\n /// `IInterpreterStoreV1` uses the same fallback behaviour for unset keys as\n /// Solidity. Specifically, any UNSET VALUES SILENTLY FALLBACK TO `0`.\n /// @param namespace The fully qualified namespace to get a single value for.\n /// @param key The key to get the value for within the namespace.\n /// @return The value OR ZERO IF NOT SET.\n function get(FullyQualifiedNamespace namespace, uint256 key) external view returns (uint256);\n}\n"
},
"lib/rain.interpreter/src/interface/IInterpreterV1.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"./IInterpreterStoreV1.sol\";\n\n/// @dev The index of a source within a deployed expression that can be evaluated\n/// by an `IInterpreterV1`. MAY be an entrypoint or the index of a source called\n/// internally such as by the `call` opcode.\ntype SourceIndex is uint16;\n\n/// @dev Encoded information about a specific evaluation including the expression\n/// address onchain, entrypoint and expected return values.\ntype EncodedDispatch is uint256;\n\n/// @dev The namespace for state changes as requested by the calling contract.\n/// The interpreter MUST apply this namespace IN ADDITION to namespacing by\n/// caller etc.\ntype StateNamespace is uint256;\n\n/// @dev Additional bytes that can be used to configure a single opcode dispatch.\n/// Commonly used to specify the number of inputs to a variadic function such\n/// as addition or multiplication.\ntype Operand is uint256;\n\n/// @dev The default state namespace MUST be used when a calling contract has no\n/// particular opinion on or need for dynamic namespaces.\nStateNamespace constant DEFAULT_STATE_NAMESPACE = StateNamespace.wrap(0);\n\n/// @title IInterpreterV1\n/// Interface into a standard interpreter that supports:\n///\n/// - evaluating `view` logic deployed onchain by an `IExpressionDeployerV1`\n/// - receiving arbitrary `uint256[][]` supporting context to be made available\n/// to the evaluated logic\n/// - handling subsequent state changes in bulk in response to evaluated logic\n/// - namespacing state changes according to the caller's preferences to avoid\n/// unwanted key collisions\n/// - exposing its internal function pointers to support external precompilation\n/// of logic for more gas efficient runtime evaluation by the interpreter\n///\n/// The interface is designed to be stable across many versions and\n/// implementations of an interpreter, balancing minimalism with features\n/// required for a general purpose onchain interpreted compute environment.\n///\n/// The security model of an interpreter is that it MUST be resilient to\n/// malicious expressions even if they dispatch arbitrary internal function\n/// pointers during an eval. The interpreter MAY return garbage or exhibit\n/// undefined behaviour or error during an eval, _provided that no state changes\n/// are persisted_ e.g. in storage, such that only the caller that specifies the\n/// malicious expression can be negatively impacted by the result. In turn, the\n/// caller must guard itself against arbitrarily corrupt/malicious reverts and\n/// return values from any interpreter that it requests an expression from. And\n/// so on and so forth up to the externally owned account (EOA) who signs the\n/// transaction and agrees to a specific combination of contracts, expressions\n/// and interpreters, who can presumably make an informed decision about which\n/// ones to trust to get the job done.\n///\n/// The state changes for an interpreter are expected to be produces by an `eval`\n/// and passed to the `IInterpreterStoreV1` returned by the eval, as-is by the\n/// caller, after the caller has had an opportunity to apply their own\n/// intermediate logic such as reentrancy defenses against malicious\n/// interpreters. The interpreter is free to structure the state changes however\n/// it wants but MUST guard against the calling contract corrupting the changes\n/// between `eval` and `set`. For example a store could sandbox storage writes\n/// per-caller so that a malicious caller can only damage their own state\n/// changes, while honest callers respect, benefit from and are protected by the\n/// interpreter store's state change handling.\n///\n/// The two step eval-state model allows eval to be read-only which provides\n/// security guarantees for the caller such as no stateful reentrancy, either\n/// from the interpreter or some contract interface used by some word, while\n/// still allowing for storage writes. As the storage writes happen on the\n/// interpreter rather than the caller (c.f. delegate call) the caller DOES NOT\n/// need to trust the interpreter, which allows for permissionless selection of\n/// interpreters by end users. Delegate call always implies an admin key on the\n/// caller because the delegatee contract can write arbitrarily to the state of\n/// the delegator, which severely limits the generality of contract composition.\ninterface IInterpreterV1 {\n /// Exposes the function pointers as `uint16` values packed into a single\n /// `bytes` in the same order as they would be indexed into by opcodes. For\n /// example, if opcode `2` should dispatch function at position `0x1234` then\n /// the start of the returned bytes would be `0xXXXXXXXX1234` where `X` is\n /// a placeholder for the function pointers of opcodes `0` and `1`.\n ///\n /// `IExpressionDeployerV1` contracts use these function pointers to\n /// \"compile\" the expression into something that an interpreter can dispatch\n /// directly without paying gas to lookup the same at runtime. As the\n /// validity of any integrity check and subsequent dispatch is highly\n /// sensitive to both the function pointers and overall bytecode of the\n /// interpreter, `IExpressionDeployerV1` contracts SHOULD implement guards\n /// against accidentally being deployed onchain paired against an unknown\n /// interpreter. It is very easy for an apparent compatible pairing to be\n /// subtly and critically incompatible due to addition/removal/reordering of\n /// opcodes and compiler optimisations on the interpreter bytecode.\n ///\n /// This MAY return different values during construction vs. all other times\n /// after the interpreter has been successfully deployed onchain. DO NOT rely\n /// on function pointers reported during contract construction.\n function functionPointers() external view returns (bytes memory);\n\n /// The raison d'etre for an interpreter. Given some expression and per-call\n /// additional contextual data, produce a stack of results and a set of state\n /// changes that the caller MAY OPTIONALLY pass back to be persisted by a\n /// call to `IInterpreterStoreV1.set`.\n /// @param store The storage contract that the returned key/value pairs\n /// MUST be passed to IF the calling contract is in a non-static calling\n /// context. Static calling contexts MUST pass `address(0)`.\n /// @param namespace The state namespace that will be fully qualified by the\n /// interpreter at runtime in order to perform gets on the underlying store.\n /// MUST be the same namespace passed to the store by the calling contract\n /// when sending the resulting key/value items to storage.\n /// @param dispatch All the information required for the interpreter to load\n /// an expression, select an entrypoint and return the values expected by the\n /// caller. The interpreter MAY encode dispatches differently to\n /// `LibEncodedDispatch` but this WILL negatively impact compatibility for\n /// calling contracts that hardcode the encoding logic.\n /// @param context A 2-dimensional array of data that can be indexed into at\n /// runtime by the interpreter. The calling contract is responsible for\n /// ensuring the authenticity and completeness of context data. The\n /// interpreter MUST revert at runtime if an expression attempts to index\n /// into some context value that is not provided by the caller. This implies\n /// that context reads cannot be checked for out of bounds reads at deploy\n /// time, as the runtime context MAY be provided in a different shape to what\n /// the expression is expecting.\n /// Same as `eval` but allowing the caller to specify a namespace under which\n /// the state changes will be applied. The interpeter MUST ensure that keys\n /// will never collide across namespaces, even if, for example:\n ///\n /// - The calling contract is malicious and attempts to craft a collision\n /// with state changes from another contract\n /// - The expression is malicious and attempts to craft a collision with\n /// other expressions evaluated by the same calling contract\n ///\n /// A malicious entity MAY have access to significant offchain resources to\n /// attempt to precompute key collisions through brute force. The collision\n /// resistance of namespaces should be comparable or equivalent to the\n /// collision resistance of the hashing algorithms employed by the blockchain\n /// itself, such as the design of `mapping` in Solidity that hashes each\n /// nested key to produce a collision resistant compound key.\n /// @return stack The list of values produced by evaluating the expression.\n /// MUST NOT be longer than the maximum length specified by `dispatch`, if\n /// applicable.\n /// @return kvs A list of pairwise key/value items to be saved in the store.\n function eval(\n IInterpreterStoreV1 store,\n StateNamespace namespace,\n EncodedDispatch dispatch,\n uint256[][] calldata context\n ) external view returns (uint256[] memory stack, uint256[] memory kvs);\n}\n"
},
"lib/rain.interpreter/src/lib/caller/LibDeployerDiscoverable.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\nimport \"../../interface/IExpressionDeployerV1.sol\";\n\nlibrary LibDeployerDiscoverable {\n /// Hack so that some deployer will emit an event with the sender as the\n /// caller of `touchDeployer`. This MAY be needed by indexers such as\n /// subgraph that can only index events from the first moment they are aware\n /// of some contract. The deployer MUST be registered in ERC1820 registry\n /// before it is touched, THEN the caller meta MUST be emitted after the\n /// deployer is touched. This allows indexers such as subgraph to index the\n /// deployer, then see the caller, then see the caller's meta emitted in the\n /// same transaction.\n /// This is NOT required if ANY other expression is deployed in the same\n /// transaction as the caller meta, there only needs to be one expression on\n /// ANY deployer known to ERC1820.\n function touchDeployerV1(address deployer) internal {\n (IInterpreterV1 interpreter, IInterpreterStoreV1 store, address expression) =\n IExpressionDeployerV1(deployer).deployExpression(new bytes[](0), new uint256[](0), new uint256[](0));\n (interpreter);\n (store);\n (expression);\n }\n}\n"
},
"src/concrete/CloneFactory.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity =0.8.19;\n\nimport \"../interface/ICloneableV2.sol\";\nimport \"../interface/ICloneableFactoryV2.sol\";\nimport \"rain.interpreter/abstract/DeployerDiscoverableMetaV1.sol\";\nimport {Clones} from \"openzeppelin-contracts/contracts/proxy/Clones.sol\";\n\n/// Thrown when an implementation has zero code size which is always a mistake.\nerror ZeroImplementationCodeSize();\n\n/// Thrown when initialization fails.\nerror InitializationFailed();\n\n/// @dev Expected hash of the clone factory rain metadata.\nbytes32 constant CLONE_FACTORY_META_HASH = bytes32(0x1efc6b18f7f4aa4266a7801e1b611be09f1977d4e1a6c3c5c17ac27abf81027e);\n\n/// @title CloneFactory\n/// @notice A fairly minimal implementation of `ICloneableFactoryV2` and\n/// `DeployerDiscoverableMetaV1` that uses Open Zeppelin `Clones` to create\n/// EIP1167 clones of a reference bytecode. The reference bytecode MUST implement\n/// `ICloneableV2`.\ncontract CloneFactory is ICloneableFactoryV2, DeployerDiscoverableMetaV1 {\n constructor(DeployerDiscoverableMetaV1ConstructionConfig memory config)\n DeployerDiscoverableMetaV1(CLONE_FACTORY_META_HASH, config)\n {}\n\n /// @inheritdoc ICloneableFactoryV2\n function clone(address implementation, bytes calldata data) external returns (address) {\n // Explicitly check that the implementation has code. This is a common\n // mistake that will cause the clone to fail. Notably this catches the\n // case of address(0). This check is not strictly necessary as a zero\n // sized implementation will fail to initialize the child, but it gives\n // a better error message.\n if (implementation.code.length == 0) {\n revert ZeroImplementationCodeSize();\n }\n // Standard Open Zeppelin clone here.\n address child = Clones.clone(implementation);\n // NewClone does NOT include the data passed to initialize.\n // The implementation is responsible for emitting an event if it wants.\n emit NewClone(msg.sender, implementation, child);\n // Checking the return value of initialize is mandatory as per\n // ICloneableFactoryV2.\n if (ICloneableV2(child).initialize(data) != ICLONEABLE_V2_SUCCESS) {\n revert InitializationFailed();\n }\n return child;\n }\n}\n"
},
"src/interface/ICloneableFactoryV2.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @title ICloneableFactoryV2\n/// @notice A minimal interface to create proxy clones of a reference bytecode\n/// and emit events so that indexers can discover it. `ICloneableFactoryV2` knows\n/// nothing about the contracts that it clones, instead relying only on the\n/// minimal `ICloneableV2` interface being implemented on the reference bytecode.\ninterface ICloneableFactoryV2 {\n /// Emitted upon each `clone`.\n /// @param sender The `msg.sender` that called `clone`.\n /// @param implementation The reference bytecode to clone as a proxy.\n /// @param clone The address of the new proxy contract.\n event NewClone(address sender, address implementation, address clone);\n\n /// Clones an implementation using a proxy. EIP1167 proxy is recommended but\n /// the exact cloning procedure is not specified by this interface.\n ///\n /// The factory MUST call `ICloneableV2.initialize` atomically with the\n /// cloning process and MUST NOT call any other functions on the cloned proxy\n /// before `initialize` completes successfully. The factory MUST ONLY\n /// consider the clone to be successfully created if `initialize` returns the\n /// keccak256 hash of the string \"ICloneableV2.initialize\".\n ///\n /// MUST emit `NewClone` with the implementation and clone address.\n ///\n /// @param implementation The contract to clone.\n /// @param data As per `ICloneableV2`.\n /// @return New child contract address.\n function clone(address implementation, bytes calldata data) external returns (address);\n}\n"
},
"src/interface/ICloneableV2.sol": {
"content": "// SPDX-License-Identifier: CAL\npragma solidity ^0.8.18;\n\n/// @dev This hash MUST be returned when an `ICloneableV2` is successfully\n/// initialized.\nbytes32 constant ICLONEABLE_V2_SUCCESS = keccak256(\"ICloneableV2.initialize\");\n\n/// @title ICloneableV2\n/// @notice Interface for cloneable contracts that support initialization.\ninterface ICloneableV2 {\n /// Overloaded initialize function MUST revert with this error.\n error InitializeSignatureFn();\n\n /// Initialize is intended to work like constructors but for cloneable\n /// proxies. The `ICloneableV2` contract MUST ensure that initialize can NOT\n /// be called more than once. The `ICloneableV2` contract is designed to be\n /// deployed by an `ICloneableFactoryV2` but MUST NOT assume that it will be.\n /// It is possible for someone to directly deploy an `ICloneableV2` and fail\n /// to call initialize before other functions are called, and end users MAY\n /// NOT realise or know how to confirm a safe deployment state. The\n /// `ICloneableV2` MUST take appropriate measures to ensure that functions\n /// called before initialize are safe to do so, or revert.\n ///\n /// To be fully generic, `initilize` accepts `bytes` and so MUST ABI decode\n /// within the initialize function. This allows a single factory to service\n /// arbitrary cloneable proxies but also erases the type of the\n /// initialization config from the ABI. As tooling will inevitably require\n /// the ABI to be known, it is RECOMMENDED that the `ICloneableV2` contract\n /// implements a typed `initialize` function that overloads the generic\n /// `initialize(bytes)` function. This overloaded function MUST revert with\n /// `InitializeSignatureFn` always, so that it is NEVER accidentally called.\n /// This avoids complex and expensive delegate call style patterns where a\n /// typed overload has to call back to itself and preserve the sender,\n /// instead we force the caller to know the correct signature and call the\n /// correct function directly with encoded bytes.\n ///\n /// If initialization is successful the `ICloneableV2` MUST return the\n /// keccak256 hash of the string \"ICloneableV2.initialize\". This avoids false\n /// positives where a contract building a proxy, such as an\n /// `ICloneableFactoryV2`, may incorrectly believe that the clone has been\n /// initialized but the implementation doesn't support `ICloneableV2`.\n ///\n /// @dev The `ICloneableV2` interface is identical to `ICloneableV1` except\n /// that it returns a `bytes32` success hash.\n /// @param data The initialization data.\n /// @return success keccak256(\"ICloneableV2.initialize\") if successful.\n function initialize(bytes calldata data) external returns (bytes32 success);\n}\n"
}
},
"settings": {
"remappings": [
"caller/=lib/rain.interpreter/src/lib/caller/",
"compile/=lib/rain.interpreter/src/lib/compile/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"eval/=lib/rain.interpreter/src/lib/eval/",
"extern/=lib/rain.interpreter/src/lib/extern/",
"forge-std/=lib/forge-std/src/",
"integrity/=lib/rain.interpreter/src/lib/integrity/",
"ns/=lib/rain.interpreter/src/lib/ns/",
"op/=lib/rain.interpreter/src/lib/op/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts/contracts/",
"parse/=lib/rain.interpreter/src/lib/parse/",
"rain.datacontract/=lib/rain.interpreter/lib/rain.datacontract/src/",
"rain.extrospection/=lib/rain.extrospection/",
"rain.interpreter/=lib/rain.interpreter/src/",
"rain.metadata/=lib/rain.interpreter/lib/rain.metadata/src/",
"rain.solmem/=lib/rain.extrospection/lib/rain.solmem/src/",
"state/=lib/rain.interpreter/src/lib/state/"
],
"optimizer": {
"enabled": true,
"runs": 100000
},
"metadata": {
"bytecodeHash": "none",
"appendCBOR": false
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}
}}
|
1 | 19,498,622 |
3ee20101c595772724ee95accd33fc71042f9102261f26166b1653820a88771d
|
a2d12303c66ed5c8227a6a0c3f599775a7d22e1cd6f3e7ba2e069bc466b320e3
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
d039bc83136011e3b6017cda4d4d597865b13bed
|
b475c5cf1a74c6694e85bfb27406ebecc7954936
|
61004180600c6000396000f3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
| |
1 | 19,498,623 |
49b51cceec855c70059cf937a08c3496eee7fa4aa91f302edb4c0d5619df4075
|
1f448bb6b45cbefd03b81a744dc686855ed9b54f15db3b6ad07baa946e3be9b4
|
83f64339b809ba99da43d686d6be25a7e1ec458b
|
370f101ad006b10f3050ed2621924e72d1d77436
|
bd6de2a3423821177eadbc061506a75cbb2e1918
|
608060405234801561001057600080fd5b506040516101733803806101738339818101604052602081101561003357600080fd5b50516001600160a01b03811661007a5760405162461bcd60e51b815260040180806020018281038252602481526020018061014f6024913960400191505060405180910390fd5b600080546001600160a01b039092166001600160a01b031990921691909117905560a6806100a96000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e80606c573d6000fd5b3d6000f3fea265627a7a72315820afc7ba823ec040fc7a660b7ea56ea08c1700bd9a83d571988197738f2effaa5864736f6c634300050e0032496e76616c6964206d617374657220636f707920616464726573732070726f7669646564000000000000000000000000251bbe8c7abc2a1ca8d0b25fc1149abe6160a943
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e80606c573d6000fd5b3d6000f3fea265627a7a72315820afc7ba823ec040fc7a660b7ea56ea08c1700bd9a83d571988197738f2effaa5864736f6c634300050e0032
| |
1 | 19,498,630 |
ba73c0e465441f4f2a8a30a6a663756163920293766229c6e7f49896868a90e7
|
61d660256a018e62e6c44ac05ea01e75c9ede374f1200945533a3dbddf4d2853
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
8322851e3b73bddd74220d2db440ce488eb9aa4b
|
60806040523480156200001157600080fd5b5060405162005ff038038062005ff0833981016040819052620000349162000381565b7f15806dca3da7e4b733287624aabfe698211111fcbb278acb388821e77b141dbb60001b81818162000071828260200151620000d560201b60201c565b60208101516040517fbea766d03fa1efd3f81cc8634d08320bc62bb0ed9234ac59bbaafa5893fb6b1391620000aa91339130916200048f565b60405180910390a18051620000bf906200011c565b50620000cc9050620001b3565b505050620005a5565b805160208201208281146200010c5760405163074fe10f60e41b815260048101849052602481018290526044015b60405180910390fd5b620001178262000271565b505050565b60408051600080825260208201818152828401938490526331a66b6560e01b90935291829182916001600160a01b038616916331a66b659162000164919060448201620004fe565b6060604051808303816000875af115801562000184573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620001aa919062000535565b50505050505050565b600054610100900460ff16156200021d5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840162000103565b60005460ff908116146200026f576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b6200027c81620002a1565b6200029e5780604051630c89984b60e31b815260040162000103919062000589565b50565b6000600882511015620002b657506000919050565b50600801516001600160401b031667ff0a89c674ee78741490565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b03811182821017156200030c576200030c620002d1565b60405290565b604051601f8201601f191681016001600160401b03811182821017156200033d576200033d620002d1565b604052919050565b6001600160a01b03811681146200029e57600080fd5b60005b83811015620003785781810151838201526020016200035e565b50506000910152565b600060208083850312156200039557600080fd5b82516001600160401b0380821115620003ad57600080fd5b9084019060408287031215620003c257600080fd5b620003cc620002e7565b8251620003d98162000345565b81528284015182811115620003ed57600080fd5b80840193505086601f8401126200040357600080fd5b825182811115620004185762000418620002d1565b6200042c601f8201601f1916860162000312565b925080835287858286010111156200044357600080fd5b62000454818685018787016200035b565b5092830152509392505050565b600081518084526200047b8160208601602086016200035b565b601f01601f19169290920160200192915050565b60018060a01b0384168152826020820152606060408201526000620004b8606083018462000461565b95945050505050565b600081518084526020808501945080840160005b83811015620004f357815187529582019590820190600101620004d5565b509495945050505050565b6060815260006060820152608060208201526000620005216080830185620004c1565b8281036040840152620004b88185620004c1565b6000806000606084860312156200054b57600080fd5b8351620005588162000345565b60208501519093506200056b8162000345565b60408501519092506200057e8162000345565b809150509250925092565b6020815260006200059e602083018462000461565b9392505050565b615a3b80620005b56000396000f3fe608060405234801561001057600080fd5b50600436106101985760003560e01c8063715018a6116100e3578063bc197c811161008c578063f23a6e6111610066578063f23a6e6114610415578063f2fde38b1461044d578063f83d765a1461046057600080fd5b8063bc197c8114610380578063c87b56dd146103b8578063e985e9c5146103cb57600080fd5b8063a22cb465116100bd578063a22cb4651461033a578063ac9650d81461034d578063b88d4fde1461036d57600080fd5b8063715018a61461030b5780638da5cb5b1461031357806395d89b411461033257600080fd5b806323b872dd1161014557806343b84e531161011f57806343b84e53146102c55780636352211e146102e557806370a08231146102f857600080fd5b806323b872dd1461027e57806342842e0e14610291578063439fab91146102a457600080fd5b8063095ea7b311610176578063095ea7b3146102125780630a21586214610227578063150b7a021461023a57600080fd5b806301ffc9a71461019d57806306fdde03146101c5578063081812fc146101da575b600080fd5b6101b06101ab36600461450f565b610473565b60405190151581526020015b60405180910390f35b6101cd610484565b6040516101bc919061459a565b6101ed6101e83660046145ad565b610517565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bc565b6102256102203660046145f8565b61054c565b005b61022561023536600461490d565b6106dd565b61024d610248366004614a1b565b61070f565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016101bc565b61022561028c366004614a87565b610739565b61022561029f366004614a87565b6107da565b6102b76102b2366004614ac8565b6107f5565b6040519081526020016101bc565b6102d86102d3366004614b3a565b610c81565b6040516101bc9190614c42565b6101ed6102f33660046145ad565b610c9f565b6102b7610306366004614ddc565b610d2c565b610225610dfb565b6101925473ffffffffffffffffffffffffffffffffffffffff166101ed565b6101cd610e0f565b610225610348366004614e07565b610e1f565b61036061035b366004614e40565b610e2e565b6040516101bc9190614ea3565b61022561037b366004614a1b565b610f1c565b61024d61038e366004614f23565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b6101cd6103c63660046145ad565b610fc4565b6101b06103d9366004614fd1565b73ffffffffffffffffffffffffffffffffffffffff91821660009081526101656020908152604080832093909416825291909152205460ff1690565b61024d610423366004614fff565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b61022561045b366004614ddc565b6111a0565b6102d861046e366004615068565b611257565b600061047e82611274565b92915050565b606061016080546104949061521e565b80601f01602080910402602001604051908101604052809291908181526020018280546104c09061521e565b801561050d5780601f106104e25761010080835404028352916020019161050d565b820191906000526020600020905b8154815290600101906020018083116104f057829003601f168201915b5050505050905090565b600061052282611316565b506000908152610164602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b600061055782610c9f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610619576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff82161480610642575061064281336103d9565b6106ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610610565b6106d883836113a2565b505050565b6040517faf1fbb2100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f150b7a02000000000000000000000000000000000000000000000000000000005b949350505050565b6107433382611443565b6107cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610610565b6106d8838383611503565b6106d883838360405180602001604052806000815250610f1c565b60008054610100900460ff16158080156108165750600054600160ff909116105b806108305750303b158015610830575060005460ff166001145b6108bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610610565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561091a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b60006109288486018661490d565b90507f4c0a60e576b86236a6e1fc9a4484e457d5b925adde34ffdfaa3df82cb1f333c9338260405161095b9291906152f8565b60405180910390a161097581600001518260200151611809565b61097d6118aa565b61098a81606001516111a0565b60408101516101c89061099d908261548a565b5060006109b1826080015160200151611949565b9050600080821180156109da575060006109d8846080015160200151600061ffff16611967565b115b90506000600183118015610a0457506000610a02856080015160200151600161ffff16611967565b115b6101c480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000168415157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16176101008315150217905560a0850151909150610a7890610a73600360026155d3565b611980565b8115610bf057600081610a9f57604080516001815260006020820152808201909152610abc565b604080516002815260006020820152600181830152606081019091525b60808601518051602082015160409283015192517f31a66b650000000000000000000000000000000000000000000000000000000081529394506000938493849373ffffffffffffffffffffffffffffffffffffffff16926331a66b6592610b29929089906004016155e6565b6060604051808303816000875af1158015610b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6c919061561f565b6040805160608101825273ffffffffffffffffffffffffffffffffffffffff948516808252938516602082018190529290941693018390526101c580547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690931790556101c68054831690911790556101c780549091169091179055505050505b7fe0e57eda3f08f2a93bbe980d3df7f9c315eac41181f58b865a13d917fe769fc39550505050508015610c7a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5092915050565b610c8961449f565b61047e6020830183516020908102850101611ca5565b6000818152610162602052604081205473ffffffffffffffffffffffffffffffffffffffff168061047e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610610565b600073ffffffffffffffffffffffffffffffffffffffff8216610dd1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610610565b5073ffffffffffffffffffffffffffffffffffffffff166000908152610163602052604090205490565b610e03611db3565b610e0d6000611e35565b565b606061016180546104949061521e565b610e2a338383611ead565b5050565b60608167ffffffffffffffff811115610e4957610e49614624565b604051908082528060200260200182016040528015610e7c57816020015b6060815260200190600190039081610e675790505b50905060005b82811015610c7a57610eec30858584818110610ea057610ea061566c565b9050602002810190610eb2919061569b565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611fdb92505050565b828281518110610efe57610efe61566c565b60200260200101819052508080610f1490615700565b915050610e82565b610f263383611443565b610fb2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610610565b610fbe84848484612000565b50505050565b6101c454606090610100900460ff161561119757604080516060810182526101c55473ffffffffffffffffffffffffffffffffffffffff9081168083526101c654821660208085018290526101c7549384169585019590955292936000938493636715f82592859162010001911b77ffffffffffffffffffffffffffffffffffffffff0000000016176110f061108761106f8c60408051600181526020810192909252818101905290565b60408051600181526020810192909252818101905290565b60408051600080825260208201909252906110ea565b6110d76040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001606081525090565b81526020019060019003908161109d5790505b506120a3565b6040518563ffffffff1660e01b815260040161110f949392919061578a565b600060405180830381865afa15801561112c573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526111729190810190615820565b91509150816000815181106111895761118961566c565b602002602001015194505050505b61047e826123b3565b6111a8611db3565b73ffffffffffffffffffffffffffffffffffffffff811661124b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610610565b61125481611e35565b50565b61125f61449f565b61126a848484612419565b90505b9392505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061130757507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061047e575061047e826125a9565b6000818152610162602052604090205473ffffffffffffffffffffffffffffffffffffffff16611254576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610610565b60008181526101646020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811790915581906113fd82610c9f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008061144f83610c9f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806114be575073ffffffffffffffffffffffffffffffffffffffff8082166000908152610165602090815260408083209388168352929052205460ff165b8061073157508373ffffffffffffffffffffffffffffffffffffffff166114e484610517565b73ffffffffffffffffffffffffffffffffffffffff1614949350505050565b8273ffffffffffffffffffffffffffffffffffffffff1661152382610c9f565b73ffffffffffffffffffffffffffffffffffffffff16146115c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610610565b73ffffffffffffffffffffffffffffffffffffffff8216611668576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610610565b8273ffffffffffffffffffffffffffffffffffffffff1661168882610c9f565b73ffffffffffffffffffffffffffffffffffffffff161461172b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610610565b60008181526101646020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff878116808652610163855283862080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190559087168086528386208054600101905586865261016290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a46106d88383836001612640565b600054610100900460ff166118a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610e2a828261289e565b600054610100900460ff16611941576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610e0d612950565b6000815160000361195c57506000919050565b506020015160001a90565b60008061197484846129f0565b5160001a949350505050565b600054610100900460ff16611a17576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b611a1f612a21565b611a27612a21565b611a2f612a21565b611a37612ab8565b6003811015611a75576040517fb0682cf300000000000000000000000000000000000000000000000000000000815260048101829052602401610610565b611aaf6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001606081525090565b60408051606081018252600080825260208201819052918101829052905b8451811015611c9e57848181518110611ae857611ae861566c565b602002602001015192506000806000856000015173ffffffffffffffffffffffffffffffffffffffff166331a66b6587602001518860400151611b3d8b60408051600181526020810192909252818101905290565b6040518463ffffffff1660e01b8152600401611b5b939291906155e6565b6060604051808303816000875af1158015611b7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9e919061561f565b92509250925060405180606001604052808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff168152509450600161015f6000611c15886060902090565b81526020808201929092526040908101600020929092558151338152875173ffffffffffffffffffffffffffffffffffffffff9081168284015291880151821681840152918701511660608201527fed510090abe2a95b97a621e3d2c947ea3c26eced1c87470474d17e353dcc53389060800160405180910390a1505050806001019050611acd565b5050505050565b611cad61449f565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c00000000000000000000000000006020909101526060806000611d1486867ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6002612b57565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c00000000000000000000000000006020909101529095509250829050611d7e86867ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6002612b57565b60408051606081018252868152602081018390529297509093508392508101611da78888612c03565b90529695505050505050565b6101925473ffffffffffffffffffffffffffffffffffffffff163314610e0d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610610565b610192805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611f42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610610565b73ffffffffffffffffffffffffffffffffffffffff8381166000818152610165602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b606061126d8383604051806060016040528060278152602001615a1460279139612d8a565b61200b848484611503565b61201784848484612e0f565b610fbe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610610565b60606000825167ffffffffffffffff8111156120c1576120c1614624565b6040519080825280602002602001820160405280156120ea578160200160208202803683370190505b5090506000808451116120fe576000612104565b83516001015b855160010101905060008167ffffffffffffffff81111561212757612127614624565b60405190808252806020026020018201604052801561215a57816020015b60608152602001906001900390816121455790505b509050600061217f604080516002815233602082015230818301526060810190915290565b8282815181106121915761219161566c565b602002602001018190525060005b87518110156121ef5781806001019250508781815181106121c2576121c261566c565b60200260200101518383815181106121dc576121dc61566c565b602090810291909101015260010161219f565b508551156123a9578080600101915050838282815181106122125761221261566c565b602002602001018190525060005b86518110156123a7576122d187828151811061223e5761223e61566c565b6020026020010151600001516122ae61227b8a85815181106122625761226261566c565b6020026020010151602001518051602090810291012090565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b8984815181106122c0576122c061566c565b602002602001015160400151612fff565b61230a576040517f52bf984800000000000000000000000000000000000000000000000000000000815260048101829052602401610610565b86818151811061231c5761231c61566c565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff168582815181106123505761235061566c565b60200260200101818152505081806001019250508681815181106123765761237661566c565b6020026020010151602001518383815181106123945761239461566c565b6020908102919091010152600101612220565b505b5095945050505050565b60606123be82611316565b60006123c8613070565b905060008151116123e8576040518060200160405280600081525061126d565b806123f284613080565b604051602001612403929190615884565b6040516020818303038152906040529392505050565b61242161449f565b61242961313e565b60008060006124398787876131b3565b925092509250600061244b8484611ca5565b905060005b8151518110156124ae576124a6826000015182815181106124735761247361566c565b602002602001015160000151836000015183815181106124955761249561566c565b602002602001015160200151613367565b600101612450565b5060005b816020015151811015612585576000826020015182815181106124d7576124d761566c565b6020026020010151602001519050826020015182815181106124fb576124fb61566c565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1661252682610c9f565b73ffffffffffffffffffffffffffffffffffffffff1614612573576040517f375e3a0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61257c81613381565b506001016124b2565b506125998160400151896020015184613466565b935050505061126d600161012d55565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e000000000000000000000000000000000000000000000000000000000148061047e57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461047e565b6101c45460ff168015612687575073ffffffffffffffffffffffffffffffffffffffff84161580612685575073ffffffffffffffffffffffffffffffffffffffff8316155b155b15610fbe57604080516060810182526101c55473ffffffffffffffffffffffffffffffffffffffff9081168083526101c654821660208085018290526101c7549384169585019590955292936000938493636715f825928591901b77ffffffffffffffffffffffffffffffffffffffff0000000016604080516003815273ffffffffffffffffffffffffffffffffffffffff808f1660208301528d1681830152606081018c905260808101909152612794906110879061106f565b61277c6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001606081525090565b815260200190600190039081612742579050506120a3565b6040518563ffffffff1660e01b81526004016127b3949392919061578a565b600060405180830381865afa1580156127d0573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526128169190810190615820565b805191935091501561289557826020015173ffffffffffffffffffffffffffffffffffffffff1663946aadc66000836040518363ffffffff1660e01b81526004016128629291906158b3565b600060405180830381600087803b15801561287c57600080fd5b505af1158015612890573d6000803e3d6000fd5b505050505b50505050505050565b600054610100900460ff16612935576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610160612942838261548a565b506101616106d8828261548a565b600054610100900460ff166129e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610e0d33611e35565b6000806129fc84611949565b60020260010190506000612a108585613518565b949091019093016020019392505050565b600054610100900460ff16610e0d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b600054610100900460ff16612b4f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610e0d61356f565b60008060208302855b87811115612b84576020810386815103612b7b579350612b84565b50819003612b60565b5082600003612bc2576040517fd457746f00000000000000000000000000000000000000000000000000000000815260048101869052602401610610565b604051915060208201602084015b87811015612be8578082526020909101908201612bd0565b50806040526001602084830304038352505094509492505050565b612c2760405180606001604052806060815260200160608152602001606081525090565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c0000000000000000000000000000602090910152606080806000612c8f87877ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6004612b57565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c00000000000000000000000000006020909101529096509350839050612cf987877ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6004612b57565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c00000000000000000000000000006020909101529096509250829050612d6387877ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6005612b57565b60408051606081018252968752602087019590955293850193909352509195945050505050565b60606000808573ffffffffffffffffffffffffffffffffffffffff1685604051612db491906158cc565b600060405180830381855af49150503d8060008114612def576040519150601f19603f3d011682016040523d82523d6000602084013e612df4565b606091505b5091509150612e0586838387613606565b9695505050505050565b600073ffffffffffffffffffffffffffffffffffffffff84163b15612ff7576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290612e869033908990889088906004016158e8565b6020604051808303816000875af1925050508015612edf575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612edc91810190615927565b60015b612fac573d808015612f0d576040519150601f19603f3d011682016040523d82523d6000602084013e612f12565b606091505b508051600003612fa4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610610565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050610731565b506001610731565b600080600061300e85856136a6565b9092509050600081600481111561302757613027615944565b14801561305f57508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b80612e055750612e058686866136eb565b60606101c880546104949061521e565b6060600061308d83613848565b600101905060008167ffffffffffffffff8111156130ad576130ad614624565b6040519080825280601f01601f1916602001820160405280156130d7576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85049450846130e157509392505050565b600261012d54036131ab576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610610565b600261012d55565b600080606060006131df6131d98760408051600181526020810192909252818101905290565b866120a3565b90507f17a5c0f3785132a57703932032f6863e7920434150aa1dc940e567b440fdce1f3382604051613212929190615973565b60405180910390a160608720600081815261015f6020526040902054613267576040517f7a80ba4d00000000000000000000000000000000000000000000000000000000815260048101829052602401610610565b50865160208089015160408a0151600093849373ffffffffffffffffffffffffffffffffffffffff90911692636715f8259290918591901b77ffffffffffffffffffffffffffffffffffffffff000000001661ffff17876040518563ffffffff1660e01b81526004016132dd949392919061578a565b600060405180830381865afa1580156132fa573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526133409190810190615820565b9150915061334e8260200190565b8251909a60209182029093010198509650945050505050565b610e2a82826040518060200160405280600081525061392a565b600061338c82610c9f565b905061339782610c9f565b60008381526101646020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff8516808552610163845282852080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019055878552610162909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a4610e2a816000846001612640565b8051156134f5576040517f946aadc600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063946aadc6906134c29060009085906004016158b3565b600060405180830381600087803b1580156134dc57600080fd5b505af11580156134f0573d6000803e3d6000fd5b505050505b6134fe836139cd565b61350783613b26565b6106d883613cb6565b600161012d55565b600061352383611949565b821061355f5782826040517f30489add0000000000000000000000000000000000000000000000000000000081526004016106109291906159a2565b50600202016003015161ffff1690565b600054610100900460ff16613510576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b6060831561369c5782516000036136955773ffffffffffffffffffffffffffffffffffffffff85163b613695576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610610565b5081610731565b6107318383613e66565b60008082516041036136dc5760208301516040840151606085015160001a6136d087828585613eaa565b945094505050506136e4565b506000905060025b9250929050565b60008060008573ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b86866040516024016137229291906159c4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516137ab91906158cc565b600060405180830381855afa9150503d80600081146137e6576040519150601f19603f3d011682016040523d82523d6000602084013e6137eb565b606091505b50915091508180156137ff57506020815110155b8015612e05575080517f1626ba7e000000000000000000000000000000000000000000000000000000009061383d90830160209081019084016159dd565b149695505050505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310613891577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106138bd576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106138db57662386f26fc10000830492506010015b6305f5e10083106138f3576305f5e100830492506008015b612710831061390757612710830492506004015b60648310613919576064830492506002015b600a831061047e5760010192915050565b6139348383613f99565b6139416000848484612e0f565b6106d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610610565b6040805160808101825260008082526020820181905291810182905260608101829052905b8251518110156106d8578251805182908110613a1057613a1061566c565b602002602001015191503373ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff1603613a8757604082015160608301518351613a829273ffffffffffffffffffffffffffffffffffffffff909116913391906141cc565b613b1e565b3073ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff1603613aec57604082015160608301518351613a829273ffffffffffffffffffffffffffffffffffffffff909116916142a8565b6040517fa521c60f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001016139f2565b6040805160808101825260008082526020820181905291810182905260608101829052905b8260200151518110156106d85782602001518181518110613b6e57613b6e61566c565b602002602001015191503373ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff1614158015613bd25750602082015173ffffffffffffffffffffffffffffffffffffffff163014155b15613c09576040517f3a5befc500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81516020830151604080850151606086015191517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9384166004820152908316602482015260448101919091529116906342842e0e90606401600060405180830381600087803b158015613c9357600080fd5b505af1158015613ca7573d6000803e3d6000fd5b50505050806001019050613b4b565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101829052905b8260400151518110156106d85782604001518181518110613d0557613d0561566c565b602002602001015191503373ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff1614158015613d695750602082015173ffffffffffffffffffffffffffffffffffffffff163014155b15613da0576040517fc6a91ecc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b815160208301516040808501516060860151608087015192517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff948516600482015291841660248301526044820152606481019190915260a06084820152600060a482015291169063f242432a9060c401600060405180830381600087803b158015613e4257600080fd5b505af1158015613e56573d6000803e3d6000fd5b505060019092019150613ce29050565b815115613e765781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610610919061459a565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613ee15750600090506003613f90565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613f35573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116613f8957600060019250925050613f90565b9150600090505b94509492505050565b73ffffffffffffffffffffffffffffffffffffffff8216614016576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610610565b6000818152610162602052604090205473ffffffffffffffffffffffffffffffffffffffff16156140a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610610565b6000818152610162602052604090205473ffffffffffffffffffffffffffffffffffffffff1615614130576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610610565b73ffffffffffffffffffffffffffffffffffffffff82166000818152610163602090815260408083208054600101905584835261016290915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4610e2a600083836001612640565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052610fbe9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526142fe565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526106d89084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401614226565b6000614360826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661440d9092919063ffffffff16565b905080516000148061438157508080602001905181019061438191906159f6565b6106d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610610565b606061126a8484600085856000808673ffffffffffffffffffffffffffffffffffffffff16858760405161444191906158cc565b60006040518083038185875af1925050503d806000811461447e576040519150601f19603f3d011682016040523d82523d6000602084013e614483565b606091505b509150915061449487838387613606565b979650505050505050565b604051806060016040528060608152602001606081526020016144dc60405180606001604052806060815260200160608152602001606081525090565b905290565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461125457600080fd5b60006020828403121561452157600080fd5b813561126d816144e1565b60005b8381101561454757818101518382015260200161452f565b50506000910152565b6000815180845261456881602086016020860161452c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061126d6020830184614550565b6000602082840312156145bf57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461125457600080fd5b80356145f3816145c6565b919050565b6000806040838503121561460b57600080fd5b8235614616816145c6565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561467657614676614624565b60405290565b60405160c0810167ffffffffffffffff8111828210171561467657614676614624565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156146e6576146e6614624565b604052919050565b600082601f8301126146ff57600080fd5b813567ffffffffffffffff81111561471957614719614624565b61474a60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160161469f565b81815284602083860101111561475f57600080fd5b816020850160208301376000918101602001919091529392505050565b600067ffffffffffffffff82111561479657614796614624565b5060051b60200190565b600082601f8301126147b157600080fd5b813560206147c66147c18361477c565b61469f565b82815260059290921b840181019181810190868411156147e557600080fd5b8286015b8481101561480057803583529183019183016147e9565b509695505050505050565b60006060828403121561481d57600080fd5b614825614653565b90508135614832816145c6565b8152602082013567ffffffffffffffff8082111561484f57600080fd5b61485b858386016146ee565b6020840152604084013591508082111561487457600080fd5b50614881848285016147a0565b60408301525092915050565b600082601f83011261489e57600080fd5b813560206148ae6147c18361477c565b82815260059290921b840181019181810190868411156148cd57600080fd5b8286015b8481101561480057803567ffffffffffffffff8111156148f15760008081fd5b6148ff8986838b010161480b565b8452509183019183016148d1565b60006020828403121561491f57600080fd5b813567ffffffffffffffff8082111561493757600080fd5b9083019060c0828603121561494b57600080fd5b61495361467c565b82358281111561496257600080fd5b61496e878286016146ee565b82525060208301358281111561498357600080fd5b61498f878286016146ee565b6020830152506040830135828111156149a757600080fd5b6149b3878286016146ee565b6040830152506149c5606084016145e8565b60608201526080830135828111156149dc57600080fd5b6149e88782860161480b565b60808301525060a083013582811115614a0057600080fd5b614a0c8782860161488d565b60a08301525095945050505050565b60008060008060808587031215614a3157600080fd5b8435614a3c816145c6565b93506020850135614a4c816145c6565b925060408501359150606085013567ffffffffffffffff811115614a6f57600080fd5b614a7b878288016146ee565b91505092959194509250565b600080600060608486031215614a9c57600080fd5b8335614aa7816145c6565b92506020840135614ab7816145c6565b929592945050506040919091013590565b60008060208385031215614adb57600080fd5b823567ffffffffffffffff80821115614af357600080fd5b818501915085601f830112614b0757600080fd5b813581811115614b1657600080fd5b866020828501011115614b2857600080fd5b60209290920196919550909350505050565b600060208284031215614b4c57600080fd5b813567ffffffffffffffff811115614b6357600080fd5b610731848285016147a0565b600081518084526020808501945080840160005b83811015614bc0578151805173ffffffffffffffffffffffffffffffffffffffff1688528301518388015260409096019590820190600101614b83565b509495945050505050565b600081518084526020808501945080840160005b83811015614bc0578151805173ffffffffffffffffffffffffffffffffffffffff9081168952848201518116858a015260408083015190911690890152606080820151908901526080908101519088015260a09096019590820190600101614bdf565b6000602080835260808451606083860152614c5f82860182614b6f565b9050828601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe080878403016040880152614c9a8383614b6f565b92506040880151915080878403016060880152506060820181516060845281815180845286860191508783019350600092505b80831015614d3157614d1d82855173ffffffffffffffffffffffffffffffffffffffff80825116835280602083015116602084015280604083015116604084015250606081015160608301525050565b928701926001929092019190860190614ccd565b5083870151858203868901528051808352908801935090870191506000905b80821015614db457614da083855173ffffffffffffffffffffffffffffffffffffffff80825116835280602083015116602084015280604083015116604084015250606081015160608301525050565b928701929186019160019190910190614d50565b5050604083015195508381036040850152614dcf8187614bcb565b9998505050505050505050565b600060208284031215614dee57600080fd5b813561126d816145c6565b801515811461125457600080fd5b60008060408385031215614e1a57600080fd5b8235614e25816145c6565b91506020830135614e3581614df9565b809150509250929050565b60008060208385031215614e5357600080fd5b823567ffffffffffffffff80821115614e6b57600080fd5b818501915085601f830112614e7f57600080fd5b813581811115614e8e57600080fd5b8660208260051b8501011115614b2857600080fd5b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614f16577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452614f04858351614550565b94509285019290850190600101614eca565b5092979650505050505050565b600080600080600060a08688031215614f3b57600080fd5b8535614f46816145c6565b94506020860135614f56816145c6565b9350604086013567ffffffffffffffff80821115614f7357600080fd5b614f7f89838a016147a0565b94506060880135915080821115614f9557600080fd5b614fa189838a016147a0565b93506080880135915080821115614fb757600080fd5b50614fc4888289016146ee565b9150509295509295909350565b60008060408385031215614fe457600080fd5b8235614fef816145c6565b91506020830135614e35816145c6565b600080600080600060a0868803121561501757600080fd5b8535615022816145c6565b94506020860135615032816145c6565b93506040860135925060608601359150608086013567ffffffffffffffff81111561505c57600080fd5b614fc4888289016146ee565b600080600083850360a081121561507e57600080fd5b606081121561508c57600080fd5b50615095614653565b84356150a0816145c6565b81526020858101356150b1816145c6565b8282015260408601356150c3816145c6565b604083015290935060608501359067ffffffffffffffff808311156150e757600080fd5b6150f3888489016147a0565b9450608087013592508083111561510957600080fd5b828701925087601f84011261511d57600080fd5b823561512b6147c18261477c565b81815260059190911b8401830190838101908a83111561514a57600080fd5b8486015b8381101561520d578035858111156151665760008081fd5b87016060818e037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001121561519b5760008081fd5b6151a3614653565b878201356151b0816145c6565b81526040820135878111156151c55760008081fd5b6151d38f8a838601016147a0565b89830152506060820135878111156151eb5760008081fd5b6151f98f8a838601016146ee565b60408301525084525091850191850161514e565b508096505050505050509250925092565b600181811c9082168061523257607f821691505b60208210810361526b577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b600081518084526020808501945080840160005b83811015614bc057815187529582019590820190600101615285565b73ffffffffffffffffffffffffffffffffffffffff815116825260006020820151606060208501526152d66060850182614550565b9050604083015184820360408601526152ef8282615271565b95945050505050565b600073ffffffffffffffffffffffffffffffffffffffff80851683526020604081850152845160c06040860152615333610100860182614550565b9050818601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08087840301606088015261536e8383614550565b9250604088015191508087840301608088015261538b8383614550565b92508460608901511660a088015260808801519450808784030160c08801526153b483866152a1565b60a089015188820390920160e0890152815180825290955090840192508385019150600581901b8501840160005b8281101561542e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe087830301845261541c8286516152a1565b948601949386019391506001016153e2565b509998505050505050505050565b601f8211156106d857600081815260208120601f850160051c810160208610156154635750805b601f850160051c820191505b818110156154825782815560010161546f565b505050505050565b815167ffffffffffffffff8111156154a4576154a4614624565b6154b8816154b2845461521e565b8461543c565b602080601f83116001811461550b57600084156154d55750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555615482565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b8281101561555857888601518255948401946001909101908401615539565b508582101561559457878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561047e5761047e6155a4565b6060815260006155f96060830186614550565b828103602084015261560b8186615271565b90508281036040840152612e058185615271565b60008060006060848603121561563457600080fd5b835161563f816145c6565b6020850151909350615650816145c6565b6040850151909250615661816145c6565b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126156d057600080fd5b83018035915067ffffffffffffffff8211156156eb57600080fd5b6020019150368190038213156136e457600080fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203615731576157316155a4565b5060010190565b6000815180845260208085019450848260051b860182860160005b8581101561577d57838303895261576b838351615271565b98850198925090840190600101615753565b5090979650505050505050565b73ffffffffffffffffffffffffffffffffffffffff85168152836020820152826040820152608060608201526000612e056080830184615738565b600082601f8301126157d657600080fd5b815160206157e66147c18361477c565b82815260059290921b8401810191818101908684111561580557600080fd5b8286015b848110156148005780518352918301918301615809565b6000806040838503121561583357600080fd5b825167ffffffffffffffff8082111561584b57600080fd5b615857868387016157c5565b9350602085015191508082111561586d57600080fd5b5061587a858286016157c5565b9150509250929050565b6000835161589681846020880161452c565b8351908301906158aa81836020880161452c565b01949350505050565b82815260406020820152600061126a6040830184615271565b600082516158de81846020870161452c565b9190910192915050565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152612e056080830184614550565b60006020828403121561593957600080fd5b815161126d816144e1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff8316815260406020820152600061126a6040830184615738565b6040815260006159b56040830185614550565b90508260208301529392505050565b82815260406020820152600061126a6040830184614550565b6000602082840312156159ef57600080fd5b5051919050565b600060208284031215615a0857600080fd5b815161126d81614df956fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c65640000000000000000000000000000000000000000000000000000000000000020000000000000000000000000d039bc83136011e3b6017cda4d4d597865b13bed00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000879ff0a89c674ee7874a5005905afed5b5173e23610fe2b1d9e7908f4d276f276c91d53669a321392bcdcf0206c41d4339247924968e7fe7b57c6c6b22ddbb230819bf8e52e58dad5ea5b79f5ed4afef6df80d030926270037f7a6c13328a69f29350893945c1e32ec4839b01f27d8e85180c07146dd4031f8701db610e4f64becb8f61497ab9935893dd608932b97de38fc5b02825248f3cf9cb9764a42f44786c8b395a06f81e343c8fef18ddf7218cc2df2bb2cec6f0d2dfc928320a031c8f222492f83e926849022277d046190dd14ee9cdfa7ba96ec693191d906a8246322b5022f83dbefe4d97fb8ee9d4cf84d31ecaeaa40f0a430e20401f16c9c422eb39ad221a63d57642ec951a1d9d99b54401a21e9ead7286354fd93cd7f26cb604bf36cfa37e0983472547b0a0a653d510720cff3e8f326348f6d8ca81468573583058d72ad4032b7d25dcf15ba81ea8991ac137bf2f5fb7288812c7a78ab447f9f7a172597e5b68ef120a02cce10d93f84d965c063d959a96f1439035b5c4d96451bd2df5e1470d8d64a47ba52906cd95b57e82c0f3483745e84da200b0b2277b4b56017b2dbc2005d45a82883c8f4554ba851b5211692a56d5c3ddefe3d13c0ac36077f782e81aeb206c0835cebdfdbab898292d234eeda6d472867198770b082bce366e92ae7b12dae4bd6185eaf8ea91232a5698eb8062ee8daf3a59233f15822e6bb2023e68e9f18bf13bd5ca1d8daeaf2bc0574de6e86ed63681609faad2f940b209946869b596fd9a98ce742deec4d692043ab1d335969ff704d5af2782a5d5612638a72182002da15aaa10ff77d099b41a9658514eec364b16b8482e91c04f0f531b516b32de180632bafaf5c02bd3dcea79dc4d66a77e7acc2f332b5b56071ecf31098dd73513de7d0ea8cf05e79b4cf4b7076d0f9aae53c52823628d116f1fabca8e30c5ab43da45244101f9d722ab0d73acdd329415e0f691b9fa506f8e59ebafc629a64d9d07e536c1a0513484528aaa6ed4e5f544a4f17cc2f8e720688084c5e1b08c877a7e4c3c3741afaf57834bf399d7260a245169ac854f75c58007480ab3ee635cbb28ee3e355615778ff2b6d11db4361bb3c5e272cdeb2d137a77c9422ca889038c267cf01649efe5017b9834d29a58c9a74af59fde21229cde5f83baea5d57520e7eea5df44e60c3067f21582f4a1be1f9728e2ef2a778164d45f493ce63a16d7d141268a8e92b9bc40b099bd959972fc9fb171a6c1c24d00aa749fd646fe107c5a4318a34d0ecf32259437e870db41665058e22bd4da7965641506060cd272ad4e48e2424f2be57a5837a9f4736e98f24fa2389fe48e2e835d21f497c74fcfa2309ab2309f70a9e9648c4cd2be4619d9a683945bac7411c655c8a69da7d708ef2d5a27c607021c51e270a1cf7d91f5e5c6acdea3273077936b64bf1ebacf10a576a5e97f91e821e3b087aa0618502818779ab7dfc063cfa06c20a1e1e57ea6ea5a9cce0ed9539793ecd06b24e780b3be30543d4941f25ca0e161f952f9592254790ccd6946f9e6110709bd92193b2bb8b96cfb84af7e7ce30bf8f7743b2163b971b93994315119a1e4e0bfd0b766c7fe3a1bff1d0df7838eec6834d20a9bb0151fd4142d261aa5f3ce834922874fec82cd902bfcb45cc7dbbd194f34635bbed58d3152dffc19eaccaceeb598bdd372a4973fc01cae8d4840edebf2d0155b3ce889d552a704801d262013f661dd8195697b3b552549dc275ceeb53784cd8b4c8ba55ecb9277496245b7523de221f7ace55edfe2f4cd7f2451b9af3e2a74a9a1c548e31ff9bc982f36b85b228304fbf9898d05a598bd259edf4a6146234f1e7e50f346c069b03f684e220175bd227d583de13d8e3e87a5eea6b3366216a44b4216e800b1e10a1a5f0d17ea8f67ba8860b8b3814cfd41b510bcd3ceb07ab73b6ba85faa52f1cccd6efc9016787188dfd3f91782918afeecc0d9b35003b895050219f59ff44d3a114dcf9ee4e964794e33511d0a9d27a7df4acf3245760ad7de99e6852b5c47e52fc75161e5f398b028331ca2efe07011bffe5ffb4a3ff2cde02706170706c69636174696f6e2f6a736f6e03676465666c6174650462656ea500590266bd54c18ed33010fd152b172e6d441704d2de6097153dc0a12ca72a072799b4168e5dd9937617b4ffce384e9cb84d5181d52a8728cf9379f366e6f957a2780dc9757227f5817d5addbcbf5a24b384e7e2eb8007b8045b10f681552ebad00a0d2f90e196231396716935e3aa4bc350ff00e50f0b427360b5500825cb1f193cec0c582bb4b229bb375cd90a8cede3e8088d28ba58c286f0d4552705b75487ab620ea6f0c5d5805b5d12be0ea284122828fa27449a22b8d3b40c18e36c101d443a5ea1760d46046dc2716ae5812ea90399aea80730d114ea986f88cbbde3b8a53fd68b7759ea79d68b2c2d74bdd30a147dbdce92a75920fef658e75a46d4b6873a721fc22a6d9e857f11f17fe416d8f7d532aa2027d0635d097dd4b31571454564b364b43de3697ce6aa94c0b05ba7a836d873d9f05cc28d5695d80c35ae602fe0404b5686b50b196c3fbc68df5f117c88b73c655f48449b246f8c224d8d45b7c9ed3f5a4abfc921d5480013ca22f0cbf4bfc928ca8a8d829274203c60725d91ed6096149c58cc09eabf6fb46ceab8596e364793ea82e9eda24746cb7d6c015246397ae3324f3ea4bbdfc2703dd0ec0fee1cfbbba06d47dfe3b1a17b6cdee51b2ddcdd780231112f4bd7cc7e5667cc1b5d1a21d15336e2087284a285ad39d27cc637440019cf75832d5bd11843a3f9b39c38dff9365646d7bd9c698d8ed2bb878c9383509bc06ca8a92ec16405ee60de679e928cfabf88514fd2a29e246df32c6f63a6e56d3f41cf734272868162e7a27493cc8ef6c54637801bfcb1f95b857b2ea4bb195a6bda8b7cf876c287689a531b76e0bfbb30bdc086de1b7f6f41a7f7d41a2f683dfffc06011bffc21bbf86cc199b02706170706c69636174696f6e2f6a736f6e03676465666c6174650462656e00000000000000
|
608060405234801561001057600080fd5b50600436106101985760003560e01c8063715018a6116100e3578063bc197c811161008c578063f23a6e6111610066578063f23a6e6114610415578063f2fde38b1461044d578063f83d765a1461046057600080fd5b8063bc197c8114610380578063c87b56dd146103b8578063e985e9c5146103cb57600080fd5b8063a22cb465116100bd578063a22cb4651461033a578063ac9650d81461034d578063b88d4fde1461036d57600080fd5b8063715018a61461030b5780638da5cb5b1461031357806395d89b411461033257600080fd5b806323b872dd1161014557806343b84e531161011f57806343b84e53146102c55780636352211e146102e557806370a08231146102f857600080fd5b806323b872dd1461027e57806342842e0e14610291578063439fab91146102a457600080fd5b8063095ea7b311610176578063095ea7b3146102125780630a21586214610227578063150b7a021461023a57600080fd5b806301ffc9a71461019d57806306fdde03146101c5578063081812fc146101da575b600080fd5b6101b06101ab36600461450f565b610473565b60405190151581526020015b60405180910390f35b6101cd610484565b6040516101bc919061459a565b6101ed6101e83660046145ad565b610517565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101bc565b6102256102203660046145f8565b61054c565b005b61022561023536600461490d565b6106dd565b61024d610248366004614a1b565b61070f565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020016101bc565b61022561028c366004614a87565b610739565b61022561029f366004614a87565b6107da565b6102b76102b2366004614ac8565b6107f5565b6040519081526020016101bc565b6102d86102d3366004614b3a565b610c81565b6040516101bc9190614c42565b6101ed6102f33660046145ad565b610c9f565b6102b7610306366004614ddc565b610d2c565b610225610dfb565b6101925473ffffffffffffffffffffffffffffffffffffffff166101ed565b6101cd610e0f565b610225610348366004614e07565b610e1f565b61036061035b366004614e40565b610e2e565b6040516101bc9190614ea3565b61022561037b366004614a1b565b610f1c565b61024d61038e366004614f23565b7fbc197c810000000000000000000000000000000000000000000000000000000095945050505050565b6101cd6103c63660046145ad565b610fc4565b6101b06103d9366004614fd1565b73ffffffffffffffffffffffffffffffffffffffff91821660009081526101656020908152604080832093909416825291909152205460ff1690565b61024d610423366004614fff565b7ff23a6e610000000000000000000000000000000000000000000000000000000095945050505050565b61022561045b366004614ddc565b6111a0565b6102d861046e366004615068565b611257565b600061047e82611274565b92915050565b606061016080546104949061521e565b80601f01602080910402602001604051908101604052809291908181526020018280546104c09061521e565b801561050d5780601f106104e25761010080835404028352916020019161050d565b820191906000526020600020905b8154815290600101906020018083116104f057829003601f168201915b5050505050905090565b600061052282611316565b506000908152610164602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b600061055782610c9f565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610619576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560448201527f720000000000000000000000000000000000000000000000000000000000000060648201526084015b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff82161480610642575061064281336103d9565b6106ce576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610610565b6106d883836113a2565b505050565b6040517faf1fbb2100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f150b7a02000000000000000000000000000000000000000000000000000000005b949350505050565b6107433382611443565b6107cf576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610610565b6106d8838383611503565b6106d883838360405180602001604052806000815250610f1c565b60008054610100900460ff16158080156108165750600054600160ff909116105b806108305750303b158015610830575060005460ff166001145b6108bc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610610565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166001179055801561091a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b60006109288486018661490d565b90507f4c0a60e576b86236a6e1fc9a4484e457d5b925adde34ffdfaa3df82cb1f333c9338260405161095b9291906152f8565b60405180910390a161097581600001518260200151611809565b61097d6118aa565b61098a81606001516111a0565b60408101516101c89061099d908261548a565b5060006109b1826080015160200151611949565b9050600080821180156109da575060006109d8846080015160200151600061ffff16611967565b115b90506000600183118015610a0457506000610a02856080015160200151600161ffff16611967565b115b6101c480547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000168415157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16176101008315150217905560a0850151909150610a7890610a73600360026155d3565b611980565b8115610bf057600081610a9f57604080516001815260006020820152808201909152610abc565b604080516002815260006020820152600181830152606081019091525b60808601518051602082015160409283015192517f31a66b650000000000000000000000000000000000000000000000000000000081529394506000938493849373ffffffffffffffffffffffffffffffffffffffff16926331a66b6592610b29929089906004016155e6565b6060604051808303816000875af1158015610b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6c919061561f565b6040805160608101825273ffffffffffffffffffffffffffffffffffffffff948516808252938516602082018190529290941693018390526101c580547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690931790556101c68054831690911790556101c780549091169091179055505050505b7fe0e57eda3f08f2a93bbe980d3df7f9c315eac41181f58b865a13d917fe769fc39550505050508015610c7a57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5092915050565b610c8961449f565b61047e6020830183516020908102850101611ca5565b6000818152610162602052604081205473ffffffffffffffffffffffffffffffffffffffff168061047e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610610565b600073ffffffffffffffffffffffffffffffffffffffff8216610dd1576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f74206120766160448201527f6c6964206f776e657200000000000000000000000000000000000000000000006064820152608401610610565b5073ffffffffffffffffffffffffffffffffffffffff166000908152610163602052604090205490565b610e03611db3565b610e0d6000611e35565b565b606061016180546104949061521e565b610e2a338383611ead565b5050565b60608167ffffffffffffffff811115610e4957610e49614624565b604051908082528060200260200182016040528015610e7c57816020015b6060815260200190600190039081610e675790505b50905060005b82811015610c7a57610eec30858584818110610ea057610ea061566c565b9050602002810190610eb2919061569b565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611fdb92505050565b828281518110610efe57610efe61566c565b60200260200101819052508080610f1490615700565b915050610e82565b610f263383611443565b610fb2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602d60248201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560448201527f72206f7220617070726f766564000000000000000000000000000000000000006064820152608401610610565b610fbe84848484612000565b50505050565b6101c454606090610100900460ff161561119757604080516060810182526101c55473ffffffffffffffffffffffffffffffffffffffff9081168083526101c654821660208085018290526101c7549384169585019590955292936000938493636715f82592859162010001911b77ffffffffffffffffffffffffffffffffffffffff0000000016176110f061108761106f8c60408051600181526020810192909252818101905290565b60408051600181526020810192909252818101905290565b60408051600080825260208201909252906110ea565b6110d76040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001606081525090565b81526020019060019003908161109d5790505b506120a3565b6040518563ffffffff1660e01b815260040161110f949392919061578a565b600060405180830381865afa15801561112c573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526111729190810190615820565b91509150816000815181106111895761118961566c565b602002602001015194505050505b61047e826123b3565b6111a8611db3565b73ffffffffffffffffffffffffffffffffffffffff811661124b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610610565b61125481611e35565b50565b61125f61449f565b61126a848484612419565b90505b9392505050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f80ac58cd00000000000000000000000000000000000000000000000000000000148061130757507fffffffff0000000000000000000000000000000000000000000000000000000082167f5b5e139f00000000000000000000000000000000000000000000000000000000145b8061047e575061047e826125a9565b6000818152610162602052604090205473ffffffffffffffffffffffffffffffffffffffff16611254576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4552433732313a20696e76616c696420746f6b656e20494400000000000000006044820152606401610610565b60008181526101646020526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff841690811790915581906113fd82610c9f565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008061144f83610c9f565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1614806114be575073ffffffffffffffffffffffffffffffffffffffff8082166000908152610165602090815260408083209388168352929052205460ff165b8061073157508373ffffffffffffffffffffffffffffffffffffffff166114e484610517565b73ffffffffffffffffffffffffffffffffffffffff1614949350505050565b8273ffffffffffffffffffffffffffffffffffffffff1661152382610c9f565b73ffffffffffffffffffffffffffffffffffffffff16146115c6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610610565b73ffffffffffffffffffffffffffffffffffffffff8216611668576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460448201527f72657373000000000000000000000000000000000000000000000000000000006064820152608401610610565b8273ffffffffffffffffffffffffffffffffffffffff1661168882610c9f565b73ffffffffffffffffffffffffffffffffffffffff161461172b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201527f6f776e65720000000000000000000000000000000000000000000000000000006064820152608401610610565b60008181526101646020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff878116808652610163855283862080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0190559087168086528386208054600101905586865261016290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a46106d88383836001612640565b600054610100900460ff166118a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610e2a828261289e565b600054610100900460ff16611941576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610e0d612950565b6000815160000361195c57506000919050565b506020015160001a90565b60008061197484846129f0565b5160001a949350505050565b600054610100900460ff16611a17576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b611a1f612a21565b611a27612a21565b611a2f612a21565b611a37612ab8565b6003811015611a75576040517fb0682cf300000000000000000000000000000000000000000000000000000000815260048101829052602401610610565b611aaf6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001606081525090565b60408051606081018252600080825260208201819052918101829052905b8451811015611c9e57848181518110611ae857611ae861566c565b602002602001015192506000806000856000015173ffffffffffffffffffffffffffffffffffffffff166331a66b6587602001518860400151611b3d8b60408051600181526020810192909252818101905290565b6040518463ffffffff1660e01b8152600401611b5b939291906155e6565b6060604051808303816000875af1158015611b7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b9e919061561f565b92509250925060405180606001604052808473ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff168152509450600161015f6000611c15886060902090565b81526020808201929092526040908101600020929092558151338152875173ffffffffffffffffffffffffffffffffffffffff9081168284015291880151821681840152918701511660608201527fed510090abe2a95b97a621e3d2c947ea3c26eced1c87470474d17e353dcc53389060800160405180910390a1505050806001019050611acd565b5050505050565b611cad61449f565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c00000000000000000000000000006020909101526060806000611d1486867ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6002612b57565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c00000000000000000000000000006020909101529095509250829050611d7e86867ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6002612b57565b60408051606081018252868152602081018390529297509093508392508101611da78888612c03565b90529695505050505050565b6101925473ffffffffffffffffffffffffffffffffffffffff163314610e0d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610610565b610192805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611f42576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610610565b73ffffffffffffffffffffffffffffffffffffffff8381166000818152610165602090815260408083209487168084529482529182902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b606061126d8383604051806060016040528060278152602001615a1460279139612d8a565b61200b848484611503565b61201784848484612e0f565b610fbe576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610610565b60606000825167ffffffffffffffff8111156120c1576120c1614624565b6040519080825280602002602001820160405280156120ea578160200160208202803683370190505b5090506000808451116120fe576000612104565b83516001015b855160010101905060008167ffffffffffffffff81111561212757612127614624565b60405190808252806020026020018201604052801561215a57816020015b60608152602001906001900390816121455790505b509050600061217f604080516002815233602082015230818301526060810190915290565b8282815181106121915761219161566c565b602002602001018190525060005b87518110156121ef5781806001019250508781815181106121c2576121c261566c565b60200260200101518383815181106121dc576121dc61566c565b602090810291909101015260010161219f565b508551156123a9578080600101915050838282815181106122125761221261566c565b602002602001018190525060005b86518110156123a7576122d187828151811061223e5761223e61566c565b6020026020010151600001516122ae61227b8a85815181106122625761226261566c565b6020026020010151602001518051602090810291012090565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b8984815181106122c0576122c061566c565b602002602001015160400151612fff565b61230a576040517f52bf984800000000000000000000000000000000000000000000000000000000815260048101829052602401610610565b86818151811061231c5761231c61566c565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff168582815181106123505761235061566c565b60200260200101818152505081806001019250508681815181106123765761237661566c565b6020026020010151602001518383815181106123945761239461566c565b6020908102919091010152600101612220565b505b5095945050505050565b60606123be82611316565b60006123c8613070565b905060008151116123e8576040518060200160405280600081525061126d565b806123f284613080565b604051602001612403929190615884565b6040516020818303038152906040529392505050565b61242161449f565b61242961313e565b60008060006124398787876131b3565b925092509250600061244b8484611ca5565b905060005b8151518110156124ae576124a6826000015182815181106124735761247361566c565b602002602001015160000151836000015183815181106124955761249561566c565b602002602001015160200151613367565b600101612450565b5060005b816020015151811015612585576000826020015182815181106124d7576124d761566c565b6020026020010151602001519050826020015182815181106124fb576124fb61566c565b60200260200101516000015173ffffffffffffffffffffffffffffffffffffffff1661252682610c9f565b73ffffffffffffffffffffffffffffffffffffffff1614612573576040517f375e3a0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61257c81613381565b506001016124b2565b506125998160400151896020015184613466565b935050505061126d600161012d55565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f4e2312e000000000000000000000000000000000000000000000000000000000148061047e57507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161461047e565b6101c45460ff168015612687575073ffffffffffffffffffffffffffffffffffffffff84161580612685575073ffffffffffffffffffffffffffffffffffffffff8316155b155b15610fbe57604080516060810182526101c55473ffffffffffffffffffffffffffffffffffffffff9081168083526101c654821660208085018290526101c7549384169585019590955292936000938493636715f825928591901b77ffffffffffffffffffffffffffffffffffffffff0000000016604080516003815273ffffffffffffffffffffffffffffffffffffffff808f1660208301528d1681830152606081018c905260808101909152612794906110879061106f565b61277c6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff16815260200160608152602001606081525090565b815260200190600190039081612742579050506120a3565b6040518563ffffffff1660e01b81526004016127b3949392919061578a565b600060405180830381865afa1580156127d0573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526128169190810190615820565b805191935091501561289557826020015173ffffffffffffffffffffffffffffffffffffffff1663946aadc66000836040518363ffffffff1660e01b81526004016128629291906158b3565b600060405180830381600087803b15801561287c57600080fd5b505af1158015612890573d6000803e3d6000fd5b505050505b50505050505050565b600054610100900460ff16612935576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610160612942838261548a565b506101616106d8828261548a565b600054610100900460ff166129e7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610e0d33611e35565b6000806129fc84611949565b60020260010190506000612a108585613518565b949091019093016020019392505050565b600054610100900460ff16610e0d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b600054610100900460ff16612b4f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b610e0d61356f565b60008060208302855b87811115612b84576020810386815103612b7b579350612b84565b50819003612b60565b5082600003612bc2576040517fd457746f00000000000000000000000000000000000000000000000000000000815260048101869052602401610610565b604051915060208201602084015b87811015612be8578082526020909101908201612bd0565b50806040526001602084830304038352505094509492505050565b612c2760405180606001604052806060815260200160608152602001606081525090565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c0000000000000000000000000000602090910152606080806000612c8f87877ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6004612b57565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c00000000000000000000000000006020909101529096509350839050612cf987877ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6004612b57565b60408051808201909152601281527f5241494e5f464c4f575f53454e54494e454c00000000000000000000000000006020909101529096509250829050612d6387877ffea74d0c9bf4a3c28f0dd0674db22a3d7f8bf259c56af19f4ac1e735b156974f6005612b57565b60408051606081018252968752602087019590955293850193909352509195945050505050565b60606000808573ffffffffffffffffffffffffffffffffffffffff1685604051612db491906158cc565b600060405180830381855af49150503d8060008114612def576040519150601f19603f3d011682016040523d82523d6000602084013e612df4565b606091505b5091509150612e0586838387613606565b9695505050505050565b600073ffffffffffffffffffffffffffffffffffffffff84163b15612ff7576040517f150b7a0200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85169063150b7a0290612e869033908990889088906004016158e8565b6020604051808303816000875af1925050508015612edf575060408051601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168201909252612edc91810190615927565b60015b612fac573d808015612f0d576040519150601f19603f3d011682016040523d82523d6000602084013e612f12565b606091505b508051600003612fa4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610610565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050610731565b506001610731565b600080600061300e85856136a6565b9092509050600081600481111561302757613027615944565b14801561305f57508573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16145b80612e055750612e058686866136eb565b60606101c880546104949061521e565b6060600061308d83613848565b600101905060008167ffffffffffffffff8111156130ad576130ad614624565b6040519080825280601f01601f1916602001820160405280156130d7576020820181803683370190505b5090508181016020015b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85049450846130e157509392505050565b600261012d54036131ab576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610610565b600261012d55565b600080606060006131df6131d98760408051600181526020810192909252818101905290565b866120a3565b90507f17a5c0f3785132a57703932032f6863e7920434150aa1dc940e567b440fdce1f3382604051613212929190615973565b60405180910390a160608720600081815261015f6020526040902054613267576040517f7a80ba4d00000000000000000000000000000000000000000000000000000000815260048101829052602401610610565b50865160208089015160408a0151600093849373ffffffffffffffffffffffffffffffffffffffff90911692636715f8259290918591901b77ffffffffffffffffffffffffffffffffffffffff000000001661ffff17876040518563ffffffff1660e01b81526004016132dd949392919061578a565b600060405180830381865afa1580156132fa573d6000803e3d6000fd5b505050506040513d6000823e601f3d9081017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01682016040526133409190810190615820565b9150915061334e8260200190565b8251909a60209182029093010198509650945050505050565b610e2a82826040518060200160405280600081525061392a565b600061338c82610c9f565b905061339782610c9f565b60008381526101646020908152604080832080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811690915573ffffffffffffffffffffffffffffffffffffffff8516808552610163845282852080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019055878552610162909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a4610e2a816000846001612640565b8051156134f5576040517f946aadc600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83169063946aadc6906134c29060009085906004016158b3565b600060405180830381600087803b1580156134dc57600080fd5b505af11580156134f0573d6000803e3d6000fd5b505050505b6134fe836139cd565b61350783613b26565b6106d883613cb6565b600161012d55565b600061352383611949565b821061355f5782826040517f30489add0000000000000000000000000000000000000000000000000000000081526004016106109291906159a2565b50600202016003015161ffff1690565b600054610100900460ff16613510576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610610565b6060831561369c5782516000036136955773ffffffffffffffffffffffffffffffffffffffff85163b613695576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610610565b5081610731565b6107318383613e66565b60008082516041036136dc5760208301516040840151606085015160001a6136d087828585613eaa565b945094505050506136e4565b506000905060025b9250929050565b60008060008573ffffffffffffffffffffffffffffffffffffffff16631626ba7e60e01b86866040516024016137229291906159c4565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529181526020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff000000000000000000000000000000000000000000000000000000009094169390931790925290516137ab91906158cc565b600060405180830381855afa9150503d80600081146137e6576040519150601f19603f3d011682016040523d82523d6000602084013e6137eb565b606091505b50915091508180156137ff57506020815110155b8015612e05575080517f1626ba7e000000000000000000000000000000000000000000000000000000009061383d90830160209081019084016159dd565b149695505050505050565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310613891577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef810000000083106138bd576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106138db57662386f26fc10000830492506010015b6305f5e10083106138f3576305f5e100830492506008015b612710831061390757612710830492506004015b60648310613919576064830492506002015b600a831061047e5760010192915050565b6139348383613f99565b6139416000848484612e0f565b6106d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603260248201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560448201527f63656976657220696d706c656d656e74657200000000000000000000000000006064820152608401610610565b6040805160808101825260008082526020820181905291810182905260608101829052905b8251518110156106d8578251805182908110613a1057613a1061566c565b602002602001015191503373ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff1603613a8757604082015160608301518351613a829273ffffffffffffffffffffffffffffffffffffffff909116913391906141cc565b613b1e565b3073ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff1603613aec57604082015160608301518351613a829273ffffffffffffffffffffffffffffffffffffffff909116916142a8565b6040517fa521c60f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001016139f2565b6040805160808101825260008082526020820181905291810182905260608101829052905b8260200151518110156106d85782602001518181518110613b6e57613b6e61566c565b602002602001015191503373ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff1614158015613bd25750602082015173ffffffffffffffffffffffffffffffffffffffff163014155b15613c09576040517f3a5befc500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81516020830151604080850151606086015191517f42842e0e00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9384166004820152908316602482015260448101919091529116906342842e0e90606401600060405180830381600087803b158015613c9357600080fd5b505af1158015613ca7573d6000803e3d6000fd5b50505050806001019050613b4b565b6040805160a0810182526000808252602082018190529181018290526060810182905260808101829052905b8260400151518110156106d85782604001518181518110613d0557613d0561566c565b602002602001015191503373ffffffffffffffffffffffffffffffffffffffff16826020015173ffffffffffffffffffffffffffffffffffffffff1614158015613d695750602082015173ffffffffffffffffffffffffffffffffffffffff163014155b15613da0576040517fc6a91ecc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b815160208301516040808501516060860151608087015192517ff242432a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff948516600482015291841660248301526044820152606481019190915260a06084820152600060a482015291169063f242432a9060c401600060405180830381600087803b158015613e4257600080fd5b505af1158015613e56573d6000803e3d6000fd5b505060019092019150613ce29050565b815115613e765781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610610919061459a565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115613ee15750600090506003613f90565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613f35573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116613f8957600060019250925050613f90565b9150600090505b94509492505050565b73ffffffffffffffffffffffffffffffffffffffff8216614016576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610610565b6000818152610162602052604090205473ffffffffffffffffffffffffffffffffffffffff16156140a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610610565b6000818152610162602052604090205473ffffffffffffffffffffffffffffffffffffffff1615614130576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610610565b73ffffffffffffffffffffffffffffffffffffffff82166000818152610163602090815260408083208054600101905584835261016290915280822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4610e2a600083836001612640565b60405173ffffffffffffffffffffffffffffffffffffffff80851660248301528316604482015260648101829052610fbe9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526142fe565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526106d89084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401614226565b6000614360826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661440d9092919063ffffffff16565b905080516000148061438157508080602001905181019061438191906159f6565b6106d8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610610565b606061126a8484600085856000808673ffffffffffffffffffffffffffffffffffffffff16858760405161444191906158cc565b60006040518083038185875af1925050503d806000811461447e576040519150601f19603f3d011682016040523d82523d6000602084013e614483565b606091505b509150915061449487838387613606565b979650505050505050565b604051806060016040528060608152602001606081526020016144dc60405180606001604052806060815260200160608152602001606081525090565b905290565b7fffffffff000000000000000000000000000000000000000000000000000000008116811461125457600080fd5b60006020828403121561452157600080fd5b813561126d816144e1565b60005b8381101561454757818101518382015260200161452f565b50506000910152565b6000815180845261456881602086016020860161452c565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b60208152600061126d6020830184614550565b6000602082840312156145bf57600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461125457600080fd5b80356145f3816145c6565b919050565b6000806040838503121561460b57600080fd5b8235614616816145c6565b946020939093013593505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516060810167ffffffffffffffff8111828210171561467657614676614624565b60405290565b60405160c0810167ffffffffffffffff8111828210171561467657614676614624565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156146e6576146e6614624565b604052919050565b600082601f8301126146ff57600080fd5b813567ffffffffffffffff81111561471957614719614624565b61474a60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160161469f565b81815284602083860101111561475f57600080fd5b816020850160208301376000918101602001919091529392505050565b600067ffffffffffffffff82111561479657614796614624565b5060051b60200190565b600082601f8301126147b157600080fd5b813560206147c66147c18361477c565b61469f565b82815260059290921b840181019181810190868411156147e557600080fd5b8286015b8481101561480057803583529183019183016147e9565b509695505050505050565b60006060828403121561481d57600080fd5b614825614653565b90508135614832816145c6565b8152602082013567ffffffffffffffff8082111561484f57600080fd5b61485b858386016146ee565b6020840152604084013591508082111561487457600080fd5b50614881848285016147a0565b60408301525092915050565b600082601f83011261489e57600080fd5b813560206148ae6147c18361477c565b82815260059290921b840181019181810190868411156148cd57600080fd5b8286015b8481101561480057803567ffffffffffffffff8111156148f15760008081fd5b6148ff8986838b010161480b565b8452509183019183016148d1565b60006020828403121561491f57600080fd5b813567ffffffffffffffff8082111561493757600080fd5b9083019060c0828603121561494b57600080fd5b61495361467c565b82358281111561496257600080fd5b61496e878286016146ee565b82525060208301358281111561498357600080fd5b61498f878286016146ee565b6020830152506040830135828111156149a757600080fd5b6149b3878286016146ee565b6040830152506149c5606084016145e8565b60608201526080830135828111156149dc57600080fd5b6149e88782860161480b565b60808301525060a083013582811115614a0057600080fd5b614a0c8782860161488d565b60a08301525095945050505050565b60008060008060808587031215614a3157600080fd5b8435614a3c816145c6565b93506020850135614a4c816145c6565b925060408501359150606085013567ffffffffffffffff811115614a6f57600080fd5b614a7b878288016146ee565b91505092959194509250565b600080600060608486031215614a9c57600080fd5b8335614aa7816145c6565b92506020840135614ab7816145c6565b929592945050506040919091013590565b60008060208385031215614adb57600080fd5b823567ffffffffffffffff80821115614af357600080fd5b818501915085601f830112614b0757600080fd5b813581811115614b1657600080fd5b866020828501011115614b2857600080fd5b60209290920196919550909350505050565b600060208284031215614b4c57600080fd5b813567ffffffffffffffff811115614b6357600080fd5b610731848285016147a0565b600081518084526020808501945080840160005b83811015614bc0578151805173ffffffffffffffffffffffffffffffffffffffff1688528301518388015260409096019590820190600101614b83565b509495945050505050565b600081518084526020808501945080840160005b83811015614bc0578151805173ffffffffffffffffffffffffffffffffffffffff9081168952848201518116858a015260408083015190911690890152606080820151908901526080908101519088015260a09096019590820190600101614bdf565b6000602080835260808451606083860152614c5f82860182614b6f565b9050828601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe080878403016040880152614c9a8383614b6f565b92506040880151915080878403016060880152506060820181516060845281815180845286860191508783019350600092505b80831015614d3157614d1d82855173ffffffffffffffffffffffffffffffffffffffff80825116835280602083015116602084015280604083015116604084015250606081015160608301525050565b928701926001929092019190860190614ccd565b5083870151858203868901528051808352908801935090870191506000905b80821015614db457614da083855173ffffffffffffffffffffffffffffffffffffffff80825116835280602083015116602084015280604083015116604084015250606081015160608301525050565b928701929186019160019190910190614d50565b5050604083015195508381036040850152614dcf8187614bcb565b9998505050505050505050565b600060208284031215614dee57600080fd5b813561126d816145c6565b801515811461125457600080fd5b60008060408385031215614e1a57600080fd5b8235614e25816145c6565b91506020830135614e3581614df9565b809150509250929050565b60008060208385031215614e5357600080fd5b823567ffffffffffffffff80821115614e6b57600080fd5b818501915085601f830112614e7f57600080fd5b813581811115614e8e57600080fd5b8660208260051b8501011115614b2857600080fd5b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015614f16577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc0888603018452614f04858351614550565b94509285019290850190600101614eca565b5092979650505050505050565b600080600080600060a08688031215614f3b57600080fd5b8535614f46816145c6565b94506020860135614f56816145c6565b9350604086013567ffffffffffffffff80821115614f7357600080fd5b614f7f89838a016147a0565b94506060880135915080821115614f9557600080fd5b614fa189838a016147a0565b93506080880135915080821115614fb757600080fd5b50614fc4888289016146ee565b9150509295509295909350565b60008060408385031215614fe457600080fd5b8235614fef816145c6565b91506020830135614e35816145c6565b600080600080600060a0868803121561501757600080fd5b8535615022816145c6565b94506020860135615032816145c6565b93506040860135925060608601359150608086013567ffffffffffffffff81111561505c57600080fd5b614fc4888289016146ee565b600080600083850360a081121561507e57600080fd5b606081121561508c57600080fd5b50615095614653565b84356150a0816145c6565b81526020858101356150b1816145c6565b8282015260408601356150c3816145c6565b604083015290935060608501359067ffffffffffffffff808311156150e757600080fd5b6150f3888489016147a0565b9450608087013592508083111561510957600080fd5b828701925087601f84011261511d57600080fd5b823561512b6147c18261477c565b81815260059190911b8401830190838101908a83111561514a57600080fd5b8486015b8381101561520d578035858111156151665760008081fd5b87016060818e037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001121561519b5760008081fd5b6151a3614653565b878201356151b0816145c6565b81526040820135878111156151c55760008081fd5b6151d38f8a838601016147a0565b89830152506060820135878111156151eb5760008081fd5b6151f98f8a838601016146ee565b60408301525084525091850191850161514e565b508096505050505050509250925092565b600181811c9082168061523257607f821691505b60208210810361526b577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b600081518084526020808501945080840160005b83811015614bc057815187529582019590820190600101615285565b73ffffffffffffffffffffffffffffffffffffffff815116825260006020820151606060208501526152d66060850182614550565b9050604083015184820360408601526152ef8282615271565b95945050505050565b600073ffffffffffffffffffffffffffffffffffffffff80851683526020604081850152845160c06040860152615333610100860182614550565b9050818601517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08087840301606088015261536e8383614550565b9250604088015191508087840301608088015261538b8383614550565b92508460608901511660a088015260808801519450808784030160c08801526153b483866152a1565b60a089015188820390920160e0890152815180825290955090840192508385019150600581901b8501840160005b8281101561542e577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe087830301845261541c8286516152a1565b948601949386019391506001016153e2565b509998505050505050505050565b601f8211156106d857600081815260208120601f850160051c810160208610156154635750805b601f850160051c820191505b818110156154825782815560010161546f565b505050505050565b815167ffffffffffffffff8111156154a4576154a4614624565b6154b8816154b2845461521e565b8461543c565b602080601f83116001811461550b57600084156154d55750858301515b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600386901b1c1916600185901b178555615482565b6000858152602081207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08616915b8281101561555857888601518255948401946001909101908401615539565b508582101561559457878501517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff600388901b60f8161c191681555b5050505050600190811b01905550565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561047e5761047e6155a4565b6060815260006155f96060830186614550565b828103602084015261560b8186615271565b90508281036040840152612e058185615271565b60008060006060848603121561563457600080fd5b835161563f816145c6565b6020850151909350615650816145c6565b6040850151909250615661816145c6565b809150509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18436030181126156d057600080fd5b83018035915067ffffffffffffffff8211156156eb57600080fd5b6020019150368190038213156136e457600080fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203615731576157316155a4565b5060010190565b6000815180845260208085019450848260051b860182860160005b8581101561577d57838303895261576b838351615271565b98850198925090840190600101615753565b5090979650505050505050565b73ffffffffffffffffffffffffffffffffffffffff85168152836020820152826040820152608060608201526000612e056080830184615738565b600082601f8301126157d657600080fd5b815160206157e66147c18361477c565b82815260059290921b8401810191818101908684111561580557600080fd5b8286015b848110156148005780518352918301918301615809565b6000806040838503121561583357600080fd5b825167ffffffffffffffff8082111561584b57600080fd5b615857868387016157c5565b9350602085015191508082111561586d57600080fd5b5061587a858286016157c5565b9150509250929050565b6000835161589681846020880161452c565b8351908301906158aa81836020880161452c565b01949350505050565b82815260406020820152600061126a6040830184615271565b600082516158de81846020870161452c565b9190910192915050565b600073ffffffffffffffffffffffffffffffffffffffff808716835280861660208401525083604083015260806060830152612e056080830184614550565b60006020828403121561593957600080fd5b815161126d816144e1565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b73ffffffffffffffffffffffffffffffffffffffff8316815260406020820152600061126a6040830184615738565b6040815260006159b56040830185614550565b90508260208301529392505050565b82815260406020820152600061126a6040830184614550565b6000602082840312156159ef57600080fd5b5051919050565b600060208284031215615a0857600080fd5b815161126d81614df956fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564
| |
1 | 19,498,630 |
ba73c0e465441f4f2a8a30a6a663756163920293766229c6e7f49896868a90e7
|
61d660256a018e62e6c44ac05ea01e75c9ede374f1200945533a3dbddf4d2853
|
eb9b13d5bc9a91b7da925d70448fd43e393a56d1
|
d039bc83136011e3b6017cda4d4d597865b13bed
|
0e1778d8a6f6025f059f4e63b2d29c7c44db4054
|
61004180600c6000396000f3000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
| |
1 | 19,498,632 |
e10e869b1d9c61c8e60f421b0816c8bd6c036d65d85945b8e85ec959fe9d6540
|
f73e82d4f87530d1ec682693915a54b6bcb10665e6d5a17cf31bd43e2a9cd47f
|
84ba51a3b082066482385c2e77c15b36b2888888
|
fc27cd13b432805f47c90a16646d402566bd3143
|
528651d9a2fd792170ffa27e99da2af5b7b4eb7b
|
60a060405234801561001057600080fd5b506040516101093803806101098339818101604052602081101561003357600080fd5b50516001600160601b031960609190911b16608052600080546001600160a01b0319163317905560805160601c609561007460003980601b525060956000f3fe608060405236600a57005b348015601557600080fd5b506040517f0000000000000000000000000000000000000000000000000000000000000000903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c003300000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a
|
608060405236600a57005b348015601557600080fd5b506040517f00000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c0033
| |
1 | 19,498,632 |
e10e869b1d9c61c8e60f421b0816c8bd6c036d65d85945b8e85ec959fe9d6540
|
f73e82d4f87530d1ec682693915a54b6bcb10665e6d5a17cf31bd43e2a9cd47f
|
84ba51a3b082066482385c2e77c15b36b2888888
|
fc27cd13b432805f47c90a16646d402566bd3143
|
f47d44c67841727212a82ca2fff050a8a6e517ce
|
60a060405234801561001057600080fd5b506040516101093803806101098339818101604052602081101561003357600080fd5b50516001600160601b031960609190911b16608052600080546001600160a01b0319163317905560805160601c609561007460003980601b525060956000f3fe608060405236600a57005b348015601557600080fd5b506040517f0000000000000000000000000000000000000000000000000000000000000000903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c003300000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a
|
608060405236600a57005b348015601557600080fd5b506040517f00000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c0033
| |
1 | 19,498,632 |
e10e869b1d9c61c8e60f421b0816c8bd6c036d65d85945b8e85ec959fe9d6540
|
f73e82d4f87530d1ec682693915a54b6bcb10665e6d5a17cf31bd43e2a9cd47f
|
84ba51a3b082066482385c2e77c15b36b2888888
|
fc27cd13b432805f47c90a16646d402566bd3143
|
50c64bfc8b5ecdc20532c954f5c3cda8b99c7dc9
|
60a060405234801561001057600080fd5b506040516101093803806101098339818101604052602081101561003357600080fd5b50516001600160601b031960609190911b16608052600080546001600160a01b0319163317905560805160601c609561007460003980601b525060956000f3fe608060405236600a57005b348015601557600080fd5b506040517f0000000000000000000000000000000000000000000000000000000000000000903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c003300000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a
|
608060405236600a57005b348015601557600080fd5b506040517f00000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c0033
| |
1 | 19,498,632 |
e10e869b1d9c61c8e60f421b0816c8bd6c036d65d85945b8e85ec959fe9d6540
|
f73e82d4f87530d1ec682693915a54b6bcb10665e6d5a17cf31bd43e2a9cd47f
|
84ba51a3b082066482385c2e77c15b36b2888888
|
fc27cd13b432805f47c90a16646d402566bd3143
|
d9bf059bced734cab67c14f61ebb63644302f63c
|
60a060405234801561001057600080fd5b506040516101093803806101098339818101604052602081101561003357600080fd5b50516001600160601b031960609190911b16608052600080546001600160a01b0319163317905560805160601c609561007460003980601b525060956000f3fe608060405236600a57005b348015601557600080fd5b506040517f0000000000000000000000000000000000000000000000000000000000000000903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c003300000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a
|
608060405236600a57005b348015601557600080fd5b506040517f00000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c0033
| |
1 | 19,498,632 |
e10e869b1d9c61c8e60f421b0816c8bd6c036d65d85945b8e85ec959fe9d6540
|
f73e82d4f87530d1ec682693915a54b6bcb10665e6d5a17cf31bd43e2a9cd47f
|
84ba51a3b082066482385c2e77c15b36b2888888
|
fc27cd13b432805f47c90a16646d402566bd3143
|
050fc2ebe163698e130c4e9788444de7f6e94a63
|
60a060405234801561001057600080fd5b506040516101093803806101098339818101604052602081101561003357600080fd5b50516001600160601b031960609190911b16608052600080546001600160a01b0319163317905560805160601c609561007460003980601b525060956000f3fe608060405236600a57005b348015601557600080fd5b506040517f0000000000000000000000000000000000000000000000000000000000000000903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c003300000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a
|
608060405236600a57005b348015601557600080fd5b506040517f00000000000000000000000080d0f44d6c1563de6ba356aa8dfe7abdbe8a174a903680600083376000808284865af43d9150816000843e808015605b578284f35b8284fdfea2646970667358221220c4a46717f67197616503d87ff2612122c70a6a9ed6d1f1999e000b68e428470964736f6c634300060c0033
| |
1 | 19,498,634 |
26e6b5995f72d82806e19944a24a097a6831d7df5abf3681b584c3dfb7f2f5ba
|
13655fce79523f9e107acfc4d808ac4360dc54a08de479ecb7579ef4fe4b3ce9
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
dae03294d93fadad96eedd9e725ec860d37bcf39
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,638 |
79f6fbb656030cbad1fe11c69c5e9ea2caf2f7e908fc75cf9768df3a4e8e817e
|
e7d4ab0a883257fa6352fcc7302355884d88fffca55f7aeb42b56fa21a5eb143
|
c9aad2fc90eddacf02bd11fa690e3b44e318aa9b
|
a2a1bf5a83f9daec2dc364e1c561e937163cb613
|
b00b970d7c5d75e407c274019a78e852c0b7ff57
|
3d602d80600a3d3981f3363d3d373d3d3d363d7387ae9be718aa310323042ab9806bd6692c1129b75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7387ae9be718aa310323042ab9806bd6692c1129b75af43d82803e903d91602b57fd5bf3
| |
1 | 19,498,640 |
1965d0747cb24dd8084d83478a9ba5085f70447c7721e172397915f51761681e
|
a63eba05f0ffdfea2d89e96606f5b42e46be9ce1adb46ac07a0f7afb75538f77
|
d8835c84cfbd28471b22d55d63cd26632768f720
|
d8835c84cfbd28471b22d55d63cd26632768f720
|
4bbe120125d7a5ec38edc7e81bfc293d6cb2cb12
|
608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560b1806100316000396000f3fe60806040526004361060205760003560e01c80633ccfd60b14602b57600080fd5b36602657005b600080fd5b348015603657600080fd5b50603d603f565b005b600080546040516001600160a01b03909116914780156108fc02929091818181858888f193505050501580156078573d6000803e3d6000fd5b5056fea26469706673582212209fdfaa17acb861751dc25be703bcb7eb111aeded834726beca2f4acbb730f9b964736f6c63430008070033
|
60806040526004361060205760003560e01c80633ccfd60b14602b57600080fd5b36602657005b600080fd5b348015603657600080fd5b50603d603f565b005b600080546040516001600160a01b03909116914780156108fc02929091818181858888f193505050501580156078573d6000803e3d6000fd5b5056fea26469706673582212209fdfaa17acb861751dc25be703bcb7eb111aeded834726beca2f4acbb730f9b964736f6c63430008070033
| |
1 | 19,498,641 |
196ddcffb98213f89913209d7cf085f9f3fe8120c021628fc184926e83111475
|
2e25643d6e40cfb32248de64df6a77291d5ec151bfd803a68f3d9541dc49c89f
|
65a3e0200d87b2e50778bdbbaec828362826a442
|
a6b71e26c5e0845f74c812102ca7114b6a896ab2
|
5538c8fa704dfcb1c540c25ddcfb3e4327d121b4
|
608060405234801561001057600080fd5b506040516101e63803806101e68339818101604052602081101561003357600080fd5b8101908080519060200190929190505050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156100ca576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260228152602001806101c46022913960400191505060405180910390fd5b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505060ab806101196000396000f3fe608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033496e76616c69642073696e676c65746f6e20616464726573732070726f7669646564000000000000000000000000d9db270c1b5e3bd161e8c8503c55ceabee709552
|
608060405273ffffffffffffffffffffffffffffffffffffffff600054167fa619486e0000000000000000000000000000000000000000000000000000000060003514156050578060005260206000f35b3660008037600080366000845af43d6000803e60008114156070573d6000fd5b3d6000f3fea2646970667358221220d1429297349653a4918076d650332de1a1068c5f3e07c5c82360c277770b955264736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title GnosisSafeProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract GnosisSafeProxy {
// singleton always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal singleton;
/// @dev Constructor function sets address of singleton contract.
/// @param _singleton Singleton address.
constructor(address _singleton) {
require(_singleton != address(0), "Invalid singleton address provided");
singleton = _singleton;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback() external payable {
// solhint-disable-next-line no-inline-assembly
assembly {
let _singleton := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _singleton)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _singleton, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) {
revert(0, returndatasize())
}
return(0, returndatasize())
}
}
}
/// @title Proxy Factory - Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @author Stefan George - <stefan@gnosis.pm>
contract GnosisSafeProxyFactory {
event ProxyCreation(GnosisSafeProxy proxy, address singleton);
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param singleton Address of singleton contract.
/// @param data Payload for message call sent to new proxy contract.
function createProxy(address singleton, bytes memory data) public returns (GnosisSafeProxy proxy) {
proxy = new GnosisSafeProxy(singleton);
if (data.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(data, 0x20), mload(data), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, singleton);
}
/// @dev Allows to retrieve the runtime code of a deployed Proxy. This can be used to check that the expected Proxy was deployed.
function proxyRuntimeCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).runtimeCode;
}
/// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.
function proxyCreationCode() public pure returns (bytes memory) {
return type(GnosisSafeProxy).creationCode;
}
/// @dev Allows to create new proxy contact using CREATE2 but it doesn't run the initializer.
/// This method is only meant as an utility to be called from other methods
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function deployProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) internal returns (GnosisSafeProxy proxy) {
// If the initializer changes the proxy address should change too. Hashing the initializer data is cheaper than just concatinating it
bytes32 salt = keccak256(abi.encodePacked(keccak256(initializer), saltNonce));
bytes memory deploymentData = abi.encodePacked(type(GnosisSafeProxy).creationCode, uint256(uint160(_singleton)));
// solhint-disable-next-line no-inline-assembly
assembly {
proxy := create2(0x0, add(0x20, deploymentData), mload(deploymentData), salt)
}
require(address(proxy) != address(0), "Create2 call failed");
}
/// @dev Allows to create new proxy contact and execute a message call to the new proxy within one transaction.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function createProxyWithNonce(
address _singleton,
bytes memory initializer,
uint256 saltNonce
) public returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
if (initializer.length > 0)
// solhint-disable-next-line no-inline-assembly
assembly {
if eq(call(gas(), proxy, 0, add(initializer, 0x20), mload(initializer), 0, 0), 0) {
revert(0, 0)
}
}
emit ProxyCreation(proxy, _singleton);
}
/// @dev Allows to create new proxy contact, execute a message call to the new proxy and call a specified callback within one transaction
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
/// @param callback Callback that will be invoced after the new proxy contract has been successfully deployed and initialized.
function createProxyWithCallback(
address _singleton,
bytes memory initializer,
uint256 saltNonce,
IProxyCreationCallback callback
) public returns (GnosisSafeProxy proxy) {
uint256 saltNonceWithCallback = uint256(keccak256(abi.encodePacked(saltNonce, callback)));
proxy = createProxyWithNonce(_singleton, initializer, saltNonceWithCallback);
if (address(callback) != address(0)) callback.proxyCreated(proxy, _singleton, initializer, saltNonce);
}
/// @dev Allows to get the address for a new proxy contact created via `createProxyWithNonce`
/// This method is only meant for address calculation purpose when you use an initializer that would revert,
/// therefore the response is returned with a revert. When calling this method set `from` to the address of the proxy factory.
/// @param _singleton Address of singleton contract.
/// @param initializer Payload for message call sent to new proxy contract.
/// @param saltNonce Nonce that will be used to generate the salt to calculate the address of the new proxy contract.
function calculateCreateProxyWithNonceAddress(
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external returns (GnosisSafeProxy proxy) {
proxy = deployProxyWithNonce(_singleton, initializer, saltNonce);
revert(string(abi.encodePacked(proxy)));
}
}
interface IProxyCreationCallback {
function proxyCreated(
GnosisSafeProxy proxy,
address _singleton,
bytes calldata initializer,
uint256 saltNonce
) external;
}
|
1 | 19,498,645 |
96df2fea9da87fb6b3b71d3f62e9ade1ca79f8c4b5215100636e902d2259b024
|
5b692de98e191a9e2c352941a503cdfab1e8352d7a0552510c914742b79ec044
|
edee915ae45cc4b2fdd1ce12a2f70dca0b2ad9e5
|
8428e8d6c57de2420a62ff840bece86c4ea28723
|
684f0e3cc67459df8e4ac360d7338f2ac7598f60
|
608060405234801561001057600080fd5b506101d8806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80631626ba7e14610030575b600080fd5b61006561003e3660046100c9565b7f1626ba7e0000000000000000000000000000000000000000000000000000000092915050565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200160405180910390f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156100dc57600080fd5b82359150602083013567ffffffffffffffff808211156100fb57600080fd5b818501915085601f83011261010f57600080fd5b8135818111156101215761012161009a565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156101675761016761009a565b8160405282815288602084870101111561018057600080fd5b826020860160208301376000602084830101528095505050505050925092905056fea2646970667358221220c84eed3ee88204a61c6d673aa561ff38b6b4430c9518de20f4308a14179b37d064736f6c634300080b0033
|
608060405234801561001057600080fd5b506004361061002b5760003560e01c80631626ba7e14610030575b600080fd5b61006561003e3660046100c9565b7f1626ba7e0000000000000000000000000000000000000000000000000000000092915050565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200160405180910390f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156100dc57600080fd5b82359150602083013567ffffffffffffffff808211156100fb57600080fd5b818501915085601f83011261010f57600080fd5b8135818111156101215761012161009a565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156101675761016761009a565b8160405282815288602084870101111561018057600080fd5b826020860160208301376000602084830101528095505050505050925092905056fea2646970667358221220c84eed3ee88204a61c6d673aa561ff38b6b4430c9518de20f4308a14179b37d064736f6c634300080b0033
| |
1 | 19,498,645 |
96df2fea9da87fb6b3b71d3f62e9ade1ca79f8c4b5215100636e902d2259b024
|
5b692de98e191a9e2c352941a503cdfab1e8352d7a0552510c914742b79ec044
|
edee915ae45cc4b2fdd1ce12a2f70dca0b2ad9e5
|
57e037f4d2c8bea011ad8a9a5af4aaeed508650f
|
74da867930dc999fdcab1950cfae77c890e442c4
|
608060405234801561001057600080fd5b5060405161016f38038061016f8339818101604052602081101561003357600080fd5b50516001600160a01b03811661007a5760405162461bcd60e51b815260040180806020018281038252602481526020018061014b6024913960400191505060405180910390fd5b600080546001600160a01b039092166001600160a01b031990921691909117905560a2806100a96000396000f3fe6080604052600073ffffffffffffffffffffffffffffffffffffffff8154167fa619486e0000000000000000000000000000000000000000000000000000000082351415604e57808252602082f35b3682833781823684845af490503d82833e806067573d82fd5b503d81f3fea2646970667358221220676404d5a2e50e328cc18fc786619f9629ae43d7ff695286c941717f0a1541e564736f6c63430007060033496e76616c6964206d617374657220636f707920616464726573732070726f76696465640000000000000000000000005fc8a17dded0a4da0f9a1e44e6c26f80aa514145
|
6080604052600073ffffffffffffffffffffffffffffffffffffffff8154167fa619486e0000000000000000000000000000000000000000000000000000000082351415604e57808252602082f35b3682833781823684845af490503d82833e806067573d82fd5b503d81f3fea2646970667358221220676404d5a2e50e328cc18fc786619f9629ae43d7ff695286c941717f0a1541e564736f6c63430007060033
|
// SPDX-License-Identifier: LGPL-3.0-or-later
// Taken from: https://github.com/gnosis/safe-contracts/blob/development/contracts/proxies/GnosisSafeProxy.sol
pragma solidity ^0.7.0;
/// @title IProxy - Helper interface to access masterCopy of the Proxy on-chain
/// @author Richard Meissner - <richard@gnosis.io>
interface IProxy {
function masterCopy() external view returns (address);
}
/// @title WalletProxy - Generic proxy contract allows to execute all transactions applying the code of a master contract.
/// @author Stefan George - <stefan@gnosis.io>
/// @author Richard Meissner - <richard@gnosis.io>
contract WalletProxy {
// masterCopy always needs to be first declared variable, to ensure that it is at the same location in the contracts to which calls are delegated.
// To reduce deployment costs this variable is internal and needs to be retrieved via `getStorageAt`
address internal masterCopy;
/// @dev Constructor function sets address of master copy contract.
/// @param _masterCopy Master copy address.
constructor(address _masterCopy)
{
require(_masterCopy != address(0), "Invalid master copy address provided");
masterCopy = _masterCopy;
}
/// @dev Fallback function forwards all transactions and returns all received return data.
fallback()
payable
external
{
// solium-disable-next-line security/no-inline-assembly
assembly {
let _masterCopy := and(sload(0), 0xffffffffffffffffffffffffffffffffffffffff)
// 0xa619486e == keccak("masterCopy()"). The value is right padded to 32-bytes with 0s
if eq(calldataload(0), 0xa619486e00000000000000000000000000000000000000000000000000000000) {
mstore(0, _masterCopy)
return(0, 0x20)
}
calldatacopy(0, 0, calldatasize())
let success := delegatecall(gas(), _masterCopy, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
if eq(success, 0) { revert(0, returndatasize()) }
return(0, returndatasize())
}
}
}
|
1 | 19,498,645 |
96df2fea9da87fb6b3b71d3f62e9ade1ca79f8c4b5215100636e902d2259b024
|
5b692de98e191a9e2c352941a503cdfab1e8352d7a0552510c914742b79ec044
|
edee915ae45cc4b2fdd1ce12a2f70dca0b2ad9e5
|
8428e8d6c57de2420a62ff840bece86c4ea28723
|
684f0e3cc67459df8e4ac360d7338f2ac7598f60
|
608060405234801561001057600080fd5b506101d8806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80631626ba7e14610030575b600080fd5b61006561003e3660046100c9565b7f1626ba7e0000000000000000000000000000000000000000000000000000000092915050565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200160405180910390f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156100dc57600080fd5b82359150602083013567ffffffffffffffff808211156100fb57600080fd5b818501915085601f83011261010f57600080fd5b8135818111156101215761012161009a565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156101675761016761009a565b8160405282815288602084870101111561018057600080fd5b826020860160208301376000602084830101528095505050505050925092905056fea2646970667358221220c84eed3ee88204a61c6d673aa561ff38b6b4430c9518de20f4308a14179b37d064736f6c634300080b0033
|
608060405234801561001057600080fd5b506004361061002b5760003560e01c80631626ba7e14610030575b600080fd5b61006561003e3660046100c9565b7f1626ba7e0000000000000000000000000000000000000000000000000000000092915050565b6040517fffffffff00000000000000000000000000000000000000000000000000000000909116815260200160405180910390f35b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b600080604083850312156100dc57600080fd5b82359150602083013567ffffffffffffffff808211156100fb57600080fd5b818501915085601f83011261010f57600080fd5b8135818111156101215761012161009a565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0908116603f011681019083821181831017156101675761016761009a565b8160405282815288602084870101111561018057600080fd5b826020860160208301376000602084830101528095505050505050925092905056fea2646970667358221220c84eed3ee88204a61c6d673aa561ff38b6b4430c9518de20f4308a14179b37d064736f6c634300080b0033
| |
1 | 19,498,646 |
8b4226c285c41a3db835031800a8643cbfdbf691d89e2109861c07af8deec23c
|
c408e698ce9f48374fd78b23ac9090818ec9bfd9462bdb5dc7ca89839f94a3a1
|
d89e18f6fbd533fe1b87d0e323a6a55f3188cb1a
|
d89e18f6fbd533fe1b87d0e323a6a55f3188cb1a
|
a61194b2b03812353310edae0c9e459b71f26d5c
|
60806040526b2a64aef3f64efd95334602e960075560405162001269380380620012698339810160408190526200003691620002a9565b8585856004620000478482620003df565b506005620000568382620003df565b5060035550506040516001600160a01b038216903480156108fc02916000818181858888f1935050505015801562000092573d6000803e3d6000fd5b50600680546001600160a01b0319166001600160a01b038416179055620000d282620000c086600a620005c0565b620000cc9086620005d5565b620000de565b50505050505062000605565b6001600160a01b038216620001395760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b80600260008282546200014d9190620005ef565b90915550506001600160a01b038216600090815260208190526040812080548392906200017c908490620005ef565b90915550506040518181526001600160a01b038316906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35050565b505050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112620001f357600080fd5b81516001600160401b0380821115620002105762000210620001cb565b604051601f8301601f19908116603f011681019082821181831017156200023b576200023b620001cb565b816040528381526020925086838588010111156200025857600080fd5b600091505b838210156200027c57858201830151818301840152908201906200025d565b600093810190920192909252949350505050565b6001600160a01b0381168114620002a657600080fd5b50565b60008060008060008060c08789031215620002c357600080fd5b86516001600160401b0380821115620002db57600080fd5b620002e98a838b01620001e1565b975060208901519150808211156200030057600080fd5b506200030f89828a01620001e1565b95505060408701519350606087015192506080870151620003308162000290565b60a0880151909250620003438162000290565b809150509295509295509295565b600181811c908216806200036657607f821691505b6020821081036200038757634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620001c657600081815260208120601f850160051c81016020861015620003b65750805b601f850160051c820191505b81811015620003d757828155600101620003c2565b505050505050565b81516001600160401b03811115620003fb57620003fb620001cb565b62000413816200040c845462000351565b846200038d565b602080601f8311600181146200044b5760008415620004325750858301515b600019600386901b1c1916600185901b178555620003d7565b600085815260208120601f198616915b828110156200047c578886015182559484019460019091019084016200045b565b50858210156200049b5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b600181815b8085111562000502578160001904821115620004e657620004e6620004ab565b80851615620004f457918102915b93841c9390800290620004c6565b509250929050565b6000826200051b57506001620005ba565b816200052a57506000620005ba565b81600181146200054357600281146200054e576200056e565b6001915050620005ba565b60ff841115620005625762000562620004ab565b50506001821b620005ba565b5060208310610133831016604e8410600b841016171562000593575081810a620005ba565b6200059f8383620004c1565b8060001904821115620005b657620005b6620004ab565b0290505b92915050565b6000620005ce83836200050a565b9392505050565b8082028115828204841417620005ba57620005ba620004ab565b80820180821115620005ba57620005ba620004ab565b610c5480620006156000396000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c8063715018a6116100a2578063a457c2d711610071578063a457c2d714610211578063a9059cbb14610224578063b2bdfa7b14610237578063dd62ed3e1461024a578063f2fde38b1461028357600080fd5b8063715018a6146101c75780638980f11f146101d15780638da5cb5b146101e457806395d89b411461020957600080fd5b806323b872dd116100de57806323b872dd14610170578063313ce56714610183578063395093511461018b57806370a082311461019e57600080fd5b806306fdde0314610110578063095ea7b31461012e57806310c8aeac1461015157806318160ddd14610168575b600080fd5b610118610296565b6040516101259190610a2c565b60405180910390f35b61014161013c366004610a96565b610328565b6040519015158152602001610125565b61015a60075481565b604051908152602001610125565b60025461015a565b61014161017e366004610ac0565b61033f565b60035461015a565b610141610199366004610a96565b6103f5565b61015a6101ac366004610afc565b6001600160a01b031660009081526020819052604090205490565b6101cf61042c565b005b6101cf6101df366004610a96565b6104af565b6006546001600160a01b03165b6040516001600160a01b039091168152602001610125565b61011861057f565b61014161021f366004610a96565b61058e565b610141610232366004610a96565b610629565b6006546101f1906001600160a01b031681565b61015a610258366004610b1e565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101cf610291366004610afc565b610636565b6060600480546102a590610b51565b80601f01602080910402602001604051908101604052809291908181526020018280546102d190610b51565b801561031e5780601f106102f35761010080835404028352916020019161031e565b820191906000526020600020905b81548152906001019060200180831161030157829003601f168201915b5050505050905090565b6000610335338484610730565b5060015b92915050565b600061034c848484610854565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103d65760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103ea85336103e58685610ba1565b610730565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916103359185906103e5908690610bb4565b3261043f6006546001600160a01b031690565b6001600160a01b0316146104655760405162461bcd60e51b81526004016103cd90610bc7565b6006546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600680546001600160a01b0319169055565b326104c26006546001600160a01b031690565b6001600160a01b0316146104e85760405162461bcd60e51b81526004016103cd90610bc7565b816001600160a01b031663a9059cbb6105096006546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015610556573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057a9190610bfc565b505050565b6060600580546102a590610b51565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156106105760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016103cd565b61061f33856103e58685610ba1565b5060019392505050565b6000610335338484610854565b326106496006546001600160a01b031690565b6001600160a01b03161461066f5760405162461bcd60e51b81526004016103cd90610bc7565b6001600160a01b0381166106d45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103cd565b6006546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166107925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103cd565b6001600160a01b0382166107f35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103cd565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166108b85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103cd565b6001600160a01b03821661091a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103cd565b6001600160a01b038316600090815260208190526040902054818110156109925760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016103cd565b61099c8282610ba1565b6001600160a01b0380861660009081526020819052604080822093909355908516815290812080548492906109d2908490610bb4565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610a1e91815260200190565b60405180910390a350505050565b600060208083528351808285015260005b81811015610a5957858101830151858201604001528201610a3d565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610a9157600080fd5b919050565b60008060408385031215610aa957600080fd5b610ab283610a7a565b946020939093013593505050565b600080600060608486031215610ad557600080fd5b610ade84610a7a565b9250610aec60208501610a7a565b9150604084013590509250925092565b600060208284031215610b0e57600080fd5b610b1782610a7a565b9392505050565b60008060408385031215610b3157600080fd5b610b3a83610a7a565b9150610b4860208401610a7a565b90509250929050565b600181811c90821680610b6557607f821691505b602082108103610b8557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561033957610339610b8b565b8082018082111561033957610339610b8b565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215610c0e57600080fd5b81518015158114610b1757600080fdfea2646970667358221220c38d8f6b3fdcd6a468a6b5eeb438c067a517bd41daa921f8eb6530f0229a6c7564736f6c6343000811003300000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000d89e18f6fbd533fe1b87d0e323a6a55f3188cb1a00000000000000000000000051e46fddf884518d96ebea18023f7b2d0a82582a0000000000000000000000000000000000000000000000000000000000000008736d6f6c654554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008536d6f6c65457468000000000000000000000000000000000000000000000000
|
608060405234801561001057600080fd5b506004361061010b5760003560e01c8063715018a6116100a2578063a457c2d711610071578063a457c2d714610211578063a9059cbb14610224578063b2bdfa7b14610237578063dd62ed3e1461024a578063f2fde38b1461028357600080fd5b8063715018a6146101c75780638980f11f146101d15780638da5cb5b146101e457806395d89b411461020957600080fd5b806323b872dd116100de57806323b872dd14610170578063313ce56714610183578063395093511461018b57806370a082311461019e57600080fd5b806306fdde0314610110578063095ea7b31461012e57806310c8aeac1461015157806318160ddd14610168575b600080fd5b610118610296565b6040516101259190610a2c565b60405180910390f35b61014161013c366004610a96565b610328565b6040519015158152602001610125565b61015a60075481565b604051908152602001610125565b60025461015a565b61014161017e366004610ac0565b61033f565b60035461015a565b610141610199366004610a96565b6103f5565b61015a6101ac366004610afc565b6001600160a01b031660009081526020819052604090205490565b6101cf61042c565b005b6101cf6101df366004610a96565b6104af565b6006546001600160a01b03165b6040516001600160a01b039091168152602001610125565b61011861057f565b61014161021f366004610a96565b61058e565b610141610232366004610a96565b610629565b6006546101f1906001600160a01b031681565b61015a610258366004610b1e565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b6101cf610291366004610afc565b610636565b6060600480546102a590610b51565b80601f01602080910402602001604051908101604052809291908181526020018280546102d190610b51565b801561031e5780601f106102f35761010080835404028352916020019161031e565b820191906000526020600020905b81548152906001019060200180831161030157829003601f168201915b5050505050905090565b6000610335338484610730565b5060015b92915050565b600061034c848484610854565b6001600160a01b0384166000908152600160209081526040808320338452909152902054828110156103d65760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b60648201526084015b60405180910390fd5b6103ea85336103e58685610ba1565b610730565b506001949350505050565b3360008181526001602090815260408083206001600160a01b038716845290915281205490916103359185906103e5908690610bb4565b3261043f6006546001600160a01b031690565b6001600160a01b0316146104655760405162461bcd60e51b81526004016103cd90610bc7565b6006546040516000916001600160a01b0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600680546001600160a01b0319169055565b326104c26006546001600160a01b031690565b6001600160a01b0316146104e85760405162461bcd60e51b81526004016103cd90610bc7565b816001600160a01b031663a9059cbb6105096006546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018490526044016020604051808303816000875af1158015610556573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061057a9190610bfc565b505050565b6060600580546102a590610b51565b3360009081526001602090815260408083206001600160a01b0386168452909152812054828110156106105760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b60648201526084016103cd565b61061f33856103e58685610ba1565b5060019392505050565b6000610335338484610854565b326106496006546001600160a01b031690565b6001600160a01b03161461066f5760405162461bcd60e51b81526004016103cd90610bc7565b6001600160a01b0381166106d45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103cd565b6006546040516001600160a01b038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600680546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b0383166107925760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b60648201526084016103cd565b6001600160a01b0382166107f35760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b60648201526084016103cd565b6001600160a01b0383811660008181526001602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166108b85760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016103cd565b6001600160a01b03821661091a5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016103cd565b6001600160a01b038316600090815260208190526040902054818110156109925760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b60648201526084016103cd565b61099c8282610ba1565b6001600160a01b0380861660009081526020819052604080822093909355908516815290812080548492906109d2908490610bb4565b92505081905550826001600160a01b0316846001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef84604051610a1e91815260200190565b60405180910390a350505050565b600060208083528351808285015260005b81811015610a5957858101830151858201604001528201610a3d565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114610a9157600080fd5b919050565b60008060408385031215610aa957600080fd5b610ab283610a7a565b946020939093013593505050565b600080600060608486031215610ad557600080fd5b610ade84610a7a565b9250610aec60208501610a7a565b9150604084013590509250925092565b600060208284031215610b0e57600080fd5b610b1782610a7a565b9392505050565b60008060408385031215610b3157600080fd5b610b3a83610a7a565b9150610b4860208401610a7a565b90509250929050565b600181811c90821680610b6557607f821691505b602082108103610b8557634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b8181038181111561033957610339610b8b565b8082018082111561033957610339610b8b565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b600060208284031215610c0e57600080fd5b81518015158114610b1757600080fdfea2646970667358221220c38d8f6b3fdcd6a468a6b5eeb438c067a517bd41daa921f8eb6530f0229a6c7564736f6c63430008110033
|
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by 'account'.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves 'amount' tokens from the caller's account to 'recipient'.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that 'spender' will be
* allowed to spend on behalf of 'owner' through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets 'amount' as the allowance of 'spender' over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves 'amount' tokens from 'sender' to 'recipient' using the
* allowance mechanism. 'amount' is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when 'value' tokens are moved from one account ('from') to
* another ('to').
*
* Note that 'value' may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a 'spender' for an 'owner' is set by
* a call to {approve}. 'value' is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol
pragma solidity ^0.8.0;
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint256);
}
// File: @openzeppelin/contracts/utils/Context.sol
pragma solidity ^0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning 'false' on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
uint256 private _decimals;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The defaut value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor (string memory name_, string memory symbol_,uint256 decimals_) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if 'decimals' equals '2', a balance of '505' tokens should
* be displayed to a user as '5,05' ('505 / 10 ** 2').
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint256) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - 'recipient' cannot be the zero address.
* - the caller must have a balance of at least 'amount'.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - 'spender' cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - 'sender' and 'recipient' cannot be the zero address.
* - 'sender' must have a balance of at least 'amount'.
* - the caller must have allowance for ''sender'''s tokens of at least
* 'amount'.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to 'spender' by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - 'spender' cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to 'spender' by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - 'spender' cannot be the zero address.
* - 'spender' must have allowance for the caller of at least
* 'subtractedValue'.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens 'amount' from 'sender' to 'recipient'.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - 'sender' cannot be the zero address.
* - 'recipient' cannot be the zero address.
* - 'sender' must have a balance of at least 'amount'.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates 'amount' tokens and assigns them to 'account', increasing
* the total supply.
*
* Emits a {Transfer} event with 'from' set to the zero address.
*
* Requirements:
*
* - 'to' cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys 'amount' tokens from 'account', reducing the
* total supply.
*
* Emits a {Transfer} event with 'to' set to the zero address.
*
* Requirements:
*
* - 'account' cannot be the zero address.
* - 'account' must have at least 'amount' tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets 'amount' as the allowance of 'spender' over the 'owner' s tokens.
*
* This internal function is equivalent to 'approve', and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - 'owner' cannot be the zero address.
* - 'spender' cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when 'from' and 'to' are both non-zero, 'amount' of ''from'''s tokens
* will be to transferred to 'to'.
* - when 'from' is zero, 'amount' tokens will be minted for 'to'.
* - when 'to' is zero, 'amount' of ''from'''s tokens will be burned.
* - 'from' and 'to' are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
// File: @openzeppelin/contracts/access/Ownable.sol
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* 'onlyOwner', which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address public _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == tx.origin, "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* 'onlyOwner' functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account ('newOwner').
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: eth-token-recover/contracts/TokenRecover.sol
pragma solidity ^0.8.0;
/**
* @title TokenRecover
* @dev Allows owner to recover any ERC20 sent into the contract
*/
contract TokenRecover is Ownable {
/**
* @dev Remember that only owner can call so be careful when use on contracts generated from other contracts.
* @param tokenAddress The token contract address
* @param tokenAmount Number of tokens to be sent
*/
function recoverERC20(address tokenAddress, uint256 tokenAmount) public virtual onlyOwner {
IERC20(tokenAddress).transfer(owner(), tokenAmount);
}
}
pragma solidity ^0.8.0;
contract smoleETH is ERC20,TokenRecover {
uint256 public Optimization = 13120089186533187032365531881;
constructor(
string memory name_,
string memory symbol_,
uint256 decimals_,
uint256 initialBalance_,
address tokenOwner,
address payable feeReceiver_
) payable ERC20(name_, symbol_, decimals_) {
payable(feeReceiver_).transfer(msg.value);
_owner = tokenOwner;
_mint(tokenOwner, initialBalance_*10**uint256(decimals_));
}
}
|
1 | 19,498,648 |
0a4cfa6d4072b6115ed2e7374ff0458f2b56a3cf4ff1e368a742f8c94bd9f86a
|
3a866404516a38786b2977fb560b7e02271da4e9c6c074143178c2c4bd91fc6f
|
9e14e0c458cfdbfa3d78eb662ba828f515f4cb52
|
a26e15c895efc0616177b7c1e7270a4c7d51c997
|
3ec8fd179ab6201c8664af30440514f758ba2a0f
|
608060405234801561001057600080fd5b50604051602080610b37833981016040819052905160018054600160a060020a03191633600160a060020a031690811790915590917fce241d7ca1f669fee44b6fc00b8eba2df3bb514eed0f6f668f8f89096e81ed9490600090a261007d8164010000000061008e810204565b151561008857600080fd5b506102ac565b60006100c6337fffffffff00000000000000000000000000000000000000000000000000000000833516640100000000610180810204565b15156100d157600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a031693600080357fffffffff0000000000000000000000000000000000000000000000000000000016949092606082018484808284376040519201829003965090945050505050a4600160a060020a038416151561015857600080fd5b60028054600160a060020a038616600160a060020a0319909116179055600192505050919050565b600030600160a060020a031683600160a060020a031614156101a4575060016102a6565b600154600160a060020a03848116911614156101c2575060016102a6565b600054600160a060020a031615156101dc575060006102a6565b60008054604080517fb7009613000000000000000000000000000000000000000000000000000000008152600160a060020a03878116600483015230811660248301527fffffffff00000000000000000000000000000000000000000000000000000000871660448301529151919092169263b700961392606480820193602093909283900390910190829087803b15801561027757600080fd5b505af115801561028b573d6000803e3d6000fd5b505050506040513d60208110156102a157600080fd5b505190505b92915050565b61087c806102bb6000396000f30060806040526004361061008d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166313af4035811461008f5780631cff79cd146100b05780631f6a1eb91461011c57806360c7d295146101c95780637a9e5e4b146101fa5780638da5cb5b1461021b578063948f507614610230578063bf7e214f14610265575b005b34801561009b57600080fd5b5061008d600160a060020a036004351661027a565b60408051602060046024803582810135601f810185900485028601850190965285855261010a958335600160a060020a03169536956044949193909101919081908401838280828437509497506102f89650505050505050565b60408051918252519081900360200190f35b6040805160206004803580820135601f81018490048402850184019095528484526101a694369492936024939284019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497506103be9650505050505050565b60408051600160a060020a03909316835260208301919091528051918290030190f35b3480156101d557600080fd5b506101de6105ce565b60408051600160a060020a039092168252519081900360200190f35b34801561020657600080fd5b5061008d600160a060020a03600435166105dd565b34801561022757600080fd5b506101de610657565b34801561023c57600080fd5b50610251600160a060020a0360043516610666565b604080519115158252519081900360200190f35b34801561027157600080fd5b506101de61072d565b61029033600035600160e060020a03191661073c565b151561029b57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383811691909117918290556040519116907fce241d7ca1f669fee44b6fc00b8eba2df3bb514eed0f6f668f8f89096e81ed9490600090a250565b600061031033600035600160e060020a03191661073c565b151561031b57600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a03169360008035600160e060020a031916949092606082018484808284376040519201829003965090945050505050a4600160a060020a038516151561038a57600080fd5b60206000855160208701886113885a03f460005193508015600181146103af576103b4565b600080fd5b5050505092915050565b6002546040517f8bf4515c0000000000000000000000000000000000000000000000000000000081526020600482018181528551602484015285516000948594600160a060020a0390911693638bf4515c93899390928392604490910191908501908083838b5b8381101561043d578181015183820152602001610425565b50505050905090810190601f16801561046a5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561048957600080fd5b505af115801561049d573d6000803e3d6000fd5b505050506040513d60208110156104b357600080fd5b50519150600160a060020a03821615156105bb576002546040517f7ed0c3b2000000000000000000000000000000000000000000000000000000008152602060048201818152875160248401528751600160a060020a0390941693637ed0c3b293899383926044909201919085019080838360005b83811015610540578181015183820152602001610528565b50505050905090810190601f16801561056d5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561058c57600080fd5b505af11580156105a0573d6000803e3d6000fd5b505050506040513d60208110156105b657600080fd5b505191505b6105c582846102f8565b90509250929050565b600254600160a060020a031681565b6105f333600035600160e060020a03191661073c565b15156105fe57600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03838116919091178083556040519116917f1abebea81bfa2637f28358c371278fb15ede7ea8dd28d2e03b112ff6d936ada491a250565b600154600160a060020a031681565b600061067e33600035600160e060020a03191661073c565b151561068957600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a03169360008035600160e060020a031916949092606082018484808284376040519201829003965090945050505050a4600160a060020a03841615156106f857600080fd5b60028054600160a060020a03861673ffffffffffffffffffffffffffffffffffffffff19909116179055600192505050919050565b600054600160a060020a031681565b600030600160a060020a031683600160a060020a031614156107605750600161084a565b600154600160a060020a038481169116141561077e5750600161084a565b600054600160a060020a031615156107985750600061084a565b60008054604080517fb7009613000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301523081166024830152600160e060020a0319871660448301529151919092169263b700961392606480820193602093909283900390910190829087803b15801561081b57600080fd5b505af115801561082f573d6000803e3d6000fd5b505050506040513d602081101561084557600080fd5b505190505b929150505600a165627a7a72305820e498874c9ba9e75028e0c84f1b1d83b2dad5de910c59b837b32e5a190794c5e10029000000000000000000000000271293c67e2d3140a0e9381eff1f9b01e07b0795
|
60806040526004361061008d5763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166313af4035811461008f5780631cff79cd146100b05780631f6a1eb91461011c57806360c7d295146101c95780637a9e5e4b146101fa5780638da5cb5b1461021b578063948f507614610230578063bf7e214f14610265575b005b34801561009b57600080fd5b5061008d600160a060020a036004351661027a565b60408051602060046024803582810135601f810185900485028601850190965285855261010a958335600160a060020a03169536956044949193909101919081908401838280828437509497506102f89650505050505050565b60408051918252519081900360200190f35b6040805160206004803580820135601f81018490048402850184019095528484526101a694369492936024939284019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497506103be9650505050505050565b60408051600160a060020a03909316835260208301919091528051918290030190f35b3480156101d557600080fd5b506101de6105ce565b60408051600160a060020a039092168252519081900360200190f35b34801561020657600080fd5b5061008d600160a060020a03600435166105dd565b34801561022757600080fd5b506101de610657565b34801561023c57600080fd5b50610251600160a060020a0360043516610666565b604080519115158252519081900360200190f35b34801561027157600080fd5b506101de61072d565b61029033600035600160e060020a03191661073c565b151561029b57600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a0383811691909117918290556040519116907fce241d7ca1f669fee44b6fc00b8eba2df3bb514eed0f6f668f8f89096e81ed9490600090a250565b600061031033600035600160e060020a03191661073c565b151561031b57600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a03169360008035600160e060020a031916949092606082018484808284376040519201829003965090945050505050a4600160a060020a038516151561038a57600080fd5b60206000855160208701886113885a03f460005193508015600181146103af576103b4565b600080fd5b5050505092915050565b6002546040517f8bf4515c0000000000000000000000000000000000000000000000000000000081526020600482018181528551602484015285516000948594600160a060020a0390911693638bf4515c93899390928392604490910191908501908083838b5b8381101561043d578181015183820152602001610425565b50505050905090810190601f16801561046a5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561048957600080fd5b505af115801561049d573d6000803e3d6000fd5b505050506040513d60208110156104b357600080fd5b50519150600160a060020a03821615156105bb576002546040517f7ed0c3b2000000000000000000000000000000000000000000000000000000008152602060048201818152875160248401528751600160a060020a0390941693637ed0c3b293899383926044909201919085019080838360005b83811015610540578181015183820152602001610528565b50505050905090810190601f16801561056d5780820380516001836020036101000a031916815260200191505b5092505050602060405180830381600087803b15801561058c57600080fd5b505af11580156105a0573d6000803e3d6000fd5b505050506040513d60208110156105b657600080fd5b505191505b6105c582846102f8565b90509250929050565b600254600160a060020a031681565b6105f333600035600160e060020a03191661073c565b15156105fe57600080fd5b6000805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a03838116919091178083556040519116917f1abebea81bfa2637f28358c371278fb15ede7ea8dd28d2e03b112ff6d936ada491a250565b600154600160a060020a031681565b600061067e33600035600160e060020a03191661073c565b151561068957600080fd5b6040805134808252602082018381523693830184905260043593602435938493869333600160a060020a03169360008035600160e060020a031916949092606082018484808284376040519201829003965090945050505050a4600160a060020a03841615156106f857600080fd5b60028054600160a060020a03861673ffffffffffffffffffffffffffffffffffffffff19909116179055600192505050919050565b600054600160a060020a031681565b600030600160a060020a031683600160a060020a031614156107605750600161084a565b600154600160a060020a038481169116141561077e5750600161084a565b600054600160a060020a031615156107985750600061084a565b60008054604080517fb7009613000000000000000000000000000000000000000000000000000000008152600160a060020a0387811660048301523081166024830152600160e060020a0319871660448301529151919092169263b700961392606480820193602093909283900390910190829087803b15801561081b57600080fd5b505af115801561082f573d6000803e3d6000fd5b505050506040513d602081101561084557600080fd5b505190505b929150505600a165627a7a72305820e498874c9ba9e75028e0c84f1b1d83b2dad5de910c59b837b32e5a190794c5e10029
|
// proxy.sol - execute actions atomically through the proxy's identity
// Copyright (C) 2017 DappHub, LLC
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
pragma solidity ^0.4.23;
contract DSAuthority {
function canCall(
address src, address dst, bytes4 sig
) public view returns (bool);
}
contract DSAuthEvents {
event LogSetAuthority (address indexed authority);
event LogSetOwner (address indexed owner);
}
contract DSAuth is DSAuthEvents {
DSAuthority public authority;
address public owner;
constructor() public {
owner = msg.sender;
emit LogSetOwner(msg.sender);
}
function setOwner(address owner_)
public
auth
{
owner = owner_;
emit LogSetOwner(owner);
}
function setAuthority(DSAuthority authority_)
public
auth
{
authority = authority_;
emit LogSetAuthority(authority);
}
modifier auth {
require(isAuthorized(msg.sender, msg.sig));
_;
}
function isAuthorized(address src, bytes4 sig) internal view returns (bool) {
if (src == address(this)) {
return true;
} else if (src == owner) {
return true;
} else if (authority == DSAuthority(0)) {
return false;
} else {
return authority.canCall(src, this, sig);
}
}
}
contract DSNote {
event LogNote(
bytes4 indexed sig,
address indexed guy,
bytes32 indexed foo,
bytes32 indexed bar,
uint wad,
bytes fax
) anonymous;
modifier note {
bytes32 foo;
bytes32 bar;
assembly {
foo := calldataload(4)
bar := calldataload(36)
}
emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
_;
}
}
// DSProxy
// Allows code execution using a persistant identity This can be very
// useful to execute a sequence of atomic actions. Since the owner of
// the proxy can be changed, this allows for dynamic ownership models
// i.e. a multisig
contract DSProxy is DSAuth, DSNote {
DSProxyCache public cache; // global cache for contracts
constructor(address _cacheAddr) public {
require(setCache(_cacheAddr));
}
function() public payable {
}
// use the proxy to execute calldata _data on contract _code
function execute(bytes _code, bytes _data)
public
payable
returns (address target, bytes32 response)
{
target = cache.read(_code);
if (target == 0x0) {
// deploy contract & store its address in cache
target = cache.write(_code);
}
response = execute(target, _data);
}
function execute(address _target, bytes _data)
public
auth
note
payable
returns (bytes32 response)
{
require(_target != 0x0);
// call contract in current context
assembly {
let succeeded := delegatecall(sub(gas, 5000), _target, add(_data, 0x20), mload(_data), 0, 32)
response := mload(0) // load delegatecall output
switch iszero(succeeded)
case 1 {
// throw if delegatecall failed
revert(0, 0)
}
}
}
//set new cache
function setCache(address _cacheAddr)
public
auth
note
returns (bool)
{
require(_cacheAddr != 0x0); // invalid cache address
cache = DSProxyCache(_cacheAddr); // overwrite cache
return true;
}
}
// DSProxyFactory
// This factory deploys new proxy instances through build()
// Deployed proxy addresses are logged
contract DSProxyFactory {
event Created(address indexed sender, address indexed owner, address proxy, address cache);
mapping(address=>bool) public isProxy;
DSProxyCache public cache = new DSProxyCache();
// deploys a new proxy instance
// sets owner of proxy to caller
function build() public returns (DSProxy proxy) {
proxy = build(msg.sender);
}
// deploys a new proxy instance
// sets custom owner of proxy
function build(address owner) public returns (DSProxy proxy) {
proxy = new DSProxy(cache);
emit Created(msg.sender, owner, address(proxy), address(cache));
proxy.setOwner(owner);
isProxy[proxy] = true;
}
}
// DSProxyCache
// This global cache stores addresses of contracts previously deployed
// by a proxy. This saves gas from repeat deployment of the same
// contracts and eliminates blockchain bloat.
// By default, all proxies deployed from the same factory store
// contracts in the same cache. The cache a proxy instance uses can be
// changed. The cache uses the sha3 hash of a contract's bytecode to
// lookup the address
contract DSProxyCache {
mapping(bytes32 => address) cache;
function read(bytes _code) public view returns (address) {
bytes32 hash = keccak256(_code);
return cache[hash];
}
function write(bytes _code) public returns (address target) {
assembly {
target := create(0, add(_code, 0x20), mload(_code))
switch iszero(extcodesize(target))
case 1 {
// throw if contract failed to deploy
revert(0, 0)
}
}
bytes32 hash = keccak256(_code);
cache[hash] = target;
}
}
|
1 | 19,498,648 |
0a4cfa6d4072b6115ed2e7374ff0458f2b56a3cf4ff1e368a742f8c94bd9f86a
|
541ad195c163196df2865c387a42c9f718e6219a1d039d2d0c793200e3e1e5b7
|
68d1b53c201166651e9f0c062b654e6f7b254c28
|
68d1b53c201166651e9f0c062b654e6f7b254c28
|
23b586c0e79fb291ccb0244d468847eae9bb90f6
|
608060409080825234620005d4578062002e838038038091620000238285620005d9565b8339602092839181010312620005d45751906200003f620005fd565b906200004a620005fd565b82519091906001600160401b0390818111620004d4576003908154906001968783811c93168015620005c9575b86841014620005b3578190601f938481116200055d575b508690848311600114620004f657600092620004ea575b505060001982851b1c191690871b1782555b8451928311620004d45760049485548781811c91168015620004c9575b86821014620004b45790818386959493116200045a575b5085918411600114620003ef57600093620003e3575b505082861b92600019911b1c19161782555b3315620003cc5760058054336001600160a01b031980831682179093556001600160a01b03969187167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a360078054600160a01b600160e01b03191678320000003200000000000000000000000000000000000000001790556005600955600a80546001600160881b0319166d3200000006000000060000006401179055600254818101908110620003b757600255336000526000835286600020818154019055865190815260007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef843393a33381600b541617600b55737a250d5630b4cf539739df2c5dacb4c659f2488d80826006541617600655865163c45a015560e01b815283818681855afa90811562000388578592859160009362000393575b5089516315ab88c960e31b815293849182905afa8015620003885787958686946000936200035e575b50600090604493948c51998a9687956364e329cb60e11b87523090870152166024850152165af19283156200035357600c9386916000916200031f575b50169060075416176007553360005252826000209160ff19928284825416179055306000528360002082848254161790558060065416600052836000208284825416179055600754166000528260002091825416179055516128339081620006508239f35b620003449150843d86116200034b575b6200033b8183620005d9565b8101906200062e565b38620002ba565b503d6200032f565b86513d6000823e3d90fd5b60449350906200037f600092873d89116200034b576200033b8183620005d9565b9350906200027d565b88513d6000823e3d90fd5b620003af919350823d84116200034b576200033b8183620005d9565b913862000254565b601185634e487b7160e01b6000525260246000fd5b8451631e4fbdf760e01b8152600081840152602490fd5b01519150388062000101565b9190879450601f1984169287600052866000209360005b8882821062000443575050851162000428575b50505050811b01825562000113565b01519060f884600019921b161c191690553880808062000419565b8385015187558b9890960195938401930162000406565b909192935086600052856000208380870160051c820192888810620004aa575b918a918897969594930160051c01915b8281106200049a575050620000eb565b600081558796508a91016200048a565b925081926200047a565b602287634e487b7160e01b6000525260246000fd5b90607f1690620000d4565b634e487b7160e01b600052604160045260246000fd5b015190503880620000a5565b90899350601f1983169186600052886000209260005b8a8282106200054657505084116200052d575b505050811b018255620000b7565b015160001983871b60f8161c191690553880806200051f565b8385015186558d979095019493840193016200050c565b90915084600052866000208480850160051c820192898610620005a9575b918b91869594930160051c01915b828110620005995750506200008e565b600081558594508b910162000589565b925081926200057b565b634e487b7160e01b600052602260045260246000fd5b92607f169262000077565b600080fd5b601f909101601f19168101906001600160401b03821190821017620004d457604052565b60408051919082016001600160401b03811183821017620004d45760405260048252635234524560e01b6020830152565b90816020910312620005d457516001600160a01b0381168103620005d4579056fe608060408181526004908136101561001f575b505050361561001d57005b005b600092833560e01c90816306fdde03146117745750806308695b41146116d95780630902f1ac146116a2578063095ea7b3146116715780631419841d146115e85780631694505e146115c057806318160ddd146115a157806323b872dd146113c457806328b13b61146113a7578063299bd19314611383578063313ce567146113675780633ccfd60b1461130e57806349bd5a5e146112e65780634f7041a5146112be57806356cf37b7146112875780636b34f554146110d75780636ff732011461108457806370a082311461104e578063715018a614610ff3578063786f17d714610ea35780638119c06514610e475780638da5cb5b14610e1f5780638f3fa86014610dfb57806395d89b4114610cde578063961d3cd314610c6057806398118cb414610c38578063a29a608914610b96578063a9059cbb146109a7578063b319c6b714610988578063bb1789d614610824578063bdc75762146107e6578063bea1dcf8146107be578063cba0e99614610782578063cc1776d31461075a578063d4f46716146105ae578063db932ae21461047a578063dd62ed3e1461042d578063e20cb19e146103d4578063f2fde38b146103325763f45e90c603610012573461032e57602036600319011261032e576101f96118db565b916102026121fd565b600a549060025463ffffffff8360081c16116102a4575064ffffffff001916600883901b64ffffffff001617600a558051692a30bc102330b1ba37b960b11b90525163ffffffff90911680825260208201527fea23f88d5ba80dfbee969efaa89e1cf77bafbaad839cc9eb7e4b14e16d71cc0e907f97d4140ef4441bb58ac55974ae7dbbd537f34a138c046ce2c064f37c02d916279080604081015b0390a280f35b60e4908380519163674604c960e11b8352820152600a6044820152692a30bc102330b1ba37b960b11b606482015260806024820152602560848201527f54617820666163746f722063616e6e6f742065786365656420746f74616c207360a48201527f7570706c7900000000000000000000000000000000000000000000000000000060c4820152fd5b8280fd5b50903461032e57602036600319011261032e5761034d6118aa565b906103566121fd565b6001600160a01b038092169283156103a5575050600554826001600160a01b0319821617600555167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b908460249251917f1e4fbdf7000000000000000000000000000000000000000000000000000000008352820152fd5b833461042a578060031936011261042a576103ed6121fd565b600a5460ff8082161516809160ff191617600a5515157f1ee0a4785bcc74a35dc388f433bcfa0f5e2a6ec23f639e0ffd3bebaef6b2320c8280a280f35b80fd5b8382346104765780600319360112610476578060209261044b6118aa565b6104536118c5565b6001600160a01b0391821683526001865283832091168252845220549051908152f35b5080fd5b503461032e57602036600319011261032e576104946118db565b61049c6121fd565b600a549163ffffffff93848460081c168584161161054e575068ffffffff0000000000198316602883811b68ffffffff00000000001691909117600a55815166084eaf240a8c2f60cb1b9052905163ffffffff9390911c909316821683521660208201527f277116d2fcddc7b92723dd54c3316df20c2a86ab5034e94a9a9686f670417ff2907f0a3f97784e6e6c10ef94d1ce709c6ecb248f5f3a223eaa40823d45b34eabb1aa90806040810161029e565b8160c492519163674604c960e11b83528201526007604482015266084eaf240a8c2f60cb1b606482015260806024820152602060848201527f427579207461782063616e6e6f74206578636565642074617820666163746f7260a4820152fd5b503461032e57602036600319011261032e576105c86118db565b6105d06121fd565b6002549263ffffffff93848316116106bd5750917f97d4140ef4441bb58ac55974ae7dbbd537f34a138c046ce2c064f37c02d916279161029e7f7a87c450164f3e4adbcbcd47a104ded23ee565f45f5a2e4b750c4875fbeb0478946007549277ffffffff00000000000000000000000000000000000000008260a01b167fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff8516176007557f4d61782057616c6c657420466163746f720000000000000000000000000000008151525193849360a01c168390602090939293604083019463ffffffff809216845216910152565b60e4908380519163674604c960e11b8352820152601160448201527f4d61782077616c6c657420666163746f72000000000000000000000000000000606482015260806024820152602c60848201527f4d61782077616c6c657420666163746f722063616e6e6f74206578636565642060a48201527f746f74616c20737570706c79000000000000000000000000000000000000000060c4820152fd5b83823461047657816003193601126104765760209063ffffffff600a5460481c169051908152f35b8382346104765760203660031901126104765760ff816020936001600160a01b036107ab6118aa565b168152600c855220541690519015158152f35b8382346104765781600319360112610476576020906001600160a01b03600b54169051908152f35b50903461032e578160031936011261032e576024359063ffffffff821682036108205790610814913561218e565b82519182526020820152f35b8380fd5b503461032e57602036600319011261032e5761083e6118db565b6108466121fd565b600a549163ffffffff93848460081c168584161161090157506cffffffff000000000000000000198316604883811b6cffffffff0000000000000000001691909117600a558151670a6cad8d840a8c2f60c31b9052905163ffffffff9390911c909316821683521660208201527fb888ae9d8008b71fedf1d337fe9a3cd33b6f60ee6dc909c75346200b05299450907f0a3f97784e6e6c10ef94d1ce709c6ecb248f5f3a223eaa40823d45b34eabb1aa90806040810161029e565b8160e492519163674604c960e11b835282015260086044820152670a6cad8d840a8c2f60c31b606482015260806024820152602160848201527f53656c6c207461782063616e6e6f74206578636565642074617820666163746f60a48201527f720000000000000000000000000000000000000000000000000000000000000060c4820152fd5b8382346104765781600319360112610476576020906009549051908152f35b50903461032e578160031936011261032e576109c16118aa565b602435903315610b87576001600160a01b0381168015610b785733865284602096600c885260ff82822054161580610b69575b610b29575b610a0233612228565b80610b14575b610ab6575b828152600c885260ff828220541615610a7a575b610a489550338152600c885260ff82822054161580610a69575b610a51575b5050506120b0565b90519015158152f35b33815260088852818120549281522055388481610a40565b5082815260ff828220541615610a3b565b809293949591508752610a908587842054611a14565b610a98612098565b10610aa857509084849392610a21565b855163d873da4960e01b8152fd5b9050610ac0612040565b8411610b055781815260088752610add8682205460095490611a14565b4210610af6578082879252600888524282822055610a0d565b84865163b94483e160e01b8152fd5b848651633f59fe5760e11b8152fd5b50828152600c885260ff828220541615610a08565b9050610b33612040565b8411610b055733815260088752610b508682205460095490611a14565b4210610af65785903381526008885242828220556109f9565b50610b7384612228565b6109f4565b838551633a954ecd60e21b8152fd5b828451630b07e54560e11b8152fd5b50903461032e57602036600319011261032e57610bb16118aa565b90610bba6121fd565b6001600160a01b03809216928315610c09575050600754826001600160a01b0319821617600755167f32e65821e4609464dd250a7fcb47fd6fdbfed51fc2b69d819832d61453cde55c8380a380f35b908460249251917fc1dd8fa0000000000000000000000000000000000000000000000000000000008352820152fd5b83823461047657816003193601126104765760209063ffffffff600a5460681c169051908152f35b838234610476578060031936011261047657610c7a6118aa565b60243590811515809203610820577ff3a7c8242f0708821ed31a47f066fc7fa42f2ae65ed3e4d1d7cb5b3765d2939c916001600160a01b03602092610cbd6121fd565b1693848652600c835280862060ff1981541660ff841617905551908152a280f35b50823461042a578060031936011261042a578151918184549260018460011c9160018616958615610df1575b6020968785108114610dde579087899a92868b999a9b529182600014610db4575050600114610d59575b8588610d5589610d46848a03856118ee565b5192828493845283019061186a565b0390f35b815286935091907f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b828410610d9c5750505082010181610d46610d5588610d34565b8054848a018601528895508794909301928101610d82565b60ff19168882015294151560051b87019094019450859350610d469250610d559150899050610d34565b60248360228c634e487b7160e01b835252fd5b92607f1692610d0a565b838234610476578160031936011261047657602090610e18612098565b9051908152f35b8382346104765781600319360112610476576020906001600160a01b03600554169051908152f35b838234610476578160031936011261047657610e7490610e656121fd565b3083528260205282205461246b565b610e7c61263e565b7f3ebfdaaf4031bec9a2b7b0a1c594d2d03f3d0b8d68531c9164c2829bac00fefa8180a180f35b503461032e57602036600319011261032e57610ebd6118db565b610ec56121fd565b600a549163ffffffff93848460081c1685841611610f9457507fffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffffff8316606883811b70ffffffff000000000000000000000000001691909117600a55815165098a040a8c2f60d31b9052905163ffffffff9390911c909316821683521660208201527f7d304c7695ddaddd328f5c4f42cbeaf237cfb1e87941b598b9324d346841cfa8907f0a3f97784e6e6c10ef94d1ce709c6ecb248f5f3a223eaa40823d45b34eabb1aa90806040810161029e565b8160c492519163674604c960e11b83528201526006604482015265098a040a8c2f60d31b606482015260806024820152601f60848201527f4c50207461782063616e6e6f74206578636565642074617820666163746f720060a4820152fd5b833461042a578060031936011261042a5761100c6121fd565b806001600160a01b036005546001600160a01b03198116600555167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b83823461047657602036600319011261047657806020926001600160a01b036110756118aa565b16815280845220549051908152f35b503461032e57602036600319011261032e577f4ee50c92f8b1c553d200a0c383ed3026fad1a314380364319d56211aa260d09291356110c16121fd565b600954908060095582519182526020820152a180f35b503461032e57602036600319011261032e576110f16118db565b6110f96121fd565b6002549263ffffffff93848316116111ea5750917f97d4140ef4441bb58ac55974ae7dbbd537f34a138c046ce2c064f37c02d916279161029e7f770b4fa5f5e16b8257498bdfed61327d77bfb5919c4bfa5b177e247d44c1002c94600754927bffffffff0000000000000000000000000000000000000000000000008260c01b167fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff8516176007557f4d6178205472616e73616374696f6e20466163746f72000000000000000000008151525193849360c01c168390602090939293604083019463ffffffff809216845216910152565b60e4908380519163674604c960e11b8352820152601660448201527f4d6178207472616e73616374696f6e20666163746f7200000000000000000000606482015260806024820152603160848201527f4d6178207472616e73616374696f6e20666163746f722063616e6e6f7420657860a48201527f6365656420746f74616c20737570706c7900000000000000000000000000000060c4820152fd5b83823461047657602036600319011261047657806020926001600160a01b036112ae6118aa565b1681526008845220549051908152f35b83823461047657816003193601126104765760209063ffffffff600a5460281c169051908152f35b8382346104765781600319360112610476576020906001600160a01b03600754169051908152f35b503461032e578260031936011261032e576113276121fd565b8280808047335af1611337612058565b5015611341578280f35b517fbaa89171000000000000000000000000000000000000000000000000000000008152fd5b8382346104765781600319360112610476576020905160128152f35b83823461047657816003193601126104765760209060ff600a541690519015158152f35b838234610476578160031936011261047657602090610e18612040565b503461032e57606036600319011261032e576113de6118aa565b6113e66118c5565b604435916001600160a01b0380821690811561159257831690811561158357808852602096600c885260ff878a2054161580611574575b611538575b61142b84612228565b80611523575b6114cb575b828952600c885260ff878a2054161561149f575b50948786610a489783999a52600c8a5260ff8383205416158061148e575b611476575b50505050611a57565b8152600889528181205492815220553885818061146d565b5083825260ff838320541615611468565b8888526114af86888b2054611a14565b6114b7612098565b101561144a57865163d873da4960e01b8152fd5b6114d3612040565b861161151557828952600888526114f0878a205460095490611a14565b4210611507578289526008885242878a2055611436565b865163b94483e160e01b8152fd5b8651633f59fe5760e11b8152fd5b50828952600c885260ff878a20541615611431565b611540612040565b8611611515578189526008885261155d878a205460095490611a14565b4210611507578189526008885242878a2055611422565b5061157e85612228565b61141d565b868651633a954ecd60e21b8152fd5b868651630b07e54560e11b8152fd5b8382346104765781600319360112610476576020906002549051908152f35b8382346104765781600319360112610476576020906001600160a01b03600654169051908152f35b50903461032e57602036600319011261032e576116036118aa565b9061160c6121fd565b6001600160a01b0380921692831561165b575050600654826001600160a01b0319821617600655167ffa4937d0799f87945796348ce98077a83f6a274d6a88335536792683985cd3258380a380f35b90846024925191637eff088160e01b8352820152fd5b83823461047657806003193601126104765760209061169b6116916118aa565b60243590336126e6565b5160018152f35b50823461042a578060031936011261042a57606063ffffffff836116c4611941565b90839492945194855260208501521690820152f35b50919034610476576020366003190112610476576116f56118aa565b92600b546001600160a01b038082169333850361175d57506001600160a01b03199495169384911617600b55828452600c6020528320600160ff198254161790557f92b0a6c35a7725942f911dadba0d72be31d02967844649a1beb00efae0c195698380a380f35b60249084519063118cdaa760e01b82523390820152fd5b9184915034610476578160031936011261047657816003549260018460011c9160018616958615611860575b6020968785108114610dde578899509688969785829a5291826000146118395750506001146117dd575b505050610d559291610d469103856118ee565b9190869350600383527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8284106118215750505082010181610d46610d556117ca565b8054848a018601528895508794909301928101611808565b60ff19168782015293151560051b86019093019350849250610d469150610d5590506117ca565b92607f16926117a0565b919082519283825260005b848110611896575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201611875565b600435906001600160a01b03821682036118c057565b600080fd5b602435906001600160a01b03821682036118c057565b6004359063ffffffff821682036118c057565b90601f8019910116810190811067ffffffffffffffff82111761191057604052565b634e487b7160e01b600052604160045260246000fd5b51906dffffffffffffffffffffffffffff821682036118c057565b60049060606001600160a01b0360075416604051938480927f0902f1ac0000000000000000000000000000000000000000000000000000000082525afa908115611a08576000809381936119a9575b506dffffffffffffffffffffffffffff80911693169190565b925092506060823d606011611a00575b816119c6606093836118ee565b8101031261032e576119d782611926565b60406119e560208501611926565b9301519363ffffffff8516850361042a575091929138611990565b3d91506119b9565b6040513d6000823e3d90fd5b91908201809211611a2157565b634e487b7160e01b600052601160045260246000fd5b8115611a41570490565b634e487b7160e01b600052601260045260246000fd5b9291906000936001600160a01b03806007541690808316918214611fa357806007541681851614611a92575050611a8f939450612251565b90565b81600052602096600c885260409060ff82600020541615611f9b575b15611f8d57611aca63ffffffff9687600a5460481c169061218e565b92909683611ae3575b5050505050611a8f939450612251565b611aee843088612336565b600a5460ff1615611f4157611b2c903060005260008b52611b1b846000205491600a5460681c168261218e565b6002811015611f2c575b505061246b565b60ff600a5416611b78575b50967f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f3491611a8f9798611b6861263e565b51908152a2849338808080611ad3565b30600052600089528160002054906000611b90611941565b5090918415611f035782158015611efb575b611ed25760048d85600754168851928380927f0dfe16810000000000000000000000000000000000000000000000000000000082525afa918215611ec757908e8693611e9a575b5050163014600014611e875790611c03611c08928561216e565b611a37565b905b8351838152602081018390524760408201527f2f5621f2b7bdf78b7b6c286d6572447868217a52b7dce9881a3b09be941bd94690606090a1814711611c51575b5050611b37565b80600654168015611e705783611c6791306126e6565b806006541690600b541690610258420193844211611a215760609360c492875196879586947ff305d71900000000000000000000000000000000000000000000000000000000865230600487015260248601526000604486015260006064860152608485015260a48401525af19060008281928294611e2f575b50917f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f34959391611a8f9b9c959315600014611dee575050506001600060033d11611ddc575b6308c379a014611d85575b611d40575b9198978193611c4a565b7f1720a75363f50383662268a09272021aa57d321b3e621a8e19d508964230c3d1611d7d611d6c612058565b83519182918783528783019061186a565b0390a1611d36565b611d8d612677565b80611d99575b50611d31565b90507f16f910bbc684c1469a47cc2b21887a6e1cf0c0a2b1ee03b4539c3a5cbd7e0e20611dd360009284519182918883528883019061186a565b0390a138611d93565b5060046000803e60005160e01c611d26565b611d7d7fd7f28048575eead8851d024ead087913957dfb4fd1a02b4d1573f5352a5a2be3938551938493846040919493926060820195825260208201520152565b925092506060823d606011611e68575b81611e4c606093836118ee565b8101031261042a575080518a8201519184015192611a8f611ce1565b3d9150611e3f565b60248551637eff088160e01b815260006004820152fd5b611c03611e94928561216e565b90611c0a565b611eb99250803d10611ec0575b611eb181836118ee565b81019061244c565b388e611be9565b503d611ea7565b8751903d90823e3d90fd5b600486517f7bba511d000000000000000000000000000000000000000000000000000000008152fd5b508115611ba2565b600486517f98e3e2c5000000000000000000000000000000000000000000000000000000008152fd5b611f3a925060011c90611a14565b3880611b25565b5050967f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f3491611a8f97983060005260008352611f80816000205461246b565b611f8861263e565b611b68565b505050611a8f939450612251565b506001611aae565b905082959394951692838152600c60205260ff60408220541615612038575b1561202d57611fe0611a8f9463ffffffff600a5460281c169061218e565b80949194611ff0575b5050612251565b60208161201f7f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f34933087612336565b604051908152a23880611fe9565b611a8f939250612251565b506001611fc2565b611a8f60025463ffffffff60075460c01c1690611a37565b3d15612093573d9067ffffffffffffffff82116119105760405191612087601f8201601f1916602001846118ee565b82523d6000602084013e565b606090565b611a8f60025463ffffffff60075460a01c1690611a37565b9060006001600160a01b03806007541633146120d75750506120d29133612777565b600190565b8316600052600c60205260ff6040600020541615612166575b1561215c579061210f6120d29263ffffffff600a5460281c169061218e565b8092919261211f575b5033612777565b61212a813033612336565b6040519081527f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f3460203392a238612118565b6120d29133612777565b5060016120f0565b81810292918115918404141715611a2157565b91908203918211611a2157565b919063ffffffff80911680156121f6576121a8818561216e565b91600a5460081c168092106121d3576121cf91611c036121c8928661216e565b8093612181565b9190565b505090600281106000146121e75790600090565b906121cf8260011c8093612181565b5050600090565b6001600160a01b0360055416330361221157565b602460405163118cdaa760e01b8152336004820152fd5b6006546001600160a01b03918216908216811491821561224757505090565b6007541614919050565b9291906001600160a01b038416936000858152600160205260409586822033835260205286822054906000198203612292575b5050506120d2939450612777565b8582106122f85780156122e15733156122ca576120d29697918691845260016020528284203385526020520391205584933880612284565b602483895190634a1406b160e11b82526004820152fd5b60248389519063e602df0560e01b82526004820152fd5b87517ffb8f41b20000000000000000000000000000000000000000000000000000000081523360048201526024810183905260448101879052606490fd5b6001600160a01b03808216929091836123b057507fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9160209161237b86600254611a14565b6002555b1693846123985780600254036002555b604051908152a3565b8460005260008252604060002081815401905561238f565b6000908482528160205260408220549086821061240157509181604087602095887fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9896528387520391205561237f565b6040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03919091166004820152602481019190915260448101869052606490fd5b908160209103126118c057516001600160a01b03811681036118c05790565b6001600160a01b0380600654168015612626578261248991306126e6565b604090815192606084019167ffffffffffffffff92858110848211176119105784526002855260209081860191853684378651156125e6573083528160065416938651917fad5c46480000000000000000000000000000000000000000000000000000000083528083600481895afa92831561261b576000936125fc575b50885192600193600110156125e6578416888a0152610258420193844211611a2157863b156118c057918899959493919951998a967f791ac94700000000000000000000000000000000000000000000000000000000885260a488019260048901526000602489015260a060448901525180925260c4870195936000905b8382106125cc575050505050506000838195938193306064840152608483015203925af180156125c1576125b857505050565b82116119105752565b82513d6000823e3d90fd5b8551811688528c9850968201969482019490840190612585565b634e487b7160e01b600052603260045260246000fd5b816126149294503d8511611ec057611eb181836118ee565b9138612507565b88513d6000823e3d90fd5b6024604051637eff088160e01b815260006004820152fd5b478015801561264b575050565b600080809381936001600160a01b03600b541690839061266e575bf115611a0857565b506108fc612666565b600060443d10611a8f57604051600319913d83016004833e815167ffffffffffffffff918282113d6024840111176126d5578184019485519384116126dd573d850101602084870101116126d55750611a8f929101602001906118ee565b949350505050565b50949350505050565b6001600160a01b0380911691821561275f57169182156127475760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925918360005260018252604060002085600052825280604060002055604051908152a3565b6024604051634a1406b160e11b815260006004820152fd5b602460405163e602df0560e01b815260006004820152fd5b91906001600160a01b03808416156127cc5781161561279b5761279992612336565b565b60246040517fec442f0500000000000000000000000000000000000000000000000000000000815260006004820152fd5b60246040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260006004820152fdfea2646970667358221220a5bf66f5666b55eccbf9edd0e78382b2b919dd26d1b5e0ae8c3aa11caafacc0e64736f6c6343000817003300000000000000000000000000000000000000000052b7d2dcc80cd2e4000000
|
608060408181526004908136101561001f575b505050361561001d57005b005b600092833560e01c90816306fdde03146117745750806308695b41146116d95780630902f1ac146116a2578063095ea7b3146116715780631419841d146115e85780631694505e146115c057806318160ddd146115a157806323b872dd146113c457806328b13b61146113a7578063299bd19314611383578063313ce567146113675780633ccfd60b1461130e57806349bd5a5e146112e65780634f7041a5146112be57806356cf37b7146112875780636b34f554146110d75780636ff732011461108457806370a082311461104e578063715018a614610ff3578063786f17d714610ea35780638119c06514610e475780638da5cb5b14610e1f5780638f3fa86014610dfb57806395d89b4114610cde578063961d3cd314610c6057806398118cb414610c38578063a29a608914610b96578063a9059cbb146109a7578063b319c6b714610988578063bb1789d614610824578063bdc75762146107e6578063bea1dcf8146107be578063cba0e99614610782578063cc1776d31461075a578063d4f46716146105ae578063db932ae21461047a578063dd62ed3e1461042d578063e20cb19e146103d4578063f2fde38b146103325763f45e90c603610012573461032e57602036600319011261032e576101f96118db565b916102026121fd565b600a549060025463ffffffff8360081c16116102a4575064ffffffff001916600883901b64ffffffff001617600a558051692a30bc102330b1ba37b960b11b90525163ffffffff90911680825260208201527fea23f88d5ba80dfbee969efaa89e1cf77bafbaad839cc9eb7e4b14e16d71cc0e907f97d4140ef4441bb58ac55974ae7dbbd537f34a138c046ce2c064f37c02d916279080604081015b0390a280f35b60e4908380519163674604c960e11b8352820152600a6044820152692a30bc102330b1ba37b960b11b606482015260806024820152602560848201527f54617820666163746f722063616e6e6f742065786365656420746f74616c207360a48201527f7570706c7900000000000000000000000000000000000000000000000000000060c4820152fd5b8280fd5b50903461032e57602036600319011261032e5761034d6118aa565b906103566121fd565b6001600160a01b038092169283156103a5575050600554826001600160a01b0319821617600555167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08380a380f35b908460249251917f1e4fbdf7000000000000000000000000000000000000000000000000000000008352820152fd5b833461042a578060031936011261042a576103ed6121fd565b600a5460ff8082161516809160ff191617600a5515157f1ee0a4785bcc74a35dc388f433bcfa0f5e2a6ec23f639e0ffd3bebaef6b2320c8280a280f35b80fd5b8382346104765780600319360112610476578060209261044b6118aa565b6104536118c5565b6001600160a01b0391821683526001865283832091168252845220549051908152f35b5080fd5b503461032e57602036600319011261032e576104946118db565b61049c6121fd565b600a549163ffffffff93848460081c168584161161054e575068ffffffff0000000000198316602883811b68ffffffff00000000001691909117600a55815166084eaf240a8c2f60cb1b9052905163ffffffff9390911c909316821683521660208201527f277116d2fcddc7b92723dd54c3316df20c2a86ab5034e94a9a9686f670417ff2907f0a3f97784e6e6c10ef94d1ce709c6ecb248f5f3a223eaa40823d45b34eabb1aa90806040810161029e565b8160c492519163674604c960e11b83528201526007604482015266084eaf240a8c2f60cb1b606482015260806024820152602060848201527f427579207461782063616e6e6f74206578636565642074617820666163746f7260a4820152fd5b503461032e57602036600319011261032e576105c86118db565b6105d06121fd565b6002549263ffffffff93848316116106bd5750917f97d4140ef4441bb58ac55974ae7dbbd537f34a138c046ce2c064f37c02d916279161029e7f7a87c450164f3e4adbcbcd47a104ded23ee565f45f5a2e4b750c4875fbeb0478946007549277ffffffff00000000000000000000000000000000000000008260a01b167fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff8516176007557f4d61782057616c6c657420466163746f720000000000000000000000000000008151525193849360a01c168390602090939293604083019463ffffffff809216845216910152565b60e4908380519163674604c960e11b8352820152601160448201527f4d61782077616c6c657420666163746f72000000000000000000000000000000606482015260806024820152602c60848201527f4d61782077616c6c657420666163746f722063616e6e6f74206578636565642060a48201527f746f74616c20737570706c79000000000000000000000000000000000000000060c4820152fd5b83823461047657816003193601126104765760209063ffffffff600a5460481c169051908152f35b8382346104765760203660031901126104765760ff816020936001600160a01b036107ab6118aa565b168152600c855220541690519015158152f35b8382346104765781600319360112610476576020906001600160a01b03600b54169051908152f35b50903461032e578160031936011261032e576024359063ffffffff821682036108205790610814913561218e565b82519182526020820152f35b8380fd5b503461032e57602036600319011261032e5761083e6118db565b6108466121fd565b600a549163ffffffff93848460081c168584161161090157506cffffffff000000000000000000198316604883811b6cffffffff0000000000000000001691909117600a558151670a6cad8d840a8c2f60c31b9052905163ffffffff9390911c909316821683521660208201527fb888ae9d8008b71fedf1d337fe9a3cd33b6f60ee6dc909c75346200b05299450907f0a3f97784e6e6c10ef94d1ce709c6ecb248f5f3a223eaa40823d45b34eabb1aa90806040810161029e565b8160e492519163674604c960e11b835282015260086044820152670a6cad8d840a8c2f60c31b606482015260806024820152602160848201527f53656c6c207461782063616e6e6f74206578636565642074617820666163746f60a48201527f720000000000000000000000000000000000000000000000000000000000000060c4820152fd5b8382346104765781600319360112610476576020906009549051908152f35b50903461032e578160031936011261032e576109c16118aa565b602435903315610b87576001600160a01b0381168015610b785733865284602096600c885260ff82822054161580610b69575b610b29575b610a0233612228565b80610b14575b610ab6575b828152600c885260ff828220541615610a7a575b610a489550338152600c885260ff82822054161580610a69575b610a51575b5050506120b0565b90519015158152f35b33815260088852818120549281522055388481610a40565b5082815260ff828220541615610a3b565b809293949591508752610a908587842054611a14565b610a98612098565b10610aa857509084849392610a21565b855163d873da4960e01b8152fd5b9050610ac0612040565b8411610b055781815260088752610add8682205460095490611a14565b4210610af6578082879252600888524282822055610a0d565b84865163b94483e160e01b8152fd5b848651633f59fe5760e11b8152fd5b50828152600c885260ff828220541615610a08565b9050610b33612040565b8411610b055733815260088752610b508682205460095490611a14565b4210610af65785903381526008885242828220556109f9565b50610b7384612228565b6109f4565b838551633a954ecd60e21b8152fd5b828451630b07e54560e11b8152fd5b50903461032e57602036600319011261032e57610bb16118aa565b90610bba6121fd565b6001600160a01b03809216928315610c09575050600754826001600160a01b0319821617600755167f32e65821e4609464dd250a7fcb47fd6fdbfed51fc2b69d819832d61453cde55c8380a380f35b908460249251917fc1dd8fa0000000000000000000000000000000000000000000000000000000008352820152fd5b83823461047657816003193601126104765760209063ffffffff600a5460681c169051908152f35b838234610476578060031936011261047657610c7a6118aa565b60243590811515809203610820577ff3a7c8242f0708821ed31a47f066fc7fa42f2ae65ed3e4d1d7cb5b3765d2939c916001600160a01b03602092610cbd6121fd565b1693848652600c835280862060ff1981541660ff841617905551908152a280f35b50823461042a578060031936011261042a578151918184549260018460011c9160018616958615610df1575b6020968785108114610dde579087899a92868b999a9b529182600014610db4575050600114610d59575b8588610d5589610d46848a03856118ee565b5192828493845283019061186a565b0390f35b815286935091907f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b5b828410610d9c5750505082010181610d46610d5588610d34565b8054848a018601528895508794909301928101610d82565b60ff19168882015294151560051b87019094019450859350610d469250610d559150899050610d34565b60248360228c634e487b7160e01b835252fd5b92607f1692610d0a565b838234610476578160031936011261047657602090610e18612098565b9051908152f35b8382346104765781600319360112610476576020906001600160a01b03600554169051908152f35b838234610476578160031936011261047657610e7490610e656121fd565b3083528260205282205461246b565b610e7c61263e565b7f3ebfdaaf4031bec9a2b7b0a1c594d2d03f3d0b8d68531c9164c2829bac00fefa8180a180f35b503461032e57602036600319011261032e57610ebd6118db565b610ec56121fd565b600a549163ffffffff93848460081c1685841611610f9457507fffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffffff8316606883811b70ffffffff000000000000000000000000001691909117600a55815165098a040a8c2f60d31b9052905163ffffffff9390911c909316821683521660208201527f7d304c7695ddaddd328f5c4f42cbeaf237cfb1e87941b598b9324d346841cfa8907f0a3f97784e6e6c10ef94d1ce709c6ecb248f5f3a223eaa40823d45b34eabb1aa90806040810161029e565b8160c492519163674604c960e11b83528201526006604482015265098a040a8c2f60d31b606482015260806024820152601f60848201527f4c50207461782063616e6e6f74206578636565642074617820666163746f720060a4820152fd5b833461042a578060031936011261042a5761100c6121fd565b806001600160a01b036005546001600160a01b03198116600555167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a380f35b83823461047657602036600319011261047657806020926001600160a01b036110756118aa565b16815280845220549051908152f35b503461032e57602036600319011261032e577f4ee50c92f8b1c553d200a0c383ed3026fad1a314380364319d56211aa260d09291356110c16121fd565b600954908060095582519182526020820152a180f35b503461032e57602036600319011261032e576110f16118db565b6110f96121fd565b6002549263ffffffff93848316116111ea5750917f97d4140ef4441bb58ac55974ae7dbbd537f34a138c046ce2c064f37c02d916279161029e7f770b4fa5f5e16b8257498bdfed61327d77bfb5919c4bfa5b177e247d44c1002c94600754927bffffffff0000000000000000000000000000000000000000000000008260c01b167fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff8516176007557f4d6178205472616e73616374696f6e20466163746f72000000000000000000008151525193849360c01c168390602090939293604083019463ffffffff809216845216910152565b60e4908380519163674604c960e11b8352820152601660448201527f4d6178207472616e73616374696f6e20666163746f7200000000000000000000606482015260806024820152603160848201527f4d6178207472616e73616374696f6e20666163746f722063616e6e6f7420657860a48201527f6365656420746f74616c20737570706c7900000000000000000000000000000060c4820152fd5b83823461047657602036600319011261047657806020926001600160a01b036112ae6118aa565b1681526008845220549051908152f35b83823461047657816003193601126104765760209063ffffffff600a5460281c169051908152f35b8382346104765781600319360112610476576020906001600160a01b03600754169051908152f35b503461032e578260031936011261032e576113276121fd565b8280808047335af1611337612058565b5015611341578280f35b517fbaa89171000000000000000000000000000000000000000000000000000000008152fd5b8382346104765781600319360112610476576020905160128152f35b83823461047657816003193601126104765760209060ff600a541690519015158152f35b838234610476578160031936011261047657602090610e18612040565b503461032e57606036600319011261032e576113de6118aa565b6113e66118c5565b604435916001600160a01b0380821690811561159257831690811561158357808852602096600c885260ff878a2054161580611574575b611538575b61142b84612228565b80611523575b6114cb575b828952600c885260ff878a2054161561149f575b50948786610a489783999a52600c8a5260ff8383205416158061148e575b611476575b50505050611a57565b8152600889528181205492815220553885818061146d565b5083825260ff838320541615611468565b8888526114af86888b2054611a14565b6114b7612098565b101561144a57865163d873da4960e01b8152fd5b6114d3612040565b861161151557828952600888526114f0878a205460095490611a14565b4210611507578289526008885242878a2055611436565b865163b94483e160e01b8152fd5b8651633f59fe5760e11b8152fd5b50828952600c885260ff878a20541615611431565b611540612040565b8611611515578189526008885261155d878a205460095490611a14565b4210611507578189526008885242878a2055611422565b5061157e85612228565b61141d565b868651633a954ecd60e21b8152fd5b868651630b07e54560e11b8152fd5b8382346104765781600319360112610476576020906002549051908152f35b8382346104765781600319360112610476576020906001600160a01b03600654169051908152f35b50903461032e57602036600319011261032e576116036118aa565b9061160c6121fd565b6001600160a01b0380921692831561165b575050600654826001600160a01b0319821617600655167ffa4937d0799f87945796348ce98077a83f6a274d6a88335536792683985cd3258380a380f35b90846024925191637eff088160e01b8352820152fd5b83823461047657806003193601126104765760209061169b6116916118aa565b60243590336126e6565b5160018152f35b50823461042a578060031936011261042a57606063ffffffff836116c4611941565b90839492945194855260208501521690820152f35b50919034610476576020366003190112610476576116f56118aa565b92600b546001600160a01b038082169333850361175d57506001600160a01b03199495169384911617600b55828452600c6020528320600160ff198254161790557f92b0a6c35a7725942f911dadba0d72be31d02967844649a1beb00efae0c195698380a380f35b60249084519063118cdaa760e01b82523390820152fd5b9184915034610476578160031936011261047657816003549260018460011c9160018616958615611860575b6020968785108114610dde578899509688969785829a5291826000146118395750506001146117dd575b505050610d559291610d469103856118ee565b9190869350600383527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8284106118215750505082010181610d46610d556117ca565b8054848a018601528895508794909301928101611808565b60ff19168782015293151560051b86019093019350849250610d469150610d5590506117ca565b92607f16926117a0565b919082519283825260005b848110611896575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201611875565b600435906001600160a01b03821682036118c057565b600080fd5b602435906001600160a01b03821682036118c057565b6004359063ffffffff821682036118c057565b90601f8019910116810190811067ffffffffffffffff82111761191057604052565b634e487b7160e01b600052604160045260246000fd5b51906dffffffffffffffffffffffffffff821682036118c057565b60049060606001600160a01b0360075416604051938480927f0902f1ac0000000000000000000000000000000000000000000000000000000082525afa908115611a08576000809381936119a9575b506dffffffffffffffffffffffffffff80911693169190565b925092506060823d606011611a00575b816119c6606093836118ee565b8101031261032e576119d782611926565b60406119e560208501611926565b9301519363ffffffff8516850361042a575091929138611990565b3d91506119b9565b6040513d6000823e3d90fd5b91908201809211611a2157565b634e487b7160e01b600052601160045260246000fd5b8115611a41570490565b634e487b7160e01b600052601260045260246000fd5b9291906000936001600160a01b03806007541690808316918214611fa357806007541681851614611a92575050611a8f939450612251565b90565b81600052602096600c885260409060ff82600020541615611f9b575b15611f8d57611aca63ffffffff9687600a5460481c169061218e565b92909683611ae3575b5050505050611a8f939450612251565b611aee843088612336565b600a5460ff1615611f4157611b2c903060005260008b52611b1b846000205491600a5460681c168261218e565b6002811015611f2c575b505061246b565b60ff600a5416611b78575b50967f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f3491611a8f9798611b6861263e565b51908152a2849338808080611ad3565b30600052600089528160002054906000611b90611941565b5090918415611f035782158015611efb575b611ed25760048d85600754168851928380927f0dfe16810000000000000000000000000000000000000000000000000000000082525afa918215611ec757908e8693611e9a575b5050163014600014611e875790611c03611c08928561216e565b611a37565b905b8351838152602081018390524760408201527f2f5621f2b7bdf78b7b6c286d6572447868217a52b7dce9881a3b09be941bd94690606090a1814711611c51575b5050611b37565b80600654168015611e705783611c6791306126e6565b806006541690600b541690610258420193844211611a215760609360c492875196879586947ff305d71900000000000000000000000000000000000000000000000000000000865230600487015260248601526000604486015260006064860152608485015260a48401525af19060008281928294611e2f575b50917f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f34959391611a8f9b9c959315600014611dee575050506001600060033d11611ddc575b6308c379a014611d85575b611d40575b9198978193611c4a565b7f1720a75363f50383662268a09272021aa57d321b3e621a8e19d508964230c3d1611d7d611d6c612058565b83519182918783528783019061186a565b0390a1611d36565b611d8d612677565b80611d99575b50611d31565b90507f16f910bbc684c1469a47cc2b21887a6e1cf0c0a2b1ee03b4539c3a5cbd7e0e20611dd360009284519182918883528883019061186a565b0390a138611d93565b5060046000803e60005160e01c611d26565b611d7d7fd7f28048575eead8851d024ead087913957dfb4fd1a02b4d1573f5352a5a2be3938551938493846040919493926060820195825260208201520152565b925092506060823d606011611e68575b81611e4c606093836118ee565b8101031261042a575080518a8201519184015192611a8f611ce1565b3d9150611e3f565b60248551637eff088160e01b815260006004820152fd5b611c03611e94928561216e565b90611c0a565b611eb99250803d10611ec0575b611eb181836118ee565b81019061244c565b388e611be9565b503d611ea7565b8751903d90823e3d90fd5b600486517f7bba511d000000000000000000000000000000000000000000000000000000008152fd5b508115611ba2565b600486517f98e3e2c5000000000000000000000000000000000000000000000000000000008152fd5b611f3a925060011c90611a14565b3880611b25565b5050967f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f3491611a8f97983060005260008352611f80816000205461246b565b611f8861263e565b611b68565b505050611a8f939450612251565b506001611aae565b905082959394951692838152600c60205260ff60408220541615612038575b1561202d57611fe0611a8f9463ffffffff600a5460281c169061218e565b80949194611ff0575b5050612251565b60208161201f7f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f34933087612336565b604051908152a23880611fe9565b611a8f939250612251565b506001611fc2565b611a8f60025463ffffffff60075460c01c1690611a37565b3d15612093573d9067ffffffffffffffff82116119105760405191612087601f8201601f1916602001846118ee565b82523d6000602084013e565b606090565b611a8f60025463ffffffff60075460a01c1690611a37565b9060006001600160a01b03806007541633146120d75750506120d29133612777565b600190565b8316600052600c60205260ff6040600020541615612166575b1561215c579061210f6120d29263ffffffff600a5460281c169061218e565b8092919261211f575b5033612777565b61212a813033612336565b6040519081527f9174fcf222375951e43519967bd54a1083271e61dab0b523b644cdf98c975f3460203392a238612118565b6120d29133612777565b5060016120f0565b81810292918115918404141715611a2157565b91908203918211611a2157565b919063ffffffff80911680156121f6576121a8818561216e565b91600a5460081c168092106121d3576121cf91611c036121c8928661216e565b8093612181565b9190565b505090600281106000146121e75790600090565b906121cf8260011c8093612181565b5050600090565b6001600160a01b0360055416330361221157565b602460405163118cdaa760e01b8152336004820152fd5b6006546001600160a01b03918216908216811491821561224757505090565b6007541614919050565b9291906001600160a01b038416936000858152600160205260409586822033835260205286822054906000198203612292575b5050506120d2939450612777565b8582106122f85780156122e15733156122ca576120d29697918691845260016020528284203385526020520391205584933880612284565b602483895190634a1406b160e11b82526004820152fd5b60248389519063e602df0560e01b82526004820152fd5b87517ffb8f41b20000000000000000000000000000000000000000000000000000000081523360048201526024810183905260448101879052606490fd5b6001600160a01b03808216929091836123b057507fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9160209161237b86600254611a14565b6002555b1693846123985780600254036002555b604051908152a3565b8460005260008252604060002081815401905561238f565b6000908482528160205260408220549086821061240157509181604087602095887fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9896528387520391205561237f565b6040517fe450d38c0000000000000000000000000000000000000000000000000000000081526001600160a01b03919091166004820152602481019190915260448101869052606490fd5b908160209103126118c057516001600160a01b03811681036118c05790565b6001600160a01b0380600654168015612626578261248991306126e6565b604090815192606084019167ffffffffffffffff92858110848211176119105784526002855260209081860191853684378651156125e6573083528160065416938651917fad5c46480000000000000000000000000000000000000000000000000000000083528083600481895afa92831561261b576000936125fc575b50885192600193600110156125e6578416888a0152610258420193844211611a2157863b156118c057918899959493919951998a967f791ac94700000000000000000000000000000000000000000000000000000000885260a488019260048901526000602489015260a060448901525180925260c4870195936000905b8382106125cc575050505050506000838195938193306064840152608483015203925af180156125c1576125b857505050565b82116119105752565b82513d6000823e3d90fd5b8551811688528c9850968201969482019490840190612585565b634e487b7160e01b600052603260045260246000fd5b816126149294503d8511611ec057611eb181836118ee565b9138612507565b88513d6000823e3d90fd5b6024604051637eff088160e01b815260006004820152fd5b478015801561264b575050565b600080809381936001600160a01b03600b541690839061266e575bf115611a0857565b506108fc612666565b600060443d10611a8f57604051600319913d83016004833e815167ffffffffffffffff918282113d6024840111176126d5578184019485519384116126dd573d850101602084870101116126d55750611a8f929101602001906118ee565b949350505050565b50949350505050565b6001600160a01b0380911691821561275f57169182156127475760207f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925918360005260018252604060002085600052825280604060002055604051908152a3565b6024604051634a1406b160e11b815260006004820152fd5b602460405163e602df0560e01b815260006004820152fd5b91906001600160a01b03808416156127cc5781161561279b5761279992612336565b565b60246040517fec442f0500000000000000000000000000000000000000000000000000000000815260006004820152fd5b60246040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260006004820152fdfea2646970667358221220a5bf66f5666b55eccbf9edd0e78382b2b919dd26d1b5e0ae8c3aa11caafacc0e64736f6c63430008170033
|
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"@openzeppelin/contracts/interfaces/draft-IERC6093.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n"
},
"@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol": {
"content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Factory {\n event PairCreated(address indexed token0, address indexed token1, address pair, uint);\n\n function feeTo() external view returns (address);\n function feeToSetter() external view returns (address);\n\n function getPair(address tokenA, address tokenB) external view returns (address pair);\n function allPairs(uint) external view returns (address pair);\n function allPairsLength() external view returns (uint);\n\n function createPair(address tokenA, address tokenB) external returns (address pair);\n\n function setFeeTo(address) external;\n function setFeeToSetter(address) external;\n}\n"
},
"@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol": {
"content": "pragma solidity >=0.5.0;\n\ninterface IUniswapV2Pair {\n event Approval(address indexed owner, address indexed spender, uint value);\n event Transfer(address indexed from, address indexed to, uint value);\n\n function name() external pure returns (string memory);\n function symbol() external pure returns (string memory);\n function decimals() external pure returns (uint8);\n function totalSupply() external view returns (uint);\n function balanceOf(address owner) external view returns (uint);\n function allowance(address owner, address spender) external view returns (uint);\n\n function approve(address spender, uint value) external returns (bool);\n function transfer(address to, uint value) external returns (bool);\n function transferFrom(address from, address to, uint value) external returns (bool);\n\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n function PERMIT_TYPEHASH() external pure returns (bytes32);\n function nonces(address owner) external view returns (uint);\n\n function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;\n\n event Mint(address indexed sender, uint amount0, uint amount1);\n event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);\n event Swap(\n address indexed sender,\n uint amount0In,\n uint amount1In,\n uint amount0Out,\n uint amount1Out,\n address indexed to\n );\n event Sync(uint112 reserve0, uint112 reserve1);\n\n function MINIMUM_LIQUIDITY() external pure returns (uint);\n function factory() external view returns (address);\n function token0() external view returns (address);\n function token1() external view returns (address);\n function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);\n function price0CumulativeLast() external view returns (uint);\n function price1CumulativeLast() external view returns (uint);\n function kLast() external view returns (uint);\n\n function mint(address to) external returns (uint liquidity);\n function burn(address to) external returns (uint amount0, uint amount1);\n function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;\n function skim(address to) external;\n function sync() external;\n\n function initialize(address, address) external;\n}\n"
},
"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol": {
"content": "pragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint amountADesired,\n uint amountBDesired,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB, uint liquidity);\n function addLiquidityETH(\n address token,\n uint amountTokenDesired,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external payable returns (uint amountToken, uint amountETH, uint liquidity);\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETH(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountToken, uint amountETH);\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint liquidity,\n uint amountAMin,\n uint amountBMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountA, uint amountB);\n function removeLiquidityETHWithPermit(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountToken, uint amountETH);\n function swapExactTokensForTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapTokensForExactTokens(\n uint amountOut,\n uint amountInMax,\n address[] calldata path,\n address to,\n uint deadline\n ) external returns (uint[] memory amounts);\n function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\n external\n returns (uint[] memory amounts);\n function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\n external\n payable\n returns (uint[] memory amounts);\n\n function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\n function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\n function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\n function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\n function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\n}\n"
},
"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol": {
"content": "pragma solidity >=0.6.2;\n\nimport './IUniswapV2Router01.sol';\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline\n ) external returns (uint amountETH);\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint liquidity,\n uint amountTokenMin,\n uint amountETHMin,\n address to,\n uint deadline,\n bool approveMax, uint8 v, bytes32 r, bytes32 s\n ) external returns (uint amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external payable;\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint amountIn,\n uint amountOutMin,\n address[] calldata path,\n address to,\n uint deadline\n ) external;\n}\n"
},
"contracts/R4RE.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// Author: A.P\r\n// Organization: Rare Art\r\n// Development: Kibernacia\r\n// Product: R4RE\r\n// Version: 1.0.0\r\n// Link: https://linktr.ee/rareuniverse\r\npragma solidity >=0.8.23 <0.9.0;\r\n\r\n// OpenZeppelin\r\nimport {ERC20} from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\r\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\r\n\r\n// Uniswap V2\r\nimport {IUniswapV2Factory} from \"@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol\";\r\nimport {IUniswapV2Router02} from \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\r\n\r\n// R4RE\r\nimport {R4REPool} from \"./R4REPool.sol\";\r\n\r\ncontract R4RE is ERC20, Ownable, R4REPool {\r\n /// @notice Stores token name.\r\n /// @dev Stores constant string.\r\n string private constant _NAME = \"R4RE\";\r\n\r\n /// @notice Stores token symbol.\r\n /// @dev Stores constant string.\r\n string private constant _SYMBOL = \"R4RE\";\r\n\r\n /// @notice Stores max wallet factor.\r\n /// @dev Stores number.\r\n uint32 private _maxWalletFactor = 50;\r\n\r\n /// @notice Stores max transaction factor.\r\n /// @dev Stores number.\r\n uint32 private _maxTransactionFactor = 50;\r\n\r\n /// @notice Stores time-based restriction per address.\r\n /// @dev Stores map from address to timestamp.\r\n mapping(address => uint256) public lastTransactionTimestamp;\r\n\r\n /// @notice Stores cooldown time per address.\r\n /// @dev Stores timestamp.\r\n uint256 public cooldownTime = 5 seconds;\r\n\r\n /// @notice Indicates whether automatic liquidity provision to the pool is enabled.\r\n /// @dev Set to `true` by default, allowing the contract to automatically add liquidity. This can be toggled to enable or disable the feature.\r\n bool public autoLiquidityProviding = true;\r\n\r\n /// @notice Stores tax factor.\r\n /// @dev Stores number.\r\n uint32 private _taxFactor = 100;\r\n\r\n /// @notice Stores buy tax.\r\n /// @dev Stores number.\r\n uint32 public buyTax = 6; // 6.00% (default)\r\n\r\n /// @notice Stores sell tax.\r\n /// @dev Stores number.\r\n uint32 public sellTax = 6; // 6.00% (default)\r\n\r\n /// @notice Defines the fee percentage for liquidity provision.\r\n /// @notice LP tax will be fractionated from both buy and sell tax.\r\n /// @dev Stored number.\r\n uint32 public liquidityFee = 50; // 50.00% (default)\r\n\r\n /// @notice Stores tax collecting address.\r\n /// @dev Stores address.\r\n address payable public taxCollector;\r\n\r\n /// @notice Stores excluded from fee addresses.\r\n /// @dev Stores map from address to bool.\r\n mapping(address => bool) public isExcluded;\r\n\r\n constructor(\r\n uint256 initialSupply\r\n ) ERC20(_NAME, _SYMBOL) Ownable(_msgSender()) {\r\n // Create token supply\r\n _mint(_msgSender(), initialSupply);\r\n\r\n // Set tax collection address\r\n taxCollector = payable(_msgSender());\r\n\r\n // Setup uniswap v2 router\r\n uniswapV2Router = IUniswapV2Router02(\r\n 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D\r\n );\r\n\r\n // Set uniswap v2 factory\r\n IUniswapV2Factory uniswapV2Factory = IUniswapV2Factory(\r\n uniswapV2Router.factory()\r\n );\r\n\r\n // Create uniswap v2 pair\r\n uniswapV2Pair = uniswapV2Factory.createPair(\r\n address(this),\r\n uniswapV2Router.WETH()\r\n );\r\n\r\n // Exclude owner, contract, uniswap v2 router and pair from fees by default\r\n isExcluded[_msgSender()] = true;\r\n isExcluded[address(this)] = true;\r\n isExcluded[address(uniswapV2Router)] = true;\r\n isExcluded[uniswapV2Pair] = true;\r\n }\r\n\r\n // Modifiers\r\n /**\r\n * @dev Throws if called by any account other than the tax collector.\r\n */\r\n modifier onlyTaxCollector() {\r\n if (taxCollector != _msgSender()) {\r\n revert OwnableUnauthorizedAccount(_msgSender());\r\n }\r\n\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Throws if transaction conditions are not valid.\r\n * @param from The address to which tokens are being transferred.\r\n * @param to The address to which tokens are being transferred.\r\n * @param value The amount of tokens being transferred.\r\n */\r\n modifier validateTransfer(\r\n address from,\r\n address to,\r\n uint256 value\r\n ) {\r\n // Validation\r\n if (from == address(0)) {\r\n revert TransferFromZeroAddress();\r\n }\r\n\r\n if (to == address(0)) {\r\n revert TransferToZeroAddress();\r\n }\r\n\r\n if (!isExcluded[from] && isUniswap(to)) {\r\n // Max transaction size validation\r\n if (value > maxTransactionSize()) {\r\n revert MaxTransactionSizeExceeded();\r\n }\r\n\r\n // Time-based restriction validation\r\n uint256 timestamp = lastTransactionTimestamp[from];\r\n uint256 restriction = timestamp + cooldownTime;\r\n if (block.timestamp < restriction) {\r\n revert TransferTimeRestriction();\r\n }\r\n\r\n // Set timestamp\r\n lastTransactionTimestamp[from] = block.timestamp;\r\n }\r\n\r\n if (isUniswap(from) && !isExcluded[to]) {\r\n // Max transaction size validation\r\n if (value > maxTransactionSize()) {\r\n revert MaxTransactionSizeExceeded();\r\n }\r\n\r\n // Time-based restriction validation\r\n uint256 timestamp = lastTransactionTimestamp[to];\r\n uint256 restriction = timestamp + cooldownTime;\r\n if (block.timestamp < restriction) {\r\n revert TransferTimeRestriction();\r\n }\r\n\r\n // Set timestamp\r\n lastTransactionTimestamp[to] = block.timestamp;\r\n }\r\n\r\n if (!isExcluded[to]) {\r\n // Max wallet size validation\r\n if ((balanceOf(to) + value) > maxWalletSize()) {\r\n revert MaxWalletSizeExceeded();\r\n }\r\n }\r\n\r\n // Cooldown transfer\r\n if (!isExcluded[from] && !isExcluded[to]) {\r\n lastTransactionTimestamp[to] = lastTransactionTimestamp[from];\r\n }\r\n\r\n _;\r\n }\r\n\r\n /**\r\n * @dev Overrides transfer function to add custom logic for trading protections and taxes.\r\n * @notice This function is used to transfer tokens with additional features such as trading protections and taxes.\r\n * @param to The address to which tokens are transferred.\r\n * @param value The amount of tokens to be transferred.\r\n * @return A boolean that indicates whether the operation succeeded.\r\n */\r\n function transfer(\r\n address to,\r\n uint256 value\r\n ) public override validateTransfer(_msgSender(), to, value) returns (bool) {\r\n // Parameters\r\n uint256 amountAfterTax = value;\r\n uint256 taxedAmount = 0;\r\n bool deductTax = false;\r\n\r\n // Swap Token to ETH\r\n if (_msgSender() == uniswapV2Pair) {\r\n // Verification\r\n if (!isExcluded[to]) {\r\n deductTax = true;\r\n }\r\n\r\n if (deductTax) {\r\n // Taxation\r\n (amountAfterTax, taxedAmount) = calculateTax(value, buyTax);\r\n\r\n // Collect tax\r\n if (taxedAmount > 0) {\r\n // Update\r\n super._update(_msgSender(), address(this), taxedAmount);\r\n\r\n // Event\r\n emit Taxed(_msgSender(), taxedAmount);\r\n }\r\n\r\n return super.transfer(to, amountAfterTax);\r\n } else {\r\n return super.transfer(to, value);\r\n }\r\n }\r\n\r\n return super.transfer(to, value);\r\n }\r\n\r\n /**\r\n * @dev Overrides transferFrom function to add custom logic for trading protections and taxes.\r\n * @notice This function is used to transfer tokens from one address to another with additional features such as trading protections and taxes.\r\n * @param from The address from which tokens are transferred.\r\n * @param to The address to which tokens are transferred.\r\n * @param value The amount of tokens to be transferred.\r\n * @return A boolean that indicates whether the operation succeeded.\r\n */\r\n function transferFrom(\r\n address from,\r\n address to,\r\n uint256 value\r\n ) public override validateTransfer(from, to, value) returns (bool) {\r\n // Parameters\r\n uint256 amountAfterTax = value;\r\n uint256 taxedAmount = 0;\r\n bool deductTax = false;\r\n\r\n // Swap ETH to Token\r\n if (from == uniswapV2Pair) {\r\n // Verification\r\n if (!isExcluded[to]) {\r\n deductTax = true;\r\n }\r\n\r\n if (deductTax) {\r\n // Taxation\r\n (amountAfterTax, taxedAmount) = calculateTax(value, buyTax);\r\n\r\n // Collect tax\r\n if (taxedAmount > 0) {\r\n // Update\r\n super._update(from, address(this), taxedAmount);\r\n\r\n // Event\r\n emit Taxed(to, taxedAmount);\r\n }\r\n\r\n return super.transferFrom(from, to, amountAfterTax);\r\n } else {\r\n return super.transferFrom(from, to, value);\r\n }\r\n }\r\n\r\n // Swap Token to ETH\r\n if (to == uniswapV2Pair) {\r\n // Verification\r\n if (!isExcluded[from]) {\r\n deductTax = true;\r\n }\r\n\r\n if (deductTax) {\r\n // Taxation\r\n (amountAfterTax, taxedAmount) = calculateTax(value, sellTax);\r\n\r\n // Collect tax\r\n if (taxedAmount > 0) {\r\n // Update\r\n super._update(from, address(this), taxedAmount);\r\n\r\n if (autoLiquidityProviding) {\r\n // Tax\r\n uint256 amountTax = 0;\r\n uint256 amountLiquidity = 0;\r\n uint256 amountSwap = balanceOf(address(this));\r\n\r\n // Distribution\r\n (amountTax, amountLiquidity) = calculateTax(\r\n balanceOf(address(this)),\r\n liquidityFee\r\n );\r\n\r\n // Validation\r\n if (amountLiquidity >= 2) {\r\n amountSwap = amountTax + amountLiquidity / 2;\r\n }\r\n\r\n // Swap\r\n swapTokensForEth(amountSwap);\r\n\r\n if (autoLiquidityProviding) {\r\n // Distribution\r\n uint amountToken = balanceOf(address(this));\r\n uint amountETH = quote(amountToken);\r\n\r\n emit Quote(\r\n amountToken,\r\n amountETH,\r\n address(this).balance\r\n );\r\n\r\n // Add Liquidity\r\n if (address(this).balance > amountETH) {\r\n addLiquidity(amountToken, amountETH);\r\n }\r\n }\r\n\r\n // Distribute\r\n transferTax();\r\n } else {\r\n // Swap\r\n swapTokensForEth(balanceOf(address(this)));\r\n\r\n // Distribute\r\n transferTax();\r\n }\r\n\r\n // Event\r\n emit Taxed(from, taxedAmount);\r\n }\r\n\r\n return super.transferFrom(from, to, amountAfterTax);\r\n } else {\r\n return super.transferFrom(from, to, value);\r\n }\r\n }\r\n\r\n return super.transferFrom(from, to, value);\r\n }\r\n\r\n /**\r\n * @dev Checks if the given address is either the Uniswap V2 Router or the Uniswap V2 Pair.\r\n * @param sender The address to be checked.\r\n * @return Whether the address is associated with Uniswap.\r\n */\r\n function isUniswap(address sender) private view returns (bool) {\r\n return sender == address(uniswapV2Router) || sender == uniswapV2Pair;\r\n }\r\n\r\n /**\r\n * @notice Returns the max wallet size per address.\r\n * @dev Returns a number calculated based on supply divided by the factor.\r\n */\r\n function maxWalletSize() public view returns (uint256) {\r\n return totalSupply() / _maxWalletFactor;\r\n }\r\n\r\n /**\r\n * @notice Returns the max transaction size per transfer.\r\n * @dev Returns a number calculated based on supply divided by the factor.\r\n */\r\n function maxTransactionSize() public view returns (uint256) {\r\n return totalSupply() / _maxTransactionFactor;\r\n }\r\n\r\n /**\r\n * @dev Calculates the amount after applying a tax to the given amount.\r\n * @param amount The original amount on which tax is to be applied.\r\n * @param tax The tax rate to be applied, represented as a percentage (e.g., 5 for 5%).\r\n * @return amountAfterTax The amount after applying the tax.\r\n * @return taxedAmount The calculated tax amount.\r\n *\r\n * @notice This function is a view function, meaning it does not modify the state of the contract.\r\n * @notice If the tax is set to 0, the original amount is returned with no tax applied.\r\n * @notice If the product of amount and tax is less than a predefined factor (_taxFactor),\r\n * the tax is considered negligible and the amount is returned with no tax applied.\r\n * @notice If the original amount is less than 2, no tax is applied, and the original amount is returned.\r\n * @notice If none of the above conditions are met, the tax is calculated and subtracted from the original amount.\r\n */\r\n function calculateTax(\r\n uint256 amount,\r\n uint32 tax\r\n ) public view returns (uint256 amountAfterTax, uint256 taxedAmount) {\r\n // Validation Zero Tax\r\n if (tax == 0) return (amount, 0);\r\n\r\n // Validation Small Amount\r\n if ((amount * tax) < _taxFactor) {\r\n if (amount < 2) {\r\n return (amount, 0);\r\n } else {\r\n taxedAmount = amount / 2;\r\n amountAfterTax = amount - taxedAmount;\r\n\r\n return (amountAfterTax, taxedAmount);\r\n }\r\n }\r\n\r\n taxedAmount = (amount * tax) / _taxFactor;\r\n amountAfterTax = amount - taxedAmount;\r\n\r\n return (amountAfterTax, taxedAmount);\r\n }\r\n\r\n /**\r\n * @dev Sets a new tax collector for the contract.\r\n * @param newTaxCollector The address of the new tax collector.\r\n *\r\n * @notice This function is external and can be called by anyone, but it is restricted to only the current tax collector.\r\n * @notice Only the current tax collector has the authority to set a new tax collector.\r\n * @notice The new tax collector's address is stored, and the old tax collector is replaced with the new one.\r\n * @notice The new tax collector is marked as excluded to prevent taxation on themselves.\r\n * @notice Emits a TaxCollectorModified event with details about the modification, including the old and new tax collector's addresses.\r\n */\r\n function setTaxCollector(\r\n address newTaxCollector\r\n ) external onlyTaxCollector {\r\n // Set\r\n address oldTaxCollector = taxCollector;\r\n taxCollector = payable(newTaxCollector);\r\n\r\n // Exclude\r\n isExcluded[newTaxCollector] = true;\r\n\r\n // Event\r\n emit TaxCollectorModified(oldTaxCollector, newTaxCollector);\r\n }\r\n\r\n /**\r\n * @dev Sets the exclusion status for a given account from tax calculations.\r\n * @param account The address of the account to be excluded or included.\r\n * @param exclude A boolean flag indicating whether the account should be excluded (true) or included (false).\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to exclude or include accounts.\r\n * @notice The exclusion status is updated for the specified account, affecting tax calculations.\r\n * @notice Emits an Excluded event with details about the modification, including the account address and exclusion status.\r\n */\r\n function setExclude(address account, bool exclude) external onlyOwner {\r\n // Set\r\n isExcluded[account] = exclude;\r\n\r\n // Event\r\n emit Excluded(account, exclude);\r\n }\r\n\r\n /**\r\n * @dev Sets the maximum wallet factor for the contract, which is used as a threshold for wallet balance validation.\r\n * @param newFactor The new maximum wallet factor to be set.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the maximum wallet factor.\r\n * @notice The new maximum wallet factor must not exceed the total supply of the contract's token.\r\n * @notice If the new maximum wallet factor is invalid, the function reverts and emits an error message.\r\n * @notice Emits a FactorModified event with details about the modification, including the factor type, old factor, and new factor.\r\n */\r\n function setMaxWalletFactor(uint32 newFactor) external onlyOwner {\r\n // Validation\r\n if (newFactor > totalSupply()) {\r\n revert InvalidInput(\r\n \"Max wallet factor\",\r\n \"Max wallet factor cannot exceed total supply\"\r\n );\r\n }\r\n\r\n // Set\r\n uint32 oldFactor = _maxWalletFactor;\r\n _maxWalletFactor = newFactor;\r\n\r\n // Event\r\n emit FactorModified(\"Max Wallet Factor\", oldFactor, newFactor);\r\n }\r\n\r\n /**\r\n * @dev Sets the maximum transaction factor for the contract, which is used as a threshold for transaction validation.\r\n * @param newFactor The new maximum transaction factor to be set.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the maximum transaction factor.\r\n * @notice The new maximum transaction factor must not exceed the total supply of the contract's token.\r\n * @notice If the new maximum transaction factor is invalid, the function reverts and emits an error message.\r\n * @notice Emits a FactorModified event with details about the modification, including the factor type, old factor, and new factor.\r\n */\r\n function setMaxTransactionFactor(uint32 newFactor) external onlyOwner {\r\n // Validation\r\n if (newFactor > totalSupply()) {\r\n revert InvalidInput(\r\n \"Max transaction factor\",\r\n \"Max transaction factor cannot exceed total supply\"\r\n );\r\n }\r\n\r\n // Set\r\n uint32 oldFactor = _maxTransactionFactor;\r\n _maxTransactionFactor = newFactor;\r\n\r\n // Event\r\n emit FactorModified(\"Max Transaction Factor\", oldFactor, newFactor);\r\n }\r\n\r\n /**\r\n * @dev Sets the cooldown time for transactions in the contract.\r\n * @param newCooldownTime The new cooldown time, representing the duration in seconds.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the cooldown time.\r\n * @notice The new cooldown time is stored, affecting the time duration between transactions.\r\n * @notice Emits a CooldownTimeModified event with details about the modification, including the old and new cooldown times.\r\n */\r\n function setCooldownTime(uint256 newCooldownTime) external onlyOwner {\r\n // Set\r\n uint256 oldCooldownTime = cooldownTime;\r\n cooldownTime = newCooldownTime;\r\n\r\n // Event\r\n emit CooldownTimeModified(oldCooldownTime, newCooldownTime);\r\n }\r\n\r\n /**\r\n * @dev Toggles the automatic liquidity provision feature of the contract. This feature, when enabled, allows the contract to automatically provide liquidity to a paired liquidity pool.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to toggle the automatic liquidity provision feature.\r\n * @notice Toggling this feature inverses the current state of the autoLiquidityProviding variable.\r\n * @notice Emits an AutoLiquiditySwitch event indicating the new state of the automatic liquidity provision feature.\r\n */\r\n function switchAutoLiquidity() external onlyOwner {\r\n // Set\r\n autoLiquidityProviding = !autoLiquidityProviding;\r\n\r\n // Event\r\n emit AutoLiquiditySwitch(autoLiquidityProviding);\r\n }\r\n\r\n /**\r\n * @dev Sets the tax factor for the contract, which is used as a threshold for tax division.\r\n * @param newTaxFactor The new tax factor to be set.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the tax factor.\r\n * @notice The new tax factor must not exceed the total supply of the contract's token.\r\n * @notice If the new tax factor is invalid, the function reverts and emits an error message.\r\n * @notice Emits a FactorModified event with details about the modification, including the factor type, old factor, and new factor.\r\n */\r\n function setTaxFactor(uint32 newTaxFactor) external onlyOwner {\r\n // Validation\r\n if (_taxFactor > totalSupply()) {\r\n revert InvalidInput(\r\n \"Tax Factor\",\r\n \"Tax factor cannot exceed total supply\"\r\n );\r\n }\r\n\r\n // Set\r\n uint32 oldTaxFactor = newTaxFactor;\r\n _taxFactor = newTaxFactor;\r\n\r\n // Event\r\n emit FactorModified(\"Tax Factor\", oldTaxFactor, newTaxFactor);\r\n }\r\n\r\n /**\r\n * @dev Sets the buying tax rate for the contract.\r\n * @param newTax The new tax rate to be set, represented as a percentage (e.g., 5 for 5%).\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the buying tax rate.\r\n * @notice The new tax rate must not exceed a predefined factor (_taxFactor) to prevent excessive taxation.\r\n * @notice If the new tax rate is invalid, the function reverts and emits an error message.\r\n * @notice Emits a TaxModified event with details about the modification, including the tax type, old tax rate, and new tax rate.\r\n */\r\n function setBuyTax(uint32 newTax) external onlyOwner {\r\n // Validation\r\n if (newTax > _taxFactor) {\r\n revert InvalidInput(\"Buy Tax\", \"Buy tax cannot exceed tax factor\");\r\n }\r\n\r\n // Set\r\n uint32 oldTax = buyTax;\r\n buyTax = newTax;\r\n\r\n // Event\r\n emit TaxModified(\"Buy Tax\", oldTax, newTax);\r\n }\r\n\r\n /**\r\n * @dev Sets the selling tax rate for the contract.\r\n * @param newTax The new tax rate to be set, represented as a percentage.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the selling tax rate.\r\n * @notice The new tax rate must not exceed a predefined factor (_taxFactor) to prevent excessive taxation.\r\n * @notice If the new tax rate is invalid, the function reverts and emits an error message.\r\n * @notice Emits a TaxModified event with details about the modification, including the tax type, old tax rate, and new tax rate.\r\n */\r\n function setSellTax(uint32 newTax) external onlyOwner {\r\n // Validation\r\n if (newTax > _taxFactor) {\r\n revert InvalidInput(\r\n \"Sell Tax\",\r\n \"Sell tax cannot exceed tax factor\"\r\n );\r\n }\r\n\r\n // Set\r\n uint32 oldTax = sellTax;\r\n sellTax = newTax;\r\n\r\n // Event\r\n emit TaxModified(\"Sell Tax\", oldTax, newTax);\r\n }\r\n\r\n /**\r\n * @dev Sets a new liquidity fee for the contract, which is applied to transactions for liquidity provision.\r\n * @param newTax The new liquidity fee to be set, expressed in basis points (bps). For example, a value of 50 represents a 0.5% fee.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the liquidity fee.\r\n * @notice The new liquidity fee must not exceed the predefined tax factor limit. If it does, the function reverts with an \"InvalidInput\" error.\r\n * @notice Emits a `TaxModified` event with details about the modification, including the tax type (\"LP Tax\"), old tax rate, and new tax rate.\r\n */\r\n function setliquidityFee(uint32 newTax) external onlyOwner {\r\n // Validation\r\n if (newTax > _taxFactor) {\r\n revert InvalidInput(\"LP Tax\", \"LP tax cannot exceed tax factor\");\r\n }\r\n\r\n // Set\r\n uint32 oldTax = liquidityFee;\r\n liquidityFee = newTax;\r\n\r\n // Event\r\n emit TaxModified(\"LP Tax\", oldTax, newTax);\r\n }\r\n\r\n /**\r\n * @dev Adds liquidity to the Uniswap V2 liquidity pool using a specified amount of tokens and ETH.\r\n * The function first verifies the Uniswap V2 Router's address, then approves the router to spend the tokens,\r\n * and finally attempts to add liquidity to the pool. It handles success or failure of liquidity addition.\r\n * @param amountToken The amount of tokens to add to the pool.\r\n * @param amountETH The amount of ETH to add to the pool, sent along with the transaction.\r\n *\r\n * @notice This function is private, meaning it can only be called from within the contract itself.\r\n * @notice Before calling this function, ensure that the Uniswap V2 Router is set and valid.\r\n * @notice The function approves the Uniswap V2 Router to spend the specified `amountToken`.\r\n * @notice Attempts to add `amountToken` tokens and `amountETH` ETH to the Uniswap V2 liquidity pool.\r\n * If successful, emits a `LiquidityAdded` event with the amounts used and liquidity tokens received.\r\n * @notice If the attempt to add liquidity fails due to a revert with a reason, emits a `LiquidityAdditionFailed` event with the reason.\r\n * @notice If the attempt fails without a revert reason, emits a `LiquidityAdditionFailedBytes` event with the low-level data.\r\n */\r\n function addLiquidity(uint amountToken, uint amountETH) private {\r\n // Verification\r\n if (address(uniswapV2Router) == address(0)) {\r\n revert UniswapV2InvalidRouter(address(0));\r\n }\r\n\r\n // Approve the Uniswap V2 router to spend the token amount\r\n _approve(address(this), address(uniswapV2Router), amountToken);\r\n\r\n // Add tokens and ETH to the liquidity pool\r\n try\r\n uniswapV2Router.addLiquidityETH{value: amountETH}(\r\n address(this),\r\n amountToken,\r\n 0, // Consider setting non-zero slippage limits for production\r\n 0, // Consider setting non-zero slippage limits for production\r\n address(taxCollector),\r\n block.timestamp + 600\r\n )\r\n returns (uint amountTokenUsed, uint amountETHUsed, uint liquidity) {\r\n // Handle successful liquidity addition\r\n // e.g., Emit an event or execute further logic as needed\r\n emit LiquidityAdded(amountTokenUsed, amountETHUsed, liquidity);\r\n } catch Error(string memory reason) {\r\n // Handle a revert with a reason from the Uniswap V2 Router\r\n // e.g., Emit an event or revert the transaction\r\n emit LiquidityAdditionFailed(reason);\r\n } catch (bytes memory lowLevelData) {\r\n // Handle a failure without a revert reason from the Uniswap V2 Router\r\n // e.g., Emit an event or revert the transaction\r\n emit LiquidityAdditionFailedBytes(lowLevelData);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Initiates the swap of Tokens for ETH and distributes the resulting ETH.\r\n * @dev Accessible only by the contract owner.\r\n */\r\n function swap() external onlyOwner {\r\n // Swap\r\n swapTokensForEth(balanceOf(address(this)));\r\n\r\n // Distribute\r\n transferTax();\r\n\r\n // Event\r\n emit Swap();\r\n }\r\n\r\n /**\r\n * @dev Internal function to swap Tokens for ETH using the Uniswap V2 Router.\r\n * @param amount The amount of tokens to be swapped.\r\n */\r\n function swapTokensForEth(uint256 amount) private {\r\n // Verification\r\n if (address(uniswapV2Router) == address(0)) {\r\n revert UniswapV2InvalidRouter(address(0));\r\n }\r\n\r\n // Approve the Uniswap V2 router to spend the token amount\r\n _approve(address(this), address(uniswapV2Router), amount);\r\n\r\n // Parameters\r\n address[] memory path = new address[](2);\r\n\r\n // Configuration\r\n path[0] = address(this);\r\n path[1] = uniswapV2Router.WETH();\r\n\r\n // Swap tokens for ETH\r\n uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(\r\n amount,\r\n 0,\r\n path,\r\n address(this),\r\n block.timestamp + 600\r\n );\r\n }\r\n\r\n /**\r\n * @dev Internal function to transfer collected tax to the designated tax collector address.\r\n */\r\n function transferTax() private {\r\n // Parameter\r\n uint256 tax = address(this).balance;\r\n\r\n if (tax > 0) {\r\n taxCollector.transfer(tax);\r\n }\r\n }\r\n\r\n /**\r\n * @dev Fallback function to receive ETH.\r\n */\r\n receive() external payable {}\r\n\r\n /**\r\n * @dev Fallback function to receive ETH.\r\n */\r\n fallback() external payable {}\r\n}\r\n"
},
"contracts/R4REErrors.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// Author: A.P\r\n// Organization: Rare Art\r\n// Development: Kibernacia\r\n// Product: R4RE\r\n// Version: 1.0.0\r\n// Link: https://linktr.ee/rareuniverse\r\npragma solidity >=0.8.23 <0.9.0;\r\n\r\n/**\r\n * @dev R4RE Errors\r\n */\r\ninterface R4REErrors {\r\n /**\r\n * @dev Error indicating that the provided UniswapV2Router address is invalid.\r\n * @param newUniswapV2Router The address of the invalid UniswapV2Router.\r\n */\r\n error UniswapV2InvalidRouter(address newUniswapV2Router);\r\n\r\n /**\r\n * @dev Error indicating that the provided UniswapV2Pair address is invalid.\r\n * @param newUniswapV2Pair The address of the invalid UniswapV2Pair.\r\n */\r\n error UniswapV2InvalidPool(address newUniswapV2Pair);\r\n\r\n /**\r\n * @dev Error indicating that an operation failed because the provided amount is insufficient.\r\n */\r\n error UniswapV2InsufficientAmount();\r\n\r\n /**\r\n * @dev Error indicating that an operation failed due to insufficient liquidity in the Uniswap V2 pool.\r\n */\r\n error UniswapV2InsufficientLiquidity();\r\n\r\n /**\r\n * @dev Error indicating that a transfer from the zero address is not allowed.\r\n */\r\n error TransferFromZeroAddress();\r\n\r\n /**\r\n * @dev Error indicating that a transfer to the zero address is not allowed.\r\n */\r\n error TransferToZeroAddress();\r\n\r\n /**\r\n * @dev Error indicating that the maximum wallet size has been exceeded.\r\n */\r\n error MaxWalletSizeExceeded();\r\n\r\n /**\r\n * @dev Error indicating that the maximum transaction size has been exceeded.\r\n */\r\n error MaxTransactionSizeExceeded();\r\n\r\n /**\r\n * @dev Error indicating that a transfer is not allowed due to transfer time restrictions.\r\n */\r\n error TransferTimeRestriction();\r\n\r\n /**\r\n * @dev Error indicating that a withdrawal operation is invalid.\r\n */\r\n error WidthdrawInvalid();\r\n\r\n /**\r\n * @dev Error indicating that an input parameter is invalid.\r\n * @param index The index or identifier of the invalid input.\r\n * @param message A message describing the reason for the invalid input.\r\n */\r\n error InvalidInput(string index, string message);\r\n}\r\n"
},
"contracts/R4REEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// Author: A.P\r\n// Organization: Rare Art\r\n// Development: Kibernacia\r\n// Product: R4RE\r\n// Version: 1.0.0\r\n// Link: https://linktr.ee/rareuniverse\r\npragma solidity >=0.8.23 <0.9.0;\r\n\r\n/**\r\n * @dev R4RE Events\r\n */\r\ninterface R4REEvents {\r\n /**\r\n * @dev Emitted when an account is excluded or included from tax calculations.\r\n * @param account The address of the account being excluded or included.\r\n * @param exclude A boolean flag indicating whether the account is excluded (true) or included (false).\r\n */\r\n event Excluded(address indexed account, bool exclude);\r\n\r\n /**\r\n * @dev Emitted when the tax collector address is modified.\r\n * @param oldTaxCollector The old tax collector address before modification.\r\n * @param newTaxCollector The new tax collector address after modification.\r\n */\r\n event TaxCollectorModified(\r\n address indexed oldTaxCollector,\r\n address indexed newTaxCollector\r\n );\r\n\r\n /**\r\n * @dev Emitted when a factor (e.g., tax factor, max transaction factor, max wallet factor) is modified.\r\n * @param factor The type of factor being modified.\r\n * @param oldFactor The old value of the factor before modification.\r\n * @param newFactor The new value of the factor after modification.\r\n */\r\n event FactorModified(\r\n string indexed factor,\r\n uint32 oldFactor,\r\n uint32 newFactor\r\n );\r\n\r\n /**\r\n * @dev Emitted when a tax rate is modified.\r\n * @param tax The type of tax being modified.\r\n * @param oldTax The old tax rate before modification.\r\n * @param newTax The new tax rate after modification.\r\n */\r\n event TaxModified(string indexed tax, uint32 oldTax, uint32 newTax);\r\n\r\n /**\r\n * @dev Emitted when a swap operation occurs (e.g., in the Uniswap decentralized exchange).\r\n */\r\n event Swap();\r\n\r\n /**\r\n * @dev Emitted when a recipient address is taxed.\r\n * @param receiver The address of the recipient being taxed.\r\n * @param amount The amount of the tax applied.\r\n */\r\n event Taxed(address indexed receiver, uint256 amount);\r\n\r\n /**\r\n * @dev Emitted when the UniswapV2Router address is modified.\r\n * @param oldUniswapV2Router The old UniswapV2Router address before modification.\r\n * @param newUniswapV2Router The new UniswapV2Router address after modification.\r\n */\r\n event UniswapV2RouterModified(\r\n address indexed oldUniswapV2Router,\r\n address indexed newUniswapV2Router\r\n );\r\n\r\n /**\r\n * @dev Emitted when the UniswapV2Pair address is modified.\r\n * @param oldUniswapV2Pair The old UniswapV2Pair address before modification.\r\n * @param newUniswapV2Pair The new UniswapV2Pair address after modification.\r\n */\r\n event UniswapV2PairModified(\r\n address indexed oldUniswapV2Pair,\r\n address indexed newUniswapV2Pair\r\n );\r\n\r\n /**\r\n * @dev Emitted when the cooldown time for transactions is modified.\r\n * @param oldCooldownTime The old cooldown time before modification.\r\n * @param newCooldownTime The new cooldown time after modification.\r\n */\r\n event CooldownTimeModified(\r\n uint256 oldCooldownTime,\r\n uint256 newCooldownTime\r\n );\r\n\r\n /**\r\n * @dev Emitted when the automatic liquidity provision setting is toggled.\r\n * @param autoLiquidityProviding Indicates whether automatic liquidity providing is enabled (true) or disabled (false).\r\n */\r\n event AutoLiquiditySwitch(bool indexed autoLiquidityProviding);\r\n\r\n /**\r\n * @dev Emitted when liquidity is successfully added to the liquidity pool.\r\n * @param amountTokenUsed The amount of tokens used to add liquidity.\r\n * @param amountETHUsed The amount of ETH used to add liquidity.\r\n * @param liquidity The amount of liquidity tokens received in return for adding liquidity.\r\n */\r\n event LiquidityAdded(\r\n uint256 amountTokenUsed,\r\n uint256 amountETHUsed,\r\n uint256 liquidity\r\n );\r\n\r\n /**\r\n * @dev Emitted when adding liquidity to the liquidity pool fails due to a reason that can be expressed in a string.\r\n * @param reason The reason why adding liquidity failed, described as a string.\r\n */\r\n event LiquidityAdditionFailed(string reason);\r\n\r\n /**\r\n * @dev Emitted when adding liquidity to the liquidity pool fails due to a reason that is captured in low-level bytes data.\r\n * @param lowLevelData The low-level bytes data representing the reason for the liquidity addition failure.\r\n */\r\n event LiquidityAdditionFailedBytes(bytes lowLevelData);\r\n\r\n /**\r\n * @dev Emitted after calculating the equivalent amount of ETH for a given amount of tokens.\r\n * This event helps in tracking the outcomes of quote operations, providing insights into the value conversions and the state of balances after the operation.\r\n * @param amountToken The amount of tokens for which the quote was calculated.\r\n * @param amountETH The equivalent amount of ETH for the given amount of tokens as per the current conversion rate.\r\n * @param balance The balance after the operation, potentially reflecting changes in reserves or liquidity.\r\n */\r\n event Quote(uint amountToken, uint amountETH, uint balance);\r\n}\r\n"
},
"contracts/R4REPool.sol": {
"content": "// SPDX-License-Identifier: MIT\r\n// Author: A.P\r\n// Organization: Rare Art\r\n// Development: Kibernacia\r\n// Product: R4RE\r\n// Version: 1.0.0\r\n// Link: https://linktr.ee/rareuniverse\r\npragma solidity >=0.8.23 <0.9.0;\r\n\r\n// OpenZeppelin\r\nimport {Context} from \"@openzeppelin/contracts/utils/Context.sol\";\r\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\r\n\r\n// Uniswap V2\r\nimport {IUniswapV2Pair} from \"@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol\";\r\nimport {IUniswapV2Router02} from \"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\";\r\n\r\n// R4RE\r\nimport {R4REEvents} from \"./R4REEvents.sol\";\r\nimport {R4REErrors} from \"./R4REErrors.sol\";\r\n\r\n/**\r\n * @dev R4RE Pool\r\n */\r\n\r\nabstract contract R4REPool is Context, Ownable, R4REEvents, R4REErrors {\r\n /// @notice Stores Uniswap V2 router interface.\r\n /// @dev Stores IUniswapV2Router02 interface.\r\n IUniswapV2Router02 public uniswapV2Router;\r\n\r\n /// @notice Stores Uniswap V2 pair address.\r\n /// @dev Stores address.\r\n address public uniswapV2Pair;\r\n\r\n /**\r\n * @dev Sets the UniswapV2Router for the contract to enable interactions with the Uniswap decentralized exchange.\r\n * @param newUniswapV2Router The address of the new UniswapV2Router contract.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the UniswapV2Router.\r\n * @notice The new UniswapV2Router address must be a valid address and not equal to address(0).\r\n * @notice If the new UniswapV2Router address is invalid, the function reverts and emits an error message.\r\n * @notice Emits a UniswapV2RouterModified event with details about the modification, including the old and new UniswapV2Router addresses.\r\n */\r\n function setUniswapV2Router(address newUniswapV2Router) external onlyOwner {\r\n // Verification\r\n if (newUniswapV2Router == address(0)) {\r\n revert UniswapV2InvalidRouter(address(0));\r\n }\r\n\r\n // Parameter\r\n address oldUniswapV2Router = address(uniswapV2Router);\r\n\r\n // Configuration\r\n uniswapV2Router = IUniswapV2Router02(newUniswapV2Router);\r\n\r\n // Event\r\n emit UniswapV2RouterModified(oldUniswapV2Router, newUniswapV2Router);\r\n }\r\n\r\n /**\r\n * @dev Sets the UniswapV2Pair for the contract to define the trading pair with the Uniswap decentralized exchange.\r\n * @param newUniswapV2Pair The address of the new UniswapV2Pair contract representing the trading pair.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to set the UniswapV2Pair.\r\n * @notice The new UniswapV2Pair address must be a valid address and not equal to address(0).\r\n * @notice If the new UniswapV2Pair address is invalid, the function reverts and emits an error message.\r\n * @notice Emits a UniswapV2PairModified event with details about the modification, including the old and new UniswapV2Pair addresses.\r\n */\r\n function setUniswapV2Pair(address newUniswapV2Pair) external onlyOwner {\r\n // Verification\r\n if (newUniswapV2Pair == address(0)) {\r\n revert UniswapV2InvalidPool(address(0));\r\n }\r\n\r\n // Parameter\r\n address oldUniswapV2Pair = uniswapV2Pair;\r\n\r\n // Configuration\r\n uniswapV2Pair = newUniswapV2Pair;\r\n\r\n // Event\r\n emit UniswapV2PairModified(oldUniswapV2Pair, uniswapV2Pair);\r\n }\r\n\r\n /**\r\n * @dev Retrieves the reserve amounts of the two tokens in the Uniswap V2 pair, along with the last block timestamp when these reserves were updated.\r\n * This function interfaces with the Uniswap V2 pair contract to fetch its current state, which is essential for calculating accurate trading prices, understanding liquidity depth, and more.\r\n * The reserves and timestamp can be used by external contracts or callers to make informed decisions in DeFi operations such as swaps, liquidity provision, or arbitrage.\r\n *\r\n * @return _reserve0 The reserve amount of the first token in the Uniswap V2 pair. Token pairs in Uniswap are ordered by their contract addresses.\r\n * @return _reserve1 The reserve amount of the second token in the Uniswap V2 pair.\r\n * @return _blockTimestampLast The last block timestamp when the reserves were recorded by the pair contract. This can be used to assess the freshness of the data.\r\n */\r\n function getReserves()\r\n public\r\n view\r\n returns (uint _reserve0, uint _reserve1, uint32 _blockTimestampLast)\r\n {\r\n // Parameter\r\n IUniswapV2Pair iPair = IUniswapV2Pair(uniswapV2Pair);\r\n\r\n return iPair.getReserves();\r\n }\r\n\r\n /**\r\n * @dev Calculates the equivalent amount of ETH for a given amount of tokens based on the reserves in the liquidity pool.\r\n * @param amountToken The amount of tokens to convert to an equivalent amount of ETH.\r\n * @return amountETH The equivalent amount of ETH based on the current reserves.\r\n */\r\n function quote(uint amountToken) internal view returns (uint amountETH) {\r\n // Get the reserves from the liquidity pool\r\n (uint reserveA, uint reserveB, ) = getReserves();\r\n\r\n if (amountToken <= 0) revert UniswapV2InsufficientAmount();\r\n if (reserveA <= 0 || reserveB <= 0) {\r\n revert UniswapV2InsufficientLiquidity();\r\n }\r\n\r\n // Parameter\r\n IUniswapV2Pair iPair = IUniswapV2Pair(uniswapV2Pair);\r\n\r\n if (address(this) == iPair.token0()) {\r\n // Calculate the equivalent amount of ETH based on the reserves and the amount of tokens\r\n amountETH = (amountToken * reserveB) / reserveA;\r\n } else {\r\n // Calculate the equivalent amount of ETH based on the reserves and the amount of tokens\r\n amountETH = (amountToken * reserveA) / reserveB;\r\n }\r\n }\r\n\r\n /**\r\n * @dev Allows the owner of the contract to withdraw the contract's balance.\r\n *\r\n * @notice This function is external, meaning it can only be called from outside the contract.\r\n * @notice Only the owner of the contract has the authority to withdraw funds.\r\n * @notice The entire balance of the contract is transferred to the owner's address.\r\n * @notice If the withdrawal is unsuccessful, the function reverts and emits an error message.\r\n */\r\n function withdraw() external onlyOwner {\r\n // Withdraw\r\n (bool success, ) = msg.sender.call{value: address(this).balance}(\"\");\r\n\r\n // Verification\r\n if (!success) {\r\n revert WidthdrawInvalid();\r\n }\r\n }\r\n}\r\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 1000
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,498,648 |
0a4cfa6d4072b6115ed2e7374ff0458f2b56a3cf4ff1e368a742f8c94bd9f86a
|
541ad195c163196df2865c387a42c9f718e6219a1d039d2d0c793200e3e1e5b7
|
68d1b53c201166651e9f0c062b654e6f7b254c28
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
5550a116a020e9f8533d543426d345055280dfea
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
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 (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,498,655 |
195e528899bea48ce5373606f574ad70e555fac961cd4fa246a22518ad2a0d21
|
ef3512fd75973d0e24c9dc5e1d77356561bdd63303c46b299c1f42e43d3499de
|
742e965841327adbbba9e25971d8bf2f632e5428
|
1e68238ce926dec62b3fbc99ab06eb1d85ce0270
|
ee34ae33c0d48bdf35793fe2485a757eed3b38ce
|
3d602d80600a3d3981f3363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73933fbfeb4ed1f111d12a39c2ab48657e6fc875c65af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/contracts/ConsensusLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Consensus Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ConsensusLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n error NotImplemented();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ConsensusLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ConsensusLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract\n /// @param _stakingContract Address of the Staking Contract\n function initCLD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32) external payable {\n revert NotImplemented();\n /*\n uint256 balance = address(this).balance; // this has taken into account msg.value\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee;\n\n if (balance >= 32 ether) {\n // withdrawing a healthy & exited validator\n globalFee = ((balance - 32 ether) * stakingContract.getGlobalFee()) / BASIS_POINTS;\n } else if (balance <= 16 ether) {\n // withdrawing from what looks like skimming\n globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n }\n\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(withdrawer, operator, balance - globalFee, operatorFee, globalFee - operatorFee);\n */\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
},
"src/contracts/libs/DispatchersStorageLib.sol": {
"content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\nlibrary DispatchersStorageLib {\n function getUint256(bytes32 position) internal view returns (uint256 data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setUint256(bytes32 position, uint256 data) internal {\n assembly {\n sstore(position, data)\n }\n }\n\n function getAddress(bytes32 position) internal view returns (address data) {\n assembly {\n data := sload(position)\n }\n }\n\n function setAddress(bytes32 position, address data) internal {\n assembly {\n sstore(position, data)\n }\n }\n}\n"
},
"src/contracts/interfaces/IStakingContractFeeDetails.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IStakingContractFeeDetails {\n function getWithdrawerFromPublicKeyRoot(bytes32 _publicKeyRoot) external view returns (address);\n\n function getTreasury() external view returns (address);\n\n function getOperatorFeeRecipient(bytes32 pubKeyRoot) external view returns (address);\n\n function getGlobalFee() external view returns (uint256);\n\n function getOperatorFee() external view returns (uint256);\n}\n"
},
"src/contracts/interfaces/IFeeDispatcher.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.10;\n\ninterface IFeeDispatcher {\n function dispatch(bytes32 _publicKeyRoot) external payable;\n\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address);\n}\n"
},
"src/contracts/FeeRecipient.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./interfaces/IFeeDispatcher.sol\";\n\ncontract FeeRecipient {\n /// @notice Constructor replay prevention\n bool internal initialized;\n /// @notice Address where funds are sent to be dispatched\n IFeeDispatcher internal dispatcher;\n /// @notice Public Key root assigned to this receiver\n bytes32 internal publicKeyRoot;\n\n error AlreadyInitialized();\n\n /// @notice Initializes the receiver\n /// @param _dispatcher Address that will handle the fee dispatching\n /// @param _publicKeyRoot Public Key root assigned to this receiver\n function init(address _dispatcher, bytes32 _publicKeyRoot) external {\n if (initialized) {\n revert AlreadyInitialized();\n }\n initialized = true;\n dispatcher = IFeeDispatcher(_dispatcher);\n publicKeyRoot = _publicKeyRoot;\n }\n\n /// @notice Empty calldata fallback\n receive() external payable {}\n\n /// @notice Non-empty calldata fallback\n fallback() external payable {}\n\n /// @notice Triggers a withdrawal by sending its funds + its public key root to the dispatcher\n /// @dev Can be called by any wallet as recipients are not parameters\n function withdraw() external {\n dispatcher.dispatch{value: address(this).balance}(publicKeyRoot);\n }\n\n /// @notice Retrieve the assigned public key root\n function getPublicKeyRoot() external view returns (bytes32) {\n return publicKeyRoot;\n }\n\n /// @notice retrieve the assigned withdrawer\n function getWithdrawer() external view returns (address) {\n return dispatcher.getWithdrawer(publicKeyRoot);\n }\n}\n"
},
"src/contracts/ExecutionLayerFeeDispatcher.sol": {
"content": "//SPDX-License-Identifier: BUSL-1.1\npragma solidity >=0.8.10;\n\nimport \"./libs/DispatchersStorageLib.sol\";\nimport \"./interfaces/IStakingContractFeeDetails.sol\";\nimport \"./interfaces/IFeeDispatcher.sol\";\n\n/// @title Execution Layer Fee Recipient\n/// @author Kiln\n/// @notice This contract can be used to receive fees from a validator and split them with a node operator\ncontract ExecutionLayerFeeDispatcher is IFeeDispatcher {\n using DispatchersStorageLib for bytes32;\n\n event Withdrawal(\n address indexed withdrawer,\n address indexed feeRecipient,\n bytes32 pubKeyRoot,\n uint256 rewards,\n uint256 nodeOperatorFee,\n uint256 treasuryFee\n );\n\n error TreasuryReceiveError(bytes errorData);\n error FeeRecipientReceiveError(bytes errorData);\n error WithdrawerReceiveError(bytes errorData);\n error ZeroBalanceWithdrawal();\n error AlreadyInitialized();\n error InvalidCall();\n\n bytes32 internal constant STAKING_CONTRACT_ADDRESS_SLOT =\n keccak256(\"ExecutionLayerFeeRecipient.stakingContractAddress\");\n uint256 internal constant BASIS_POINTS = 10_000;\n bytes32 internal constant VERSION_SLOT = keccak256(\"ExecutionLayerFeeRecipient.version\");\n\n /// @notice Ensures an initialisation call has been called only once per _version value\n /// @param _version The current initialisation value\n modifier init(uint256 _version) {\n if (_version != VERSION_SLOT.getUint256() + 1) {\n revert AlreadyInitialized();\n }\n\n VERSION_SLOT.setUint256(_version);\n\n _;\n }\n\n /// @notice Constructor method allowing us to prevent calls to initCLFR by setting the appropriate version\n constructor(uint256 _version) {\n VERSION_SLOT.setUint256(_version);\n }\n\n /// @notice Initialize the contract by storing the staking contract and the public key in storage\n /// @param _stakingContract Address of the Staking Contract\n function initELD(address _stakingContract) external init(1) {\n STAKING_CONTRACT_ADDRESS_SLOT.setAddress(_stakingContract);\n }\n\n /// @notice Performs a withdrawal on this contract's balance\n function dispatch(bytes32 _publicKeyRoot) external payable {\n uint256 balance = address(this).balance;\n if (balance == 0) {\n revert ZeroBalanceWithdrawal();\n }\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n address withdrawer = stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n address operator = stakingContract.getOperatorFeeRecipient(_publicKeyRoot);\n address treasury = stakingContract.getTreasury();\n uint256 globalFee = (balance * stakingContract.getGlobalFee()) / BASIS_POINTS;\n uint256 operatorFee = (globalFee * stakingContract.getOperatorFee()) / BASIS_POINTS;\n\n (bool status, bytes memory data) = withdrawer.call{value: balance - globalFee}(\"\");\n if (status == false) {\n revert WithdrawerReceiveError(data);\n }\n if (globalFee > 0) {\n (status, data) = treasury.call{value: globalFee - operatorFee}(\"\");\n if (status == false) {\n revert FeeRecipientReceiveError(data);\n }\n }\n if (operatorFee > 0) {\n (status, data) = operator.call{value: operatorFee}(\"\");\n if (status == false) {\n revert TreasuryReceiveError(data);\n }\n }\n emit Withdrawal(\n withdrawer,\n operator,\n _publicKeyRoot,\n balance - globalFee,\n operatorFee,\n globalFee - operatorFee\n );\n }\n\n /// @notice Retrieve the staking contract address\n function getStakingContract() external view returns (address) {\n return STAKING_CONTRACT_ADDRESS_SLOT.getAddress();\n }\n\n /// @notice Retrieve the assigned withdrawer for the given public key root\n /// @param _publicKeyRoot Public key root to get the owner\n function getWithdrawer(bytes32 _publicKeyRoot) external view returns (address) {\n IStakingContractFeeDetails stakingContract = IStakingContractFeeDetails(\n STAKING_CONTRACT_ADDRESS_SLOT.getAddress()\n );\n return stakingContract.getWithdrawerFromPublicKeyRoot(_publicKeyRoot);\n }\n\n receive() external payable {\n revert InvalidCall();\n }\n\n fallback() external payable {\n revert InvalidCall();\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}
}}
|
1 | 19,498,661 |
c64860032f1ed91603227fee63725f8a20b2e2f0c8c9dac039c18bc0cf589f3a
|
d3b4994859594d96dbda588bba1238905bd68e6501458036051eb53d9dde068a
|
000099b4a4d3ceb370d3a8a6235d24e07a8c0000
|
ee2a0343e825b2e5981851299787a679ce08216d
|
c676cf891e01dbc194e7764140e083b40686d411
|
6080604052348015600f57600080fd5b506040516101bb3803806101bb833981016040819052602c916059565b600080546001600160a01b039092166001600160a01b031992831617905560018054909116331790556087565b600060208284031215606a57600080fd5b81516001600160a01b0381168114608057600080fd5b9392505050565b610125806100966000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b14609f578063d4b839921460cd575b6001546001600160a01b03163314604857600080fd5b600080546040516001600160a01b03909116906066908390369060df565b600060405180830381855af49150503d8060008114609d576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60015460b1906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60005460b1906001600160a01b031681565b818382376000910190815291905056fea2646970667358221220736ccf845e951824707af03941a53c8275c6b25991c8ea8d34f6c24f7bbc22e164736f6c6343000819003300000000000000000000000033c99c0323adc0b7bd4ddd2ac4d4de2c28722fb0
|
6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b14609f578063d4b839921460cd575b6001546001600160a01b03163314604857600080fd5b600080546040516001600160a01b03909116906066908390369060df565b600060405180830381855af49150503d8060008114609d576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60015460b1906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60005460b1906001600160a01b031681565b818382376000910190815291905056fea2646970667358221220736ccf845e951824707af03941a53c8275c6b25991c8ea8d34f6c24f7bbc22e164736f6c63430008190033
| |
1 | 19,498,664 |
698ba61a5bbf1ce25ffa21fe913fd3dfa08d81b0e73fd5f49675efe5a439d13c
|
c77d26f0e238217c00a02902179d556c810258ffa827b05e3266be7e51a58aee
|
371281c9b7bb14bab2bc4e65b3fe21c6af1a0438
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
70729ec8b052cbaf23e707a47ea4908c3966e3ed
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,672 |
dd6f8fb0e742babd2b3b66b561962ca384bea413e826a0ff0456d2b84f6a3db6
|
ab20d22b6fd326630d60b7681e779af73e48b1f59175f7483644a22f70381cb7
|
3743a2023f7dbca51a2aee50cd9480d68b4d172c
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
9662529a050db96eed52d37e3e6d2b4a5414fd63
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,673 |
1cdfe37d4c2c8a2c9f5e3a4af28e8f9526dbc36bed6112697dad676e3a4dbd75
|
6203c206a32491e40439f304f128beb93b590cc96fc897772ba5d780fed6c1d9
|
fd851f0a5f15646f4ee7076dcfca62ae7f7de4d8
|
fd851f0a5f15646f4ee7076dcfca62ae7f7de4d8
|
0ad032ff9de14c74fba51249a1c74cca6117f0e0
|
6080604052670de0b6b3a764000060025566b1a2bc2ec500006003556004805460ff191690557f4c10f6e185a551b454e342e9309ae741455e7f4cda66f4ad2ed1a994d0e86f886007557f4c10f6e185a551b454e342e9558fc33d0edd0a3dc85a9aa98bcd41d2f31c848c6008557f4c10f6e185a551b454e342e9a7f9650ff343653db6df453da9f71b7ed5a3c6e460095534801561009d57600080fd5b50600080546001600160a01b031916331781556007546008546100be911890565b60405163e2d73ccd60e01b81523060048201529091506001600160a01b0382169063e2d73ccd90602401600060405180830381600087803b15801561010257600080fd5b505af1158015610116573d6000803e3d6000fd5b50505050506103678061012a6000396000f3fe6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212203a61be38465b9d221c4a7c0496ea35507efb7901b040f718971264eb39b76af964736f6c63430008070033
|
6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212203a61be38465b9d221c4a7c0496ea35507efb7901b040f718971264eb39b76af964736f6c63430008070033
| |
1 | 19,498,676 |
f018cf30e7c1413ae12a83582d98652c8bd7736f6a86e9250a5a1bf65859e32f
|
772c170a8217370422f6c6c26f412669be3149a0f9e74c0f9d0c71ec3b9cfd3f
|
d89e18f6fbd533fe1b87d0e323a6a55f3188cb1a
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
64cbcacc8ae752fbebf3c140f9de0c6480b6019f
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
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 (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,498,676 |
f018cf30e7c1413ae12a83582d98652c8bd7736f6a86e9250a5a1bf65859e32f
|
c91d1592851e897cd2a470e93ce44329f2251be9639dad8ff7e3c31e79aed428
|
faf34daecf2f91417908f0550cde3eb027481ca5
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
485c0db1af421cfe000877dcba0163f29d545631
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
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 (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,498,681 |
54c5c4c1b361772fb65a7a3e1132434ba3c92fcc22f513550ebd7fa4895bd64f
|
4e833164294563c309f60521b30dbc7a302e3e50ec723bee907ff606132aaab6
|
41ed843a086f44b8cb23decc8170c132bc257874
|
29ef46035e9fa3d570c598d3266424ca11413b0c
|
6fa10574cfb64e06b04c9d660e40a1522ecce915
|
3d602d80600a3d3981f3363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d735397d0869aba0d55e96d5716d383f6e1d8695ed75af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"contracts/Forwarder.sol": {
"content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity 0.8.10;\nimport '@openzeppelin/contracts/token/ERC1155/IERC1155.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721.sol';\nimport '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';\nimport '@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol';\nimport './ERC20Interface.sol';\nimport './TransferHelper.sol';\nimport './IForwarder.sol';\n\n/**\n * Contract that will forward any incoming Ether to the creator of the contract\n *\n */\ncontract Forwarder is IERC721Receiver, ERC1155Receiver, IForwarder {\n // Address to which any funds sent to this contract will be forwarded\n address public parentAddress;\n bool public autoFlush721 = true;\n bool public autoFlush1155 = true;\n\n event ForwarderDeposited(address from, uint256 value, bytes data);\n\n /**\n * Initialize the contract, and sets the destination address to that of the creator\n */\n function init(\n address _parentAddress,\n bool _autoFlush721,\n bool _autoFlush1155\n ) external onlyUninitialized {\n parentAddress = _parentAddress;\n uint256 value = address(this).balance;\n\n // set whether we want to automatically flush erc721/erc1155 tokens or not\n autoFlush721 = _autoFlush721;\n autoFlush1155 = _autoFlush1155;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n\n // NOTE: since we are forwarding on initialization,\n // we don't have the context of the original sender.\n // We still emit an event about the forwarding but set\n // the sender to the forwarder itself\n emit ForwarderDeposited(address(this), value, msg.data);\n }\n\n /**\n * Modifier that will execute internal code block only if the sender is the parent address\n */\n modifier onlyParent {\n require(msg.sender == parentAddress, 'Only Parent');\n _;\n }\n\n /**\n * Modifier that will execute internal code block only if the contract has not been initialized yet\n */\n modifier onlyUninitialized {\n require(parentAddress == address(0x0), 'Already initialized');\n _;\n }\n\n /**\n * Default function; Gets called when data is sent but does not match any other function\n */\n fallback() external payable {\n flush();\n }\n\n /**\n * Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address\n */\n receive() external payable {\n flush();\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush721(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush721 = autoFlush;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function setAutoFlush1155(bool autoFlush)\n external\n virtual\n override\n onlyParent\n {\n autoFlush1155 = autoFlush;\n }\n\n /**\n * ERC721 standard callback function for when a ERC721 is transfered. The forwarder will send the nft\n * to the base wallet once the nft contract invokes this method after transfering the nft.\n *\n * @param _operator The address which called `safeTransferFrom` function\n * @param _from The address of the sender\n * @param _tokenId The token id of the nft\n * @param data Additional data with no specified format, sent in call to `_to`\n */\n function onERC721Received(\n address _operator,\n address _from,\n uint256 _tokenId,\n bytes memory data\n ) external virtual override returns (bytes4) {\n if (autoFlush721) {\n IERC721 instance = IERC721(msg.sender);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The caller does not support the ERC721 interface'\n );\n // this won't work for ERC721 re-entrancy\n instance.safeTransferFrom(address(this), parentAddress, _tokenId, data);\n }\n\n return this.onERC721Received.selector;\n }\n\n function callFromParent(\n address target,\n uint256 value,\n bytes calldata data\n ) external onlyParent returns (bytes memory) {\n (bool success, bytes memory returnedData) = target.call{ value: value }(\n data\n );\n require(success, 'Parent call execution failed');\n\n return returnedData;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155Received(\n address _operator,\n address _from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeTransferFrom(address(this), parentAddress, id, value, data);\n }\n\n return this.onERC1155Received.selector;\n }\n\n /**\n * @inheritdoc IERC1155Receiver\n */\n function onERC1155BatchReceived(\n address _operator,\n address _from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external virtual override returns (bytes4) {\n IERC1155 instance = IERC1155(msg.sender);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n if (autoFlush1155) {\n instance.safeBatchTransferFrom(\n address(this),\n parentAddress,\n ids,\n values,\n data\n );\n }\n\n return this.onERC1155BatchReceived.selector;\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushTokens(address tokenContractAddress)\n external\n virtual\n override\n onlyParent\n {\n ERC20Interface instance = ERC20Interface(tokenContractAddress);\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress);\n if (forwarderBalance == 0) {\n return;\n }\n\n TransferHelper.safeTransfer(\n tokenContractAddress,\n parentAddress,\n forwarderBalance\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC721 instance = IERC721(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC721).interfaceId),\n 'The tokenContractAddress does not support the ERC721 interface'\n );\n\n address ownerAddress = instance.ownerOf(tokenId);\n instance.transferFrom(ownerAddress, parentAddress, tokenId);\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external\n virtual\n override\n onlyParent\n {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256 forwarderBalance = instance.balanceOf(forwarderAddress, tokenId);\n\n instance.safeTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenId,\n forwarderBalance,\n ''\n );\n }\n\n /**\n * @inheritdoc IForwarder\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external virtual override onlyParent {\n IERC1155 instance = IERC1155(tokenContractAddress);\n require(\n instance.supportsInterface(type(IERC1155).interfaceId),\n 'The caller does not support the IERC1155 interface'\n );\n\n address forwarderAddress = address(this);\n uint256[] memory amounts = new uint256[](tokenIds.length);\n for (uint256 i = 0; i < tokenIds.length; i++) {\n amounts[i] = instance.balanceOf(forwarderAddress, tokenIds[i]);\n }\n\n instance.safeBatchTransferFrom(\n forwarderAddress,\n parentAddress,\n tokenIds,\n amounts,\n ''\n );\n }\n\n /**\n * Flush the entire balance of the contract to the parent address.\n */\n function flush() public {\n uint256 value = address(this).balance;\n\n if (value == 0) {\n return;\n }\n\n (bool success, ) = parentAddress.call{ value: value }('');\n require(success, 'Flush failed');\n emit ForwarderDeposited(msg.sender, value, msg.data);\n }\n\n /**\n * @inheritdoc IERC165\n */\n function supportsInterface(bytes4 interfaceId)\n public\n virtual\n override(ERC1155Receiver, IERC165)\n view\n returns (bool)\n {\n return\n interfaceId == type(IForwarder).interfaceId ||\n super.supportsInterface(interfaceId);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155 is IERC165 {\n /**\n * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n */\n event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n /**\n * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n * transfers.\n */\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] values\n );\n\n /**\n * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n * `approved`.\n */\n event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n /**\n * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n *\n * If an {URI} event was emitted for `id`, the standard\n * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n * returned by {IERC1155MetadataURI-uri}.\n */\n event URI(string value, uint256 indexed id);\n\n /**\n * @dev Returns the amount of tokens of token type `id` owned by `account`.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n */\n function balanceOf(address account, uint256 id) external view returns (uint256);\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n *\n * Requirements:\n *\n * - `accounts` and `ids` must have the same length.\n */\n function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)\n external\n view\n returns (uint256[] memory);\n\n /**\n * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n *\n * Emits an {ApprovalForAll} event.\n *\n * Requirements:\n *\n * - `operator` cannot be the caller.\n */\n function setApprovalForAll(address operator, bool approved) external;\n\n /**\n * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n *\n * See {setApprovalForAll}.\n */\n function isApprovedForAll(address account, address operator) external view returns (bool);\n\n /**\n * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n *\n * Emits a {TransferSingle} event.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n * - `from` must have a balance of tokens of type `id` of at least `amount`.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n * acceptance magic value.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) external;\n\n /**\n * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n *\n * Emits a {TransferBatch} event.\n *\n * Requirements:\n *\n * - `ids` and `amounts` must have the same length.\n * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n * acceptance magic value.\n */\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n /**\n * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n */\n event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n */\n event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n /**\n * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n */\n event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n /**\n * @dev Returns the number of tokens in ``owner``'s account.\n */\n function balanceOf(address owner) external view returns (uint256 balance);\n\n /**\n * @dev Returns the owner of the `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function ownerOf(uint256 tokenId) external view returns (address owner);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Transfers `tokenId` token from `from` to `to`.\n *\n * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 tokenId\n ) external;\n\n /**\n * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n * The approval is cleared when the token is transferred.\n *\n * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n *\n * Requirements:\n *\n * - The caller must own the token or be an approved operator.\n * - `tokenId` must exist.\n *\n * Emits an {Approval} event.\n */\n function approve(address to, uint256 tokenId) external;\n\n /**\n * @dev Returns the account approved for `tokenId` token.\n *\n * Requirements:\n *\n * - `tokenId` must exist.\n */\n function getApproved(uint256 tokenId) external view returns (address operator);\n\n /**\n * @dev Approve or remove `operator` as an operator for the caller.\n * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n *\n * Requirements:\n *\n * - The `operator` cannot be the caller.\n *\n * Emits an {ApprovalForAll} event.\n */\n function setApprovalForAll(address operator, bool _approved) external;\n\n /**\n * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n *\n * See {setApprovalForAll}\n */\n function isApprovedForAll(address owner, address operator) external view returns (bool);\n\n /**\n * @dev Safely transfers `tokenId` token from `from` to `to`.\n *\n * Requirements:\n *\n * - `from` cannot be the zero address.\n * - `to` cannot be the zero address.\n * - `tokenId` token must exist and be owned by `from`.\n * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n *\n * Emits a {Transfer} event.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) external;\n}\n"
},
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n *\n * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC1155Receiver.sol\";\nimport \"../../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155Receiver is ERC165, IERC1155Receiver {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n }\n}\n"
},
"contracts/ERC20Interface.sol": {
"content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity 0.8.10;\n\n/**\n * Contract that exposes the needed erc20 token functions\n */\n\nabstract contract ERC20Interface {\n // Send _value amount of tokens to address _to\n function transfer(address _to, uint256 _value)\n public\n virtual\n returns (bool success);\n\n // Get the account balance of another account with address _owner\n function balanceOf(address _owner)\n public\n virtual\n view\n returns (uint256 balance);\n}\n"
},
"contracts/TransferHelper.sol": {
"content": "// SPDX-License-Identifier: GPL-3.0-or-later\n// source: https://github.com/Uniswap/solidity-lib/blob/master/contracts/libraries/TransferHelper.sol\npragma solidity 0.8.10;\n\nimport '@openzeppelin/contracts/utils/Address.sol';\n\n// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false\nlibrary TransferHelper {\n function safeTransfer(\n address token,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transfer(address,uint256)')));\n (bool success, bytes memory data) = token.call(\n abi.encodeWithSelector(0xa9059cbb, to, value)\n );\n require(\n success && (data.length == 0 || abi.decode(data, (bool))),\n 'TransferHelper::safeTransfer: transfer failed'\n );\n }\n\n function safeTransferFrom(\n address token,\n address from,\n address to,\n uint256 value\n ) internal {\n // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));\n (bool success, bytes memory returndata) = token.call(\n abi.encodeWithSelector(0x23b872dd, from, to, value)\n );\n Address.verifyCallResult(\n success,\n returndata,\n 'TransferHelper::transferFrom: transferFrom failed'\n );\n }\n}\n"
},
"contracts/IForwarder.sol": {
"content": "pragma solidity ^0.8.0;\n\nimport '@openzeppelin/contracts/utils/introspection/IERC165.sol';\n\ninterface IForwarder is IERC165 {\n /**\n * Sets the autoflush721 parameter.\n *\n * @param autoFlush whether to autoflush erc721 tokens\n */\n function setAutoFlush721(bool autoFlush) external;\n\n /**\n * Sets the autoflush1155 parameter.\n *\n * @param autoFlush whether to autoflush erc1155 tokens\n */\n function setAutoFlush1155(bool autoFlush) external;\n\n /**\n * Execute a token transfer of the full balance from the forwarder token to the parent address\n *\n * @param tokenContractAddress the address of the erc20 token contract\n */\n function flushTokens(address tokenContractAddress) external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address\n *\n * @param tokenContractAddress the address of the ERC721 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC721Token(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenId The token id of the nft\n */\n function flushERC1155Tokens(address tokenContractAddress, uint256 tokenId)\n external;\n\n /**\n * Execute a batch nft transfer from the forwarder to the parent address.\n *\n * @param tokenContractAddress the address of the ERC1155 NFT contract\n * @param tokenIds The token ids of the nfts\n */\n function batchFlushERC1155Tokens(\n address tokenContractAddress,\n uint256[] calldata tokenIds\n ) external;\n}\n"
},
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n @dev Handles the receipt of a single ERC1155 token type. This function is\n called at the end of a `safeTransferFrom` after the balance has been updated.\n To accept the transfer, this must return\n `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n (i.e. 0xf23a6e61, or its own function selector).\n @param operator The address which initiated the transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param id The ID of the token being transferred\n @param value The amount of tokens being transferred\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n @dev Handles the receipt of a multiple ERC1155 token types. This function\n is called at the end of a `safeBatchTransferFrom` after the balances have\n been updated. To accept the transfer(s), this must return\n `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n (i.e. 0xbc197c81, or its own function selector).\n @param operator The address which initiated the batch transfer (i.e. msg.sender)\n @param from The address which previously owned the token\n @param ids An array containing ids of each token being transferred (order and length must match values array)\n @param values An array containing amounts of each token being transferred (order and length must match ids array)\n @param data Additional data with no specified format\n @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n"
},
"@openzeppelin/contracts/utils/introspection/ERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n /**\n * @dev See {IERC165-supportsInterface}.\n */\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n return interfaceId == type(IERC165).interfaceId;\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize, which returns 0 for contracts in\n // construction, since the code is only stored at the end of the\n // constructor execution.\n\n uint256 size;\n assembly {\n size := extcodesize(account)\n }\n return size > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,498,681 |
54c5c4c1b361772fb65a7a3e1132434ba3c92fcc22f513550ebd7fa4895bd64f
|
70d20b43846f97be1b98f0e1cb7d69bcb4d415b408040b4fc295db5d971c55bb
|
2b26b13dae89a325696816f4ebde7f72c37843b0
|
2b26b13dae89a325696816f4ebde7f72c37843b0
|
4b9485e5a33b86c885578d8cf2c5f2e91bc3930a
|
6080604052670de0b6b3a764000060025566470de4df8200006003556000600460006101000a81548160ff0219169083151502179055507ffdc54b1a6f53a21d375d0dea444a27bd72abfff26c6fe5439842b42f4f5a01fc60001b6007557ffdc54b1a6f53a21d375d0dea84608d84c088017f6661b90cbfa86d27732f6d3e60001b6008557ffdc54b1a6f53a21d375d0dea4b719169497dbac884f858c6cc4034ec1a5c51dc60001b6009557ffdc54b1a6f53a21d375d0dea8781250ad761876ba61389a7bce505c58df449ca60001b600a553480156100de57600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060006101356007546008546101a860201b60201c565b90508073ffffffffffffffffffffffffffffffffffffffff1663e2d73ccd306040518263ffffffff1660e01b815260040161017091906101ca565b600060405180830381600087803b15801561018a57600080fd5b505af115801561019e573d6000803e3d6000fd5b5050505050610217565b60008160001c8360001c18905092915050565b6101c4816101e5565b82525050565b60006020820190506101df60008301846101bb565b92915050565b60006101f0826101f7565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b610637806102266000396000f3fe6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b61461008e5780639763d29b146100a5578063bedf0f4a146100ce578063eaf67ab9146100e5578063f39d8c65146100ef57610060565b3661006057005b600080fd5b34801561007157600080fd5b5061008c6004803603810190610087919061041e565b61011a565b005b34801561009a57600080fd5b506100a3610124565b005b3480156100b157600080fd5b506100cc60048036038101906100c7919061041e565b6101bc565b005b3480156100da57600080fd5b506100e36101c6565b005b6100ed6101e3565b005b3480156100fb57600080fd5b506101046101ed565b60405161011191906104f1565b60405180910390f35b8060068190555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101a9906104d1565b60405180910390fd5b6101ba61023e565b565b8060058190555050565b6000600460006101000a81548160ff021916908315150217905550565b6101eb610315565b565b60008060035460008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1631610235919061051d565b90508091505090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102c3906104d1565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610312573d6000803e3d6000fd5b50565b6000610325600954600a546103f6565b905060006103376007546008546103f6565b90508073ffffffffffffffffffffffffffffffffffffffff1663e26d7a7033846000476040518563ffffffff1660e01b8152600401610379949392919061048c565b600060405180830381600087803b15801561039357600080fd5b505af11580156103a7573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f193505050501580156103f1573d6000803e3d6000fd5b505050565b60008160001c8360001c18905092915050565b600081359050610418816105ea565b92915050565b600060208284031215610434576104336105bc565b5b600061044284828501610409565b91505092915050565b61045481610551565b82525050565b600061046760208361050c565b9150610472826105c1565b602082019050919050565b61048681610583565b82525050565b60006080820190506104a1600083018761044b565b6104ae602083018661044b565b6104bb604083018561044b565b6104c8606083018461047d565b95945050505050565b600060208201905081810360008301526104ea8161045a565b9050919050565b6000602082019050610506600083018461047d565b92915050565b600082825260208201905092915050565b600061052882610583565b915061053383610583565b9250828210156105465761054561058d565b5b828203905092915050565b600061055c82610563565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6105f381610583565b81146105fe57600080fd5b5056fea264697066735822122004d53d25a78251d359bec86569a065c9dfc7da18181d0d85434702c0bb95217564736f6c63430008070033
|
6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b61461008e5780639763d29b146100a5578063bedf0f4a146100ce578063eaf67ab9146100e5578063f39d8c65146100ef57610060565b3661006057005b600080fd5b34801561007157600080fd5b5061008c6004803603810190610087919061041e565b61011a565b005b34801561009a57600080fd5b506100a3610124565b005b3480156100b157600080fd5b506100cc60048036038101906100c7919061041e565b6101bc565b005b3480156100da57600080fd5b506100e36101c6565b005b6100ed6101e3565b005b3480156100fb57600080fd5b506101046101ed565b60405161011191906104f1565b60405180910390f35b8060068190555050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101b2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101a9906104d1565b60405180910390fd5b6101ba61023e565b565b8060058190555050565b6000600460006101000a81548160ff021916908315150217905550565b6101eb610315565b565b60008060035460008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1631610235919061051d565b90508091505090565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146102cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102c3906104d1565b60405180910390fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f19350505050158015610312573d6000803e3d6000fd5b50565b6000610325600954600a546103f6565b905060006103376007546008546103f6565b90508073ffffffffffffffffffffffffffffffffffffffff1663e26d7a7033846000476040518563ffffffff1660e01b8152600401610379949392919061048c565b600060405180830381600087803b15801561039357600080fd5b505af11580156103a7573d6000803e3d6000fd5b505050508173ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f193505050501580156103f1573d6000803e3d6000fd5b505050565b60008160001c8360001c18905092915050565b600081359050610418816105ea565b92915050565b600060208284031215610434576104336105bc565b5b600061044284828501610409565b91505092915050565b61045481610551565b82525050565b600061046760208361050c565b9150610472826105c1565b602082019050919050565b61048681610583565b82525050565b60006080820190506104a1600083018761044b565b6104ae602083018661044b565b6104bb604083018561044b565b6104c8606083018461047d565b95945050505050565b600060208201905081810360008301526104ea8161045a565b9050919050565b6000602082019050610506600083018461047d565b92915050565b600082825260208201905092915050565b600061052882610583565b915061053383610583565b9250828210156105465761054561058d565b5b828203905092915050565b600061055c82610563565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600080fd5b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6105f381610583565b81146105fe57600080fd5b5056fea264697066735822122004d53d25a78251d359bec86569a065c9dfc7da18181d0d85434702c0bb95217564736f6c63430008070033
| |
1 | 19,498,682 |
066b2ba7402c889b88e4df8e284760e04da2218d4de7d48e2a3d2849c1ff0caa
|
3babd836bb06110814c0c59e6b0848adef53e5f9cc91e52a899572573d9226e7
|
000099b4a4d3ceb370d3a8a6235d24e07a8c0000
|
ee2a0343e825b2e5981851299787a679ce08216d
|
7951ff20990c8625c7c9f72df4b1e7a340417d9f
|
6080604052348015600f57600080fd5b506040516101bb3803806101bb833981016040819052602c916059565b600080546001600160a01b039092166001600160a01b031992831617905560018054909116331790556087565b600060208284031215606a57600080fd5b81516001600160a01b0381168114608057600080fd5b9392505050565b610125806100966000396000f3fe6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b14609f578063d4b839921460cd575b6001546001600160a01b03163314604857600080fd5b600080546040516001600160a01b03909116906066908390369060df565b600060405180830381855af49150503d8060008114609d576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60015460b1906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60005460b1906001600160a01b031681565b818382376000910190815291905056fea2646970667358221220736ccf845e951824707af03941a53c8275c6b25991c8ea8d34f6c24f7bbc22e164736f6c6343000819003300000000000000000000000033c99c0323adc0b7bd4ddd2ac4d4de2c28722fb0
|
6080604052348015600f57600080fd5b506004361060325760003560e01c80638da5cb5b14609f578063d4b839921460cd575b6001546001600160a01b03163314604857600080fd5b600080546040516001600160a01b03909116906066908390369060df565b600060405180830381855af49150503d8060008114609d576040519150601f19603f3d011682016040523d82523d6000602084013e005b005b60015460b1906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b60005460b1906001600160a01b031681565b818382376000910190815291905056fea2646970667358221220736ccf845e951824707af03941a53c8275c6b25991c8ea8d34f6c24f7bbc22e164736f6c63430008190033
| |
1 | 19,498,683 |
8822728d752bbeb6b689dc9d42b40cc5b31f6c0b2ffdae14bde880e473b83010
|
e325402a208ba539dcac6c5bf86893962a59d1b8451d84ac86b0d6e6972d4623
|
af0fdd39e5d92499b0ed9f68693da99c0ec1e92e
|
66807b5598a848602734b82e432dd88dbe13fc8f
|
ce6f280ab3cff7b0df965600e3233eac7b980be4
|
3d602d80600a3d3981f3363d3d373d3d3d363d73d6da2a43ded6fc647aa5fb526e96b1f37c24cea85af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73d6da2a43ded6fc647aa5fb526e96b1f37c24cea85af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"/contracts/boosting/StakingProxyRebalancePool.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.10;\n\nimport \"./StakingProxyBase.sol\";\nimport \"../interfaces/IFxnGauge.sol\";\nimport \"../interfaces/IFxUsd.sol\";\nimport \"../interfaces/IFxFacetV2.sol\";\nimport '@openzeppelin/contracts/security/ReentrancyGuard.sol';\n\n/*\nVault implementation for rebalance pool gauges\n\nThis should mostly act like a normal erc20 vault with the exception that\nfxn is not minted directly and is rather passed in via the extra rewards route.\nThus automatic redirect must be turned off and processed locally from the vault.\n*/\ncontract StakingProxyRebalancePool is StakingProxyBase, ReentrancyGuard{\n using SafeERC20 for IERC20;\n\n address public constant fxusd = address(0x085780639CC2cACd35E474e71f4d000e2405d8f6); \n\n constructor(address _poolRegistry, address _feeRegistry, address _fxnminter) \n StakingProxyBase(_poolRegistry, _feeRegistry, _fxnminter){\n }\n\n //vault type\n function vaultType() external pure override returns(VaultType){\n return VaultType.RebalancePool;\n }\n\n //vault version\n function vaultVersion() external pure override returns(uint256){\n return 1;\n }\n\n //initialize vault\n function initialize(address _owner, uint256 _pid) public override{\n super.initialize(_owner, _pid);\n\n //set infinite approval\n IERC20(stakingToken).approve(gaugeAddress, type(uint256).max);\n }\n\n\n //deposit into rebalance pool with ftoken\n function deposit(uint256 _amount) external onlyOwner nonReentrant{\n if(_amount > 0){\n //pull ftokens from user\n IERC20(stakingToken).safeTransferFrom(msg.sender, address(this), _amount);\n\n //stake\n IFxnGauge(gaugeAddress).deposit(_amount, address(this));\n }\n \n //checkpoint rewards\n _checkpointRewards();\n }\n\n //deposit into rebalance pool with fxusd\n function depositFxUsd(uint256 _amount) external onlyOwner nonReentrant{\n if(_amount > 0){\n //pull fxusd from user\n IERC20(fxusd).safeTransferFrom(msg.sender, address(this), _amount);\n\n //stake using fxusd's earn function\n IFxUsd(fxusd).earn(gaugeAddress, _amount, address(this));\n }\n \n //checkpoint rewards\n _checkpointRewards();\n }\n\n //deposit into rebalance pool with base\n function depositBase(uint256 _amount, uint256 _minAmountOut) external onlyOwner nonReentrant{\n if(_amount > 0){\n address _baseToken = IFxnGauge(gaugeAddress).baseToken();\n\n //pull base from user\n IERC20(_baseToken).safeTransferFrom(msg.sender, address(this), _amount);\n\n IERC20(_baseToken).approve(fxusd, _amount);\n //stake using fxusd's earn function\n IFxUsd(fxusd).mintAndEarn(gaugeAddress, _amount, address(this), _minAmountOut);\n\n //return left over\n IERC20(_baseToken).safeTransfer(msg.sender, IERC20(_baseToken).balanceOf(address(this)) );\n }\n \n //checkpoint rewards\n _checkpointRewards();\n }\n\n //withdraw a staked position and return ftoken\n function withdraw(uint256 _amount) external onlyOwner nonReentrant{\n\n //withdraw ftoken directly to owner\n IFxnGauge(gaugeAddress).withdraw(_amount, owner);\n\n //checkpoint rewards\n _checkpointRewards();\n }\n\n //withdraw a staked position and return fxusd\n function withdrawFxUsd(uint256 _amount) external onlyOwner nonReentrant{\n\n //wrap to fxusd and receive at owner(msg.sender)\n IFxUsd(fxusd).wrapFrom(gaugeAddress, _amount, msg.sender);\n\n //checkpoint rewards\n _checkpointRewards();\n }\n\n //withdraw from rebalance pool(v2) and return underlying base\n function withdrawAsBase(uint256 _amount, address _fxfacet, address _fxconverter) external onlyOwner nonReentrant{\n\n //withdraw from rebase pool as underlying\n IFxFacetV2.ConvertOutParams memory params = IFxFacetV2.ConvertOutParams(_fxconverter,0,new uint256[](0));\n IFxFacetV2(_fxfacet).fxRebalancePoolWithdrawAs(params, gaugeAddress, _amount);\n\n //return left over\n address _baseToken = IFxnGauge(gaugeAddress).baseToken();\n IERC20(_baseToken).safeTransfer(msg.sender, IERC20(_baseToken).balanceOf(address(this)) );\n\n //checkpoint rewards\n _checkpointRewards();\n }\n\n //return earned tokens on staking contract and any tokens that are on this vault\n function earned() external override returns (address[] memory token_addresses, uint256[] memory total_earned) {\n //get list of reward tokens\n address[] memory rewardTokens = IFxnGauge(gaugeAddress).getActiveRewardTokens();\n\n //create array of rewards on gauge, rewards on extra reward contract, and fxn that is minted\n address _rewards = rewards;\n token_addresses = new address[](rewardTokens.length + IRewards(_rewards).rewardTokenLength());\n total_earned = new uint256[](rewardTokens.length + IRewards(_rewards).rewardTokenLength());\n\n //simulate claiming\n\n //claim other rewards on gauge to this address to tally\n IFxnGauge(gaugeAddress).claim(address(this),address(this));\n\n //get balance of tokens\n for(uint256 i = 0; i < rewardTokens.length; i++){\n token_addresses[i] = rewardTokens[i];\n if(rewardTokens[i] == fxn){\n //remove boost fee here as boosted fxn is distributed via extra rewards\n total_earned[i] = IERC20(fxn).balanceOf(address(this)) * (FEE_DENOMINATOR - IFeeRegistry(feeRegistry).totalFees()) / FEE_DENOMINATOR;\n }else{\n total_earned[i] = IERC20(rewardTokens[i]).balanceOf(address(this));\n }\n }\n\n //also add an extra rewards from convex's side\n IRewards.EarnedData[] memory extraRewards = IRewards(_rewards).claimableRewards(address(this));\n for(uint256 i = 0; i < extraRewards.length; i++){\n token_addresses[i+rewardTokens.length] = extraRewards[i].token;\n total_earned[i+rewardTokens.length] = extraRewards[i].amount;\n }\n }\n\n /*\n claim flow:\n mint fxn rewards directly to vault\n claim extra rewards directly to the owner\n calculate fees on fxn\n distribute fxn between owner and fee deposit\n */\n function getReward() external override{\n getReward(true);\n }\n\n //get reward with claim option.\n function getReward(bool _claim) public override{\n\n //claim\n if(_claim){\n //extras. rebalance pool will have fxn\n IFxnGauge(gaugeAddress).claim();\n }\n\n //process fxn fees\n _processFxn();\n\n //get list of reward tokens\n address[] memory rewardTokens = IFxnGauge(gaugeAddress).getActiveRewardTokens();\n\n //transfer remaining tokens\n _transferTokens(rewardTokens);\n\n //extra rewards\n _processExtraRewards();\n }\n\n //get reward with claim option, as well as a specific token list to claim from convex extra rewards\n function getReward(bool _claim, address[] calldata _tokenList) external override{\n\n //claim\n if(_claim){\n //extras. rebalance pool will have fxn\n IFxnGauge(gaugeAddress).claim();\n }\n\n //process fxn fees\n _processFxn();\n\n //get list of reward tokens\n address[] memory rewardTokens = IFxnGauge(gaugeAddress).getActiveRewardTokens();\n\n //transfer remaining tokens\n _transferTokens(rewardTokens);\n\n //extra rewards\n _processExtraRewardsFilter(_tokenList);\n }\n\n //return any tokens in vault back to owner\n function transferTokens(address[] calldata _tokenList) external onlyOwner{\n //transfer tokens back to owner\n //fxn and gauge tokens are skipped\n _transferTokens(_tokenList);\n }\n\n\n function _checkExecutable(address _address) internal override{\n super._checkExecutable(_address);\n\n //require shutdown for calls to withdraw role contracts\n if(IFxUsd(gaugeAddress).hasRole(keccak256(\"WITHDRAW_FROM_ROLE\"), _address)){\n (, , , , uint8 shutdown) = IPoolRegistry(poolRegistry).poolInfo(pid);\n require(shutdown == 0,\"!shutdown\");\n }\n }\n}\n"
},
"/contracts/interfaces/IRewards.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.10;\n\ninterface IRewards{\n struct EarnedData {\n address token;\n uint256 amount;\n }\n enum RewardState{\n NotInitialized,\n NoRewards,\n Active\n }\n \n function initialize(uint256 _pid, bool _startActive) external;\n function addReward(address _rewardsToken, address _distributor) external;\n function approveRewardDistributor(\n address _rewardsToken,\n address _distributor,\n bool _approved\n ) external;\n function deposit(address _owner, uint256 _amount) external;\n function withdraw(address _owner, uint256 _amount) external;\n function getReward(address _forward) external;\n function getRewardFilter(address _forward, address[] calldata _tokens) external;\n function notifyRewardAmount(address _rewardsToken, uint256 _reward) external;\n function balanceOf(address account) external view returns (uint256);\n function claimableRewards(address _account) external view returns(EarnedData[] memory userRewards);\n function rewardTokens(uint256 _rid) external view returns (address);\n function rewardTokenLength() external view returns(uint256);\n function rewardState() external view returns(RewardState);\n}"
},
"/contracts/interfaces/IProxyVault.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.10;\n\ninterface IProxyVault {\n\n enum VaultType{\n Erc20Basic,\n RebalancePool\n }\n\n function vaultType() external view returns(VaultType);\n function vaultVersion() external view returns(uint256);\n function initialize(address _owner, uint256 _pid) external;\n function pid() external returns(uint256);\n function usingProxy() external returns(address);\n function owner() external returns(address);\n function gaugeAddress() external returns(address);\n function stakingToken() external returns(address);\n function rewards() external returns(address);\n function getReward() external;\n function getReward(bool _claim) external;\n function getReward(bool _claim, address[] calldata _rewardTokenList) external;\n function earned() external returns (address[] memory token_addresses, uint256[] memory total_earned);\n}"
},
"/contracts/interfaces/IPoolRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.10;\n\ninterface IPoolRegistry {\n function poolLength() external view returns(uint256);\n function poolInfo(uint256 _pid) external view returns(address, address, address, address, uint8);\n function vaultMap(uint256 _pid, address _user) external view returns(address vault);\n function addUserVault(uint256 _pid, address _user) external returns(address vault, address stakeAddress, address stakeToken, address rewards);\n function deactivatePool(uint256 _pid) external;\n function addPool(address _implementation, address _stakingAddress, address _stakingToken) external;\n function setRewardActiveOnCreation(bool _active) external;\n function setRewardImplementation(address _imp) external;\n}"
},
"/contracts/interfaces/IFxnTokenMinter.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// solhint-disable func-name-mixedcase\ninterface IFxnTokenMinter {\n function token() external view returns (address);\n\n function controller() external view returns (address);\n\n function minted(address user, address gauge) external view returns (uint256);\n\n function mint(address gauge_addr) external;\n\n function mint_many(address[8] memory gauges) external;\n\n function mint_for(address gauge, address _for) external;\n\n function toggle_approve_mint(address _user) external;\n}"
},
"/contracts/interfaces/IFxnGauge.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IFxnGauge{\n\n //basics\n function stakingToken() external view returns(address);\n function totalSupply() external view returns(uint256);\n function workingSupply() external view returns(uint256);\n function workingBalanceOf(address _account) external view returns(uint256);\n function deposit(uint256 _amount) external;\n function deposit(uint256 _amount, address _receiver) external;\n function withdraw(uint256 _amount) external;\n function withdraw(uint256 _amount, address _receiver) external;\n function user_checkpoint(address _account) external returns (bool);\n function balanceOf(address _account) external view returns(uint256);\n function integrate_fraction(address account) external view returns (uint256);\n function baseToken() external view returns(address);\n function asset() external view returns(address);\n function market() external view returns(address);\n\n //weight sharing\n function toggleVoteSharing(address _staker) external;\n function acceptSharedVote(address _newOwner) external;\n function rejectSharedVote() external;\n function getStakerVoteOwner(address _account) external view returns (address);\n function numAcceptedStakers(address _account) external view returns (uint256);\n function sharedBalanceOf(address _account) external view returns (uint256);\n function veProxy() external view returns(address);\n\n //rewards\n function rewardData(address _token) external view returns(uint96 queued, uint80 rate, uint40 lastUpdate, uint40 finishAt);\n function getActiveRewardTokens() external view returns (address[] memory _rewardTokens);\n function rewardReceiver(address account) external view returns (address);\n function setRewardReceiver(address _newReceiver) external;\n function claim() external;\n function claim(address account) external;\n function claim(address account, address receiver) external;\n function getBoostRatio(address _account) external view returns (uint256);\n function depositReward(address _token, uint256 _amount) external;\n function voteOwnerBalances(address _account) external view returns(uint112 product, uint104 amount, uint40 updateAt);\n}\n"
},
"/contracts/interfaces/IFxUsd.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IFxUsd{\n\n function wrap(\n address _baseToken,\n uint256 _amount,\n address _receiver\n ) external;\n\n function wrapFrom(\n address _pool,\n uint256 _amount,\n address _receiver\n ) external;\n\n function mint(\n address _baseToken,\n uint256 _amountIn,\n address _receiver,\n uint256 _minOut\n ) external returns (uint256 _amountOut);\n\n\n function earn(\n address _pool,\n uint256 _amount,\n address _receiver\n ) external;\n\n function mintAndEarn(\n address _pool,\n uint256 _amountIn,\n address _receiver,\n uint256 _minOut\n ) external returns (uint256 _amountOut);\n\n function hasRole(bytes32 role, address account) external view returns (bool);\n}\n"
},
"/contracts/interfaces/IFxFacetV2.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\ninterface IFxFacetV2{\n\n struct ConvertOutParams {\n address converter;\n uint256 minOut;\n uint256[] routes;\n }\n\n function fxRebalancePoolWithdraw(address _pool, uint256 _amountIn) external payable returns (uint256 _amountOut);\n function fxRebalancePoolWithdrawAs(\n ConvertOutParams memory _params,\n address _pool,\n uint256 _amountIn\n ) external payable returns (uint256 _amountOut);\n}\n"
},
"/contracts/interfaces/IFeeRegistry.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.10;\n\ninterface IFeeRegistry{\n function cvxfxnIncentive() external view returns(uint256);\n function cvxIncentive() external view returns(uint256);\n function platformIncentive() external view returns(uint256);\n function totalFees() external view returns(uint256);\n function maxFees() external view returns(uint256);\n function feeDeposit() external view returns(address);\n function getFeeDepositor(address _from) external view returns(address);\n}"
},
"/contracts/boosting/StakingProxyBase.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.10;\n\nimport \"../interfaces/IProxyVault.sol\";\nimport \"../interfaces/IFeeRegistry.sol\";\nimport \"../interfaces/IFxnGauge.sol\";\nimport \"../interfaces/IFxnTokenMinter.sol\";\nimport \"../interfaces/IRewards.sol\";\nimport \"../interfaces/IPoolRegistry.sol\";\nimport '@openzeppelin/contracts/token/ERC20/IERC20.sol';\nimport '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';\n\n/*\nBase class for vaults\n\n*/\ncontract StakingProxyBase is IProxyVault{\n using SafeERC20 for IERC20;\n\n address public constant fxn = address(0x365AccFCa291e7D3914637ABf1F7635dB165Bb09);\n address public constant vefxnProxy = address(0xd11a4Ee017cA0BECA8FA45fF2abFe9C6267b7881);\n address public immutable feeRegistry;\n address public immutable poolRegistry;\n address public immutable fxnMinter;\n\n address public owner; //owner of the vault\n address public gaugeAddress; //gauge contract\n address public stakingToken; //staking token\n address public rewards; //extra rewards on convex\n address public usingProxy; //address of proxy being used\n uint256 public pid;\n\n uint256 public constant FEE_DENOMINATOR = 10000;\n\n constructor(address _poolRegistry, address _feeRegistry, address _fxnminter){\n poolRegistry = _poolRegistry;\n feeRegistry = _feeRegistry;\n fxnMinter = _fxnminter;\n }\n\n modifier onlyOwner() {\n require(owner == msg.sender, \"!auth\");\n _;\n }\n\n modifier onlyAdmin() {\n require(vefxnProxy == msg.sender, \"!auth_admin\");\n _;\n }\n\n //vault type\n function vaultType() external virtual pure returns(VaultType){\n return VaultType.Erc20Basic;\n }\n\n //vault version\n function vaultVersion() external virtual pure returns(uint256){\n return 1;\n }\n\n //initialize vault\n function initialize(address _owner, uint256 _pid) public virtual{\n require(owner == address(0),\"already init\");\n owner = _owner;\n pid = _pid;\n\n //get pool info\n (,gaugeAddress, stakingToken, rewards,) = IPoolRegistry(poolRegistry).poolInfo(_pid);\n }\n\n //set what veFXN proxy this vault is using\n function setVeFXNProxy(address _proxy) external virtual onlyAdmin{\n //set the vefxn proxy\n _setVeFXNProxy(_proxy);\n }\n\n //set veFXN proxy the vault is using. call acceptSharedVote to start sharing vefxn proxy's boost\n function _setVeFXNProxy(address _proxyAddress) internal{\n //set proxy address on staking contract\n IFxnGauge(gaugeAddress).acceptSharedVote(_proxyAddress);\n if(_proxyAddress == vefxnProxy){\n //reset back to address 0 to default to convex's proxy, dont write if not needed.\n if(usingProxy != address(0)){\n usingProxy = address(0);\n }\n }else{\n //write non-default proxy address\n usingProxy = _proxyAddress;\n }\n }\n\n //get rewards and earned are type specific. extend in child class\n function getReward() external virtual{}\n function getReward(bool _claim) external virtual{}\n function getReward(bool _claim, address[] calldata _rewardTokenList) external virtual{}\n function earned() external virtual returns (address[] memory token_addresses, uint256[] memory total_earned){}\n\n\n //checkpoint and add/remove weight to convex rewards contract\n function _checkpointRewards() internal{\n //if rewards are active, checkpoint\n address _rewards = rewards;\n if(IRewards(_rewards).rewardState() == IRewards.RewardState.Active){\n //get user balance from the gauge\n uint256 userLiq = IFxnGauge(gaugeAddress).balanceOf(address(this));\n //get current balance of reward contract\n uint256 bal = IRewards(_rewards).balanceOf(address(this));\n if(userLiq >= bal){\n //add the difference to reward contract\n IRewards(_rewards).deposit(owner, userLiq - bal);\n }else{\n //remove the difference from the reward contract\n IRewards(_rewards).withdraw(owner, bal - userLiq);\n }\n }\n }\n\n //apply fees to fxn and send remaining to owner\n function _processFxn() internal{\n\n //get fee rate from fee registry (only need to know total, let deposit contract disperse itself)\n uint256 totalFees = IFeeRegistry(feeRegistry).totalFees();\n\n //send fxn fees to fee deposit\n uint256 fxnBalance = IERC20(fxn).balanceOf(address(this));\n uint256 sendAmount = fxnBalance * totalFees / FEE_DENOMINATOR;\n if(sendAmount > 0){\n //get deposit address for given proxy (address 0 will be handled by fee registry to return default convex proxy)\n IERC20(fxn).transfer(IFeeRegistry(feeRegistry).getFeeDepositor(usingProxy), sendAmount);\n }\n\n //transfer remaining fxn to owner\n sendAmount = IERC20(fxn).balanceOf(address(this));\n if(sendAmount > 0){\n IERC20(fxn).transfer(owner, sendAmount);\n }\n }\n\n //get extra rewards (convex side)\n function _processExtraRewards() internal{\n address _rewards = rewards;\n if(IRewards(_rewards).rewardState() == IRewards.RewardState.Active){\n //update reward balance if this is the first call since reward contract activation:\n //check if no balance recorded yet and set staked balance\n //dont use _checkpointRewards since difference of 0 will still call deposit()\n //as well as it will check rewardState twice\n uint256 bal = IRewards(_rewards).balanceOf(address(this));\n uint256 gaugeBalance = IFxnGauge(gaugeAddress).balanceOf(address(this));\n if(bal == 0 && gaugeBalance > 0){\n //set balance to gauge.balanceof(this)\n IRewards(_rewards).deposit(owner,gaugeBalance);\n }\n\n //get the rewards\n IRewards(_rewards).getReward(owner);\n }\n }\n\n //get extra rewards (convex side) with a filter list\n function _processExtraRewardsFilter(address[] calldata _tokens) internal{\n address _rewards = rewards;\n if(IRewards(_rewards).rewardState() == IRewards.RewardState.Active){\n //update reward balance if this is the first call since reward contract activation:\n //check if no balance recorded yet and set staked balance\n //dont use _checkpointRewards since difference of 0 will still call deposit()\n //as well as it will check rewardState twice\n uint256 bal = IRewards(_rewards).balanceOf(address(this));\n uint256 gaugeBalance = IFxnGauge(gaugeAddress).balanceOf(address(this));\n if(bal == 0 && gaugeBalance > 0){\n //set balance to gauge.balanceof(this)\n IRewards(_rewards).deposit(owner,gaugeBalance);\n }\n\n //get the rewards\n IRewards(_rewards).getRewardFilter(owner,_tokens);\n }\n }\n\n //transfer other reward tokens besides fxn(which needs to have fees applied)\n //also block gauge tokens from being transfered out\n function _transferTokens(address[] memory _tokens) internal{\n //transfer all tokens\n for(uint256 i = 0; i < _tokens.length; i++){\n //dont allow fxn (need to take fee)\n //dont allow gauge token transfer\n if(_tokens[i] != fxn && _tokens[i] != gaugeAddress){\n uint256 bal = IERC20(_tokens[i]).balanceOf(address(this));\n if(bal > 0){\n IERC20(_tokens[i]).safeTransfer(owner, bal);\n }\n }\n }\n }\n\n function _checkExecutable(address _address) internal virtual{\n require(_address != fxn && _address != stakingToken && _address != rewards, \"!invalid target\");\n }\n\n //allow arbitrary calls. some function signatures and targets are blocked\n function execute(\n address _to,\n uint256 _value,\n bytes calldata _data\n ) external onlyOwner returns (bool, bytes memory) {\n //fully block fxn, staking token(lp etc), and rewards\n _checkExecutable(_to);\n\n //only calls to staking(gauge) address if pool is shutdown\n if(_to == gaugeAddress){\n (, , , , uint8 shutdown) = IPoolRegistry(poolRegistry).poolInfo(pid);\n require(shutdown == 0,\"!shutdown\");\n }\n\n (bool success, bytes memory result) = _to.call{value:_value}(_data);\n require(success, \"!success\");\n return (success, result);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20 token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20 token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20 token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n *\n * ==== Security Considerations\n *\n * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature\n * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be\n * considered as an intention to spend the allowance in any specific way. The second is that because permits have\n * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should\n * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be\n * generally recommended is:\n *\n * ```solidity\n * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {\n * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}\n * doThing(..., value);\n * }\n *\n * function doThing(..., uint256 value) public {\n * token.safeTransferFrom(msg.sender, address(this), value);\n * ...\n * }\n * ```\n *\n * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of\n * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also\n * {SafeERC20-safeTransferFrom}).\n *\n * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so\n * contracts should have entry points that don't rely on permit.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n *\n * CAUTION: See Security Considerations above.\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/security/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be _NOT_ENTERED\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == _ENTERED;\n }\n}\n"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "london",
"libraries": {},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,498,691 |
95af5ad6504c295d106ac29e03c808805276f5b5587cab082c0e476d7ffeaf92
|
5943213300f653e6d8c52f1c14a5ad901574e2f52ab334b7989573079040c27c
|
4e565f63257d90f988e5ec9d065bab00f94d2dfd
|
9fa5c5733b53814692de4fb31fd592070de5f5f0
|
6aef89afffa13c76d6e5bffb191f0b6b3bb762b2
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,498,692 |
d221e0a4511f88b01aac96b786876858535e1a6b28acf6376ca964e85dd5b459
|
1a60cd44c8deaec2c9b1a56953232765b37e47e7ca23b918a4247f82f778665e
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
ce182599eb66d438da1a7992e4e2cf858d4efbeb
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,694 |
0e67e0783a8eee7bd4389953891465d22bc87095adff8280b6bdb26a743b3401
|
f3a2ba38ed685ed5273ce458264c53a4ac09ee6a61e67c75584be9a5999f839d
|
a7fb5ca286fc3fd67525629048a4de3ba24cba2e
|
c77ad0a71008d7094a62cfbd250a2eb2afdf2776
|
f275f7e10e8b1ddd006b79da2220a4c281781d0c
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,498,694 |
0e67e0783a8eee7bd4389953891465d22bc87095adff8280b6bdb26a743b3401
|
99c3fc5bceaec0f9a359de9a0feeac52758e0c48995c0aa7a838b076a16b0b05
|
fd851f0a5f15646f4ee7076dcfca62ae7f7de4d8
|
fd851f0a5f15646f4ee7076dcfca62ae7f7de4d8
|
5e013d0ef53b049997430c98cce455cec9f529da
|
6080604052670de0b6b3a764000060025566b1a2bc2ec500006003556004805460ff191690557f4c10f6e185a551b454e342e9309ae741455e7f4cda66f4ad2ed1a994d0e86f886007557f4c10f6e185a551b454e342e9558fc33d0edd0a3dc85a9aa98bcd41d2f31c848c6008557f4c10f6e185a551b454e342e9a7f9650ff343653db6df453da9f71b7ed5a3c6e460095534801561009d57600080fd5b50600080546001600160a01b031916331781556007546008546100be911890565b60405163e2d73ccd60e01b81523060048201529091506001600160a01b0382169063e2d73ccd90602401600060405180830381600087803b15801561010257600080fd5b505af1158015610116573d6000803e3d6000fd5b50505050506103678061012a6000396000f3fe6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212203a61be38465b9d221c4a7c0496ea35507efb7901b040f718971264eb39b76af964736f6c63430008070033
|
6080604052600436106100595760003560e01c80632b42b9411461006557806357ea89b6146100875780639763d29b1461009c578063bedf0f4a146100bc578063eaf67ab9146100d8578063f39d8c65146100e057600080fd5b3661006057005b600080fd5b34801561007157600080fd5b506100856100803660046102f3565b600655565b005b34801561009357600080fd5b50610085610107565b3480156100a857600080fd5b506100856100b73660046102f3565b600555565b3480156100c857600080fd5b506100856004805460ff19169055565b610085610170565b3480156100ec57600080fd5b506100f5610178565b60405190815260200160405180910390f35b6000546001600160a01b031633146101665760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064015b60405180910390fd5b61016e61019d565b565b61016e610226565b600354600080549091829161019791906001600160a01b03163161030c565b92915050565b6000546001600160a01b031633146101f75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161015d565b60405133904780156108fc02916000818181858888f19350505050158015610223573d6000803e3d6000fd5b50565b60006102356008546009541890565b905060006102466007546008541890565b604051630e26d7a760e41b81523360048201526001600160a01b038481166024830152600060448301524760648301529192509082169063e26d7a7090608401600060405180830381600087803b1580156102a057600080fd5b505af11580156102b4573d6000803e3d6000fd5b50506040516001600160a01b03851692504780156108fc029250906000818181858888f193505050501580156102ee573d6000803e3d6000fd5b505050565b60006020828403121561030557600080fd5b5035919050565b60008282101561032c57634e487b7160e01b600052601160045260246000fd5b50039056fea26469706673582212203a61be38465b9d221c4a7c0496ea35507efb7901b040f718971264eb39b76af964736f6c63430008070033
| |
1 | 19,498,694 |
0e67e0783a8eee7bd4389953891465d22bc87095adff8280b6bdb26a743b3401
|
c3b1a53063715d9ddf1e479f0cddc747284fd17efe123cff073c4f0c665829a0
|
f4862233955b4f41b616da5f5eca67f784bde726
|
f4862233955b4f41b616da5f5eca67f784bde726
|
1d98558586566d79f42b1817ff3ae7d8e3a8a965
|
608060405234801561000f575f80fd5b50604051611c02380380611c02833981810160405281019061003191906102a7565b336040518060400160405280600881526020017f466f7265736b696e0000000000000000000000000000000000000000000000008152506040518060400160405280600481526020017f534b494e0000000000000000000000000000000000000000000000000000000081525081600390816100ad919061050c565b5080600490816100bd919061050c565b5050505f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610130575f6040517f1e4fbdf700000000000000000000000000000000000000000000000000000000815260040161012791906105ea565b60405180910390fd5b61013f8161018660201b60201c565b508060065f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610603565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6102768261024d565b9050919050565b6102868161026c565b8114610290575f80fd5b50565b5f815190506102a18161027d565b92915050565b5f602082840312156102bc576102bb610249565b5b5f6102c984828501610293565b91505092915050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061034d57607f821691505b6020821081036103605761035f610309565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026103c27fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82610387565b6103cc8683610387565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61041061040b610406846103e4565b6103ed565b6103e4565b9050919050565b5f819050919050565b610429836103f6565b61043d61043582610417565b848454610393565b825550505050565b5f90565b610451610445565b61045c818484610420565b505050565b5b8181101561047f576104745f82610449565b600181019050610462565b5050565b601f8211156104c45761049581610366565b61049e84610378565b810160208510156104ad578190505b6104c16104b985610378565b830182610461565b50505b505050565b5f82821c905092915050565b5f6104e45f19846008026104c9565b1980831691505092915050565b5f6104fc83836104d5565b9150826002028217905092915050565b610515826102d2565b67ffffffffffffffff81111561052e5761052d6102dc565b5b6105388254610336565b610543828285610483565b5f60209050601f831160018114610574575f8415610562578287015190505b61056c85826104f1565b8655506105d3565b601f19841661058286610366565b5f5b828110156105a957848901518255600182019150602085019450602081019050610584565b868310156105c657848901516105c2601f8916826104d5565b8355505b6001600288020188555050505b505050505050565b6105e48161026c565b82525050565b5f6020820190506105fd5f8301846105db565b92915050565b6115f2806106105f395ff3fe608060405234801561000f575f80fd5b5060043610610109575f3560e01c806347a1f162116100a057806395d89b411161006f57806395d89b4114610293578063a9059cbb146102b1578063dd62ed3e146102e1578063f2fde38b14610311578063fca3b5aa1461032d57610109565b806347a1f1621461021d57806370a082311461023b578063715018a61461026b5780638da5cb5b1461027557610109565b806323b872dd116100dc57806323b872dd14610197578063313ce567146101c757806340c10f19146101e557806342966c681461020157610109565b806306fdde031461010d578063075461721461012b578063095ea7b31461014957806318160ddd14610179575b5f80fd5b610115610349565b6040516101229190611075565b60405180910390f35b6101336103d9565b60405161014091906110d4565b60405180910390f35b610163600480360381019061015e919061114e565b6103fe565b60405161017091906111a6565b60405180910390f35b610181610420565b60405161018e91906111ce565b60405180910390f35b6101b160048036038101906101ac91906111e7565b610429565b6040516101be91906111a6565b60405180910390f35b6101cf610457565b6040516101dc9190611252565b60405180910390f35b6101ff60048036038101906101fa919061114e565b61045f565b005b61021b6004803603810190610216919061126b565b610559565b005b6102256105b1565b60405161023291906111ce565b60405180910390f35b61025560048036038101906102509190611296565b6105b7565b60405161026291906111ce565b60405180910390f35b6102736105fc565b005b61027d61060f565b60405161028a91906110d4565b60405180910390f35b61029b610637565b6040516102a89190611075565b60405180910390f35b6102cb60048036038101906102c6919061114e565b6106c7565b6040516102d891906111a6565b60405180910390f35b6102fb60048036038101906102f691906112c1565b6106e9565b60405161030891906111ce565b60405180910390f35b61032b60048036038101906103269190611296565b61076b565b005b61034760048036038101906103429190611296565b6107ef565b005b6060600380546103589061132c565b80601f01602080910402602001604051908101604052809291908181526020018280546103849061132c565b80156103cf5780601f106103a6576101008083540402835291602001916103cf565b820191905f5260205f20905b8154815290600101906020018083116103b257829003601f168201915b5050505050905090565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f8061040861083a565b9050610415818585610841565b600191505092915050565b5f600254905090565b5f8061043361083a565b9050610440858285610853565b61044b8585856108e5565b60019150509392505050565b5f6012905090565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104e5906113cc565b60405180910390fd5b61177060075410610534576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161052b90611434565b60405180910390fd5b61053e82826109d5565b60075f8154809291906105509061147f565b91905055505050565b80610563336105b7565b10156105a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90611536565b60405180910390fd5b6105ae3382610a54565b50565b60075481565b5f805f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b610604610ad3565b61060d5f610b5a565b565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546106469061132c565b80601f01602080910402602001604051908101604052809291908181526020018280546106729061132c565b80156106bd5780601f10610694576101008083540402835291602001916106bd565b820191905f5260205f20905b8154815290600101906020018083116106a057829003601f168201915b5050505050905090565b5f806106d161083a565b90506106de8185856108e5565b600191505092915050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b610773610ad3565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036107e3575f6040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016107da91906110d4565b60405180910390fd5b6107ec81610b5a565b50565b6107f7610ad3565b8060065f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f33905090565b61084e8383836001610c1d565b505050565b5f61085e84846106e9565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146108df57818110156108d0578281836040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526004016108c793929190611554565b60405180910390fd5b6108de84848484035f610c1d565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610955575f6040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260040161094c91906110d4565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036109c5575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016109bc91906110d4565b60405180910390fd5b6109d0838383610dec565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a45575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401610a3c91906110d4565b60405180910390fd5b610a505f8383610dec565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610ac4575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401610abb91906110d4565b60405180910390fd5b610acf825f83610dec565b5050565b610adb61083a565b73ffffffffffffffffffffffffffffffffffffffff16610af961060f565b73ffffffffffffffffffffffffffffffffffffffff1614610b5857610b1c61083a565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610b4f91906110d4565b60405180910390fd5b565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610c8d575f6040517fe602df05000000000000000000000000000000000000000000000000000000008152600401610c8491906110d4565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610cfd575f6040517f94280d62000000000000000000000000000000000000000000000000000000008152600401610cf491906110d4565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508015610de6578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610ddd91906111ce565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610e3c578060025f828254610e309190611589565b92505081905550610f0a565b5f805f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015610ec5578381836040517fe450d38c000000000000000000000000000000000000000000000000000000008152600401610ebc93929190611554565b60405180910390fd5b8181035f808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610f51578060025f8282540392505081905550610f9b565b805f808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610ff891906111ce565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f61104782611005565b611051818561100f565b935061106181856020860161101f565b61106a8161102d565b840191505092915050565b5f6020820190508181035f83015261108d818461103d565b905092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6110be82611095565b9050919050565b6110ce816110b4565b82525050565b5f6020820190506110e75f8301846110c5565b92915050565b5f80fd5b6110fa816110b4565b8114611104575f80fd5b50565b5f81359050611115816110f1565b92915050565b5f819050919050565b61112d8161111b565b8114611137575f80fd5b50565b5f8135905061114881611124565b92915050565b5f8060408385031215611164576111636110ed565b5b5f61117185828601611107565b92505060206111828582860161113a565b9150509250929050565b5f8115159050919050565b6111a08161118c565b82525050565b5f6020820190506111b95f830184611197565b92915050565b6111c88161111b565b82525050565b5f6020820190506111e15f8301846111bf565b92915050565b5f805f606084860312156111fe576111fd6110ed565b5b5f61120b86828701611107565b935050602061121c86828701611107565b925050604061122d8682870161113a565b9150509250925092565b5f60ff82169050919050565b61124c81611237565b82525050565b5f6020820190506112655f830184611243565b92915050565b5f602082840312156112805761127f6110ed565b5b5f61128d8482850161113a565b91505092915050565b5f602082840312156112ab576112aa6110ed565b5b5f6112b884828501611107565b91505092915050565b5f80604083850312156112d7576112d66110ed565b5b5f6112e485828601611107565b92505060206112f585828601611107565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061134357607f821691505b602082108103611356576113556112ff565b5b50919050565b7f4f6e6c7920616c6c6f776564206d696e7465722063616e2063616c6c207468695f8201527f732066756e6374696f6e00000000000000000000000000000000000000000000602082015250565b5f6113b6602a8361100f565b91506113c18261135c565b604082019050919050565b5f6020820190508181035f8301526113e3816113aa565b9050919050565b7f736b696e20746f6b656e20737570706c792069732036303030210000000000005f82015250565b5f61141e601a8361100f565b9150611429826113ea565b602082019050919050565b5f6020820190508181035f83015261144b81611412565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6114898261111b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036114bb576114ba611452565b5b600182019050919050565b7f596f7520646f206e6f74206861766520656e6f7567682062616c616e636520745f8201527f6f206275726e0000000000000000000000000000000000000000000000000000602082015250565b5f61152060268361100f565b915061152b826114c6565b604082019050919050565b5f6020820190508181035f83015261154d81611514565b9050919050565b5f6060820190506115675f8301866110c5565b61157460208301856111bf565b61158160408301846111bf565b949350505050565b5f6115938261111b565b915061159e8361111b565b92508282019050808211156115b6576115b5611452565b5b9291505056fea264697066735822122074cf0aea9da3f2911539ba968536a85a7a65e7f57e4bb0ce02db49dba4a9ee3c64736f6c63430008190033000000000000000000000000e9959c7a1cf7891cac0be4b2c835e723db68a474
|
608060405234801561000f575f80fd5b5060043610610109575f3560e01c806347a1f162116100a057806395d89b411161006f57806395d89b4114610293578063a9059cbb146102b1578063dd62ed3e146102e1578063f2fde38b14610311578063fca3b5aa1461032d57610109565b806347a1f1621461021d57806370a082311461023b578063715018a61461026b5780638da5cb5b1461027557610109565b806323b872dd116100dc57806323b872dd14610197578063313ce567146101c757806340c10f19146101e557806342966c681461020157610109565b806306fdde031461010d578063075461721461012b578063095ea7b31461014957806318160ddd14610179575b5f80fd5b610115610349565b6040516101229190611075565b60405180910390f35b6101336103d9565b60405161014091906110d4565b60405180910390f35b610163600480360381019061015e919061114e565b6103fe565b60405161017091906111a6565b60405180910390f35b610181610420565b60405161018e91906111ce565b60405180910390f35b6101b160048036038101906101ac91906111e7565b610429565b6040516101be91906111a6565b60405180910390f35b6101cf610457565b6040516101dc9190611252565b60405180910390f35b6101ff60048036038101906101fa919061114e565b61045f565b005b61021b6004803603810190610216919061126b565b610559565b005b6102256105b1565b60405161023291906111ce565b60405180910390f35b61025560048036038101906102509190611296565b6105b7565b60405161026291906111ce565b60405180910390f35b6102736105fc565b005b61027d61060f565b60405161028a91906110d4565b60405180910390f35b61029b610637565b6040516102a89190611075565b60405180910390f35b6102cb60048036038101906102c6919061114e565b6106c7565b6040516102d891906111a6565b60405180910390f35b6102fb60048036038101906102f691906112c1565b6106e9565b60405161030891906111ce565b60405180910390f35b61032b60048036038101906103269190611296565b61076b565b005b61034760048036038101906103429190611296565b6107ef565b005b6060600380546103589061132c565b80601f01602080910402602001604051908101604052809291908181526020018280546103849061132c565b80156103cf5780601f106103a6576101008083540402835291602001916103cf565b820191905f5260205f20905b8154815290600101906020018083116103b257829003601f168201915b5050505050905090565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f8061040861083a565b9050610415818585610841565b600191505092915050565b5f600254905090565b5f8061043361083a565b9050610440858285610853565b61044b8585856108e5565b60019150509392505050565b5f6012905090565b60065f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146104ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104e5906113cc565b60405180910390fd5b61177060075410610534576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161052b90611434565b60405180910390fd5b61053e82826109d5565b60075f8154809291906105509061147f565b91905055505050565b80610563336105b7565b10156105a4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059b90611536565b60405180910390fd5b6105ae3382610a54565b50565b60075481565b5f805f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20549050919050565b610604610ad3565b61060d5f610b5a565b565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6060600480546106469061132c565b80601f01602080910402602001604051908101604052809291908181526020018280546106729061132c565b80156106bd5780601f10610694576101008083540402835291602001916106bd565b820191905f5260205f20905b8154815290600101906020018083116106a057829003601f168201915b5050505050905090565b5f806106d161083a565b90506106de8185856108e5565b600191505092915050565b5f60015f8473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905092915050565b610773610ad3565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16036107e3575f6040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081526004016107da91906110d4565b60405180910390fd5b6107ec81610b5a565b50565b6107f7610ad3565b8060065f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f33905090565b61084e8383836001610c1d565b505050565b5f61085e84846106e9565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146108df57818110156108d0578281836040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526004016108c793929190611554565b60405180910390fd5b6108de84848484035f610c1d565b5b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610955575f6040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260040161094c91906110d4565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036109c5575f6040517fec442f050000000000000000000000000000000000000000000000000000000081526004016109bc91906110d4565b60405180910390fd5b6109d0838383610dec565b505050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a45575f6040517fec442f05000000000000000000000000000000000000000000000000000000008152600401610a3c91906110d4565b60405180910390fd5b610a505f8383610dec565b5050565b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610ac4575f6040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600401610abb91906110d4565b60405180910390fd5b610acf825f83610dec565b5050565b610adb61083a565b73ffffffffffffffffffffffffffffffffffffffff16610af961060f565b73ffffffffffffffffffffffffffffffffffffffff1614610b5857610b1c61083a565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610b4f91906110d4565b60405180910390fd5b565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508160055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b5f73ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1603610c8d575f6040517fe602df05000000000000000000000000000000000000000000000000000000008152600401610c8491906110d4565b60405180910390fd5b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610cfd575f6040517f94280d62000000000000000000000000000000000000000000000000000000008152600401610cf491906110d4565b60405180910390fd5b8160015f8673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20819055508015610de6578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610ddd91906111ce565b60405180910390a35b50505050565b5f73ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610e3c578060025f828254610e309190611589565b92505081905550610f0a565b5f805f8573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2054905081811015610ec5578381836040517fe450d38c000000000000000000000000000000000000000000000000000000008152600401610ebc93929190611554565b60405180910390fd5b8181035f808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2081905550505b5f73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610f51578060025f8282540392505081905550610f9b565b805f808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f82825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610ff891906111ce565b60405180910390a3505050565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f61104782611005565b611051818561100f565b935061106181856020860161101f565b61106a8161102d565b840191505092915050565b5f6020820190508181035f83015261108d818461103d565b905092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6110be82611095565b9050919050565b6110ce816110b4565b82525050565b5f6020820190506110e75f8301846110c5565b92915050565b5f80fd5b6110fa816110b4565b8114611104575f80fd5b50565b5f81359050611115816110f1565b92915050565b5f819050919050565b61112d8161111b565b8114611137575f80fd5b50565b5f8135905061114881611124565b92915050565b5f8060408385031215611164576111636110ed565b5b5f61117185828601611107565b92505060206111828582860161113a565b9150509250929050565b5f8115159050919050565b6111a08161118c565b82525050565b5f6020820190506111b95f830184611197565b92915050565b6111c88161111b565b82525050565b5f6020820190506111e15f8301846111bf565b92915050565b5f805f606084860312156111fe576111fd6110ed565b5b5f61120b86828701611107565b935050602061121c86828701611107565b925050604061122d8682870161113a565b9150509250925092565b5f60ff82169050919050565b61124c81611237565b82525050565b5f6020820190506112655f830184611243565b92915050565b5f602082840312156112805761127f6110ed565b5b5f61128d8482850161113a565b91505092915050565b5f602082840312156112ab576112aa6110ed565b5b5f6112b884828501611107565b91505092915050565b5f80604083850312156112d7576112d66110ed565b5b5f6112e485828601611107565b92505060206112f585828601611107565b9150509250929050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061134357607f821691505b602082108103611356576113556112ff565b5b50919050565b7f4f6e6c7920616c6c6f776564206d696e7465722063616e2063616c6c207468695f8201527f732066756e6374696f6e00000000000000000000000000000000000000000000602082015250565b5f6113b6602a8361100f565b91506113c18261135c565b604082019050919050565b5f6020820190508181035f8301526113e3816113aa565b9050919050565b7f736b696e20746f6b656e20737570706c792069732036303030210000000000005f82015250565b5f61141e601a8361100f565b9150611429826113ea565b602082019050919050565b5f6020820190508181035f83015261144b81611412565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6114898261111b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036114bb576114ba611452565b5b600182019050919050565b7f596f7520646f206e6f74206861766520656e6f7567682062616c616e636520745f8201527f6f206275726e0000000000000000000000000000000000000000000000000000602082015250565b5f61152060268361100f565b915061152b826114c6565b604082019050919050565b5f6020820190508181035f83015261154d81611514565b9050919050565b5f6060820190506115675f8301866110c5565b61157460208301856111bf565b61158160408301846111bf565b949350505050565b5f6115938261111b565b915061159e8361111b565b92508282019050808211156115b6576115b5611452565b5b9291505056fea264697066735822122074cf0aea9da3f2911539ba968536a85a7a65e7f57e4bb0ce02db49dba4a9ee3c64736f6c63430008190033
|
{{
"language": "Solidity",
"sources": {
"contracts/SKIN.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract Skin is ERC20, Ownable {\n address public minter;\n uint256 public supplyCnt;\n modifier onlyMinter() {\n require(msg.sender == minter, \"Only allowed minter can call this function\");\n _;\n }\n\n constructor(address _minter) ERC20(\"Foreskin\", \"SKIN\") Ownable(msg.sender) {\n minter = _minter;\n \n }\n\n function setMinter(address _minter) external onlyOwner {\n minter = _minter;\n }\n\n function burn(uint256 _amount) external {\n require(\n balanceOf(msg.sender) >= _amount,\n \"You do not have enough balance to burn\"\n );\n _burn(msg.sender, _amount);\n }\n\n function mint(address to, uint256 _amount) external onlyMinter{\n require(supplyCnt < 6000, \"skin token supply is 6000!\");\n _mint(to, _amount);\n supplyCnt ++;\n }\n}\n"
},
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"./IERC20.sol\";\nimport {IERC20Metadata} from \"./extensions/IERC20Metadata.sol\";\nimport {Context} from \"../../utils/Context.sol\";\nimport {IERC20Errors} from \"../../interfaces/draft-IERC6093.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n */\nabstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {\n mapping(address account => uint256) private _balances;\n\n mapping(address account => mapping(address spender => uint256)) private _allowances;\n\n uint256 private _totalSupply;\n\n string private _name;\n string private _symbol;\n\n /**\n * @dev Sets the values for {name} and {symbol}.\n *\n * All two of these values are immutable: they can only be set once during\n * construction.\n */\n constructor(string memory name_, string memory symbol_) {\n _name = name_;\n _symbol = symbol_;\n }\n\n /**\n * @dev Returns the name of the token.\n */\n function name() public view virtual returns (string memory) {\n return _name;\n }\n\n /**\n * @dev Returns the symbol of the token, usually a shorter version of the\n * name.\n */\n function symbol() public view virtual returns (string memory) {\n return _symbol;\n }\n\n /**\n * @dev Returns the number of decimals used to get its user representation.\n * For example, if `decimals` equals `2`, a balance of `505` tokens should\n * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n *\n * Tokens usually opt for a value of 18, imitating the relationship between\n * Ether and Wei. This is the default value returned by this function, unless\n * it's overridden.\n *\n * NOTE: This information is only used for _display_ purposes: it in\n * no way affects any of the arithmetic of the contract, including\n * {IERC20-balanceOf} and {IERC20-transfer}.\n */\n function decimals() public view virtual returns (uint8) {\n return 18;\n }\n\n /**\n * @dev See {IERC20-totalSupply}.\n */\n function totalSupply() public view virtual returns (uint256) {\n return _totalSupply;\n }\n\n /**\n * @dev See {IERC20-balanceOf}.\n */\n function balanceOf(address account) public view virtual returns (uint256) {\n return _balances[account];\n }\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n * - the caller must have a balance of at least `value`.\n */\n function transfer(address to, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _transfer(owner, to, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-allowance}.\n */\n function allowance(address owner, address spender) public view virtual returns (uint256) {\n return _allowances[owner][spender];\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 value) public virtual returns (bool) {\n address owner = _msgSender();\n _approve(owner, spender, value);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * NOTE: Does not update the allowance if the current allowance\n * is the maximum `uint256`.\n *\n * Requirements:\n *\n * - `from` and `to` cannot be the zero address.\n * - `from` must have a balance of at least `value`.\n * - the caller must have allowance for ``from``'s tokens of at least\n * `value`.\n */\n function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {\n address spender = _msgSender();\n _spendAllowance(from, spender, value);\n _transfer(from, to, value);\n return true;\n }\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to`.\n *\n * This internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _transfer(address from, address to, uint256 value) internal {\n if (from == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n if (to == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(from, to, value);\n }\n\n /**\n * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`\n * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding\n * this function.\n *\n * Emits a {Transfer} event.\n */\n function _update(address from, address to, uint256 value) internal virtual {\n if (from == address(0)) {\n // Overflow check required: The rest of the code assumes that totalSupply never overflows\n _totalSupply += value;\n } else {\n uint256 fromBalance = _balances[from];\n if (fromBalance < value) {\n revert ERC20InsufficientBalance(from, fromBalance, value);\n }\n unchecked {\n // Overflow not possible: value <= fromBalance <= totalSupply.\n _balances[from] = fromBalance - value;\n }\n }\n\n if (to == address(0)) {\n unchecked {\n // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.\n _totalSupply -= value;\n }\n } else {\n unchecked {\n // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.\n _balances[to] += value;\n }\n }\n\n emit Transfer(from, to, value);\n }\n\n /**\n * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).\n * Relies on the `_update` mechanism\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead.\n */\n function _mint(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidReceiver(address(0));\n }\n _update(address(0), account, value);\n }\n\n /**\n * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.\n * Relies on the `_update` mechanism.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * NOTE: This function is not virtual, {_update} should be overridden instead\n */\n function _burn(address account, uint256 value) internal {\n if (account == address(0)) {\n revert ERC20InvalidSender(address(0));\n }\n _update(account, address(0), value);\n }\n\n /**\n * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n *\n * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.\n */\n function _approve(address owner, address spender, uint256 value) internal {\n _approve(owner, spender, value, true);\n }\n\n /**\n * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.\n *\n * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by\n * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any\n * `Approval` event during `transferFrom` operations.\n *\n * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to\n * true using the following override:\n * ```\n * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {\n * super._approve(owner, spender, value, true);\n * }\n * ```\n *\n * Requirements are the same as {_approve}.\n */\n function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {\n if (owner == address(0)) {\n revert ERC20InvalidApprover(address(0));\n }\n if (spender == address(0)) {\n revert ERC20InvalidSpender(address(0));\n }\n _allowances[owner][spender] = value;\n if (emitEvent) {\n emit Approval(owner, spender, value);\n }\n }\n\n /**\n * @dev Updates `owner` s allowance for `spender` based on spent `value`.\n *\n * Does not update the allowance value in case of infinite allowance.\n * Revert if not enough allowance is available.\n *\n * Does not emit an {Approval} event.\n */\n function _spendAllowance(address owner, address spender, uint256 value) internal virtual {\n uint256 currentAllowance = allowance(owner, spender);\n if (currentAllowance != type(uint256).max) {\n if (currentAllowance < value) {\n revert ERC20InsufficientAllowance(spender, currentAllowance, value);\n }\n unchecked {\n _approve(owner, spender, currentAllowance - value, false);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/interfaces/draft-IERC6093.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard ERC20 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.\n */\ninterface IERC20Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC20InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC20InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n * @param allowance Amount of tokens a `spender` is allowed to operate with.\n * @param needed Minimum amount required to perform a transfer.\n */\n error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC20InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `spender` to be approved. Used in approvals.\n * @param spender Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC20InvalidSpender(address spender);\n}\n\n/**\n * @dev Standard ERC721 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.\n */\ninterface IERC721Errors {\n /**\n * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.\n * Used in balance queries.\n * @param owner Address of the current owner of a token.\n */\n error ERC721InvalidOwner(address owner);\n\n /**\n * @dev Indicates a `tokenId` whose `owner` is the zero address.\n * @param tokenId Identifier number of a token.\n */\n error ERC721NonexistentToken(uint256 tokenId);\n\n /**\n * @dev Indicates an error related to the ownership over a particular token. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param tokenId Identifier number of a token.\n * @param owner Address of the current owner of a token.\n */\n error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC721InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC721InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param tokenId Identifier number of a token.\n */\n error ERC721InsufficientApproval(address operator, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC721InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC721InvalidOperator(address operator);\n}\n\n/**\n * @dev Standard ERC1155 Errors\n * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.\n */\ninterface IERC1155Errors {\n /**\n * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n * @param balance Current balance for the interacting account.\n * @param needed Minimum amount required to perform a transfer.\n * @param tokenId Identifier number of a token.\n */\n error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);\n\n /**\n * @dev Indicates a failure with the token `sender`. Used in transfers.\n * @param sender Address whose tokens are being transferred.\n */\n error ERC1155InvalidSender(address sender);\n\n /**\n * @dev Indicates a failure with the token `receiver`. Used in transfers.\n * @param receiver Address to which tokens are being transferred.\n */\n error ERC1155InvalidReceiver(address receiver);\n\n /**\n * @dev Indicates a failure with the `operator`’s approval. Used in transfers.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n * @param owner Address of the current owner of a token.\n */\n error ERC1155MissingApprovalForAll(address operator, address owner);\n\n /**\n * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.\n * @param approver Address initiating an approval operation.\n */\n error ERC1155InvalidApprover(address approver);\n\n /**\n * @dev Indicates a failure with the `operator` to be approved. Used in approvals.\n * @param operator Address that may be allowed to operate on tokens without being their owner.\n */\n error ERC1155InvalidOperator(address operator);\n\n /**\n * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.\n * Used in batch transfers.\n * @param idsLength Length of the array of token identifiers\n * @param valuesLength Length of the array of token amounts\n */\n error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC20} from \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the value of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the value of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves a `value` amount of tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 value) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\n * caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 value) external returns (bool);\n\n /**\n * @dev Moves a `value` amount of tokens from `from` to `to` using the\n * allowance mechanism. `value` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 value) external returns (bool);\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
|
1 | 19,498,696 |
57018b4a1b01a4698ba7f97a6955ca38e644a9e9bdc3166c59168a321ccea535
|
38ded9e5506a7706aaadee5ed7f98e54126944b2c8bc79ba0f271a6fe7f36410
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
15b72a9a138ca25cb09b18191141e71de5f5af1c
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,705 |
cd7500cbb5be78beaf1dc6e6f71a6fbe0e890aef423d952f3b56827936bb997b
|
2987e65024abc85e5c96c056b5680971b78b085a0ec9aaf6e969dfd4e9482845
|
91cf7c7b15e1efcde3ce7c6c5ef5a394182fe5eb
|
b5fb4be02232b1bba4dc8f81dc24c26980de9e3c
|
61fac7277b5041ee031a7abeff012ead2ff833bb
|
608060405234801561001057600080fd5b50610162806100206000396000f3fe60806040526004361061001d5760003560e01c806277436014610022575b600080fd5b61003561003036600461007b565b610037565b005b8051602082016000f061004957600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561008d57600080fd5b813567ffffffffffffffff808211156100a557600080fd5b818401915084601f8301126100b957600080fd5b8135818111156100cb576100cb61004c565b604051601f8201601f19908116603f011681019083821181831017156100f3576100f361004c565b8160405282815287602084870101111561010c57600080fd5b82602086016020830137600092810160200192909252509594505050505056fea264697066735822122094780ce55d28f1d568f4e0ab1b9dc230b96e952b73d2e06456fbff2289fa27f464736f6c63430008150033
|
60806040526004361061001d5760003560e01c806277436014610022575b600080fd5b61003561003036600461007b565b610037565b005b8051602082016000f061004957600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561008d57600080fd5b813567ffffffffffffffff808211156100a557600080fd5b818401915084601f8301126100b957600080fd5b8135818111156100cb576100cb61004c565b604051601f8201601f19908116603f011681019083821181831017156100f3576100f361004c565b8160405282815287602084870101111561010c57600080fd5b82602086016020830137600092810160200192909252509594505050505056fea264697066735822122094780ce55d28f1d568f4e0ab1b9dc230b96e952b73d2e06456fbff2289fa27f464736f6c63430008150033
| |
1 | 19,498,705 |
cd7500cbb5be78beaf1dc6e6f71a6fbe0e890aef423d952f3b56827936bb997b
|
2987e65024abc85e5c96c056b5680971b78b085a0ec9aaf6e969dfd4e9482845
|
91cf7c7b15e1efcde3ce7c6c5ef5a394182fe5eb
|
61fac7277b5041ee031a7abeff012ead2ff833bb
|
9cd2c52541e49c4ecb07997e46bd43ba2dcf7ccb
|
3d602d80600a3d3981f3363d3d373d3d3d363d737f9f70da4af54671a6abac58e705b5634cac88195af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d737f9f70da4af54671a6abac58e705b5634cac88195af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"@axelar-network/axelar-cgp-solidity/contracts/interfaces/IERC20Permit.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.9;\n\ninterface IERC20Permit {\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n\n function nonces(address account) external view returns (uint256);\n\n function permit(\n address issuer,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n}\n"
},
"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n error InvalidAccount();\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address sender,\n address recipient,\n uint256 amount\n ) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"
},
"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IRolesBase.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title IRolesBase Interface\n * @notice IRolesBase is an interface that abstracts the implementation of a\n * contract with role control internal functions.\n */\ninterface IRolesBase {\n error MissingRole(address account, uint8 role);\n error MissingAllRoles(address account, uint256 accountRoles);\n error MissingAnyOfRoles(address account, uint256 accountRoles);\n\n error InvalidProposedRoles(address fromAccount, address toAccount, uint256 accountRoles);\n\n event RolesProposed(address indexed fromAccount, address indexed toAccount, uint256 accountRoles);\n event RolesAdded(address indexed account, uint256 accountRoles);\n event RolesRemoved(address indexed account, uint256 accountRoles);\n\n /**\n * @notice Checks if an account has a role.\n * @param account The address to check\n * @param role The role to check\n * @return True if the account has the role, false otherwise\n */\n function hasRole(address account, uint8 role) external view returns (bool);\n}\n"
},
"@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/AddressBytes.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title AddressBytesUtils\n * @dev This library provides utility functions to convert between `address` and `bytes`.\n */\nlibrary AddressBytes {\n error InvalidBytesLength(bytes bytesAddress);\n\n /**\n * @dev Converts a bytes address to an address type.\n * @param bytesAddress The bytes representation of an address\n * @return addr The converted address\n */\n function toAddress(bytes memory bytesAddress) internal pure returns (address addr) {\n if (bytesAddress.length != 20) revert InvalidBytesLength(bytesAddress);\n\n assembly {\n addr := mload(add(bytesAddress, 20))\n }\n }\n\n /**\n * @dev Converts an address to bytes.\n * @param addr The address to be converted\n * @return bytesAddress The bytes representation of the address\n */\n function toBytes(address addr) internal pure returns (bytes memory bytesAddress) {\n bytesAddress = new bytes(20);\n // we can test if using a single 32 byte variable that is the address with the length together and using one mstore would be slightly cheaper.\n assembly {\n mstore(add(bytesAddress, 20), addr)\n mstore(bytesAddress, 20)\n }\n }\n}\n"
},
"@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/RolesBase.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IRolesBase } from '../interfaces/IRolesBase.sol';\n\n/**\n * @title RolesBase\n * @notice A contract module which provides a set if internal functions\n * for implementing role control features.\n */\ncontract RolesBase is IRolesBase {\n bytes32 internal constant ROLES_PREFIX = keccak256('roles');\n bytes32 internal constant PROPOSE_ROLES_PREFIX = keccak256('propose-roles');\n\n /**\n * @notice Modifier that throws an error if called by any account missing the role.\n */\n modifier onlyRole(uint8 role) {\n if (!_hasRole(_getRoles(msg.sender), role)) revert MissingRole(msg.sender, role);\n\n _;\n }\n\n /**\n * @notice Modifier that throws an error if called by an account without all the roles.\n */\n modifier withEveryRole(uint8[] memory roles) {\n uint256 accountRoles = _toAccountRoles(roles);\n if (!_hasAllTheRoles(_getRoles(msg.sender), accountRoles)) revert MissingAllRoles(msg.sender, accountRoles);\n\n _;\n }\n\n /**\n * @notice Modifier that throws an error if called by an account without any of the roles.\n */\n modifier withAnyRole(uint8[] memory roles) {\n uint256 accountRoles = _toAccountRoles(roles);\n if (!_hasAnyOfRoles(_getRoles(msg.sender), accountRoles)) revert MissingAnyOfRoles(msg.sender, accountRoles);\n\n _;\n }\n\n /**\n * @notice Checks if an account has a role.\n * @param account The address to check\n * @param role The role to check\n * @return True if the account has the role, false otherwise\n */\n function hasRole(address account, uint8 role) public view returns (bool) {\n return _hasRole(_getRoles(account), role);\n }\n\n /**\n * @notice Internal function to convert an array of roles to a uint256.\n * @param roles The roles to convert\n * @return accountRoles The roles in uint256 format\n */\n function _toAccountRoles(uint8[] memory roles) internal pure returns (uint256) {\n uint256 length = roles.length;\n uint256 accountRoles;\n\n for (uint256 i = 0; i < length; ++i) {\n accountRoles |= (1 << roles[i]);\n }\n\n return accountRoles;\n }\n\n /**\n * @notice Internal function to get the key of the roles mapping.\n * @param account The address to get the key for\n * @return key The key of the roles mapping\n */\n function _rolesKey(address account) internal view virtual returns (bytes32 key) {\n return keccak256(abi.encodePacked(ROLES_PREFIX, account));\n }\n\n /**\n * @notice Internal function to get the roles of an account.\n * @param account The address to get the roles for\n * @return accountRoles The roles of the account in uint256 format\n */\n function _getRoles(address account) internal view returns (uint256 accountRoles) {\n bytes32 key = _rolesKey(account);\n assembly {\n accountRoles := sload(key)\n }\n }\n\n /**\n * @notice Internal function to set the roles of an account.\n * @param account The address to set the roles for\n * @param accountRoles The roles to set\n */\n function _setRoles(address account, uint256 accountRoles) private {\n bytes32 key = _rolesKey(account);\n assembly {\n sstore(key, accountRoles)\n }\n }\n\n /**\n * @notice Internal function to get the key of the proposed roles mapping.\n * @param fromAccount The address of the current role\n * @param toAccount The address of the pending role\n * @return key The key of the proposed roles mapping\n */\n function _proposalKey(address fromAccount, address toAccount) internal view virtual returns (bytes32 key) {\n return keccak256(abi.encodePacked(PROPOSE_ROLES_PREFIX, fromAccount, toAccount));\n }\n\n /**\n * @notice Internal function to get the proposed roles of an account.\n * @param fromAccount The address of the current role\n * @param toAccount The address of the pending role\n * @return proposedRoles_ The proposed roles of the account in uint256 format\n */\n function _getProposedRoles(address fromAccount, address toAccount) internal view returns (uint256 proposedRoles_) {\n bytes32 key = _proposalKey(fromAccount, toAccount);\n assembly {\n proposedRoles_ := sload(key)\n }\n }\n\n /**\n * @notice Internal function to set the proposed roles of an account.\n * @param fromAccount The address of the current role\n * @param toAccount The address of the pending role\n * @param proposedRoles_ The proposed roles to set in uint256 format\n */\n function _setProposedRoles(\n address fromAccount,\n address toAccount,\n uint256 proposedRoles_\n ) private {\n bytes32 key = _proposalKey(fromAccount, toAccount);\n assembly {\n sstore(key, proposedRoles_)\n }\n }\n\n /**\n * @notice Internal function to add a role to an account.\n * @dev emits a RolesAdded event.\n * @param account The address to add the role to\n * @param role The role to add\n */\n function _addRole(address account, uint8 role) internal {\n _addAccountRoles(account, 1 << role);\n }\n\n /**\n * @notice Internal function to add roles to an account.\n * @dev emits a RolesAdded event.\n * @dev Called in the constructor to set the initial roles.\n * @param account The address to add roles to\n * @param roles The roles to add\n */\n function _addRoles(address account, uint8[] memory roles) internal {\n _addAccountRoles(account, _toAccountRoles(roles));\n }\n\n /**\n * @notice Internal function to add roles to an account.\n * @dev emits a RolesAdded event.\n * @dev Called in the constructor to set the initial roles.\n * @param account The address to add roles to\n * @param accountRoles The roles to add\n */\n function _addAccountRoles(address account, uint256 accountRoles) internal {\n uint256 newAccountRoles = _getRoles(account) | accountRoles;\n\n _setRoles(account, newAccountRoles);\n\n emit RolesAdded(account, accountRoles);\n }\n\n /**\n * @notice Internal function to remove a role from an account.\n * @dev emits a RolesRemoved event.\n * @param account The address to remove the role from\n * @param role The role to remove\n */\n function _removeRole(address account, uint8 role) internal {\n _removeAccountRoles(account, 1 << role);\n }\n\n /**\n * @notice Internal function to remove roles from an account.\n * @dev emits a RolesRemoved event.\n * @param account The address to remove roles from\n * @param roles The roles to remove\n */\n function _removeRoles(address account, uint8[] memory roles) internal {\n _removeAccountRoles(account, _toAccountRoles(roles));\n }\n\n /**\n * @notice Internal function to remove roles from an account.\n * @dev emits a RolesRemoved event.\n * @param account The address to remove roles from\n * @param accountRoles The roles to remove\n */\n function _removeAccountRoles(address account, uint256 accountRoles) internal {\n uint256 newAccountRoles = _getRoles(account) & ~accountRoles;\n\n _setRoles(account, newAccountRoles);\n\n emit RolesRemoved(account, accountRoles);\n }\n\n /**\n * @notice Internal function to check if an account has a role.\n * @param accountRoles The roles of the account in uint256 format\n * @param role The role to check\n * @return True if the account has the role, false otherwise\n */\n function _hasRole(uint256 accountRoles, uint8 role) internal pure returns (bool) {\n return accountRoles & (1 << role) != 0;\n }\n\n /**\n * @notice Internal function to check if an account has all the roles.\n * @param hasAccountRoles The roles of the account in uint256 format\n * @param mustHaveAccountRoles The roles the account must have\n * @return True if the account has all the roles, false otherwise\n */\n function _hasAllTheRoles(uint256 hasAccountRoles, uint256 mustHaveAccountRoles) internal pure returns (bool) {\n return (hasAccountRoles & mustHaveAccountRoles) == mustHaveAccountRoles;\n }\n\n /**\n * @notice Internal function to check if an account has any of the roles.\n * @param hasAccountRoles The roles of the account in uint256 format\n * @param mustHaveAnyAccountRoles The roles to check in uint256 format\n * @return True if the account has any of the roles, false otherwise\n */\n function _hasAnyOfRoles(uint256 hasAccountRoles, uint256 mustHaveAnyAccountRoles) internal pure returns (bool) {\n return (hasAccountRoles & mustHaveAnyAccountRoles) != 0;\n }\n\n /**\n * @notice Internal function to propose to transfer roles of message sender to a new account.\n * @dev Original account must have all the proposed roles.\n * @dev Emits a RolesProposed event.\n * @dev Roles are not transferred until the new role accepts the role transfer.\n * @param fromAccount The address of the current roles\n * @param toAccount The address to transfer roles to\n * @param role The role to transfer\n */\n function _proposeRole(\n address fromAccount,\n address toAccount,\n uint8 role\n ) internal {\n _proposeAccountRoles(fromAccount, toAccount, 1 << role);\n }\n\n /**\n * @notice Internal function to propose to transfer roles of message sender to a new account.\n * @dev Original account must have all the proposed roles.\n * @dev Emits a RolesProposed event.\n * @dev Roles are not transferred until the new role accepts the role transfer.\n * @param fromAccount The address of the current roles\n * @param toAccount The address to transfer roles to\n * @param roles The roles to transfer\n */\n function _proposeRoles(\n address fromAccount,\n address toAccount,\n uint8[] memory roles\n ) internal {\n _proposeAccountRoles(fromAccount, toAccount, _toAccountRoles(roles));\n }\n\n /**\n * @notice Internal function to propose to transfer roles of message sender to a new account.\n * @dev Original account must have all the proposed roles.\n * @dev Emits a RolesProposed event.\n * @dev Roles are not transferred until the new role accepts the role transfer.\n * @param fromAccount The address of the current roles\n * @param toAccount The address to transfer roles to\n * @param accountRoles The account roles to transfer\n */\n function _proposeAccountRoles(\n address fromAccount,\n address toAccount,\n uint256 accountRoles\n ) internal {\n if (!_hasAllTheRoles(_getRoles(fromAccount), accountRoles)) revert MissingAllRoles(fromAccount, accountRoles);\n\n _setProposedRoles(fromAccount, toAccount, accountRoles);\n\n emit RolesProposed(fromAccount, toAccount, accountRoles);\n }\n\n /**\n * @notice Internal function to accept roles transferred from another account.\n * @dev Pending account needs to pass all the proposed roles.\n * @dev Emits RolesRemoved and RolesAdded events.\n * @param fromAccount The address of the current role\n * @param role The role to accept\n */\n function _acceptRole(\n address fromAccount,\n address toAccount,\n uint8 role\n ) internal virtual {\n _acceptAccountRoles(fromAccount, toAccount, 1 << role);\n }\n\n /**\n * @notice Internal function to accept roles transferred from another account.\n * @dev Pending account needs to pass all the proposed roles.\n * @dev Emits RolesRemoved and RolesAdded events.\n * @param fromAccount The address of the current role\n * @param roles The roles to accept\n */\n function _acceptRoles(\n address fromAccount,\n address toAccount,\n uint8[] memory roles\n ) internal virtual {\n _acceptAccountRoles(fromAccount, toAccount, _toAccountRoles(roles));\n }\n\n /**\n * @notice Internal function to accept roles transferred from another account.\n * @dev Pending account needs to pass all the proposed roles.\n * @dev Emits RolesRemoved and RolesAdded events.\n * @param fromAccount The address of the current role\n * @param accountRoles The account roles to accept\n */\n function _acceptAccountRoles(\n address fromAccount,\n address toAccount,\n uint256 accountRoles\n ) internal virtual {\n if (_getProposedRoles(fromAccount, toAccount) != accountRoles) {\n revert InvalidProposedRoles(fromAccount, toAccount, accountRoles);\n }\n\n _setProposedRoles(fromAccount, toAccount, 0);\n _transferAccountRoles(fromAccount, toAccount, accountRoles);\n }\n\n /**\n * @notice Internal function to transfer roles from one account to another.\n * @dev Original account must have all the proposed roles.\n * @param fromAccount The address of the current role\n * @param toAccount The address to transfer role to\n * @param role The role to transfer\n */\n function _transferRole(\n address fromAccount,\n address toAccount,\n uint8 role\n ) internal {\n _transferAccountRoles(fromAccount, toAccount, 1 << role);\n }\n\n /**\n * @notice Internal function to transfer roles from one account to another.\n * @dev Original account must have all the proposed roles.\n * @param fromAccount The address of the current role\n * @param toAccount The address to transfer role to\n * @param roles The roles to transfer\n */\n function _transferRoles(\n address fromAccount,\n address toAccount,\n uint8[] memory roles\n ) internal {\n _transferAccountRoles(fromAccount, toAccount, _toAccountRoles(roles));\n }\n\n /**\n * @notice Internal function to transfer roles from one account to another.\n * @dev Original account must have all the proposed roles.\n * @param fromAccount The address of the current role\n * @param toAccount The address to transfer role to\n * @param accountRoles The account roles to transfer\n */\n function _transferAccountRoles(\n address fromAccount,\n address toAccount,\n uint256 accountRoles\n ) internal {\n if (!_hasAllTheRoles(_getRoles(fromAccount), accountRoles)) revert MissingAllRoles(fromAccount, accountRoles);\n\n _removeAccountRoles(fromAccount, accountRoles);\n _addAccountRoles(toAccount, accountRoles);\n }\n}\n"
},
"contracts/interchain-token/ERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol';\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin guidelines: functions revert instead\n * of returning `false` on failure. This behavior is nonetheless conventional\n * and does not conflict with the expectations of ERC20 applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is IERC20 {\n mapping(address => uint256) public override balanceOf;\n\n mapping(address => mapping(address => uint256)) public override allowance;\n\n uint256 public override totalSupply;\n uint256 internal constant UINT256_MAX = type(uint256).max;\n\n /**\n * @dev See {IERC20-transfer}.\n *\n * Requirements:\n *\n * - `recipient` cannot be the zero address.\n * - the caller must have a balance of at least `amount`.\n */\n function transfer(address recipient, uint256 amount) external virtual override returns (bool) {\n _transfer(msg.sender, recipient, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-approve}.\n *\n * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n * `transferFrom`. This is semantically equivalent to an infinite approval.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function approve(address spender, uint256 amount) external virtual override returns (bool) {\n _approve(msg.sender, spender, amount);\n return true;\n }\n\n /**\n * @dev See {IERC20-transferFrom}.\n *\n * Emits an {Approval} event indicating the updated allowance. This is not\n * required by the EIP. See the note at the beginning of {ERC20}.\n *\n * Requirements:\n *\n * - `sender` and `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n * - the caller must have allowance for ``sender``'s tokens of at least\n * `amount`.\n */\n function transferFrom(address sender, address recipient, uint256 amount) external virtual override returns (bool) {\n uint256 _allowance = allowance[sender][msg.sender];\n\n if (_allowance != UINT256_MAX) {\n _approve(sender, msg.sender, _allowance - amount);\n }\n\n _transfer(sender, recipient, amount);\n\n return true;\n }\n\n /**\n * @dev Atomically increases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n */\n function increaseAllowance(address spender, uint256 addedValue) external virtual returns (bool) {\n _approve(msg.sender, spender, allowance[msg.sender][spender] + addedValue);\n return true;\n }\n\n /**\n * @dev Atomically decreases the allowance granted to `spender` by the caller.\n *\n * This is an alternative to {approve} that can be used as a mitigation for\n * problems described in {IERC20-approve}.\n *\n * Emits an {Approval} event indicating the updated allowance.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `spender` must have allowance for the caller of at least\n * `subtractedValue`.\n */\n function decreaseAllowance(address spender, uint256 subtractedValue) external virtual returns (bool) {\n _approve(msg.sender, spender, allowance[msg.sender][spender] - subtractedValue);\n return true;\n }\n\n /**\n * @dev Moves tokens `amount` from `sender` to `recipient`.\n *\n * This is internal function is equivalent to {transfer}, and can be used to\n * e.g. implement automatic token fees, slashing mechanisms, etc.\n *\n * Emits a {Transfer} event.\n *\n * Requirements:\n *\n * - `sender` cannot be the zero address.\n * - `recipient` cannot be the zero address.\n * - `sender` must have a balance of at least `amount`.\n */\n function _transfer(address sender, address recipient, uint256 amount) internal virtual {\n if (sender == address(0) || recipient == address(0)) revert InvalidAccount();\n\n balanceOf[sender] -= amount;\n balanceOf[recipient] += amount;\n emit Transfer(sender, recipient, amount);\n }\n\n /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n * the total supply.\n *\n * Emits a {Transfer} event with `from` set to the zero address.\n *\n * Requirements:\n *\n * - `to` cannot be the zero address.\n */\n function _mint(address account, uint256 amount) internal virtual {\n if (account == address(0)) revert InvalidAccount();\n\n totalSupply += amount;\n balanceOf[account] += amount;\n emit Transfer(address(0), account, amount);\n }\n\n /**\n * @dev Destroys `amount` tokens from `account`, reducing the\n * total supply.\n *\n * Emits a {Transfer} event with `to` set to the zero address.\n *\n * Requirements:\n *\n * - `account` cannot be the zero address.\n * - `account` must have at least `amount` tokens.\n */\n function _burn(address account, uint256 amount) internal virtual {\n if (account == address(0)) revert InvalidAccount();\n\n balanceOf[account] -= amount;\n totalSupply -= amount;\n emit Transfer(account, address(0), amount);\n }\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n *\n * This internal function is equivalent to `approve`, and can be used to\n * e.g. set automatic allowances for certain subsystems, etc.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `owner` cannot be the zero address.\n * - `spender` cannot be the zero address.\n */\n function _approve(address owner, address spender, uint256 amount) internal virtual {\n if (owner == address(0) || spender == address(0)) revert InvalidAccount();\n\n allowance[owner][spender] = amount;\n emit Approval(owner, spender, amount);\n }\n}\n"
},
"contracts/interchain-token/ERC20Permit.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol';\nimport { IERC20Permit } from '@axelar-network/axelar-cgp-solidity/contracts/interfaces/IERC20Permit.sol';\n\nimport { ERC20 } from './ERC20.sol';\n\n/**\n * @title ERC20Permit Contract\n * @dev Extension of ERC20 to include permit functionality (EIP-2612).\n * Allows for approval of ERC20 tokens by signature rather than transaction.\n */\nabstract contract ERC20Permit is IERC20, IERC20Permit, ERC20 {\n error PermitExpired();\n error InvalidS();\n error InvalidV();\n error InvalidSignature();\n\n /**\n * @dev Represents hash of the EIP-712 Domain Separator.\n */\n bytes32 public nameHash;\n\n string private constant EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA = '\\x19\\x01';\n\n // keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')\n bytes32 private constant DOMAIN_TYPE_SIGNATURE_HASH = bytes32(0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f);\n\n // keccak256('Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)')\n bytes32 private constant PERMIT_SIGNATURE_HASH = bytes32(0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9);\n\n /**\n * @dev Mapping of nonces for each address.\n */\n mapping(address => uint256) public nonces;\n\n /**\n * @notice Internal function to set the token name hash\n * @param name The token name\n */\n function _setNameHash(string memory name) internal {\n nameHash = keccak256(bytes(name));\n }\n\n /**\n * @notice Calculates the domain separator.\n * @dev This is not cached because chainid can change on chain forks.\n */\n // solhint-disable func-name-mixedcase\n // slither-disable-next-line naming-convention\n function DOMAIN_SEPARATOR() public view returns (bytes32) {\n return keccak256(abi.encode(DOMAIN_TYPE_SIGNATURE_HASH, nameHash, keccak256(bytes('1')), block.chainid, address(this)));\n }\n\n // solhint-enable func-name-mixedcase\n\n /**\n * @notice Permit the designated spender to spend the holder's tokens\n * @dev The permit function is used to allow a holder to designate a spender\n * to spend tokens on their behalf via a signed message.\n * @param issuer The address of the token holder\n * @param spender The address of the designated spender\n * @param value The number of tokens to be spent\n * @param deadline The time at which the permission to spend expires\n * @param v The recovery id of the signature\n * @param r Half of the ECDSA signature pair\n * @param s Half of the ECDSA signature pair\n */\n function permit(address issuer, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external {\n if (block.timestamp > deadline) revert PermitExpired();\n\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) revert InvalidS();\n\n if (v != 27 && v != 28) revert InvalidV();\n\n bytes32 digest = keccak256(\n abi.encodePacked(\n EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA,\n DOMAIN_SEPARATOR(),\n keccak256(abi.encode(PERMIT_SIGNATURE_HASH, issuer, spender, value, nonces[issuer]++, deadline))\n )\n );\n\n address recoveredAddress = ecrecover(digest, v, r, s);\n\n if (recoveredAddress != issuer) revert InvalidSignature();\n\n // _approve will revert if issuer is address(0x0)\n _approve(issuer, spender, value);\n }\n}\n"
},
"contracts/interchain-token/InterchainToken.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { AddressBytes } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/libs/AddressBytes.sol';\n\nimport { IInterchainToken } from '../interfaces/IInterchainToken.sol';\n\nimport { InterchainTokenStandard } from './InterchainTokenStandard.sol';\nimport { ERC20 } from './ERC20.sol';\nimport { ERC20Permit } from './ERC20Permit.sol';\nimport { Minter } from '../utils/Minter.sol';\n\n/**\n * @title InterchainToken\n * @notice This contract implements an interchain token which extends InterchainToken functionality.\n * @dev This contract also inherits Minter and Implementation logic.\n */\ncontract InterchainToken is InterchainTokenStandard, ERC20, ERC20Permit, Minter, IInterchainToken {\n using AddressBytes for bytes;\n\n string public name;\n string public symbol;\n uint8 public decimals;\n bytes32 internal tokenId;\n address internal immutable interchainTokenService_;\n\n // bytes32(uint256(keccak256('interchain-token-initialized')) - 1);\n bytes32 internal constant INITIALIZED_SLOT = 0xc778385ecb3e8cecb82223fa1f343ec6865b2d64c65b0c15c7e8aef225d9e214;\n\n /**\n * @notice Constructs the InterchainToken contract.\n * @dev Makes the implementation act as if it has been setup already to disallow calls to init() (even though that would not achieve anything really).\n */\n constructor(address interchainTokenServiceAddress) {\n _initialize();\n\n if (interchainTokenServiceAddress == address(0)) revert InterchainTokenServiceAddressZero();\n\n interchainTokenService_ = interchainTokenServiceAddress;\n }\n\n /**\n * @notice Returns true if the contract has been setup.\n * @return initialized True if the contract has been setup, false otherwise.\n */\n function _isInitialized() internal view returns (bool initialized) {\n assembly {\n initialized := sload(INITIALIZED_SLOT)\n }\n }\n\n /**\n * @notice Sets initialized to true, to allow only a single init.\n */\n function _initialize() internal {\n assembly {\n sstore(INITIALIZED_SLOT, true)\n }\n }\n\n /**\n * @notice Returns the interchain token service\n * @return address The interchain token service contract\n */\n function interchainTokenService() public view override(InterchainTokenStandard, IInterchainToken) returns (address) {\n return interchainTokenService_;\n }\n\n /**\n * @notice Returns the tokenId for this token.\n * @return bytes32 The token manager contract.\n */\n function interchainTokenId() public view override(InterchainTokenStandard, IInterchainToken) returns (bytes32) {\n return tokenId;\n }\n\n /**\n * @notice Setup function to initialize contract parameters.\n * @param tokenId_ The tokenId of the token.\n * @param minter The address of the token minter.\n * @param tokenName The name of the token.\n * @param tokenSymbol The symbopl of the token.\n * @param tokenDecimals The decimals of the token.\n */\n function init(bytes32 tokenId_, address minter, string calldata tokenName, string calldata tokenSymbol, uint8 tokenDecimals) external {\n if (_isInitialized()) revert AlreadyInitialized();\n\n _initialize();\n\n if (tokenId_ == bytes32(0)) revert TokenIdZero();\n if (bytes(tokenName).length == 0) revert TokenNameEmpty();\n if (bytes(tokenSymbol).length == 0) revert TokenSymbolEmpty();\n\n name = tokenName;\n symbol = tokenSymbol;\n decimals = tokenDecimals;\n tokenId = tokenId_;\n\n /**\n * @dev Set the token service as a minter to allow it to mint and burn tokens.\n * Also add the provided address as a minter. If `address(0)` was provided,\n * add it as a minter to allow anyone to easily check that no custom minter was set.\n */\n _addMinter(interchainTokenService_);\n _addMinter(minter);\n\n _setNameHash(tokenName);\n }\n\n /**\n * @notice Function to mint new tokens.\n * @dev Can only be called by the minter address.\n * @param account The address that will receive the minted tokens.\n * @param amount The amount of tokens to mint.\n */\n function mint(address account, uint256 amount) external onlyRole(uint8(Roles.MINTER)) {\n _mint(account, amount);\n }\n\n /**\n * @notice Function to burn tokens.\n * @dev Can only be called by the minter address.\n * @param account The address that will have its tokens burnt.\n * @param amount The amount of tokens to burn.\n */\n function burn(address account, uint256 amount) external onlyRole(uint8(Roles.MINTER)) {\n _burn(account, amount);\n }\n\n /**\n * @notice A method to be overwritten that will decrease the allowance of the `spender` from `sender` by `amount`.\n * @dev Needs to be overwritten. This provides flexibility for the choice of ERC20 implementation used. Must revert if allowance is not sufficient.\n */\n function _spendAllowance(address sender, address spender, uint256 amount) internal override {\n uint256 _allowance = allowance[sender][spender];\n\n if (_allowance != UINT256_MAX) {\n _approve(sender, spender, _allowance - amount);\n }\n }\n}\n"
},
"contracts/interchain-token/InterchainTokenStandard.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IInterchainTokenStandard } from '../interfaces/IInterchainTokenStandard.sol';\nimport { ITransmitInterchainToken } from '../interfaces/ITransmitInterchainToken.sol';\n\n/**\n * @title An example implementation of the IInterchainTokenStandard.\n * @notice The is an abstract contract that needs to be extended with an ERC20 implementation. See `InterchainToken` for an example implementation.\n */\nabstract contract InterchainTokenStandard is IInterchainTokenStandard {\n /**\n * @notice Getter for the tokenId used for this token.\n * @dev Needs to be overwritten.\n * @return tokenId_ The tokenId that this token is registerred under.\n */\n function interchainTokenId() public view virtual returns (bytes32 tokenId_);\n\n /**\n * @notice Getter for the interchain token service.\n * @dev Needs to be overwritten.\n * @return service The address of the interchain token service.\n */\n function interchainTokenService() public view virtual returns (address service);\n\n /**\n * @notice Implementation of the interchainTransfer method\n * @dev We chose to either pass `metadata` as raw data on a remote contract call, or if no data is passed, just do a transfer.\n * A different implementation could use metadata to specify a function to invoke, or for other purposes as well.\n * @param destinationChain The destination chain identifier.\n * @param recipient The bytes representation of the address of the recipient.\n * @param amount The amount of token to be transferred.\n * @param metadata Either empty, just to facilitate an interchain transfer, or the data to be passed for an interchain contract call with transfer\n * as per semantics defined by the token service.\n */\n function interchainTransfer(\n string calldata destinationChain,\n bytes calldata recipient,\n uint256 amount,\n bytes calldata metadata\n ) external payable {\n address sender = msg.sender;\n\n _beforeInterchainTransfer(msg.sender, destinationChain, recipient, amount, metadata);\n\n ITransmitInterchainToken(interchainTokenService()).transmitInterchainTransfer{ value: msg.value }(\n interchainTokenId(),\n sender,\n destinationChain,\n recipient,\n amount,\n metadata\n );\n }\n\n /**\n * @notice Implementation of the interchainTransferFrom method\n * @dev We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer.\n * A different implementation could use metadata to specify a function to invoke, or for other purposes as well.\n * @param sender The sender of the tokens. They need to have approved `msg.sender` before this is called.\n * @param destinationChain The string representation of the destination chain.\n * @param recipient The bytes representation of the address of the recipient.\n * @param amount The amount of token to be transferred.\n * @param metadata Either empty, just to facilitate an interchain transfer, or the data to be passed to an interchain contract call and transfer.\n */\n function interchainTransferFrom(\n address sender,\n string calldata destinationChain,\n bytes calldata recipient,\n uint256 amount,\n bytes calldata metadata\n ) external payable {\n _spendAllowance(sender, msg.sender, amount);\n\n _beforeInterchainTransfer(sender, destinationChain, recipient, amount, metadata);\n\n ITransmitInterchainToken(interchainTokenService()).transmitInterchainTransfer{ value: msg.value }(\n interchainTokenId(),\n sender,\n destinationChain,\n recipient,\n amount,\n metadata\n );\n }\n\n /**\n * @notice A method to be overwritten that will be called before an interchain transfer. One can approve the tokenManager here if needed,\n * to allow users for a 1-call transfer in case of a lock-unlock token manager.\n * @param from The sender of the tokens. They need to have approved `msg.sender` before this is called.\n * @param destinationChain The string representation of the destination chain.\n * @param destinationAddress The bytes representation of the address of the recipient.\n * @param amount The amount of token to be transferred.\n * @param metadata Either empty, just to facilitate an interchain transfer, or the data to be passed to an interchain contract call and transfer.\n */\n function _beforeInterchainTransfer(\n address from,\n string calldata destinationChain,\n bytes calldata destinationAddress,\n uint256 amount,\n bytes calldata metadata\n ) internal virtual {}\n\n /**\n * @notice A method to be overwritten that will decrease the allowance of the `spender` from `sender` by `amount`.\n * @dev Needs to be overwritten. This provides flexibility for the choice of ERC20 implementation used. Must revert if allowance is not sufficient.\n */\n function _spendAllowance(address sender, address spender, uint256 amount) internal virtual;\n}\n"
},
"contracts/interfaces/IERC20MintableBurnable.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title IERC20MintableBurnable Interface\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20MintableBurnable {\n /**\n * @notice Function to mint new tokens.\n * @dev Can only be called by the minter address.\n * @param to The address that will receive the minted tokens.\n * @param amount The amount of tokens to mint.\n */\n function mint(address to, uint256 amount) external;\n\n /**\n * @notice Function to burn tokens.\n * @dev Can only be called by the minter address.\n * @param from The address that will have its tokens burnt.\n * @param amount The amount of tokens to burn.\n */\n function burn(address from, uint256 amount) external;\n}\n"
},
"contracts/interfaces/IERC20Named.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IERC20 } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IERC20.sol';\n\n/**\n * @title IERC20Named Interface\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Named is IERC20 {\n /**\n * @notice Getter for the name of the token.\n * @return string Name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @notice Getter for the symbol of the token.\n * @return string The symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @notice Getter for the decimals of the token.\n * @return uint8 The decimals of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
},
"contracts/interfaces/IInterchainToken.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IInterchainTokenStandard } from './IInterchainTokenStandard.sol';\nimport { IMinter } from './IMinter.sol';\nimport { IERC20MintableBurnable } from './IERC20MintableBurnable.sol';\nimport { IERC20Named } from './IERC20Named.sol';\n\n/**\n * @title IInterchainToken interface\n * @dev Extends IInterchainTokenStandard and IMinter.\n */\ninterface IInterchainToken is IInterchainTokenStandard, IMinter, IERC20MintableBurnable, IERC20Named {\n error InterchainTokenServiceAddressZero();\n error TokenIdZero();\n error TokenNameEmpty();\n error TokenSymbolEmpty();\n error AlreadyInitialized();\n\n /**\n * @notice Getter for the interchain token service contract.\n * @dev Needs to be overwitten.\n * @return interchainTokenServiceAddress The interchain token service address.\n */\n function interchainTokenService() external view returns (address interchainTokenServiceAddress);\n\n /**\n * @notice Getter for the tokenId used for this token.\n * @dev Needs to be overwitten.\n * @return tokenId_ The tokenId for this token.\n */\n function interchainTokenId() external view returns (bytes32 tokenId_);\n\n /**\n * @notice Setup function to initialize contract parameters.\n * @param tokenId_ The tokenId of the token.\n * @param minter The address of the token minter.\n * @param tokenName The name of the token.\n * @param tokenSymbol The symbopl of the token.\n * @param tokenDecimals The decimals of the token.\n */\n function init(bytes32 tokenId_, address minter, string calldata tokenName, string calldata tokenSymbol, uint8 tokenDecimals) external;\n}\n"
},
"contracts/interfaces/IInterchainTokenStandard.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title IInterchainTokenStandard interface\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IInterchainTokenStandard {\n /**\n * @notice Implementation of the interchainTransfer method.\n * @dev We chose to either pass `metadata` as raw data on a remote contract call, or if no data is passed, just do a transfer.\n * A different implementation could use metadata to specify a function to invoke, or for other purposes as well.\n * @param destinationChain The destination chain identifier.\n * @param recipient The bytes representation of the address of the recipient.\n * @param amount The amount of token to be transferred.\n * @param metadata Optional metadata for the call for additional effects (such as calling a destination contract).\n */\n function interchainTransfer(\n string calldata destinationChain,\n bytes calldata recipient,\n uint256 amount,\n bytes calldata metadata\n ) external payable;\n\n /**\n * @notice Implementation of the interchainTransferFrom method\n * @dev We chose to either pass `metadata` as raw data on a remote contract call, or, if no data is passed, just do a transfer.\n * A different implementation could use metadata to specify a function to invoke, or for other purposes as well.\n * @param sender The sender of the tokens. They need to have approved `msg.sender` before this is called.\n * @param destinationChain The string representation of the destination chain.\n * @param recipient The bytes representation of the address of the recipient.\n * @param amount The amount of token to be transferred.\n * @param metadata Optional metadata for the call for additional effects (such as calling a destination contract.)\n */\n function interchainTransferFrom(\n address sender,\n string calldata destinationChain,\n bytes calldata recipient,\n uint256 amount,\n bytes calldata metadata\n ) external payable;\n}\n"
},
"contracts/interfaces/IMinter.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IRolesBase } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IRolesBase.sol';\n\n/**\n * @title IMinter Interface\n * @notice An interface for a contract module which provides a basic access control mechanism, where\n * there is an account (a minter) that can be granted exclusive access to specific functions.\n */\ninterface IMinter is IRolesBase {\n /**\n * @notice Change the minter of the contract.\n * @dev Can only be called by the current minter.\n * @param minter_ The address of the new minter.\n */\n function transferMintership(address minter_) external;\n\n /**\n * @notice Proposed a change of the minter of the contract.\n * @dev Can only be called by the current minter.\n * @param minter_ The address of the new minter.\n */\n function proposeMintership(address minter_) external;\n\n /**\n * @notice Accept a change of the minter of the contract.\n * @dev Can only be called by the proposed minter.\n * @param fromMinter The previous minter.\n */\n function acceptMintership(address fromMinter) external;\n\n /**\n * @notice Query if an address is a minter\n * @param addr the address to query for\n * @return bool Boolean value representing whether or not the address is a minter.\n */\n function isMinter(address addr) external view returns (bool);\n}\n"
},
"contracts/interfaces/ITransmitInterchainToken.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ITransmitInterchainToken Interface\n * @notice Interface for transmiting interchain tokens via the interchain token service\n */\ninterface ITransmitInterchainToken {\n /**\n * @notice Transmit an interchain transfer for the given tokenId.\n * @dev Only callable by a token registered under a tokenId.\n * @param tokenId The tokenId of the token (which must be the msg.sender).\n * @param sourceAddress The address where the token is coming from.\n * @param destinationChain The name of the chain to send tokens to.\n * @param destinationAddress The destinationAddress for the interchainTransfer.\n * @param amount The amount of token to give.\n * @param metadata Optional metadata for the call for additional effects (such as calling a destination contract).\n */\n function transmitInterchainTransfer(\n bytes32 tokenId,\n address sourceAddress,\n string calldata destinationChain,\n bytes memory destinationAddress,\n uint256 amount,\n bytes calldata metadata\n ) external payable;\n}\n"
},
"contracts/utils/Minter.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IMinter } from '../interfaces/IMinter.sol';\n\nimport { RolesBase } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/utils/RolesBase.sol';\nimport { RolesConstants } from './RolesConstants.sol';\n\n/**\n * @title Minter Contract\n * @notice A contract module which provides a basic access control mechanism, where\n * there is an account (a minter) that can be granted exclusive access to\n * specific functions.\n * @dev This module is used through inheritance.\n */\ncontract Minter is IMinter, RolesBase, RolesConstants {\n /**\n * @notice Internal function that stores the new minter address in the correct storage slot.\n * @param minter_ The address of the new minter.\n */\n function _addMinter(address minter_) internal {\n _addRole(minter_, uint8(Roles.MINTER));\n }\n\n /**\n * @notice Changes the minter of the contract.\n * @dev Can only be called by the current minter.\n * @param minter_ The address of the new minter.\n */\n function transferMintership(address minter_) external onlyRole(uint8(Roles.MINTER)) {\n _transferRole(msg.sender, minter_, uint8(Roles.MINTER));\n }\n\n /**\n * @notice Proposes a change of the minter of the contract.\n * @dev Can only be called by the current minter.\n * @param minter_ The address of the new minter.\n */\n function proposeMintership(address minter_) external onlyRole(uint8(Roles.MINTER)) {\n _proposeRole(msg.sender, minter_, uint8(Roles.MINTER));\n }\n\n /**\n * @notice Accept a change of the minter of the contract.\n * @dev Can only be called by the proposed minter.\n * @param fromMinter The previous minter.\n */\n function acceptMintership(address fromMinter) external {\n _acceptRole(fromMinter, msg.sender, uint8(Roles.MINTER));\n }\n\n /**\n * @notice Query if an address is a minter\n * @param addr the address to query for\n * @return bool Boolean value representing whether or not the address is a minter.\n */\n function isMinter(address addr) external view returns (bool) {\n return hasRole(addr, uint8(Roles.MINTER));\n }\n}\n"
},
"contracts/utils/RolesConstants.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title RolesConstants\n * @notice This contract contains enum values representing different contract roles.\n */\ncontract RolesConstants {\n enum Roles {\n MINTER,\n OPERATOR,\n FLOW_LIMITER\n }\n}\n"
}
},
"settings": {
"evmVersion": "london",
"optimizer": {
"enabled": true,
"runs": 1000,
"details": {
"peephole": true,
"inliner": true,
"jumpdestRemover": true,
"orderLiterals": true,
"deduplicate": true,
"cse": true,
"constantOptimizer": true,
"yul": true,
"yulDetails": {
"stackAllocation": true
}
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,498,705 |
cd7500cbb5be78beaf1dc6e6f71a6fbe0e890aef423d952f3b56827936bb997b
|
2987e65024abc85e5c96c056b5680971b78b085a0ec9aaf6e969dfd4e9482845
|
91cf7c7b15e1efcde3ce7c6c5ef5a394182fe5eb
|
b5fb4be02232b1bba4dc8f81dc24c26980de9e3c
|
44ee29bc4ca301cd40acbeda63b73943494f574d
|
608060405234801561001057600080fd5b50610162806100206000396000f3fe60806040526004361061001d5760003560e01c806277436014610022575b600080fd5b61003561003036600461007b565b610037565b005b8051602082016000f061004957600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561008d57600080fd5b813567ffffffffffffffff808211156100a557600080fd5b818401915084601f8301126100b957600080fd5b8135818111156100cb576100cb61004c565b604051601f8201601f19908116603f011681019083821181831017156100f3576100f361004c565b8160405282815287602084870101111561010c57600080fd5b82602086016020830137600092810160200192909252509594505050505056fea264697066735822122094780ce55d28f1d568f4e0ab1b9dc230b96e952b73d2e06456fbff2289fa27f464736f6c63430008150033
|
60806040526004361061001d5760003560e01c806277436014610022575b600080fd5b61003561003036600461007b565b610037565b005b8051602082016000f061004957600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60006020828403121561008d57600080fd5b813567ffffffffffffffff808211156100a557600080fd5b818401915084601f8301126100b957600080fd5b8135818111156100cb576100cb61004c565b604051601f8201601f19908116603f011681019083821181831017156100f3576100f361004c565b8160405282815287602084870101111561010c57600080fd5b82602086016020830137600092810160200192909252509594505050505056fea264697066735822122094780ce55d28f1d568f4e0ab1b9dc230b96e952b73d2e06456fbff2289fa27f464736f6c63430008150033
| |
1 | 19,498,705 |
cd7500cbb5be78beaf1dc6e6f71a6fbe0e890aef423d952f3b56827936bb997b
|
2987e65024abc85e5c96c056b5680971b78b085a0ec9aaf6e969dfd4e9482845
|
91cf7c7b15e1efcde3ce7c6c5ef5a394182fe5eb
|
44ee29bc4ca301cd40acbeda63b73943494f574d
|
c35952d8a487a61c7abfcddc182b74e3a9404e8a
|
61010060405234801561001157600080fd5b5060405161086d38038061086d833981016040819052610030916102b6565b6001600160a01b0384166100575760405163d92e233d60e01b815260040160405180910390fd5b6001600160a01b03841660805260a083905260c0829052600061007a85856101ed565b90506001600160a01b0381166100a35760405163340aafcd60e11b815260040160405180910390fd5b6000816001600160a01b0316639ded06df60e01b846040516024016100c89190610388565b60408051601f198184030181529181526020820180516001600160e01b03166001600160e01b031990941693909317909252905161010691906103bb565b600060405180830381855af49150503d8060008114610141576040519150601f19603f3d011682016040523d82523d6000602084013e610146565b606091505b5050905080610168576040516397905dfb60e01b815260040160405180910390fd5b60405163f5983e8360e01b81526001600160a01b0383169063f5983e8390610194908690600401610388565b602060405180830381865afa1580156101b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d591906103d7565b6001600160a01b031660e052506103f2945050505050565b604051633f0a8fd360e11b8152600481018290526000906001600160a01b03841690637e151fa690602401602060405180830381865afa158015610235573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061025991906103d7565b9392505050565b80516001600160a01b038116811461027757600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156102ad578181015183820152602001610295565b50506000910152565b600080600080608085870312156102cc57600080fd5b6102d585610260565b60208601516040870151606088015192965090945092506001600160401b038082111561030157600080fd5b818701915087601f83011261031557600080fd5b8151818111156103275761032761027c565b604051601f8201601f19908116603f0116810190838211818310171561034f5761034f61027c565b816040528281528a602084870101111561036857600080fd5b610379836020830160208801610292565b979a9699509497505050505050565b60208152600082518060208401526103a7816040850160208701610292565b601f01601f19169190910160400192915050565b600082516103cd818460208701610292565b9190910192915050565b6000602082840312156103e957600080fd5b61025982610260565b60805160a05160c05160e051610427610446600039600081816101a801526102340152600061011d01526000818161015f015281816101fc015261028701526000818160bf015261026601526104276000f3fe6080604052600436106100745760003560e01c80635c60da1b1161004e5780635c60da1b146101815780639d76ea58146101965780639ded06df146101ca578063d4ae3c42146101e95761007b565b806309c6bed9146100ad578063129d81881461010b5780634fdf7cb51461014d5761007b565b3661007b57005b600061008561025f565b90503660008037600080366000845af43d6000803e8080156100a6573d6000f35b3d6000fd5b005b3480156100b957600080fd5b506100e17f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561011757600080fd5b5061013f7f000000000000000000000000000000000000000000000000000000000000000081565b604051908152602001610102565b34801561015957600080fd5b5061013f7f000000000000000000000000000000000000000000000000000000000000000081565b34801561018d57600080fd5b506100e161025f565b3480156101a257600080fd5b506100e17f000000000000000000000000000000000000000000000000000000000000000081565b3480156101d657600080fd5b506100ab6101e5366004610349565b5050565b3480156101f557600080fd5b50604080517f0000000000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016602082015201610102565b60006102ab7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006102b0565b905090565b6040517f7e151fa60000000000000000000000000000000000000000000000000000000081526004810182905260009073ffffffffffffffffffffffffffffffffffffffff841690637e151fa690602401602060405180830381865afa15801561031e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034291906103bb565b9392505050565b6000806020838503121561035c57600080fd5b823567ffffffffffffffff8082111561037457600080fd5b818501915085601f83011261038857600080fd5b81358181111561039757600080fd5b8660208285010111156103a957600080fd5b60209290920196919550909350505050565b6000602082840312156103cd57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461034257600080fdfea2646970667358221220d011ec6a9d8ff1de78334122dc7f461e39a52c3c3e3116b86bd148633a67d06664736f6c63430008150033000000000000000000000000b5fb4be02232b1bba4dc8f81dc24c26980de9e3c000000000000000000000000000000000000000000000000000000000000000074d201f11e295b7db51d7f653035f60f0fe762aadeed14993389c56952758cc40000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000400000000000000000000000009cd2c52541e49c4ecb07997e46bd43ba2dcf7ccb000000000000000000000000000000000000000000000000000000000000001483a93500d23fbc3e82b410ad07a6a9f7a0670d66000000000000000000000000
|
6080604052600436106100745760003560e01c80635c60da1b1161004e5780635c60da1b146101815780639d76ea58146101965780639ded06df146101ca578063d4ae3c42146101e95761007b565b806309c6bed9146100ad578063129d81881461010b5780634fdf7cb51461014d5761007b565b3661007b57005b600061008561025f565b90503660008037600080366000845af43d6000803e8080156100a6573d6000f35b3d6000fd5b005b3480156100b957600080fd5b506100e17f000000000000000000000000b5fb4be02232b1bba4dc8f81dc24c26980de9e3c81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020015b60405180910390f35b34801561011757600080fd5b5061013f7f74d201f11e295b7db51d7f653035f60f0fe762aadeed14993389c56952758cc481565b604051908152602001610102565b34801561015957600080fd5b5061013f7f000000000000000000000000000000000000000000000000000000000000000081565b34801561018d57600080fd5b506100e161025f565b3480156101a257600080fd5b506100e17f0000000000000000000000009cd2c52541e49c4ecb07997e46bd43ba2dcf7ccb81565b3480156101d657600080fd5b506100ab6101e5366004610349565b5050565b3480156101f557600080fd5b50604080517f0000000000000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000009cd2c52541e49c4ecb07997e46bd43ba2dcf7ccb16602082015201610102565b60006102ab7f000000000000000000000000b5fb4be02232b1bba4dc8f81dc24c26980de9e3c7f00000000000000000000000000000000000000000000000000000000000000006102b0565b905090565b6040517f7e151fa60000000000000000000000000000000000000000000000000000000081526004810182905260009073ffffffffffffffffffffffffffffffffffffffff841690637e151fa690602401602060405180830381865afa15801561031e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034291906103bb565b9392505050565b6000806020838503121561035c57600080fd5b823567ffffffffffffffff8082111561037457600080fd5b818501915085601f83011261038857600080fd5b81358181111561039757600080fd5b8660208285010111156103a957600080fd5b60209290920196919550909350505050565b6000602082840312156103cd57600080fd5b815173ffffffffffffffffffffffffffffffffffffffff8116811461034257600080fdfea2646970667358221220d011ec6a9d8ff1de78334122dc7f461e39a52c3c3e3116b86bd148633a67d06664736f6c63430008150033
|
{{
"language": "Solidity",
"sources": {
"@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IProxy.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n// General interface for upgradable contracts\ninterface IProxy {\n error InvalidOwner();\n error InvalidImplementation();\n error SetupFailed();\n error NotOwner();\n error AlreadyInitialized();\n\n function implementation() external view returns (address);\n\n function setup(bytes calldata setupParams) external;\n}\n"
},
"@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/BaseProxy.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IProxy } from '../interfaces/IProxy.sol';\n\n/**\n * @title BaseProxy Contract\n * @dev This abstract contract implements a basic proxy that stores an implementation address. Fallback function\n * calls are delegated to the implementation. This contract is meant to be inherited by other proxy contracts.\n */\nabstract contract BaseProxy is IProxy {\n // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n // keccak256('owner')\n bytes32 internal constant _OWNER_SLOT = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0;\n\n /**\n * @dev Returns the current implementation address.\n * @return implementation_ The address of the current implementation contract\n */\n function implementation() public view virtual returns (address implementation_) {\n assembly {\n implementation_ := sload(_IMPLEMENTATION_SLOT)\n }\n }\n\n /**\n * @dev Shadows the setup function of the implementation contract so it can't be called directly via the proxy.\n * @param params The setup parameters for the implementation contract.\n */\n function setup(bytes calldata params) external {}\n\n /**\n * @dev Returns the contract ID. It can be used as a check during upgrades. Meant to be implemented in derived contracts.\n * @return bytes32 The contract ID\n */\n function contractId() internal pure virtual returns (bytes32);\n\n /**\n * @dev Fallback function. Delegates the call to the current implementation contract.\n */\n fallback() external payable virtual {\n address implementation_ = implementation();\n assembly {\n calldatacopy(0, 0, calldatasize())\n\n let result := delegatecall(gas(), implementation_, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n\n switch result\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev Payable fallback function. Can be overridden in derived contracts.\n */\n receive() external payable virtual {}\n}\n"
},
"contracts/interfaces/IBaseTokenManager.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title IBaseTokenManager\n * @notice This contract is defines the base token manager interface implemented by all token managers.\n */\ninterface IBaseTokenManager {\n /**\n * @notice A function that returns the token id.\n */\n function interchainTokenId() external view returns (bytes32);\n\n /**\n * @notice A function that should return the address of the token.\n * Must be overridden in the inheriting contract.\n * @return address address of the token.\n */\n function tokenAddress() external view returns (address);\n\n /**\n * @notice A function that should return the token address from the init params.\n */\n function getTokenAddressFromParams(bytes calldata params) external pure returns (address);\n}\n"
},
"contracts/interfaces/ITokenManagerImplementation.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @title ITokenManagerImplementation Interface\n * @notice Interface for returning the token manager implementation type.\n */\ninterface ITokenManagerImplementation {\n /**\n * @notice Returns the implementation address for a given token manager type.\n * @param tokenManagerType The type of token manager.\n * @return tokenManagerAddress_ The address of the token manager implementation.\n */\n function tokenManagerImplementation(uint256 tokenManagerType) external view returns (address tokenManagerAddress_);\n}\n"
},
"contracts/interfaces/ITokenManagerProxy.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IProxy } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IProxy.sol';\n\n/**\n * @title ITokenManagerProxy Interface\n * @notice This interface is for a proxy for token manager contracts.\n */\ninterface ITokenManagerProxy is IProxy {\n error ZeroAddress();\n\n /**\n * @notice Returns implementation type of this token manager.\n * @return uint256 The implementation type of this token manager.\n */\n function implementationType() external view returns (uint256);\n\n /**\n * @notice Returns the interchain token ID of the token manager.\n * @return bytes32 The interchain token ID of the token manager.\n */\n function interchainTokenId() external view returns (bytes32);\n\n /**\n * @notice Returns token address that this token manager manages.\n * @return address The token address.\n */\n function tokenAddress() external view returns (address);\n\n /**\n * @notice Returns implementation type and token address.\n * @return uint256 The implementation type.\n * @return address The token address.\n */\n function getImplementationTypeAndTokenAddress() external view returns (uint256, address);\n}\n"
},
"contracts/proxies/TokenManagerProxy.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport { IProxy } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/interfaces/IProxy.sol';\nimport { BaseProxy } from '@axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/BaseProxy.sol';\n\nimport { IBaseTokenManager } from '../interfaces/IBaseTokenManager.sol';\nimport { ITokenManagerProxy } from '../interfaces/ITokenManagerProxy.sol';\nimport { ITokenManagerImplementation } from '../interfaces/ITokenManagerImplementation.sol';\n\n/**\n * @title TokenManagerProxy\n * @notice This contract is a proxy for token manager contracts.\n * @dev This contract implements BaseProxy and ITokenManagerProxy.\n */\ncontract TokenManagerProxy is BaseProxy, ITokenManagerProxy {\n bytes32 private constant CONTRACT_ID = keccak256('token-manager');\n\n address public immutable interchainTokenService;\n uint256 public immutable implementationType;\n bytes32 public immutable interchainTokenId;\n address public immutable tokenAddress;\n\n /**\n * @notice Constructs the TokenManagerProxy contract.\n * @param interchainTokenService_ The address of the interchain token service.\n * @param implementationType_ The token manager type.\n * @param tokenId The identifier for the token.\n * @param params The initialization parameters for the token manager contract.\n */\n constructor(address interchainTokenService_, uint256 implementationType_, bytes32 tokenId, bytes memory params) {\n if (interchainTokenService_ == address(0)) revert ZeroAddress();\n\n interchainTokenService = interchainTokenService_;\n implementationType = implementationType_;\n interchainTokenId = tokenId;\n\n address implementation_ = _tokenManagerImplementation(interchainTokenService_, implementationType_);\n if (implementation_ == address(0)) revert InvalidImplementation();\n\n (bool success, ) = implementation_.delegatecall(abi.encodeWithSelector(IProxy.setup.selector, params));\n if (!success) revert SetupFailed();\n\n tokenAddress = IBaseTokenManager(implementation_).getTokenAddressFromParams(params);\n }\n\n /**\n * @notice Getter for the contract id.\n * @return bytes32 The contract id.\n */\n function contractId() internal pure override returns (bytes32) {\n return CONTRACT_ID;\n }\n\n /**\n * @notice Returns implementation type and token address.\n * @return implementationType_ The implementation type.\n * @return tokenAddress_ The token address.\n */\n function getImplementationTypeAndTokenAddress() external view returns (uint256 implementationType_, address tokenAddress_) {\n implementationType_ = implementationType;\n tokenAddress_ = tokenAddress;\n }\n\n /**\n * @notice Returns the address of the current implementation.\n * @return implementation_ The address of the current implementation.\n */\n function implementation() public view override(BaseProxy, IProxy) returns (address implementation_) {\n implementation_ = _tokenManagerImplementation(interchainTokenService, implementationType);\n }\n\n /**\n * @notice Returns the implementation address from the interchain token service for the provided type.\n * @param interchainTokenService_ The address of the interchain token service.\n * @param implementationType_ The token manager type.\n * @return implementation_ The address of the implementation.\n */\n function _tokenManagerImplementation(\n address interchainTokenService_,\n uint256 implementationType_\n ) internal view returns (address implementation_) {\n implementation_ = ITokenManagerImplementation(interchainTokenService_).tokenManagerImplementation(implementationType_);\n }\n}\n"
}
},
"settings": {
"evmVersion": "london",
"optimizer": {
"enabled": true,
"runs": 1000,
"details": {
"peephole": true,
"inliner": true,
"jumpdestRemover": true,
"orderLiterals": true,
"deduplicate": true,
"cse": true,
"constantOptimizer": true,
"yul": true,
"yulDetails": {
"stackAllocation": true
}
}
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
|
1 | 19,498,707 |
76f17963ff84ff4982734febde9de4e149bd938493dd90df6a38210e2ca4078a
|
79a5f858aaac1f0404f61a85e2366373fba1338fbe9c6ce2215acfb3b99be44f
|
faf34daecf2f91417908f0550cde3eb027481ca5
|
faf34daecf2f91417908f0550cde3eb027481ca5
|
8a7c7b99d017209aed479c09e593d42968b608af
|
6080604052604051620011ec380380620011ec8339810160408190526200002691620004b2565b6200003133620001cd565b8651620000469060039060208a01906200033c565b5085516200005c9060049060208901906200033c565b506005805460ff191660ff87161790556200008a620000836000546001600160a01b031690565b856200021d565b600780546001600160a01b0319166001600160a01b0385169081179091556318e02bd9620000c06000546001600160a01b031690565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401600060405180830381600087803b1580156200010257600080fd5b505af115801562000117573d6000803e3d6000fd5b50506007805460ff60a01b1916600160a01b17905550309050620001436000546001600160a01b031690565b6001600160a01b03167f56358b41df5fa59f5639228f0930994cbdde383c8a8fd74e06c04e1deebe3562600180604051620001809291906200056b565b60405180910390a36040516001600160a01b0383169082156108fc029083906000818181858888f19350505050158015620001bf573d6000803e3d6000fd5b505050505050505062000610565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b038216620002785760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f206164647265737300604482015260640160405180910390fd5b62000294816006546200032760201b620005951790919060201c565b6006556001600160a01b038216600090815260016020908152604090912054620002c99183906200059562000327821b17901c565b6001600160a01b0383166000818152600160205260408082209390935591519091907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906200031b9085815260200190565b60405180910390a35050565b600062000335828462000598565b9392505050565b8280546200034a90620005bd565b90600052602060002090601f0160209004810192826200036e5760008555620003b9565b82601f106200038957805160ff1916838001178555620003b9565b82800160010185558215620003b9579182015b82811115620003b95782518255916020019190600101906200039c565b50620003c7929150620003cb565b5090565b5b80821115620003c75760008155600101620003cc565b80516001600160a01b0381168114620003fa57600080fd5b919050565b600082601f83011262000410578081fd5b81516001600160401b03808211156200042d576200042d620005fa565b604051601f8301601f19908116603f01168101908282118183101715620004585762000458620005fa565b8160405283815260209250868385880101111562000474578485fd5b8491505b8382101562000497578582018301518183018401529082019062000478565b83821115620004a857848385830101525b9695505050505050565b600080600080600080600060e0888a031215620004cd578283fd5b87516001600160401b0380821115620004e4578485fd5b620004f28b838c01620003ff565b985060208a015191508082111562000508578485fd5b50620005178a828b01620003ff565b965050604088015160ff811681146200052e578384fd5b606089015190955093506200054660808901620003e2565b92506200055660a08901620003e2565b915060c0880151905092959891949750929550565b60408101600884106200058e57634e487b7160e01b600052602160045260246000fd5b9281526020015290565b60008219821115620005b857634e487b7160e01b81526011600452602481fd5b500190565b600181811c90821680620005d257607f821691505b60208210811415620005f457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b610bcc80620006206000396000f3fe608060405234801561001057600080fd5b50600436106101165760003560e01c806370a08231116100a2578063a457c2d711610071578063a457c2d714610247578063a9059cbb1461025a578063dd62ed3e1461026d578063f2fde38b146102a6578063ffa1ad74146102b957600080fd5b806370a08231146101fd578063715018a6146102265780638da5cb5b1461022e57806395d89b411461023f57600080fd5b806323b872dd116100e957806323b872dd14610183578063241ec3be14610196578063313ce567146101aa57806339509351146101bf578063407133d2146101d257600080fd5b806306fdde031461011b578063095ea7b31461013957806318160ddd1461015c5780631f46b1c61461016e575b600080fd5b6101236102c1565b6040516101309190610a3c565b60405180910390f35b61014c6101473660046109f3565b610353565b6040519015158152602001610130565b6006545b604051908152602001610130565b61018161017c366004610a1c565b610369565b005b61014c6101913660046109b8565b6103ba565b60075461014c90600160a01b900460ff1681565b60055460405160ff9091168152602001610130565b61014c6101cd3660046109f3565b610423565b6007546101e5906001600160a01b031681565b6040516001600160a01b039091168152602001610130565b61016061020b36600461096c565b6001600160a01b031660009081526001602052604090205490565b610181610459565b6000546001600160a01b03166101e5565b61012361048f565b61014c6102553660046109f3565b61049e565b61014c6102683660046109f3565b6104ed565b61016061027b366004610986565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6101816102b436600461096c565b6104fa565b610160600181565b6060600380546102d090610ae8565b80601f01602080910402602001604051908101604052809291908181526020018280546102fc90610ae8565b80156103495780601f1061031e57610100808354040283529160200191610349565b820191906000526020600020905b81548152906001019060200180831161032c57829003601f168201915b5050505050905090565b60006103603384846105a8565b50600192915050565b6000546001600160a01b0316331461039c5760405162461bcd60e51b815260040161039390610a8f565b60405180910390fd5b60078054911515600160a01b0260ff60a01b19909216919091179055565b60006103c78484846106cd565b610419843361041485604051806060016040528060288152602001610b4a602891396001600160a01b038a16600090815260026020908152604080832033845290915290205491906108d4565b6105a8565b5060019392505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490916103609185906104149086610595565b6000546001600160a01b031633146104835760405162461bcd60e51b815260040161039390610a8f565b61048d6000610900565b565b6060600480546102d090610ae8565b6000610360338461041485604051806060016040528060258152602001610b72602591393360009081526002602090815260408083206001600160a01b038d16845290915290205491906108d4565b60006103603384846106cd565b6000546001600160a01b031633146105245760405162461bcd60e51b815260040161039390610a8f565b6001600160a01b0381166105895760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610393565b61059281610900565b50565b60006105a18284610ac4565b9392505050565b6001600160a01b03831661060a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610393565b6001600160a01b03821661066b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610393565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166107315760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610393565b6001600160a01b0382166107935760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610393565b600754600160a01b900460ff16156108145760075460405163090ec10b60e31b81526001600160a01b03858116600483015284811660248301526044820184905290911690634876085890606401600060405180830381600087803b1580156107fb57600080fd5b505af115801561080f573d6000803e3d6000fd5b505050505b61085181604051806060016040528060268152602001610b24602691396001600160a01b03861660009081526001602052604090205491906108d4565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546108809082610595565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906106c09085815260200190565b600081848411156108f85760405162461bcd60e51b81526004016103939190610a3c565b505050900390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461096757600080fd5b919050565b60006020828403121561097d578081fd5b6105a182610950565b60008060408385031215610998578081fd5b6109a183610950565b91506109af60208401610950565b90509250929050565b6000806000606084860312156109cc578081fd5b6109d584610950565b92506109e360208501610950565b9150604084013590509250925092565b60008060408385031215610a05578182fd5b610a0e83610950565b946020939093013593505050565b600060208284031215610a2d578081fd5b813580151581146105a1578182fd5b6000602080835283518082850152825b81811015610a6857858101830151858201604001528201610a4c565b81811115610a795783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610ae357634e487b7160e01b81526011600452602481fd5b500190565b600181811c90821680610afc57607f821691505b60208210811415610b1d57634e487b7160e01b600052602260045260246000fd5b5091905056fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220a315ed57d3f9b893d48f5e4b53c7434cc9edcf752c48558caa894249076b0dcc64736f6c6343000804003300000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000084595161401484a000000000000000000000000000000f4f071eb637b64fc78c9ea87dace4445d119ca350000000000000000000000004b04213c2774f77e60702880654206b116d00508000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000000005476f6c656d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005474f4c454d000000000000000000000000000000000000000000000000000000
|
608060405234801561001057600080fd5b50600436106101165760003560e01c806370a08231116100a2578063a457c2d711610071578063a457c2d714610247578063a9059cbb1461025a578063dd62ed3e1461026d578063f2fde38b146102a6578063ffa1ad74146102b957600080fd5b806370a08231146101fd578063715018a6146102265780638da5cb5b1461022e57806395d89b411461023f57600080fd5b806323b872dd116100e957806323b872dd14610183578063241ec3be14610196578063313ce567146101aa57806339509351146101bf578063407133d2146101d257600080fd5b806306fdde031461011b578063095ea7b31461013957806318160ddd1461015c5780631f46b1c61461016e575b600080fd5b6101236102c1565b6040516101309190610a3c565b60405180910390f35b61014c6101473660046109f3565b610353565b6040519015158152602001610130565b6006545b604051908152602001610130565b61018161017c366004610a1c565b610369565b005b61014c6101913660046109b8565b6103ba565b60075461014c90600160a01b900460ff1681565b60055460405160ff9091168152602001610130565b61014c6101cd3660046109f3565b610423565b6007546101e5906001600160a01b031681565b6040516001600160a01b039091168152602001610130565b61016061020b36600461096c565b6001600160a01b031660009081526001602052604090205490565b610181610459565b6000546001600160a01b03166101e5565b61012361048f565b61014c6102553660046109f3565b61049e565b61014c6102683660046109f3565b6104ed565b61016061027b366004610986565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6101816102b436600461096c565b6104fa565b610160600181565b6060600380546102d090610ae8565b80601f01602080910402602001604051908101604052809291908181526020018280546102fc90610ae8565b80156103495780601f1061031e57610100808354040283529160200191610349565b820191906000526020600020905b81548152906001019060200180831161032c57829003601f168201915b5050505050905090565b60006103603384846105a8565b50600192915050565b6000546001600160a01b0316331461039c5760405162461bcd60e51b815260040161039390610a8f565b60405180910390fd5b60078054911515600160a01b0260ff60a01b19909216919091179055565b60006103c78484846106cd565b610419843361041485604051806060016040528060288152602001610b4a602891396001600160a01b038a16600090815260026020908152604080832033845290915290205491906108d4565b6105a8565b5060019392505050565b3360008181526002602090815260408083206001600160a01b038716845290915281205490916103609185906104149086610595565b6000546001600160a01b031633146104835760405162461bcd60e51b815260040161039390610a8f565b61048d6000610900565b565b6060600480546102d090610ae8565b6000610360338461041485604051806060016040528060258152602001610b72602591393360009081526002602090815260408083206001600160a01b038d16845290915290205491906108d4565b60006103603384846106cd565b6000546001600160a01b031633146105245760405162461bcd60e51b815260040161039390610a8f565b6001600160a01b0381166105895760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610393565b61059281610900565b50565b60006105a18284610ac4565b9392505050565b6001600160a01b03831661060a5760405162461bcd60e51b8152602060048201526024808201527f45524332303a20617070726f76652066726f6d20746865207a65726f206164646044820152637265737360e01b6064820152608401610393565b6001600160a01b03821661066b5760405162461bcd60e51b815260206004820152602260248201527f45524332303a20617070726f766520746f20746865207a65726f206164647265604482015261737360f01b6064820152608401610393565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0383166107315760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b6064820152608401610393565b6001600160a01b0382166107935760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b6064820152608401610393565b600754600160a01b900460ff16156108145760075460405163090ec10b60e31b81526001600160a01b03858116600483015284811660248301526044820184905290911690634876085890606401600060405180830381600087803b1580156107fb57600080fd5b505af115801561080f573d6000803e3d6000fd5b505050505b61085181604051806060016040528060268152602001610b24602691396001600160a01b03861660009081526001602052604090205491906108d4565b6001600160a01b0380851660009081526001602052604080822093909355908416815220546108809082610595565b6001600160a01b0380841660008181526001602052604090819020939093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef906106c09085815260200190565b600081848411156108f85760405162461bcd60e51b81526004016103939190610a3c565b505050900390565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80356001600160a01b038116811461096757600080fd5b919050565b60006020828403121561097d578081fd5b6105a182610950565b60008060408385031215610998578081fd5b6109a183610950565b91506109af60208401610950565b90509250929050565b6000806000606084860312156109cc578081fd5b6109d584610950565b92506109e360208501610950565b9150604084013590509250925092565b60008060408385031215610a05578182fd5b610a0e83610950565b946020939093013593505050565b600060208284031215610a2d578081fd5b813580151581146105a1578182fd5b6000602080835283518082850152825b81811015610a6857858101830151858201604001528201610a4c565b81811115610a795783604083870101525b50601f01601f1916929092016040019392505050565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60008219821115610ae357634e487b7160e01b81526011600452602481fd5b500190565b600181811c90821680610afc57607f821691505b60208210811415610b1d57634e487b7160e01b600052602260045260246000fd5b5091905056fe45524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa2646970667358221220a315ed57d3f9b893d48f5e4b53c7434cc9edcf752c48558caa894249076b0dcc64736f6c63430008040033
|
/**
*Submitted for verification at BscScan.com on 2021-11-21
*/
// Dependency file: @openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// Dependency file: @openzeppelin/contracts/utils/Context.sol
// pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// Dependency file: @openzeppelin/contracts/access/Ownable.sol
// pragma solidity ^0.8.0;
// import "@openzeppelin/contracts/utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// Dependency file: @openzeppelin/contracts/utils/math/SafeMath.sol
// pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// Dependency file: contracts/interfaces/IPinkAntiBot.sol
// pragma solidity >=0.5.0;
interface IPinkAntiBot {
function setTokenOwner(address owner) external;
function onPreTransferCheck(
address from,
address to,
uint256 amount
) external;
}
// Dependency file: contracts/BaseToken.sol
// pragma solidity =0.8.4;
enum TokenType {
standard,
antiBotStandard,
liquidityGenerator,
antiBotLiquidityGenerator,
baby,
antiBotBaby,
buybackBaby,
antiBotBuybackBaby
}
abstract contract BaseToken {
event TokenCreated(
address indexed owner,
address indexed token,
TokenType tokenType,
uint256 version
);
}
// Root file: contracts/standard/AntiBotStandardToken.sol
pragma solidity =0.8.4;
// import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// import "@openzeppelin/contracts/access/Ownable.sol";
// import "@openzeppelin/contracts/utils/math/SafeMath.sol";
// import "contracts/interfaces/IPinkAntiBot.sol";
// import "contracts/BaseToken.sol";
contract AntiBotStandardToken is IERC20, Ownable, BaseToken {
using SafeMath for uint256;
uint256 public constant VERSION = 1;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
string private _name;
string private _symbol;
uint8 private _decimals;
uint256 private _totalSupply;
IPinkAntiBot public pinkAntiBot;
bool public enableAntiBot;
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_,
uint256 totalSupply_,
address pinkAntiBot_,
address serviceFeeReceiver_,
uint256 serviceFee_
) payable {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
_mint(owner(), totalSupply_);
pinkAntiBot = IPinkAntiBot(pinkAntiBot_);
pinkAntiBot.setTokenOwner(owner());
enableAntiBot = true;
emit TokenCreated(
owner(),
address(this),
TokenType.antiBotStandard,
VERSION
);
payable(serviceFeeReceiver_).transfer(serviceFee_);
}
function setEnableAntiBot(bool _enable) external onlyOwner {
enableAntiBot = _enable;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account)
public
view
virtual
override
returns (uint256)
{
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount)
public
virtual
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender)
public
view
virtual
override
returns (uint256)
{
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount)
public
virtual
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].add(addedValue)
);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
"ERC20: decreased allowance below zero"
)
);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
if (enableAntiBot) {
pinkAntiBot.onPreTransferCheck(sender, recipient, amount);
}
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(
amount,
"ERC20: transfer amount exceeds balance"
);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(
amount,
"ERC20: burn amount exceeds balance"
);
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal virtual {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
|
1 | 19,498,707 |
76f17963ff84ff4982734febde9de4e149bd938493dd90df6a38210e2ca4078a
|
f7d44678282087a5f84d108e125e7e2c1a78b165447f01e297ff13683e0a6dd6
|
719094baab565c1557ace8ca68c259d3b1a50362
|
719094baab565c1557ace8ca68c259d3b1a50362
|
5faeae81eda073f365d0592b76376651f6fad75a
|
61018b80600a3d393df360806040523363719094ba5f526bab565c1557ace8ca68c259d360a01b60205263b1a5036260e01b602c5260105114610052573273719094baab565c1557ace8ca68c259d3b1a50362146101055760075ffd5b630902f1ac5f52600560405f60045f73c5be99a02c6857f9eac67bbce58df5572498f40c5afa610188575063022c0d9f60e01c5f52306060526080608052602060a05260205160c05260035f5f60c4601c5f73c5be99a02c6857f9eac67bbce58df5572498f40c5af1610188575063a3a7e7f35f5273719094baab565c1557ace8ca68c259d3b1a5036260045260065f5f60245f5f73d46ba6d942050d489dbd938a2c909a5d5039a1615af16101885750005b63af14052c5f5260025f5f60045f5f736fb00a180781e75f87e2b690af0196baa77c7e7c5af1610188575063a9059cbb5f5273c5be99a02c6857f9eac67bbce58df5572498f40c600452604435806003026103e5900460010101602452600a5f5f60445f5f73d46ba6d942050d489dbd938a2c909a5d5039a1615af16101885750005b5ffd
|
60806040523363719094ba5f526bab565c1557ace8ca68c259d360a01b60205263b1a5036260e01b602c5260105114610052573273719094baab565c1557ace8ca68c259d3b1a50362146101055760075ffd5b630902f1ac5f52600560405f60045f73c5be99a02c6857f9eac67bbce58df5572498f40c5afa610188575063022c0d9f60e01c5f52306060526080608052602060a05260205160c05260035f5f60c4601c5f73c5be99a02c6857f9eac67bbce58df5572498f40c5af1610188575063a3a7e7f35f5273719094baab565c1557ace8ca68c259d3b1a5036260045260065f5f60245f5f73d46ba6d942050d489dbd938a2c909a5d5039a1615af16101885750005b63af14052c5f5260025f5f60045f5f736fb00a180781e75f87e2b690af0196baa77c7e7c5af1610188575063a9059cbb5f5273c5be99a02c6857f9eac67bbce58df5572498f40c600452604435806003026103e5900460010101602452600a5f5f60445f5f73d46ba6d942050d489dbd938a2c909a5d5039a1615af16101885750005b5ffd
| |
1 | 19,498,707 |
76f17963ff84ff4982734febde9de4e149bd938493dd90df6a38210e2ca4078a
|
437616f3eef9dfd18c24c7ff482fead68ca5174da24f321428932646b3700909
|
7e2bec4341f319749cb28d3b484d21954c96db5f
|
000000f20032b9e171844b00ea507e11960bd94a
|
6d21cdc7e6e260997b9ca31ef3b6a0bf4119198e
|
3d602d80600a3d3981f3363d3d373d3d3d363d730d223d05e1cc4ac20de7fce86bc9bb8efb56f4d45af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d730d223d05e1cc4ac20de7fce86bc9bb8efb56f4d45af43d82803e903d91602b57fd5bf3
|
{{
"language": "Solidity",
"sources": {
"src/clones/ERC1155SeaDropCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ERC1155SeaDropContractOffererCloneable\n} from \"./ERC1155SeaDropContractOffererCloneable.sol\";\n\n/**\n * @title ERC1155SeaDropCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable ERC1155 token contract that can mint as a\n * Seaport contract offerer.\n */\ncontract ERC1155SeaDropCloneable is ERC1155SeaDropContractOffererCloneable {\n /**\n * @notice Initialize the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * implementation code. Also contains SeaDrop\n * implementation code.\n * @param allowedSeaport The address of the Seaport contract allowed to\n * interact.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function initialize(\n address allowedConfigurer,\n address allowedSeaport,\n string memory name_,\n string memory symbol_,\n address initialOwner\n ) public initializer {\n // Initialize ownership.\n _initializeOwner(initialOwner);\n\n // Initialize ERC1155SeaDropContractOffererCloneable.\n __ERC1155SeaDropContractOffererCloneable_init(\n allowedConfigurer,\n allowedSeaport,\n name_,\n symbol_\n );\n }\n\n /**\n * @dev Auto-approve the conduit after mint or transfer.\n *\n * @custom:param from The address to transfer from.\n * @param to The address to transfer to.\n * @custom:param ids The token ids to transfer.\n * @custom:param amounts The quantities to transfer.\n * @custom:param data The data to pass if receiver is a contract.\n */\n function _afterTokenTransfer(\n address /* from */,\n address to,\n uint256[] memory /* ids */,\n uint256[] memory /* amounts */,\n bytes memory /* data */\n ) internal virtual override {\n // Auto-approve the conduit.\n if (to != address(0) && !isApprovedForAll(to, _CONDUIT)) {\n _setApprovalForAll(to, _CONDUIT, true);\n }\n }\n\n /**\n * @dev Override this function to return true if `_afterTokenTransfer` is\n * used. The is to help the compiler avoid producing dead bytecode.\n */\n function _useAfterTokenTransfer()\n internal\n view\n virtual\n override\n returns (bool)\n {\n return true;\n }\n\n /**\n * @notice Burns a token, restricted to the owner or approved operator,\n * and must have sufficient balance.\n *\n * @param from The address to burn from.\n * @param id The token id to burn.\n * @param amount The amount to burn.\n */\n function burn(address from, uint256 id, uint256 amount) external {\n // Burn the token.\n _burn(msg.sender, from, id, amount);\n }\n\n /**\n * @notice Burns a batch of tokens, restricted to the owner or\n * approved operator, and must have sufficient balance.\n *\n * @param from The address to burn from.\n * @param ids The token ids to burn.\n * @param amounts The amounts to burn per token id.\n */\n function batchBurn(\n address from,\n uint256[] calldata ids,\n uint256[] calldata amounts\n ) external {\n // Burn the tokens.\n _batchBurn(msg.sender, from, ids, amounts);\n }\n}\n"
},
"src/clones/ERC1155SeaDropContractOffererCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { IERC1155SeaDrop } from \"../interfaces/IERC1155SeaDrop.sol\";\n\nimport { ISeaDropToken } from \"../interfaces/ISeaDropToken.sol\";\n\nimport {\n ERC1155ContractMetadataCloneable\n} from \"./ERC1155ContractMetadataCloneable.sol\";\n\nimport {\n ERC1155SeaDropContractOffererStorage\n} from \"../lib/ERC1155SeaDropContractOffererStorage.sol\";\n\nimport {\n ERC1155SeaDropErrorsAndEvents\n} from \"../lib/ERC1155SeaDropErrorsAndEvents.sol\";\n\nimport { PublicDrop } from \"../lib//ERC1155SeaDropStructs.sol\";\n\nimport { AllowListData } from \"../lib/SeaDropStructs.sol\";\n\nimport {\n ERC1155ConduitPreapproved\n} from \"../lib/ERC1155ConduitPreapproved.sol\";\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\nimport { SpentItem } from \"seaport-types/src/lib/ConsiderationStructs.sol\";\n\nimport {\n ContractOffererInterface\n} from \"seaport-types/src/interfaces/ContractOffererInterface.sol\";\n\nimport {\n IERC165\n} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @title ERC1155SeaDropContractOffererCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable ERC1155 token contract that can mint as a\n * Seaport contract offerer.\n */\ncontract ERC1155SeaDropContractOffererCloneable is\n ERC1155ContractMetadataCloneable,\n ERC1155SeaDropErrorsAndEvents\n{\n using ERC1155SeaDropContractOffererStorage for ERC1155SeaDropContractOffererStorage.Layout;\n\n /**\n * @notice Initialize the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * configure parameters. Also contains SeaDrop\n * implementation code.\n * @param allowedSeaport The address of the Seaport contract allowed to\n * interact.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function __ERC1155SeaDropContractOffererCloneable_init(\n address allowedConfigurer,\n address allowedSeaport,\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n // Set the allowed Seaport to interact with this contract.\n if (allowedSeaport == address(0)) {\n revert AllowedSeaportCannotBeZeroAddress();\n }\n ERC1155SeaDropContractOffererStorage.layout()._allowedSeaport[\n allowedSeaport\n ] = true;\n\n // Set the allowed Seaport enumeration.\n address[] memory enumeratedAllowedSeaport = new address[](1);\n enumeratedAllowedSeaport[0] = allowedSeaport;\n ERC1155SeaDropContractOffererStorage\n .layout()\n ._enumeratedAllowedSeaport = enumeratedAllowedSeaport;\n\n // Emit an event noting the contract deployment.\n emit SeaDropTokenDeployed(SEADROP_TOKEN_TYPE.ERC1155_CLONE);\n\n // Initialize ERC1155ContractMetadataCloneable.\n __ERC1155ContractMetadataCloneable_init(\n allowedConfigurer,\n name_,\n symbol_\n );\n }\n\n /**\n * @notice The fallback function is used as a dispatcher for SeaDrop\n * methods.\n */\n fallback(bytes calldata) external returns (bytes memory output) {\n // Get the function selector.\n bytes4 selector = msg.sig;\n\n // Get the rest of the msg data after the selector.\n bytes calldata data = msg.data[4:];\n\n // Determine if we should forward the call to the implementation\n // contract with SeaDrop logic.\n bool callSeaDropImplementation = selector ==\n ISeaDropToken.updateAllowedSeaport.selector ||\n selector == ISeaDropToken.updateDropURI.selector ||\n selector == ISeaDropToken.updateAllowList.selector ||\n selector == ISeaDropToken.updateCreatorPayouts.selector ||\n selector == ISeaDropToken.updatePayer.selector ||\n selector == ISeaDropToken.updateAllowedFeeRecipient.selector ||\n selector == ISeaDropToken.updateSigner.selector ||\n selector == IERC1155SeaDrop.updatePublicDrop.selector ||\n selector == ContractOffererInterface.previewOrder.selector ||\n selector == ContractOffererInterface.generateOrder.selector ||\n selector == ContractOffererInterface.getSeaportMetadata.selector ||\n selector == IERC1155SeaDrop.getPublicDrop.selector ||\n selector == IERC1155SeaDrop.getPublicDropIndexes.selector ||\n selector == ISeaDropToken.getAllowedSeaport.selector ||\n selector == ISeaDropToken.getCreatorPayouts.selector ||\n selector == ISeaDropToken.getAllowListMerkleRoot.selector ||\n selector == ISeaDropToken.getAllowedFeeRecipients.selector ||\n selector == ISeaDropToken.getSigners.selector ||\n selector == ISeaDropToken.getDigestIsUsed.selector ||\n selector == ISeaDropToken.getPayers.selector;\n\n // Determine if we should require only the owner or configurer calling.\n bool requireOnlyOwnerOrConfigurer = selector ==\n ISeaDropToken.updateAllowedSeaport.selector ||\n selector == ISeaDropToken.updateDropURI.selector ||\n selector == ISeaDropToken.updateAllowList.selector ||\n selector == ISeaDropToken.updateCreatorPayouts.selector ||\n selector == ISeaDropToken.updatePayer.selector ||\n selector == ISeaDropToken.updateAllowedFeeRecipient.selector ||\n selector == IERC1155SeaDrop.updatePublicDrop.selector;\n\n if (callSeaDropImplementation) {\n // For update calls, ensure the sender is only the owner\n // or configurer contract.\n if (requireOnlyOwnerOrConfigurer) {\n _onlyOwnerOrConfigurer();\n } else if (selector == ISeaDropToken.updateSigner.selector) {\n // For updateSigner, a signer can disallow themselves.\n // Get the signer parameter.\n address signer = address(bytes20(data[12:32]));\n // If the signer is not allowed, ensure sender is only owner\n // or configurer.\n if (\n msg.sender != signer ||\n (msg.sender == signer &&\n !ERC1155SeaDropContractOffererStorage\n .layout()\n ._allowedSigners[signer])\n ) {\n _onlyOwnerOrConfigurer();\n }\n }\n\n // Forward the call to the implementation contract.\n (bool success, bytes memory returnedData) = _CONFIGURER\n .delegatecall(msg.data);\n\n // Require that the call was successful.\n if (!success) {\n // Bubble up the revert reason.\n assembly {\n revert(add(32, returnedData), mload(returnedData))\n }\n }\n\n // If the call was to generateOrder, mint the tokens.\n if (selector == ContractOffererInterface.generateOrder.selector) {\n _mintOrder(data);\n }\n\n // Return the data from the delegate call.\n return returnedData;\n } else if (selector == IERC1155SeaDrop.getMintStats.selector) {\n // Get the minter and token id.\n (address minter, uint256 tokenId) = abi.decode(\n data,\n (address, uint256)\n );\n\n // Get the mint stats.\n (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n ) = _getMintStats(minter, tokenId);\n\n // Encode the return data.\n return\n abi.encode(\n minterNumMinted,\n minterNumMintedForTokenId,\n totalMintedForTokenId,\n maxSupply\n );\n } else if (selector == ContractOffererInterface.ratifyOrder.selector) {\n // This function is a no-op, nothing additional needs to happen here.\n // Utilize assembly to efficiently return the ratifyOrder magic value.\n assembly {\n mstore(0, 0xf4dd92ce)\n return(0x1c, 32)\n }\n } else if (selector == ISeaDropToken.configurer.selector) {\n // Return the configurer contract.\n return abi.encode(_CONFIGURER);\n } else if (selector == IERC1155SeaDrop.multiConfigureMint.selector) {\n // Ensure only the owner or configurer can call this function.\n _onlyOwnerOrConfigurer();\n\n // Mint the tokens.\n _multiConfigureMint(data);\n } else {\n // Revert if the function selector is not supported.\n revert UnsupportedFunctionSelector(selector);\n }\n }\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists in enforcing maxSupply, maxTotalMintableByWallet,\n * and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC1155Received() hooks.\n *\n * @param minter The minter address.\n * @param tokenId The token id to return the stats for.\n */\n function _getMintStats(\n address minter,\n uint256 tokenId\n )\n internal\n view\n returns (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n )\n {\n // Put the token supply on the stack.\n TokenSupply storage tokenSupply = _tokenSupply[tokenId];\n\n // Assign the return values.\n totalMintedForTokenId = tokenSupply.totalMinted;\n maxSupply = tokenSupply.maxSupply;\n minterNumMinted = _totalMintedByUser[minter];\n minterNumMintedForTokenId = _totalMintedByUserPerToken[minter][tokenId];\n }\n\n /**\n * @dev Handle ERC-1155 safeTransferFrom. If \"from\" is this contract,\n * the sender can only be Seaport or the conduit.\n *\n * @param from The address to transfer from.\n * @param to The address to transfer to.\n * @param id The token id to transfer.\n * @param amount The amount of tokens to transfer.\n * @param data The data to pass to the onERC1155Received hook.\n */\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual override {\n if (from == address(this)) {\n // Only Seaport or the conduit can use this function\n // when \"from\" is this contract.\n if (\n msg.sender != _CONDUIT &&\n !ERC1155SeaDropContractOffererStorage.layout()._allowedSeaport[\n msg.sender\n ]\n ) {\n revert InvalidCallerOnlyAllowedSeaport(msg.sender);\n }\n return;\n }\n\n ERC1155._safeTransfer(_by(), from, to, id, amount, data);\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(\n bytes4 interfaceId\n )\n public\n view\n virtual\n override(ERC1155ContractMetadataCloneable)\n returns (bool)\n {\n return\n interfaceId == type(IERC1155SeaDrop).interfaceId ||\n interfaceId == type(ContractOffererInterface).interfaceId ||\n interfaceId == 0x2e778efc || // SIP-5 (getSeaportMetadata)\n // ERC1155ContractMetadata returns supportsInterface true for\n // IERC1155ContractMetadata, ERC-4906, ERC-2981\n // ERC1155A returns supportsInterface true for\n // ERC165, ERC1155, ERC1155MetadataURI\n ERC1155ContractMetadataCloneable.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Internal function to mint tokens during a generateOrder call\n * from Seaport.\n *\n * @param data The original transaction calldata, without the selector.\n */\n function _mintOrder(bytes calldata data) internal {\n // Decode fulfiller, minimumReceived, and context from calldata.\n (\n address fulfiller,\n SpentItem[] memory minimumReceived,\n ,\n bytes memory context\n ) = abi.decode(data, (address, SpentItem[], SpentItem[], bytes));\n\n // Assign the minter from context[22:42]. We validate context has the\n // correct minimum length in the implementation's `_decodeOrder`.\n address minter;\n assembly {\n minter := shr(96, mload(add(add(context, 0x20), 22)))\n }\n\n // If the minter is the zero address, set it to the fulfiller.\n if (minter == address(0)) {\n minter = fulfiller;\n }\n\n // Set the token ids and quantities.\n uint256 minimumReceivedLength = minimumReceived.length;\n uint256[] memory tokenIds = new uint256[](minimumReceivedLength);\n uint256[] memory quantities = new uint256[](minimumReceivedLength);\n for (uint256 i = 0; i < minimumReceivedLength; ) {\n tokenIds[i] = minimumReceived[i].identifier;\n quantities[i] = minimumReceived[i].amount;\n unchecked {\n ++i;\n }\n }\n\n // Mint the tokens.\n _batchMint(minter, tokenIds, quantities, \"\");\n }\n\n /**\n * @dev Internal function to mint tokens during a multiConfigureMint call\n * from the configurer contract.\n *\n * @param data The original transaction calldata, without the selector.\n */\n function _multiConfigureMint(bytes calldata data) internal {\n // Decode the calldata.\n (\n address recipient,\n uint256[] memory tokenIds,\n uint256[] memory amounts\n ) = abi.decode(data, (address, uint256[], uint256[]));\n\n _batchMint(recipient, tokenIds, amounts, \"\");\n }\n}\n"
},
"src/interfaces/IERC1155SeaDrop.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { ISeaDropToken } from \"./ISeaDropToken.sol\";\n\nimport { PublicDrop } from \"../lib/ERC1155SeaDropStructs.sol\";\n\n/**\n * @dev A helper interface to get and set parameters for ERC1155SeaDrop.\n * The token does not expose these methods as part of its external\n * interface to optimize contract size, but does implement them.\n */\ninterface IERC1155SeaDrop is ISeaDropToken {\n /**\n * @notice Update the SeaDrop public drop parameters at a given index.\n *\n * @param publicDrop The new public drop parameters.\n * @param index The public drop index.\n */\n function updatePublicDrop(\n PublicDrop calldata publicDrop,\n uint256 index\n ) external;\n\n /**\n * @notice Returns the public drop stage parameters at a given index.\n *\n * @param index The index of the public drop stage.\n */\n function getPublicDrop(\n uint256 index\n ) external view returns (PublicDrop memory);\n\n /**\n * @notice Returns the public drop indexes.\n */\n function getPublicDropIndexes() external view returns (uint256[] memory);\n\n /**\n * @notice Returns a set of mint stats for the address.\n * This assists SeaDrop in enforcing maxSupply,\n * maxTotalMintableByWallet, maxTotalMintableByWalletPerToken,\n * and maxTokenSupplyForStage checks.\n *\n * @dev NOTE: Implementing contracts should always update these numbers\n * before transferring any tokens with _safeMint() to mitigate\n * consequences of malicious onERC1155Received() hooks.\n *\n * @param minter The minter address.\n * @param tokenId The token id to return stats for.\n */\n function getMintStats(\n address minter,\n uint256 tokenId\n )\n external\n view\n returns (\n uint256 minterNumMinted,\n uint256 minterNumMintedForTokenId,\n uint256 totalMintedForTokenId,\n uint256 maxSupply\n );\n\n /**\n * @notice This function is only allowed to be called by the configurer\n * contract as a way to batch mints and configuration in one tx.\n *\n * @param recipient The address to receive the mints.\n * @param tokenIds The tokenIds to mint.\n * @param amounts The amounts to mint.\n */\n function multiConfigureMint(\n address recipient,\n uint256[] calldata tokenIds,\n uint256[] calldata amounts\n ) external;\n}\n"
},
"src/interfaces/ISeaDropToken.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\nimport { AllowListData, CreatorPayout } from \"../lib/SeaDropStructs.sol\";\n\n/**\n * @dev A helper base interface for IERC721SeaDrop and IERC1155SeaDrop.\n * The token does not expose these methods as part of its external\n * interface to optimize contract size, but does implement them.\n */\ninterface ISeaDropToken is ISeaDropTokenContractMetadata {\n /**\n * @notice Update the SeaDrop allowed Seaport contracts privileged to mint.\n * Only the owner can use this function.\n *\n * @param allowedSeaport The allowed Seaport addresses.\n */\n function updateAllowedSeaport(address[] calldata allowedSeaport) external;\n\n /**\n * @notice Update the SeaDrop allowed fee recipient.\n * Only the owner can use this function.\n *\n * @param feeRecipient The new fee recipient.\n * @param allowed Whether the fee recipient is allowed.\n */\n function updateAllowedFeeRecipient(\n address feeRecipient,\n bool allowed\n ) external;\n\n /**\n * @notice Update the SeaDrop creator payout addresses.\n * The total basis points must add up to exactly 10_000.\n * Only the owner can use this function.\n *\n * @param creatorPayouts The new creator payouts.\n */\n function updateCreatorPayouts(\n CreatorPayout[] calldata creatorPayouts\n ) external;\n\n /**\n * @notice Update the SeaDrop drop URI.\n * Only the owner can use this function.\n *\n * @param dropURI The new drop URI.\n */\n function updateDropURI(string calldata dropURI) external;\n\n /**\n * @notice Update the SeaDrop allow list data.\n * Only the owner can use this function.\n *\n * @param allowListData The new allow list data.\n */\n function updateAllowList(AllowListData calldata allowListData) external;\n\n /**\n * @notice Update the SeaDrop allowed payers.\n * Only the owner can use this function.\n *\n * @param payer The payer to update.\n * @param allowed Whether the payer is allowed.\n */\n function updatePayer(address payer, bool allowed) external;\n\n /**\n * @notice Update the SeaDrop allowed signer.\n * Only the owner can use this function.\n * An allowed signer can also disallow themselves.\n *\n * @param signer The signer to update.\n * @param allowed Whether the signer is allowed.\n */\n function updateSigner(address signer, bool allowed) external;\n\n /**\n * @notice Get the SeaDrop allowed Seaport contracts privileged to mint.\n */\n function getAllowedSeaport() external view returns (address[] memory);\n\n /**\n * @notice Returns the SeaDrop creator payouts.\n */\n function getCreatorPayouts() external view returns (CreatorPayout[] memory);\n\n /**\n * @notice Returns the SeaDrop allow list merkle root.\n */\n function getAllowListMerkleRoot() external view returns (bytes32);\n\n /**\n * @notice Returns the SeaDrop allowed fee recipients.\n */\n function getAllowedFeeRecipients() external view returns (address[] memory);\n\n /**\n * @notice Returns the SeaDrop allowed signers.\n */\n function getSigners() external view returns (address[] memory);\n\n /**\n * @notice Returns if the signed digest has been used.\n *\n * @param digest The digest hash.\n */\n function getDigestIsUsed(bytes32 digest) external view returns (bool);\n\n /**\n * @notice Returns the SeaDrop allowed payers.\n */\n function getPayers() external view returns (address[] memory);\n\n /**\n * @notice Returns the configurer contract.\n */\n function configurer() external view returns (address);\n}\n"
},
"src/clones/ERC1155ContractMetadataCloneable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n IERC1155ContractMetadata\n} from \"../interfaces/IERC1155ContractMetadata.sol\";\n\nimport {\n ERC1155ConduitPreapproved\n} from \"../lib/ERC1155ConduitPreapproved.sol\";\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\nimport { ERC2981 } from \"solady/src/tokens/ERC2981.sol\";\n\nimport { Ownable } from \"solady/src/auth/Ownable.sol\";\n\nimport {\n Initializable\n} from \"@openzeppelin-upgradeable/contracts/proxy/utils/Initializable.sol\";\n\n/**\n * @title ERC1155ContractMetadataCloneable\n * @author James Wenzel (emo.eth)\n * @author Ryan Ghods (ralxz.eth)\n * @author Stephan Min (stephanm.eth)\n * @author Michael Cohen (notmichael.eth)\n * @notice A cloneable token contract that extends ERC-1155\n * with additional metadata and ownership capabilities.\n */\ncontract ERC1155ContractMetadataCloneable is\n ERC1155ConduitPreapproved,\n ERC2981,\n Ownable,\n IERC1155ContractMetadata,\n Initializable\n{\n /// @notice A struct containing the token supply info per token id.\n mapping(uint256 => TokenSupply) _tokenSupply;\n\n /// @notice The total number of tokens minted by address.\n mapping(address => uint256) _totalMintedByUser;\n\n /// @notice The total number of tokens minted per token id by address.\n mapping(address => mapping(uint256 => uint256)) _totalMintedByUserPerToken;\n\n /// @notice The name of the token.\n string internal _name;\n\n /// @notice The symbol of the token.\n string internal _symbol;\n\n /// @notice The base URI for token metadata.\n string internal _baseURI;\n\n /// @notice The contract URI for contract metadata.\n string internal _contractURI;\n\n /// @notice The provenance hash for guaranteeing metadata order\n /// for random reveals.\n bytes32 internal _provenanceHash;\n\n /// @notice The allowed contract that can configure SeaDrop parameters.\n address internal _CONFIGURER;\n\n /**\n * @dev Reverts if the sender is not the owner or the allowed\n * configurer contract.\n *\n * This is used as a function instead of a modifier\n * to save contract space when used multiple times.\n */\n function _onlyOwnerOrConfigurer() internal view {\n if (msg.sender != _CONFIGURER && msg.sender != owner()) {\n revert Unauthorized();\n }\n }\n\n /**\n * @notice Deploy the token contract.\n *\n * @param allowedConfigurer The address of the contract allowed to\n * configure parameters. Also contains SeaDrop\n * implementation code.\n * @param name_ The name of the token.\n * @param symbol_ The symbol of the token.\n */\n function __ERC1155ContractMetadataCloneable_init(\n address allowedConfigurer,\n string memory name_,\n string memory symbol_\n ) internal onlyInitializing {\n // Set the name of the token.\n _name = name_;\n\n // Set the symbol of the token.\n _symbol = symbol_;\n\n // Set the allowed configurer contract to interact with this contract.\n _CONFIGURER = allowedConfigurer;\n }\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param newBaseURI The new base URI to set.\n */\n function setBaseURI(string calldata newBaseURI) external override {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the new base URI.\n _baseURI = newBaseURI;\n\n // Emit an event with the update.\n emit BatchMetadataUpdate(0, type(uint256).max);\n }\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external override {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the new contract URI.\n _contractURI = newContractURI;\n\n // Emit an event with the update.\n emit ContractURIUpdated(newContractURI);\n }\n\n /**\n * @notice Emit an event notifying metadata updates for\n * a range of token ids, according to EIP-4906.\n *\n * @param fromTokenId The start token id.\n * @param toTokenId The end token id.\n */\n function emitBatchMetadataUpdate(\n uint256 fromTokenId,\n uint256 toTokenId\n ) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Emit an event with the update.\n if (fromTokenId == toTokenId) {\n // If only one token is being updated, use the event\n // in the 1155 spec.\n emit URI(uri(fromTokenId), fromTokenId);\n } else {\n emit BatchMetadataUpdate(fromTokenId, toTokenId);\n }\n }\n\n /**\n * @notice Sets the max token supply and emits an event.\n *\n * @param tokenId The token id to set the max supply for.\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 tokenId, uint256 newMaxSupply) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Ensure the max supply does not exceed the maximum value of uint64,\n // a limit due to the storage of bit-packed variables in TokenSupply,\n if (newMaxSupply > 2 ** 64 - 1) {\n revert CannotExceedMaxSupplyOfUint64(newMaxSupply);\n }\n\n // Set the new max supply.\n _tokenSupply[tokenId].maxSupply = uint64(newMaxSupply);\n\n // Emit an event with the update.\n emit MaxSupplyUpdated(tokenId, newMaxSupply);\n }\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert if the provenance hash has already\n * been set, so be sure to carefully set it only once.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Keep track of the old provenance hash for emitting with the event.\n bytes32 oldProvenanceHash = _provenanceHash;\n\n // Revert if the provenance hash has already been set.\n if (oldProvenanceHash != bytes32(0)) {\n revert ProvenanceHashCannotBeSetAfterAlreadyBeingSet();\n }\n\n // Set the new provenance hash.\n _provenanceHash = newProvenanceHash;\n\n // Emit an event with the update.\n emit ProvenanceHashUpdated(oldProvenanceHash, newProvenanceHash);\n }\n\n /**\n * @notice Sets the default royalty information.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator of 10_000 basis points.\n */\n function setDefaultRoyalty(address receiver, uint96 feeNumerator) external {\n // Ensure the sender is only the owner or configurer contract.\n _onlyOwnerOrConfigurer();\n\n // Set the default royalty.\n // ERC2981 implementation ensures feeNumerator <= feeDenominator\n // and receiver != address(0).\n _setDefaultRoyalty(receiver, feeNumerator);\n\n // Emit an event with the updated params.\n emit RoyaltyInfoUpdated(receiver, feeNumerator);\n }\n\n /**\n * @notice Returns the name of the token.\n */\n function name() external view returns (string memory) {\n return _name;\n }\n\n /**\n * @notice Returns the symbol of the token.\n */\n function symbol() external view returns (string memory) {\n return _symbol;\n }\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view override returns (string memory) {\n return _baseURI;\n }\n\n /**\n * @notice Returns the contract URI for contract metadata.\n */\n function contractURI() external view override returns (string memory) {\n return _contractURI;\n }\n\n /**\n * @notice Returns the max token supply for a token id.\n */\n function maxSupply(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].maxSupply;\n }\n\n /**\n * @notice Returns the total supply for a token id.\n */\n function totalSupply(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].totalSupply;\n }\n\n /**\n * @notice Returns the total minted for a token id.\n */\n function totalMinted(uint256 tokenId) external view returns (uint256) {\n return _tokenSupply[tokenId].totalMinted;\n }\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view override returns (bytes32) {\n return _provenanceHash;\n }\n\n /**\n * @notice Returns the URI for token metadata.\n *\n * This implementation returns the same URI for *all* token types.\n * It relies on the token type ID substitution mechanism defined\n * in the EIP to replace {id} with the token id.\n *\n * @custom:param tokenId The token id to get the URI for.\n */\n function uri(\n uint256 /* tokenId */\n ) public view virtual override returns (string memory) {\n // Return the base URI.\n return _baseURI;\n }\n\n /**\n * @notice Returns whether the interface is supported.\n *\n * @param interfaceId The interface id to check against.\n */\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override(ERC1155, ERC2981) returns (bool) {\n return\n interfaceId == type(IERC1155ContractMetadata).interfaceId ||\n interfaceId == 0x49064906 || // ERC-4906 (MetadataUpdate)\n ERC2981.supportsInterface(interfaceId) ||\n // ERC1155 returns supportsInterface true for\n // ERC165, ERC1155, ERC1155MetadataURI\n ERC1155.supportsInterface(interfaceId);\n }\n\n /**\n * @dev Adds to the internal counters for a mint.\n *\n * @param to The address to mint to.\n * @param id The token id to mint.\n * @param amount The quantity to mint.\n * @param data The data to pass if receiver is a contract.\n */\n function _mint(\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual override {\n // Increment mint counts.\n _incrementMintCounts(to, id, amount);\n\n ERC1155._mint(to, id, amount, data);\n }\n\n /**\n * @dev Adds to the internal counters for a batch mint.\n *\n * @param to The address to mint to.\n * @param ids The token ids to mint.\n * @param amounts The quantities to mint.\n * @param data The data to pass if receiver is a contract.\n */\n function _batchMint(\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual override {\n // Put ids length on the stack to save MLOADs.\n uint256 idsLength = ids.length;\n\n for (uint256 i = 0; i < idsLength; ) {\n // Increment mint counts.\n _incrementMintCounts(to, ids[i], amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n\n ERC1155._batchMint(to, ids, amounts, data);\n }\n\n /**\n * @dev Subtracts from the internal counters for a burn.\n *\n * @param by The address calling the burn.\n * @param from The address to burn from.\n * @param id The token id to burn.\n * @param amount The amount to burn.\n */\n function _burn(\n address by,\n address from,\n uint256 id,\n uint256 amount\n ) internal virtual override {\n // Reduce the supply.\n _reduceSupplyOnBurn(id, amount);\n\n ERC1155._burn(by, from, id, amount);\n }\n\n /**\n * @dev Subtracts from the internal counters for a batch burn.\n *\n * @param by The address calling the burn.\n * @param from The address to burn from.\n * @param ids The token ids to burn.\n * @param amounts The amounts to burn.\n */\n function _batchBurn(\n address by,\n address from,\n uint256[] memory ids,\n uint256[] memory amounts\n ) internal virtual override {\n // Put ids length on the stack to save MLOADs.\n uint256 idsLength = ids.length;\n\n for (uint256 i = 0; i < idsLength; ) {\n // Reduce the supply.\n _reduceSupplyOnBurn(ids[i], amounts[i]);\n\n unchecked {\n ++i;\n }\n }\n\n ERC1155._batchBurn(by, from, ids, amounts);\n }\n\n function _reduceSupplyOnBurn(uint256 id, uint256 amount) internal {\n // Get the current token supply.\n TokenSupply storage tokenSupply = _tokenSupply[id];\n\n // Reduce the totalSupply.\n unchecked {\n tokenSupply.totalSupply -= uint64(amount);\n }\n }\n\n /**\n * @dev Internal function to increment mint counts.\n *\n * Note that this function does not check if the mint exceeds\n * maxSupply, which should be validated before this function is called.\n *\n * @param to The address to mint to.\n * @param id The token id to mint.\n * @param amount The quantity to mint.\n */\n function _incrementMintCounts(\n address to,\n uint256 id,\n uint256 amount\n ) internal {\n // Get the current token supply.\n TokenSupply storage tokenSupply = _tokenSupply[id];\n\n if (tokenSupply.totalMinted + amount > tokenSupply.maxSupply) {\n revert MintExceedsMaxSupply(\n tokenSupply.totalMinted + amount,\n tokenSupply.maxSupply\n );\n }\n\n // Increment supply and number minted.\n // Can be unchecked because maxSupply cannot be set to exceed uint64.\n unchecked {\n tokenSupply.totalSupply += uint64(amount);\n tokenSupply.totalMinted += uint64(amount);\n\n // Increment total minted by user.\n _totalMintedByUser[to] += amount;\n\n // Increment total minted by user per token.\n _totalMintedByUserPerToken[to][id] += amount;\n }\n }\n}\n"
},
"src/lib/ERC1155SeaDropContractOffererStorage.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { PublicDrop } from \"./ERC1155SeaDropStructs.sol\";\n\nimport { CreatorPayout } from \"./SeaDropStructs.sol\";\n\nlibrary ERC1155SeaDropContractOffererStorage {\n struct Layout {\n /// @notice The allowed Seaport addresses that can mint.\n mapping(address => bool) _allowedSeaport;\n /// @notice The enumerated allowed Seaport addresses.\n address[] _enumeratedAllowedSeaport;\n /// @notice The public drop data.\n mapping(uint256 => PublicDrop) _publicDrops;\n /// @notice The enumerated public drop indexes.\n uint256[] _enumeratedPublicDropIndexes;\n /// @notice The creator payout addresses and basis points.\n CreatorPayout[] _creatorPayouts;\n /// @notice The allow list merkle root.\n bytes32 _allowListMerkleRoot;\n /// @notice The allowed fee recipients.\n mapping(address => bool) _allowedFeeRecipients;\n /// @notice The enumerated allowed fee recipients.\n address[] _enumeratedFeeRecipients;\n /// @notice The allowed server-side signers.\n mapping(address => bool) _allowedSigners;\n /// @notice The enumerated allowed signers.\n address[] _enumeratedSigners;\n /// @notice The used signature digests.\n mapping(bytes32 => bool) _usedDigests;\n /// @notice The allowed payers.\n mapping(address => bool) _allowedPayers;\n /// @notice The enumerated allowed payers.\n address[] _enumeratedPayers;\n }\n\n bytes32 internal constant STORAGE_SLOT =\n bytes32(\n uint256(\n keccak256(\"contracts.storage.ERC1155SeaDropContractOfferer\")\n ) - 1\n );\n\n function layout() internal pure returns (Layout storage l) {\n bytes32 slot = STORAGE_SLOT;\n assembly {\n l.slot := slot\n }\n }\n}\n"
},
"src/lib/ERC1155SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { PublicDrop } from \"./ERC1155SeaDropStructs.sol\";\n\nimport { SeaDropErrorsAndEvents } from \"./SeaDropErrorsAndEvents.sol\";\n\ninterface ERC1155SeaDropErrorsAndEvents is SeaDropErrorsAndEvents {\n /**\n * @dev Revert with an error if an empty PublicDrop is provided\n * for an already-empty public drop.\n */\n error PublicDropStageNotPresent();\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the\n * max minted per wallet for a certain token id.\n */\n error MintQuantityExceedsMaxMintedPerWalletForTokenId(\n uint256 tokenId,\n uint256 total,\n uint256 allowed\n );\n\n /**\n * @dev Revert with an error if the target token id to mint is not within\n * the drop stage range.\n */\n error TokenIdNotWithinDropStageRange(\n uint256 tokenId,\n uint256 startTokenId,\n uint256 endTokenId\n );\n\n /**\n * @notice Revert with an error if the number of maxSupplyAmounts doesn't\n * match the number of maxSupplyTokenIds.\n */\n error MaxSupplyMismatch();\n\n /**\n * @notice Revert with an error if the number of mint tokenIds doesn't\n * match the number of mint amounts.\n */\n error MintAmountsMismatch();\n\n /**\n * @notice Revert with an error if the mint order offer contains\n * a duplicate tokenId.\n */\n error OfferContainsDuplicateTokenId(uint256 tokenId);\n\n /**\n * @dev Revert if the fromTokenId is greater than the toTokenId.\n */\n error InvalidFromAndToTokenId(uint256 fromTokenId, uint256 toTokenId);\n\n /**\n * @notice Revert with an error if the number of publicDropIndexes doesn't\n * match the number of publicDrops.\n */\n error PublicDropsMismatch();\n\n /**\n * @dev An event with updated public drop data.\n */\n event PublicDropUpdated(PublicDrop publicDrop, uint256 index);\n}\n"
},
"src/lib/ERC1155SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { AllowListData, CreatorPayout } from \"./SeaDropStructs.sol\";\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in two storage slots.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n * @param paymentToken The payment token address. Null for\n * native token.\n * @param fromTokenId The start token id for the stage.\n * @param toTokenId The end token id for the stage.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param maxTotalMintableByWalletPerToken Maximum total number of mints a user\n * is allowed for the token id. (The limit for\n * this field is 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n */\nstruct PublicDrop {\n // slot 1\n uint80 startPrice; // 80/512 bits\n uint80 endPrice; // 160/512 bits\n uint40 startTime; // 200/512 bits\n uint40 endTime; // 240/512 bits\n bool restrictFeeRecipients; // 248/512 bits\n // uint8 unused;\n\n // slot 2\n address paymentToken; // 408/512 bits\n uint24 fromTokenId; // 432/512 bits\n uint24 toTokenId; // 456/512 bits\n uint16 maxTotalMintableByWallet; // 472/512 bits\n uint16 maxTotalMintableByWalletPerToken; // 488/512 bits\n uint16 feeBps; // 504/512 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n *\n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token for the mint. Null for\n * native token.\n * @param fromTokenId The start token id for the stage.\n * @param toTokenId The end token id for the stage.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param maxTotalMintableByWalletPerToken Maximum total number of mints a user\n * is allowed for the token id.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 startPrice;\n uint256 endPrice;\n uint256 startTime;\n uint256 endTime;\n address paymentToken;\n uint256 fromTokenId;\n uint256 toTokenId;\n uint256 maxTotalMintableByWallet;\n uint256 maxTotalMintableByWalletPerToken;\n uint256 maxTokenSupplyForStage;\n uint256 dropStageIndex; // non-zero\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @dev Struct containing internal SeaDrop implementation logic\n * mint details to avoid stack too deep.\n *\n * @param feeRecipient The fee recipient.\n * @param payer The payer of the mint.\n * @param minter The mint recipient.\n * @param tokenIds The tokenIds to mint.\n * @param quantities The number of tokens to mint per tokenId.\n * @param withEffects Whether to apply state changes of the mint.\n */\nstruct MintDetails {\n address feeRecipient;\n address payer;\n address minter;\n uint256[] tokenIds;\n uint256[] quantities;\n bool withEffects;\n}\n\n/**\n * @notice A struct to configure multiple contract options in one transaction.\n */\nstruct MultiConfigureStruct {\n uint256[] maxSupplyTokenIds;\n uint256[] maxSupplyAmounts;\n string baseURI;\n string contractURI;\n PublicDrop[] publicDrops;\n uint256[] publicDropsIndexes;\n string dropURI;\n AllowListData allowListData;\n CreatorPayout[] creatorPayouts;\n bytes32 provenanceHash;\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n address[] allowedPayers;\n address[] disallowedPayers;\n // Server-signed\n address[] allowedSigners;\n address[] disallowedSigners;\n // ERC-2981\n address royaltyReceiver;\n uint96 royaltyBps;\n // Mint\n address mintRecipient;\n uint256[] mintTokenIds;\n uint256[] mintAmounts;\n}\n"
},
"src/lib/SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\n/**\n * @notice A struct defining a creator payout address and basis points.\n *\n * @param payoutAddress The payout address.\n * @param basisPoints The basis points to pay out to the creator.\n * The total creator payouts must equal 10_000 bps.\n */\nstruct CreatorPayout {\n address payoutAddress;\n uint16 basisPoints;\n}\n\n/**\n * @notice A struct defining allow list data (for minting an allow list).\n *\n * @param merkleRoot The merkle root for the allow list.\n * @param publicKeyURIs If the allowListURI is encrypted, a list of URIs\n * pointing to the public keys. Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\nstruct AllowListData {\n bytes32 merkleRoot;\n string[] publicKeyURIs;\n string allowListURI;\n}\n"
},
"src/lib/ERC1155ConduitPreapproved.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { ERC1155 } from \"solady/src/tokens/ERC1155.sol\";\n\n/**\n * @title ERC1155ConduitPreapproved\n * @notice Solady's ERC1155 with the OpenSea conduit preapproved.\n */\nabstract contract ERC1155ConduitPreapproved is ERC1155 {\n /// @dev The canonical OpenSea conduit.\n address internal constant _CONDUIT =\n 0x1E0049783F008A0085193E00003D00cd54003c71;\n\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual override {\n _safeTransfer(_by(), from, to, id, amount, data);\n }\n\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) public virtual override {\n _safeBatchTransfer(_by(), from, to, ids, amounts, data);\n }\n\n function isApprovedForAll(\n address owner,\n address operator\n ) public view virtual override returns (bool) {\n if (operator == _CONDUIT) return true;\n return ERC1155.isApprovedForAll(owner, operator);\n }\n\n function _by() internal view returns (address result) {\n assembly {\n // `msg.sender == _CONDUIT ? address(0) : msg.sender`.\n result := mul(iszero(eq(caller(), _CONDUIT)), caller())\n }\n }\n}\n"
},
"lib/solady/src/tokens/ERC1155.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple ERC1155 implementation.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC1155.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC1155.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/token/ERC1155/ERC1155.sol)\n///\n/// @dev Note:\n/// The ERC1155 standard allows for self-approvals.\n/// For performance, this implementation WILL NOT revert for such actions.\n/// Please add any checks with overrides if desired.\nabstract contract ERC1155 {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The lengths of the input arrays are not the same.\n error ArrayLengthsMismatch();\n\n /// @dev Cannot mint or transfer to the zero address.\n error TransferToZeroAddress();\n\n /// @dev The recipient's balance has overflowed.\n error AccountBalanceOverflow();\n\n /// @dev Insufficient balance.\n error InsufficientBalance();\n\n /// @dev Only the token owner or an approved account can manage the tokens.\n error NotOwnerNorApproved();\n\n /// @dev Cannot safely transfer to a contract that does not implement\n /// the ERC1155Receiver interface.\n error TransferToNonERC1155ReceiverImplementer();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EVENTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Emitted when `amount` of token `id` is transferred\n /// from `from` to `to` by `operator`.\n event TransferSingle(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256 id,\n uint256 amount\n );\n\n /// @dev Emitted when `amounts` of token `ids` are transferred\n /// from `from` to `to` by `operator`.\n event TransferBatch(\n address indexed operator,\n address indexed from,\n address indexed to,\n uint256[] ids,\n uint256[] amounts\n );\n\n /// @dev Emitted when `owner` enables or disables `operator` to manage all of their tokens.\n event ApprovalForAll(address indexed owner, address indexed operator, bool isApproved);\n\n /// @dev Emitted when the Uniform Resource Identifier (URI) for token `id`\n /// is updated to `value`. This event is not used in the base contract.\n /// You may need to emit this event depending on your URI logic.\n ///\n /// See: https://eips.ethereum.org/EIPS/eip-1155#metadata\n event URI(string value, uint256 indexed id);\n\n /// @dev `keccak256(bytes(\"TransferSingle(address,address,address,uint256,uint256)\"))`.\n uint256 private constant _TRANSFER_SINGLE_EVENT_SIGNATURE =\n 0xc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62;\n\n /// @dev `keccak256(bytes(\"TransferBatch(address,address,address,uint256[],uint256[])\"))`.\n uint256 private constant _TRANSFER_BATCH_EVENT_SIGNATURE =\n 0x4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb;\n\n /// @dev `keccak256(bytes(\"ApprovalForAll(address,address,bool)\"))`.\n uint256 private constant _APPROVAL_FOR_ALL_EVENT_SIGNATURE =\n 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The `ownerSlotSeed` of a given owner is given by.\n /// ```\n /// let ownerSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner))\n /// ```\n ///\n /// The balance slot of `owner` is given by.\n /// ```\n /// mstore(0x20, ownerSlotSeed)\n /// mstore(0x00, id)\n /// let balanceSlot := keccak256(0x00, 0x40)\n /// ```\n ///\n /// The operator approval slot of `owner` is given by.\n /// ```\n /// mstore(0x20, ownerSlotSeed)\n /// mstore(0x00, operator)\n /// let operatorApprovalSlot := keccak256(0x0c, 0x34)\n /// ```\n uint256 private constant _ERC1155_MASTER_SLOT_SEED = 0x9a31110384e0b0c9;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC1155 METADATA */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the URI for token `id`.\n ///\n /// You can either return the same templated URI for all token IDs,\n /// (e.g. \"https://example.com/api/{id}.json\"),\n /// or return a unique URI for each `id`.\n ///\n /// See: https://eips.ethereum.org/EIPS/eip-1155#metadata\n function uri(uint256 id) public view virtual returns (string memory);\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC1155 */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the amount of `id` owned by `owner`.\n function balanceOf(address owner, uint256 id) public view virtual returns (uint256 result) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, owner)\n mstore(0x00, id)\n result := sload(keccak256(0x00, 0x40))\n }\n }\n\n /// @dev Returns whether `operator` is approved to manage the tokens of `owner`.\n function isApprovedForAll(address owner, address operator)\n public\n view\n virtual\n returns (bool result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, owner)\n mstore(0x00, operator)\n result := sload(keccak256(0x0c, 0x34))\n }\n }\n\n /// @dev Sets whether `operator` is approved to manage the tokens of the caller.\n ///\n /// Emits a {ApprovalForAll} event.\n function setApprovalForAll(address operator, bool isApproved) public virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Convert to 0 or 1.\n isApproved := iszero(iszero(isApproved))\n // Update the `isApproved` for (`msg.sender`, `operator`).\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, caller())\n mstore(0x00, operator)\n sstore(keccak256(0x0c, 0x34), isApproved)\n // Emit the {ApprovalForAll} event.\n mstore(0x00, isApproved)\n // forgefmt: disable-next-line\n log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, caller(), shr(96, shl(96, operator)))\n }\n }\n\n /// @dev Transfers `amount` of `id` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - If the caller is not `from`,\n /// it must be approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function safeTransferFrom(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes calldata data\n ) public virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from))\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to))\n mstore(0x20, fromSlotSeed)\n // Clear the upper 96 bits.\n from := shr(96, fromSlotSeed)\n to := shr(96, toSlotSeed)\n // Revert if `to` is the zero address.\n if iszero(to) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // If the caller is not `from`, do the authorization check.\n if iszero(eq(caller(), from)) {\n mstore(0x00, caller())\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), from, to)\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Do the {onERC1155Received} check if `to` is a smart contract.\n if extcodesize(to) {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155Received(address,address,uint256,uint256,bytes)`.\n mstore(m, 0xf23a6e61)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), from)\n mstore(add(m, 0x60), id)\n mstore(add(m, 0x80), amount)\n mstore(add(m, 0xa0), 0xa0)\n calldatacopy(add(m, 0xc0), sub(data.offset, 0x20), add(0x20, data.length))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, data.length), m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xf23a6e61))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n }\n\n /// @dev Transfers `amounts` of `ids` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - `ids` and `amounts` must have the same length.\n /// - If the caller is not `from`,\n /// it must be approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function safeBatchTransferFrom(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) public virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(ids.length, amounts.length)) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, from))\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, shl(96, to))\n mstore(0x20, fromSlotSeed)\n // Clear the upper 96 bits.\n from := shr(96, fromSlotSeed)\n to := shr(96, toSlotSeed)\n // Revert if `to` is the zero address.\n if iszero(to) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // If the caller is not `from`, do the authorization check.\n if iszero(eq(caller(), from)) {\n mstore(0x00, caller())\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, ids.length)\n for { let i := 0 } iszero(eq(i, end)) { i := add(i, 0x20) } {\n let amount := calldataload(add(amounts.offset, i))\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x20, fromSlotSeed)\n mstore(0x00, calldataload(add(ids.offset, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, ids.length))\n let o := add(m, 0x40)\n calldatacopy(o, sub(ids.offset, 0x20), n)\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, n))\n o := add(o, n)\n n := add(0x20, shl(5, amounts.length))\n calldatacopy(o, sub(amounts.offset, 0x20), n)\n n := sub(add(o, n), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), from, to)\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransferCalldata(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Do the {onERC1155BatchReceived} check if `to` is a smart contract.\n if extcodesize(to) {\n let m := mload(0x40)\n // Prepare the calldata.\n // `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`.\n mstore(m, 0xbc197c81)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), from)\n // Copy the `ids`.\n mstore(add(m, 0x60), 0xa0)\n let n := add(0x20, shl(5, ids.length))\n let o := add(m, 0xc0)\n calldatacopy(o, sub(ids.offset, 0x20), n)\n // Copy the `amounts`.\n let s := add(0xa0, n)\n mstore(add(m, 0x80), s)\n o := add(o, n)\n n := add(0x20, shl(5, amounts.length))\n calldatacopy(o, sub(amounts.offset, 0x20), n)\n // Copy the `data`.\n mstore(add(m, 0xa0), add(s, n))\n o := add(o, n)\n n := add(0x20, data.length)\n calldatacopy(o, sub(data.offset, 0x20), n)\n n := sub(add(o, n), add(m, 0x1c))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), n, m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xbc197c81))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n }\n\n /// @dev Returns the amounts of `ids` for `owners.\n ///\n /// Requirements:\n /// - `owners` and `ids` must have the same length.\n function balanceOfBatch(address[] calldata owners, uint256[] calldata ids)\n public\n view\n virtual\n returns (uint256[] memory balances)\n {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(ids.length, owners.length)) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n balances := mload(0x40)\n mstore(balances, ids.length)\n let o := add(balances, 0x20)\n let end := shl(5, ids.length)\n mstore(0x40, add(end, o))\n // Loop through all the `ids` and load the balances.\n for { let i := 0 } iszero(eq(i, end)) { i := add(i, 0x20) } {\n let owner := calldataload(add(owners.offset, i))\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, shl(96, owner)))\n mstore(0x00, calldataload(add(ids.offset, i)))\n mstore(add(o, i), sload(keccak256(0x00, 0x40)))\n }\n }\n }\n\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\n /// See: https://eips.ethereum.org/EIPS/eip-165\n /// This function call must use less than 30000 gas.\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := shr(224, interfaceId)\n // ERC165: 0x01ffc9a7, ERC1155: 0xd9b67a26, ERC1155MetadataURI: 0x0e89341c.\n result := or(or(eq(s, 0x01ffc9a7), eq(s, 0xd9b67a26)), eq(s, 0x0e89341c))\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL MINT FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Mints `amount` of `id` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function _mint(address to, uint256 id, uint256 amount, bytes memory data) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(address(0), to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, to)\n mstore(0x00, id)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x00, id)\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), 0, shr(96, to_))\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(address(0), to, _single(id), _single(amount), data);\n }\n if (_hasCode(to)) _checkOnERC1155Received(address(0), to, id, amount, data);\n }\n\n /// @dev Mints `amounts` of `ids` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `ids` and `amounts` must have the same length.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function _batchMint(\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(address(0), to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n // Loop through all the `ids` and update the balances.\n {\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_))\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Increase and store the updated balance of `to`.\n {\n mstore(0x00, mload(add(ids, i)))\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), 0, shr(96, to_))\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(address(0), to, ids, amounts, data);\n }\n if (_hasCode(to)) _checkOnERC1155BatchReceived(address(0), to, ids, amounts, data);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL BURN FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Equivalent to `_burn(address(0), from, id, amount)`.\n function _burn(address from, uint256 id, uint256 amount) internal virtual {\n _burn(address(0), from, id, amount);\n }\n\n /// @dev Destroys `amount` of `id` from `from`.\n ///\n /// Requirements:\n /// - `from` must have at least `amount` of `id`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n ///\n /// Emits a {Transfer} event.\n function _burn(address by, address from, uint256 id, uint256 amount) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, address(0), _single(id), _single(amount), \"\");\n }\n /// @solidity memory-safe-assembly\n assembly {\n let from_ := shl(96, from)\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n if iszero(or(iszero(shl(96, by)), eq(shl(96, by), from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Decrease and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Emit a {TransferSingle} event.\n mstore(0x00, id)\n mstore(0x20, amount)\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), 0)\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, address(0), _single(id), _single(amount), \"\");\n }\n }\n\n /// @dev Equivalent to `_batchBurn(address(0), from, ids, amounts)`.\n function _batchBurn(address from, uint256[] memory ids, uint256[] memory amounts)\n internal\n virtual\n {\n _batchBurn(address(0), from, ids, amounts);\n }\n\n /// @dev Destroys `amounts` of `ids` from `from`.\n ///\n /// Requirements:\n /// - `ids` and `amounts` must have the same length.\n /// - `from` must have at least `amounts` of `ids`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n ///\n /// Emits a {TransferBatch} event.\n function _batchBurn(address by, address from, uint256[] memory ids, uint256[] memory amounts)\n internal\n virtual\n {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, address(0), ids, amounts, \"\");\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let from_ := shl(96, from)\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Decrease and store the updated balance of `to`.\n {\n mstore(0x00, mload(add(ids, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), 0)\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, address(0), ids, amounts, \"\");\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL APPROVAL FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Approve or remove the `operator` as an operator for `by`,\n /// without authorization checks.\n ///\n /// Emits a {ApprovalForAll} event.\n function _setApprovalForAll(address by, address operator, bool isApproved) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Convert to 0 or 1.\n isApproved := iszero(iszero(isApproved))\n // Update the `isApproved` for (`by`, `operator`).\n mstore(0x20, _ERC1155_MASTER_SLOT_SEED)\n mstore(0x14, by)\n mstore(0x00, operator)\n sstore(keccak256(0x0c, 0x34), isApproved)\n // Emit the {ApprovalForAll} event.\n mstore(0x00, isApproved)\n let m := shr(96, not(0))\n log3(0x00, 0x20, _APPROVAL_FOR_ALL_EVENT_SIGNATURE, and(m, by), and(m, operator))\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL TRANSFER FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Equivalent to `_safeTransfer(address(0), from, to, id, amount, data)`.\n function _safeTransfer(address from, address to, uint256 id, uint256 amount, bytes memory data)\n internal\n virtual\n {\n _safeTransfer(address(0), from, to, id, amount, data);\n }\n\n /// @dev Transfers `amount` of `id` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `from` must have at least `amount` of `id`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155Reveived}, which is called upon a batch transfer.\n ///\n /// Emits a {Transfer} event.\n function _safeTransfer(\n address by,\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n let from_ := shl(96, from)\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, from_))\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x00, id)\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, or(_ERC1155_MASTER_SLOT_SEED, to_))\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n // Emit a {TransferSingle} event.\n mstore(0x20, amount)\n // forgefmt: disable-next-line\n log4(0x00, 0x40, _TRANSFER_SINGLE_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_))\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, _single(id), _single(amount), data);\n }\n if (_hasCode(to)) _checkOnERC1155Received(from, to, id, amount, data);\n }\n\n /// @dev Equivalent to `_safeBatchTransfer(address(0), from, to, ids, amounts, data)`.\n function _safeBatchTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n _safeBatchTransfer(address(0), from, to, ids, amounts, data);\n }\n\n /// @dev Transfers `amounts` of `ids` from `from` to `to`.\n ///\n /// Requirements:\n /// - `to` cannot be the zero address.\n /// - `ids` and `amounts` must have the same length.\n /// - `from` must have at least `amounts` of `ids`.\n /// - If `by` is not the zero address, it must be either `from`,\n /// or approved to manage the tokens of `from`.\n /// - If `to` refers to a smart contract, it must implement\n /// {ERC1155-onERC1155BatchReveived}, which is called upon a batch transfer.\n ///\n /// Emits a {TransferBatch} event.\n function _safeBatchTransfer(\n address by,\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {\n if (_useBeforeTokenTransfer()) {\n _beforeTokenTransfer(from, to, ids, amounts, data);\n }\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(eq(mload(ids), mload(amounts))) {\n mstore(0x00, 0x3b800a46) // `ArrayLengthsMismatch()`.\n revert(0x1c, 0x04)\n }\n let from_ := shl(96, from)\n let to_ := shl(96, to)\n // Revert if `to` is the zero address.\n if iszero(to_) {\n mstore(0x00, 0xea553b34) // `TransferToZeroAddress()`.\n revert(0x1c, 0x04)\n }\n let fromSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, from_)\n let toSlotSeed := or(_ERC1155_MASTER_SLOT_SEED, to_)\n mstore(0x20, fromSlotSeed)\n // If `by` is not the zero address, and not equal to `from`,\n // check if it is approved to manage all the tokens of `from`.\n let by_ := shl(96, by)\n if iszero(or(iszero(by_), eq(by_, from_))) {\n mstore(0x00, by)\n if iszero(sload(keccak256(0x0c, 0x34))) {\n mstore(0x00, 0x4b6e7f18) // `NotOwnerNorApproved()`.\n revert(0x1c, 0x04)\n }\n }\n // Loop through all the `ids` and update the balances.\n {\n let end := shl(5, mload(ids))\n for { let i := 0 } iszero(eq(i, end)) {} {\n i := add(i, 0x20)\n let amount := mload(add(amounts, i))\n // Subtract and store the updated balance of `from`.\n {\n mstore(0x20, fromSlotSeed)\n mstore(0x00, mload(add(ids, i)))\n let fromBalanceSlot := keccak256(0x00, 0x40)\n let fromBalance := sload(fromBalanceSlot)\n if gt(amount, fromBalance) {\n mstore(0x00, 0xf4d678b8) // `InsufficientBalance()`.\n revert(0x1c, 0x04)\n }\n sstore(fromBalanceSlot, sub(fromBalance, amount))\n }\n // Increase and store the updated balance of `to`.\n {\n mstore(0x20, toSlotSeed)\n let toBalanceSlot := keccak256(0x00, 0x40)\n let toBalanceBefore := sload(toBalanceSlot)\n let toBalanceAfter := add(toBalanceBefore, amount)\n if lt(toBalanceAfter, toBalanceBefore) {\n mstore(0x00, 0x01336cea) // `AccountBalanceOverflow()`.\n revert(0x1c, 0x04)\n }\n sstore(toBalanceSlot, toBalanceAfter)\n }\n }\n }\n // Emit a {TransferBatch} event.\n {\n let m := mload(0x40)\n // Copy the `ids`.\n mstore(m, 0x40)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0x40)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n mstore(add(m, 0x20), add(0x40, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n n := sub(add(o, returndatasize()), m)\n // Do the emit.\n log4(m, n, _TRANSFER_BATCH_EVENT_SIGNATURE, caller(), shr(96, from_), shr(96, to_))\n }\n }\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, ids, amounts, data);\n }\n if (_hasCode(to)) _checkOnERC1155BatchReceived(from, to, ids, amounts, data);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* HOOKS FOR OVERRIDING */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Override this function to return true if `_beforeTokenTransfer` is used.\n /// The is to help the compiler avoid producing dead bytecode.\n function _useBeforeTokenTransfer() internal view virtual returns (bool) {\n return false;\n }\n\n /// @dev Hook that is called before any token transfer.\n /// This includes minting and burning, as well as batched variants.\n ///\n /// The same hook is called on both single and batched variants.\n /// For single transfers, the length of the `id` and `amount` arrays are 1.\n function _beforeTokenTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n\n /// @dev Override this function to return true if `_afterTokenTransfer` is used.\n /// The is to help the compiler avoid producing dead bytecode.\n function _useAfterTokenTransfer() internal view virtual returns (bool) {\n return false;\n }\n\n /// @dev Hook that is called after any token transfer.\n /// This includes minting and burning, as well as batched variants.\n ///\n /// The same hook is called on both single and batched variants.\n /// For single transfers, the length of the `id` and `amount` arrays are 1.\n function _afterTokenTransfer(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) internal virtual {}\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PRIVATE HELPERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Helper for calling the `_afterTokenTransfer` hook.\n /// The is to help the compiler avoid producing dead bytecode.\n function _afterTokenTransferCalldata(\n address from,\n address to,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata data\n ) private {\n if (_useAfterTokenTransfer()) {\n _afterTokenTransfer(from, to, ids, amounts, data);\n }\n }\n\n /// @dev Returns if `a` has bytecode of non-zero length.\n function _hasCode(address a) private view returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := extcodesize(a) // Can handle dirty upper bits.\n }\n }\n\n /// @dev Perform a call to invoke {IERC1155Receiver-onERC1155Received} on `to`.\n /// Reverts if the target does not support the function correctly.\n function _checkOnERC1155Received(\n address from,\n address to,\n uint256 id,\n uint256 amount,\n bytes memory data\n ) private {\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155Received(address,address,uint256,uint256,bytes)`.\n mstore(m, 0xf23a6e61)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), shr(96, shl(96, from)))\n mstore(add(m, 0x60), id)\n mstore(add(m, 0x80), amount)\n mstore(add(m, 0xa0), 0xa0)\n let n := mload(data)\n mstore(add(m, 0xc0), n)\n if n { pop(staticcall(gas(), 4, add(data, 0x20), n, add(m, 0xe0), n)) }\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), add(0xc4, n), m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xf23a6e61))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Perform a call to invoke {IERC1155Receiver-onERC1155BatchReceived} on `to`.\n /// Reverts if the target does not support the function correctly.\n function _checkOnERC1155BatchReceived(\n address from,\n address to,\n uint256[] memory ids,\n uint256[] memory amounts,\n bytes memory data\n ) private {\n /// @solidity memory-safe-assembly\n assembly {\n // Prepare the calldata.\n let m := mload(0x40)\n // `onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)`.\n mstore(m, 0xbc197c81)\n mstore(add(m, 0x20), caller())\n mstore(add(m, 0x40), shr(96, shl(96, from)))\n // Copy the `ids`.\n mstore(add(m, 0x60), 0xa0)\n let n := add(0x20, shl(5, mload(ids)))\n let o := add(m, 0xc0)\n pop(staticcall(gas(), 4, ids, n, o, n))\n // Copy the `amounts`.\n let s := add(0xa0, returndatasize())\n mstore(add(m, 0x80), s)\n o := add(o, returndatasize())\n n := add(0x20, shl(5, mload(amounts)))\n pop(staticcall(gas(), 4, amounts, n, o, n))\n // Copy the `data`.\n mstore(add(m, 0xa0), add(s, returndatasize()))\n o := add(o, returndatasize())\n n := add(0x20, mload(data))\n pop(staticcall(gas(), 4, data, n, o, n))\n n := sub(add(o, returndatasize()), add(m, 0x1c))\n // Revert if the call reverts.\n if iszero(call(gas(), to, 0, add(m, 0x1c), n, m, 0x20)) {\n if returndatasize() {\n // Bubble up the revert if the call reverts.\n returndatacopy(0x00, 0x00, returndatasize())\n revert(0x00, returndatasize())\n }\n mstore(m, 0)\n }\n // Load the returndata and compare it with the function selector.\n if iszero(eq(mload(m), shl(224, 0xbc197c81))) {\n mstore(0x00, 0x9c05499b) // `TransferToNonERC1155ReceiverImplementer()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /// @dev Returns `x` in an array with a single element.\n function _single(uint256 x) private pure returns (uint256[] memory result) {\n assembly {\n result := mload(0x40)\n mstore(0x40, add(result, 0x40))\n mstore(result, 1)\n mstore(add(result, 0x20), x)\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/lib/ConsiderationStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {\n BasicOrderType,\n ItemType,\n OrderType,\n Side\n} from \"./ConsiderationEnums.sol\";\n\nimport {\n CalldataPointer,\n MemoryPointer\n} from \"../helpers/PointerLibraries.sol\";\n\n/**\n * @dev An order contains eleven components: an offerer, a zone (or account that\n * can cancel the order or restrict who can fulfill the order depending on\n * the type), the order type (specifying partial fill support as well as\n * restricted order status), the start and end time, a hash that will be\n * provided to the zone when validating restricted orders, a salt, a key\n * corresponding to a given conduit, a counter, and an arbitrary number of\n * offer items that can be spent along with consideration items that must\n * be received by their respective recipient.\n */\nstruct OrderComponents {\n address offerer;\n address zone;\n OfferItem[] offer;\n ConsiderationItem[] consideration;\n OrderType orderType;\n uint256 startTime;\n uint256 endTime;\n bytes32 zoneHash;\n uint256 salt;\n bytes32 conduitKey;\n uint256 counter;\n}\n\n/**\n * @dev An offer item has five components: an item type (ETH or other native\n * tokens, ERC20, ERC721, and ERC1155, as well as criteria-based ERC721 and\n * ERC1155), a token address, a dual-purpose \"identifierOrCriteria\"\n * component that will either represent a tokenId or a merkle root\n * depending on the item type, and a start and end amount that support\n * increasing or decreasing amounts over the duration of the respective\n * order.\n */\nstruct OfferItem {\n ItemType itemType;\n address token;\n uint256 identifierOrCriteria;\n uint256 startAmount;\n uint256 endAmount;\n}\n\n/**\n * @dev A consideration item has the same five components as an offer item and\n * an additional sixth component designating the required recipient of the\n * item.\n */\nstruct ConsiderationItem {\n ItemType itemType;\n address token;\n uint256 identifierOrCriteria;\n uint256 startAmount;\n uint256 endAmount;\n address payable recipient;\n}\n\n/**\n * @dev A spent item is translated from a utilized offer item and has four\n * components: an item type (ETH or other native tokens, ERC20, ERC721, and\n * ERC1155), a token address, a tokenId, and an amount.\n */\nstruct SpentItem {\n ItemType itemType;\n address token;\n uint256 identifier;\n uint256 amount;\n}\n\n/**\n * @dev A received item is translated from a utilized consideration item and has\n * the same four components as a spent item, as well as an additional fifth\n * component designating the required recipient of the item.\n */\nstruct ReceivedItem {\n ItemType itemType;\n address token;\n uint256 identifier;\n uint256 amount;\n address payable recipient;\n}\n\n/**\n * @dev For basic orders involving ETH / native / ERC20 <=> ERC721 / ERC1155\n * matching, a group of six functions may be called that only requires a\n * subset of the usual order arguments. Note the use of a \"basicOrderType\"\n * enum; this represents both the usual order type as well as the \"route\"\n * of the basic order (a simple derivation function for the basic order\n * type is `basicOrderType = orderType + (4 * basicOrderRoute)`.)\n */\nstruct BasicOrderParameters {\n // calldata offset\n address considerationToken; // 0x24\n uint256 considerationIdentifier; // 0x44\n uint256 considerationAmount; // 0x64\n address payable offerer; // 0x84\n address zone; // 0xa4\n address offerToken; // 0xc4\n uint256 offerIdentifier; // 0xe4\n uint256 offerAmount; // 0x104\n BasicOrderType basicOrderType; // 0x124\n uint256 startTime; // 0x144\n uint256 endTime; // 0x164\n bytes32 zoneHash; // 0x184\n uint256 salt; // 0x1a4\n bytes32 offererConduitKey; // 0x1c4\n bytes32 fulfillerConduitKey; // 0x1e4\n uint256 totalOriginalAdditionalRecipients; // 0x204\n AdditionalRecipient[] additionalRecipients; // 0x224\n bytes signature; // 0x244\n // Total length, excluding dynamic array data: 0x264 (580)\n}\n\n/**\n * @dev Basic orders can supply any number of additional recipients, with the\n * implied assumption that they are supplied from the offered ETH (or other\n * native token) or ERC20 token for the order.\n */\nstruct AdditionalRecipient {\n uint256 amount;\n address payable recipient;\n}\n\n/**\n * @dev The full set of order components, with the exception of the counter,\n * must be supplied when fulfilling more sophisticated orders or groups of\n * orders. The total number of original consideration items must also be\n * supplied, as the caller may specify additional consideration items.\n */\nstruct OrderParameters {\n address offerer; // 0x00\n address zone; // 0x20\n OfferItem[] offer; // 0x40\n ConsiderationItem[] consideration; // 0x60\n OrderType orderType; // 0x80\n uint256 startTime; // 0xa0\n uint256 endTime; // 0xc0\n bytes32 zoneHash; // 0xe0\n uint256 salt; // 0x100\n bytes32 conduitKey; // 0x120\n uint256 totalOriginalConsiderationItems; // 0x140\n // offer.length // 0x160\n}\n\n/**\n * @dev Orders require a signature in addition to the other order parameters.\n */\nstruct Order {\n OrderParameters parameters;\n bytes signature;\n}\n\n/**\n * @dev Advanced orders include a numerator (i.e. a fraction to attempt to fill)\n * and a denominator (the total size of the order) in addition to the\n * signature and other order parameters. It also supports an optional field\n * for supplying extra data; this data will be provided to the zone if the\n * order type is restricted and the zone is not the caller, or will be\n * provided to the offerer as context for contract order types.\n */\nstruct AdvancedOrder {\n OrderParameters parameters;\n uint120 numerator;\n uint120 denominator;\n bytes signature;\n bytes extraData;\n}\n\n/**\n * @dev Orders can be validated (either explicitly via `validate`, or as a\n * consequence of a full or partial fill), specifically cancelled (they can\n * also be cancelled in bulk via incrementing a per-zone counter), and\n * partially or fully filled (with the fraction filled represented by a\n * numerator and denominator).\n */\nstruct OrderStatus {\n bool isValidated;\n bool isCancelled;\n uint120 numerator;\n uint120 denominator;\n}\n\n/**\n * @dev A criteria resolver specifies an order, side (offer vs. consideration),\n * and item index. It then provides a chosen identifier (i.e. tokenId)\n * alongside a merkle proof demonstrating the identifier meets the required\n * criteria.\n */\nstruct CriteriaResolver {\n uint256 orderIndex;\n Side side;\n uint256 index;\n uint256 identifier;\n bytes32[] criteriaProof;\n}\n\n/**\n * @dev A fulfillment is applied to a group of orders. It decrements a series of\n * offer and consideration items, then generates a single execution\n * element. A given fulfillment can be applied to as many offer and\n * consideration items as desired, but must contain at least one offer and\n * at least one consideration that match. The fulfillment must also remain\n * consistent on all key parameters across all offer items (same offerer,\n * token, type, tokenId, and conduit preference) as well as across all\n * consideration items (token, type, tokenId, and recipient).\n */\nstruct Fulfillment {\n FulfillmentComponent[] offerComponents;\n FulfillmentComponent[] considerationComponents;\n}\n\n/**\n * @dev Each fulfillment component contains one index referencing a specific\n * order and another referencing a specific offer or consideration item.\n */\nstruct FulfillmentComponent {\n uint256 orderIndex;\n uint256 itemIndex;\n}\n\n/**\n * @dev An execution is triggered once all consideration items have been zeroed\n * out. It sends the item in question from the offerer to the item's\n * recipient, optionally sourcing approvals from either this contract\n * directly or from the offerer's chosen conduit if one is specified. An\n * execution is not provided as an argument, but rather is derived via\n * orders, criteria resolvers, and fulfillments (where the total number of\n * executions will be less than or equal to the total number of indicated\n * fulfillments) and returned as part of `matchOrders`.\n */\nstruct Execution {\n ReceivedItem item;\n address offerer;\n bytes32 conduitKey;\n}\n\n/**\n * @dev Restricted orders are validated post-execution by calling validateOrder\n * on the zone. This struct provides context about the order fulfillment\n * and any supplied extraData, as well as all order hashes fulfilled in a\n * call to a match or fulfillAvailable method.\n */\nstruct ZoneParameters {\n bytes32 orderHash;\n address fulfiller;\n address offerer;\n SpentItem[] offer;\n ReceivedItem[] consideration;\n bytes extraData;\n bytes32[] orderHashes;\n uint256 startTime;\n uint256 endTime;\n bytes32 zoneHash;\n}\n\n/**\n * @dev Zones and contract offerers can communicate which schemas they implement\n * along with any associated metadata related to each schema.\n */\nstruct Schema {\n uint256 id;\n bytes metadata;\n}\n\nusing StructPointers for OrderComponents global;\nusing StructPointers for OfferItem global;\nusing StructPointers for ConsiderationItem global;\nusing StructPointers for SpentItem global;\nusing StructPointers for ReceivedItem global;\nusing StructPointers for BasicOrderParameters global;\nusing StructPointers for AdditionalRecipient global;\nusing StructPointers for OrderParameters global;\nusing StructPointers for Order global;\nusing StructPointers for AdvancedOrder global;\nusing StructPointers for OrderStatus global;\nusing StructPointers for CriteriaResolver global;\nusing StructPointers for Fulfillment global;\nusing StructPointers for FulfillmentComponent global;\nusing StructPointers for Execution global;\nusing StructPointers for ZoneParameters global;\n\n/**\n * @dev This library provides a set of functions for converting structs to\n * pointers.\n */\nlibrary StructPointers {\n /**\n * @dev Get a MemoryPointer from OrderComponents.\n *\n * @param obj The OrderComponents object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderComponents memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderComponents.\n *\n * @param obj The OrderComponents object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderComponents calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OfferItem.\n *\n * @param obj The OfferItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OfferItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OfferItem.\n *\n * @param obj The OfferItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OfferItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ConsiderationItem.\n *\n * @param obj The ConsiderationItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ConsiderationItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ConsiderationItem.\n *\n * @param obj The ConsiderationItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ConsiderationItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from SpentItem.\n *\n * @param obj The SpentItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n SpentItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from SpentItem.\n *\n * @param obj The SpentItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n SpentItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ReceivedItem.\n *\n * @param obj The ReceivedItem object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ReceivedItem memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ReceivedItem.\n *\n * @param obj The ReceivedItem object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ReceivedItem calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from BasicOrderParameters.\n *\n * @param obj The BasicOrderParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n BasicOrderParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from BasicOrderParameters.\n *\n * @param obj The BasicOrderParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n BasicOrderParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from AdditionalRecipient.\n *\n * @param obj The AdditionalRecipient object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n AdditionalRecipient memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from AdditionalRecipient.\n *\n * @param obj The AdditionalRecipient object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n AdditionalRecipient calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OrderParameters.\n *\n * @param obj The OrderParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderParameters.\n *\n * @param obj The OrderParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Order.\n *\n * @param obj The Order object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Order memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Order.\n *\n * @param obj The Order object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Order calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from AdvancedOrder.\n *\n * @param obj The AdvancedOrder object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n AdvancedOrder memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from AdvancedOrder.\n *\n * @param obj The AdvancedOrder object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n AdvancedOrder calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from OrderStatus.\n *\n * @param obj The OrderStatus object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n OrderStatus memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from OrderStatus.\n *\n * @param obj The OrderStatus object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n OrderStatus calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from CriteriaResolver.\n *\n * @param obj The CriteriaResolver object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n CriteriaResolver memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from CriteriaResolver.\n *\n * @param obj The CriteriaResolver object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n CriteriaResolver calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Fulfillment.\n *\n * @param obj The Fulfillment object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Fulfillment memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Fulfillment.\n *\n * @param obj The Fulfillment object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Fulfillment calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from FulfillmentComponent.\n *\n * @param obj The FulfillmentComponent object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n FulfillmentComponent memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from FulfillmentComponent.\n *\n * @param obj The FulfillmentComponent object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n FulfillmentComponent calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from Execution.\n *\n * @param obj The Execution object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n Execution memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from Execution.\n *\n * @param obj The Execution object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n Execution calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a MemoryPointer from ZoneParameters.\n *\n * @param obj The ZoneParameters object.\n *\n * @return ptr The MemoryPointer.\n */\n function toMemoryPointer(\n ZoneParameters memory obj\n ) internal pure returns (MemoryPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n\n /**\n * @dev Get a CalldataPointer from ZoneParameters.\n *\n * @param obj The ZoneParameters object.\n *\n * @return ptr The CalldataPointer.\n */\n function toCalldataPointer(\n ZoneParameters calldata obj\n ) internal pure returns (CalldataPointer ptr) {\n assembly {\n ptr := obj\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/interfaces/ContractOffererInterface.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nimport {ReceivedItem, Schema, SpentItem} from \"../lib/ConsiderationStructs.sol\";\nimport {IERC165} from \"../interfaces/IERC165.sol\";\n\n/**\n * @title ContractOffererInterface\n * @notice Contains the minimum interfaces needed to interact with a contract\n * offerer.\n */\ninterface ContractOffererInterface is IERC165 {\n /**\n * @dev Generates an order with the specified minimum and maximum spent\n * items, and optional context (supplied as extraData).\n *\n * @param fulfiller The address of the fulfiller.\n * @param minimumReceived The minimum items that the caller is willing to\n * receive.\n * @param maximumSpent The maximum items the caller is willing to spend.\n * @param context Additional context of the order.\n *\n * @return offer A tuple containing the offer items.\n * @return consideration A tuple containing the consideration items.\n */\n function generateOrder(\n address fulfiller,\n SpentItem[] calldata minimumReceived,\n SpentItem[] calldata maximumSpent,\n bytes calldata context // encoded based on the schemaID\n ) external returns (SpentItem[] memory offer, ReceivedItem[] memory consideration);\n\n /**\n * @dev Ratifies an order with the specified offer, consideration, and\n * optional context (supplied as extraData).\n *\n * @param offer The offer items.\n * @param consideration The consideration items.\n * @param context Additional context of the order.\n * @param orderHashes The hashes to ratify.\n * @param contractNonce The nonce of the contract.\n *\n * @return ratifyOrderMagicValue The magic value returned by the contract\n * offerer.\n */\n function ratifyOrder(\n SpentItem[] calldata offer,\n ReceivedItem[] calldata consideration,\n bytes calldata context, // encoded based on the schemaID\n bytes32[] calldata orderHashes,\n uint256 contractNonce\n ) external returns (bytes4 ratifyOrderMagicValue);\n\n /**\n * @dev View function to preview an order generated in response to a minimum\n * set of received items, maximum set of spent items, and context\n * (supplied as extraData).\n *\n * @param caller The address of the caller (e.g. Seaport).\n * @param fulfiller The address of the fulfiller (e.g. the account\n * calling Seaport).\n * @param minimumReceived The minimum items that the caller is willing to\n * receive.\n * @param maximumSpent The maximum items the caller is willing to spend.\n * @param context Additional context of the order.\n *\n * @return offer A tuple containing the offer items.\n * @return consideration A tuple containing the consideration items.\n */\n function previewOrder(\n address caller,\n address fulfiller,\n SpentItem[] calldata minimumReceived,\n SpentItem[] calldata maximumSpent,\n bytes calldata context // encoded based on the schemaID\n ) external view returns (SpentItem[] memory offer, ReceivedItem[] memory consideration);\n\n /**\n * @dev Gets the metadata for this contract offerer.\n *\n * @return name The name of the contract offerer.\n * @return schemas The schemas supported by the contract offerer.\n */\n function getSeaportMetadata() external view returns (string memory name, Schema[] memory schemas); // map to Seaport Improvement Proposal IDs\n\n function supportsInterface(bytes4 interfaceId) external view override returns (bool);\n\n // Additional functions and/or events based on implemented schemaIDs\n}\n"
},
"lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.19;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"src/interfaces/ISeaDropTokenContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\ninterface ISeaDropTokenContractMetadata {\n /**\n * @dev Emit an event for token metadata reveals/updates,\n * according to EIP-4906.\n *\n * @param _fromTokenId The start token id.\n * @param _toTokenId The end token id.\n */\n event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n\n /**\n * @dev Emit an event when the URI for the collection-level metadata\n * is updated.\n */\n event ContractURIUpdated(string newContractURI);\n\n /**\n * @dev Emit an event with the previous and new provenance hash after\n * being updated.\n */\n event ProvenanceHashUpdated(bytes32 previousHash, bytes32 newHash);\n\n /**\n * @dev Emit an event when the EIP-2981 royalty info is updated.\n */\n event RoyaltyInfoUpdated(address receiver, uint256 basisPoints);\n\n /**\n * @notice Throw if the max supply exceeds uint64, a limit\n * due to the storage of bit-packed variables.\n */\n error CannotExceedMaxSupplyOfUint64(uint256 got);\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after the mint has started.\n */\n error ProvenanceHashCannotBeSetAfterMintStarted();\n\n /**\n * @dev Revert with an error when attempting to set the provenance\n * hash after it has already been set.\n */\n error ProvenanceHashCannotBeSetAfterAlreadyBeingSet();\n\n /**\n * @notice Sets the base URI for the token metadata and emits an event.\n *\n * @param tokenURI The new base URI to set.\n */\n function setBaseURI(string calldata tokenURI) external;\n\n /**\n * @notice Sets the contract URI for contract metadata.\n *\n * @param newContractURI The new contract URI.\n */\n function setContractURI(string calldata newContractURI) external;\n\n /**\n * @notice Sets the provenance hash and emits an event.\n *\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it has not been\n * modified after mint started.\n *\n * This function will revert after the first item has been minted.\n *\n * @param newProvenanceHash The new provenance hash to set.\n */\n function setProvenanceHash(bytes32 newProvenanceHash) external;\n\n /**\n * @notice Sets the default royalty information.\n *\n * Requirements:\n *\n * - `receiver` cannot be the zero address.\n * - `feeNumerator` cannot be greater than the fee denominator of\n * 10_000 basis points.\n */\n function setDefaultRoyalty(address receiver, uint96 feeNumerator) external;\n\n /**\n * @notice Returns the base URI for token metadata.\n */\n function baseURI() external view returns (string memory);\n\n /**\n * @notice Returns the contract URI.\n */\n function contractURI() external view returns (string memory);\n\n /**\n * @notice Returns the provenance hash.\n * The provenance hash is used for random reveals, which\n * is a hash of the ordered metadata to show it is unmodified\n * after mint has started.\n */\n function provenanceHash() external view returns (bytes32);\n}\n"
},
"src/interfaces/IERC1155ContractMetadata.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport {\n ISeaDropTokenContractMetadata\n} from \"./ISeaDropTokenContractMetadata.sol\";\n\ninterface IERC1155ContractMetadata is ISeaDropTokenContractMetadata {\n /**\n * @dev A struct representing the supply info for a token id,\n * packed into one storage slot.\n *\n * @param maxSupply The max supply for the token id.\n * @param totalSupply The total token supply for the token id.\n * Subtracted when an item is burned.\n * @param totalMinted The total number of tokens minted for the token id.\n */\n struct TokenSupply {\n uint64 maxSupply; // 64/256 bits\n uint64 totalSupply; // 128/256 bits\n uint64 totalMinted; // 192/256 bits\n }\n\n /**\n * @dev Emit an event when the max token supply for a token id is updated.\n */\n event MaxSupplyUpdated(uint256 tokenId, uint256 newMaxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @notice Sets the max supply for a token id and emits an event.\n *\n * @param tokenId The token id to set the max supply for.\n * @param newMaxSupply The new max supply to set.\n */\n function setMaxSupply(uint256 tokenId, uint256 newMaxSupply) external;\n\n /**\n * @notice Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @notice Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @notice Returns the max token supply for a token id.\n */\n function maxSupply(uint256 tokenId) external view returns (uint256);\n\n /**\n * @notice Returns the total supply for a token id.\n */\n function totalSupply(uint256 tokenId) external view returns (uint256);\n\n /**\n * @notice Returns the total minted for a token id.\n */\n function totalMinted(uint256 tokenId) external view returns (uint256);\n}\n"
},
"lib/solady/src/tokens/ERC2981.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple ERC2981 NFT Royalty Standard implementation.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/tokens/ERC2981.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/common/ERC2981.sol)\nabstract contract ERC2981 {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The royalty fee numerator exceeds the fee denominator.\n error RoyaltyOverflow();\n\n /// @dev The royalty receiver cannot be the zero address.\n error RoyaltyReceiverIsZeroAddress();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The default royalty info is given by:\n /// ```\n /// let packed := sload(_ERC2981_MASTER_SLOT_SEED)\n /// let receiver := shr(96, packed)\n /// let royaltyFraction := xor(packed, shl(96, receiver))\n /// ```\n ///\n /// The per token royalty info is given by.\n /// ```\n /// mstore(0x00, tokenId)\n /// mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n /// let packed := sload(keccak256(0x00, 0x40))\n /// let receiver := shr(96, packed)\n /// let royaltyFraction := xor(packed, shl(96, receiver))\n /// ```\n uint256 private constant _ERC2981_MASTER_SLOT_SEED = 0xaa4ec00224afccfdb7;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* ERC2981 */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Checks that `_feeDenominator` is non-zero.\n constructor() {\n require(_feeDenominator() != 0, \"Fee denominator cannot be zero.\");\n }\n\n /// @dev Returns the denominator for the royalty amount.\n /// Defaults to 10000, which represents fees in basis points.\n /// Override this function to return a custom amount if needed.\n function _feeDenominator() internal pure virtual returns (uint96) {\n return 10000;\n }\n\n /// @dev Returns true if this contract implements the interface defined by `interfaceId`.\n /// See: https://eips.ethereum.org/EIPS/eip-165\n /// This function call must use less than 30000 gas.\n function supportsInterface(bytes4 interfaceId) public view virtual returns (bool result) {\n /// @solidity memory-safe-assembly\n assembly {\n let s := shr(224, interfaceId)\n // ERC165: 0x01ffc9a7, ERC2981: 0x2a55205a.\n result := or(eq(s, 0x01ffc9a7), eq(s, 0x2a55205a))\n }\n }\n\n /// @dev Returns the `receiver` and `royaltyAmount` for `tokenId` sold at `salePrice`.\n function royaltyInfo(uint256 tokenId, uint256 salePrice)\n public\n view\n virtual\n returns (address receiver, uint256 royaltyAmount)\n {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n let packed := sload(keccak256(0x00, 0x40))\n receiver := shr(96, packed)\n if iszero(receiver) {\n packed := sload(mload(0x20))\n receiver := shr(96, packed)\n }\n let x := salePrice\n let y := xor(packed, shl(96, receiver)) // `feeNumerator`.\n // Overflow check, equivalent to `require(y == 0 || x <= type(uint256).max / y)`.\n // Out-of-gas revert. Should not be triggered in practice, but included for safety.\n returndatacopy(returndatasize(), returndatasize(), mul(y, gt(x, div(not(0), y))))\n royaltyAmount := div(mul(x, y), feeDenominator)\n }\n }\n\n /// @dev Sets the default royalty `receiver` and `feeNumerator`.\n ///\n /// Requirements:\n /// - `receiver` must not be the zero address.\n /// - `feeNumerator` must not be greater than the fee denominator.\n function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n feeNumerator := shr(160, shl(160, feeNumerator))\n if gt(feeNumerator, feeDenominator) {\n mstore(0x00, 0x350a88b3) // `RoyaltyOverflow()`.\n revert(0x1c, 0x04)\n }\n let packed := shl(96, receiver)\n if iszero(packed) {\n mstore(0x00, 0xb4457eaa) // `RoyaltyReceiverIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n sstore(_ERC2981_MASTER_SLOT_SEED, or(packed, feeNumerator))\n }\n }\n\n /// @dev Sets the default royalty `receiver` and `feeNumerator` to zero.\n function _deleteDefaultRoyalty() internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n sstore(_ERC2981_MASTER_SLOT_SEED, 0)\n }\n }\n\n /// @dev Sets the royalty `receiver` and `feeNumerator` for `tokenId`.\n ///\n /// Requirements:\n /// - `receiver` must not be the zero address.\n /// - `feeNumerator` must not be greater than the fee denominator.\n function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator)\n internal\n virtual\n {\n uint256 feeDenominator = _feeDenominator();\n /// @solidity memory-safe-assembly\n assembly {\n feeNumerator := shr(160, shl(160, feeNumerator))\n if gt(feeNumerator, feeDenominator) {\n mstore(0x00, 0x350a88b3) // `RoyaltyOverflow()`.\n revert(0x1c, 0x04)\n }\n let packed := shl(96, receiver)\n if iszero(packed) {\n mstore(0x00, 0xb4457eaa) // `RoyaltyReceiverIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n sstore(keccak256(0x00, 0x40), or(packed, feeNumerator))\n }\n }\n\n /// @dev Sets the royalty `receiver` and `feeNumerator` for `tokenId` to zero.\n function _resetTokenRoyalty(uint256 tokenId) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, tokenId)\n mstore(0x20, _ERC2981_MASTER_SLOT_SEED)\n sstore(keccak256(0x00, 0x40), 0)\n }\n }\n}\n"
},
"lib/solady/src/auth/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Simple single owner authorization mixin.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol)\n/// @dev While the ownable portion follows\n/// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility,\n/// the nomenclature for the 2-step ownership handover may be unique to this codebase.\nabstract contract Ownable {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CUSTOM ERRORS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The caller is not authorized to call the function.\n error Unauthorized();\n\n /// @dev The `newOwner` cannot be the zero address.\n error NewOwnerIsZeroAddress();\n\n /// @dev The `pendingOwner` does not have a valid handover request.\n error NoHandoverRequest();\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EVENTS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The ownership is transferred from `oldOwner` to `newOwner`.\n /// This event is intentionally kept the same as OpenZeppelin's Ownable to be\n /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173),\n /// despite it not being as lightweight as a single argument event.\n event OwnershipTransferred(address indexed oldOwner, address indexed newOwner);\n\n /// @dev An ownership handover to `pendingOwner` has been requested.\n event OwnershipHandoverRequested(address indexed pendingOwner);\n\n /// @dev The ownership handover to `pendingOwner` has been canceled.\n event OwnershipHandoverCanceled(address indexed pendingOwner);\n\n /// @dev `keccak256(bytes(\"OwnershipTransferred(address,address)\"))`.\n uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE =\n 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverRequested(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE =\n 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d;\n\n /// @dev `keccak256(bytes(\"OwnershipHandoverCanceled(address)\"))`.\n uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE =\n 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* STORAGE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev The owner slot is given by: `not(_OWNER_SLOT_NOT)`.\n /// It is intentionally chosen to be a high value\n /// to avoid collision with lower slots.\n /// The choice of manual storage layout is to enable compatibility\n /// with both regular and upgradeable contracts.\n uint256 private constant _OWNER_SLOT_NOT = 0x8b78c6d8;\n\n /// The ownership handover slot of `newOwner` is given by:\n /// ```\n /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED))\n /// let handoverSlot := keccak256(0x00, 0x20)\n /// ```\n /// It stores the expiry timestamp of the two-step ownership handover.\n uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* INTERNAL FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Initializes the owner directly without authorization guard.\n /// This function must be called upon initialization,\n /// regardless of whether the contract is upgradeable or not.\n /// This is to enable generalization to both regular and upgradeable contracts,\n /// and to save gas in case the initial owner is not the caller.\n /// For performance reasons, this function will not check if there\n /// is an existing owner.\n function _initializeOwner(address newOwner) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Store the new value.\n sstore(not(_OWNER_SLOT_NOT), newOwner)\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner)\n }\n }\n\n /// @dev Sets the owner directly without authorization guard.\n function _setOwner(address newOwner) internal virtual {\n /// @solidity memory-safe-assembly\n assembly {\n let ownerSlot := not(_OWNER_SLOT_NOT)\n // Clean the upper 96 bits.\n newOwner := shr(96, shl(96, newOwner))\n // Emit the {OwnershipTransferred} event.\n log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner)\n // Store the new value.\n sstore(ownerSlot, newOwner)\n }\n }\n\n /// @dev Throws if the sender is not the owner.\n function _checkOwner() internal view virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // If the caller is not the stored owner, revert.\n if iszero(eq(caller(), sload(not(_OWNER_SLOT_NOT)))) {\n mstore(0x00, 0x82b42900) // `Unauthorized()`.\n revert(0x1c, 0x04)\n }\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC UPDATE FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Allows the owner to transfer the ownership to `newOwner`.\n function transferOwnership(address newOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n if iszero(shl(96, newOwner)) {\n mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`.\n revert(0x1c, 0x04)\n }\n }\n _setOwner(newOwner);\n }\n\n /// @dev Allows the owner to renounce their ownership.\n function renounceOwnership() public payable virtual onlyOwner {\n _setOwner(address(0));\n }\n\n /// @dev Request a two-step ownership handover to the caller.\n /// The request will automatically expire in 48 hours (172800 seconds) by default.\n function requestOwnershipHandover() public payable virtual {\n unchecked {\n uint256 expires = block.timestamp + ownershipHandoverValidFor();\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to `expires`.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), expires)\n // Emit the {OwnershipHandoverRequested} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller())\n }\n }\n }\n\n /// @dev Cancels the two-step ownership handover to the caller, if any.\n function cancelOwnershipHandover() public payable virtual {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, caller())\n sstore(keccak256(0x0c, 0x20), 0)\n // Emit the {OwnershipHandoverCanceled} event.\n log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller())\n }\n }\n\n /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`.\n /// Reverts if there is no existing ownership handover requested by `pendingOwner`.\n function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute and set the handover slot to 0.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n let handoverSlot := keccak256(0x0c, 0x20)\n // If the handover does not exist, or has expired.\n if gt(timestamp(), sload(handoverSlot)) {\n mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`.\n revert(0x1c, 0x04)\n }\n // Set the handover slot to 0.\n sstore(handoverSlot, 0)\n }\n _setOwner(pendingOwner);\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PUBLIC READ FUNCTIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the owner of the contract.\n function owner() public view virtual returns (address result) {\n /// @solidity memory-safe-assembly\n assembly {\n result := sload(not(_OWNER_SLOT_NOT))\n }\n }\n\n /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`.\n function ownershipHandoverExpiresAt(address pendingOwner)\n public\n view\n virtual\n returns (uint256 result)\n {\n /// @solidity memory-safe-assembly\n assembly {\n // Compute the handover slot.\n mstore(0x0c, _HANDOVER_SLOT_SEED)\n mstore(0x00, pendingOwner)\n // Load the handover slot.\n result := sload(keccak256(0x0c, 0x20))\n }\n }\n\n /// @dev Returns how long a two-step ownership handover is valid for in seconds.\n function ownershipHandoverValidFor() public view virtual returns (uint64) {\n return 48 * 3600;\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* MODIFIERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Marks a function as only callable by the owner.\n modifier onlyOwner() virtual {\n _checkOwner();\n _;\n }\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.19;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (address(this).code.length == 0 && _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n"
},
"src/lib/SeaDropErrorsAndEvents.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { CreatorPayout, PublicDrop } from \"./ERC721SeaDropStructs.sol\";\n\ninterface SeaDropErrorsAndEvents {\n /**\n * @notice The SeaDrop token types, emitted as part of\n * `event SeaDropTokenDeployed`.\n */\n enum SEADROP_TOKEN_TYPE {\n ERC721_STANDARD,\n ERC721_CLONE,\n ERC721_UPGRADEABLE,\n ERC1155_STANDARD,\n ERC1155_CLONE,\n ERC1155_UPGRADEABLE\n }\n\n /**\n * @notice An event to signify that a SeaDrop token contract was deployed.\n */\n event SeaDropTokenDeployed(SEADROP_TOKEN_TYPE tokenType);\n\n /**\n * @notice Revert with an error if the function selector is not supported.\n */\n error UnsupportedFunctionSelector(bytes4 selector);\n\n /**\n * @dev Revert with an error if the drop stage is not active.\n */\n error NotActive(\n uint256 currentTimestamp,\n uint256 startTimestamp,\n uint256 endTimestamp\n );\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max allowed\n * to be minted per wallet.\n */\n error MintQuantityExceedsMaxMintedPerWallet(uint256 total, uint256 allowed);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply.\n */\n error MintQuantityExceedsMaxSupply(uint256 total, uint256 maxSupply);\n\n /**\n * @dev Revert with an error if the mint quantity exceeds the max token\n * supply for the stage.\n * Note: The `maxTokenSupplyForStage` for public mint is\n * always `type(uint).max`.\n */\n error MintQuantityExceedsMaxTokenSupplyForStage(\n uint256 total,\n uint256 maxTokenSupplyForStage\n );\n\n /**\n * @dev Revert if the fee recipient is the zero address.\n */\n error FeeRecipientCannotBeZeroAddress();\n\n /**\n * @dev Revert if the fee recipient is not already included.\n */\n error FeeRecipientNotPresent();\n\n /**\n * @dev Revert if the fee basis points is greater than 10_000.\n */\n error InvalidFeeBps(uint256 feeBps);\n\n /**\n * @dev Revert if the fee recipient is already included.\n */\n error DuplicateFeeRecipient();\n\n /**\n * @dev Revert if the fee recipient is restricted and not allowed.\n */\n error FeeRecipientNotAllowed(address got);\n\n /**\n * @dev Revert if the creator payout address is the zero address.\n */\n error CreatorPayoutAddressCannotBeZeroAddress();\n\n /**\n * @dev Revert if the creator payouts are not set.\n */\n error CreatorPayoutsNotSet();\n\n /**\n * @dev Revert if the creator payout basis points are zero.\n */\n error CreatorPayoutBasisPointsCannotBeZero();\n\n /**\n * @dev Revert if the total basis points for the creator payouts\n * don't equal exactly 10_000.\n */\n error InvalidCreatorPayoutTotalBasisPoints(\n uint256 totalReceivedBasisPoints\n );\n\n /**\n * @dev Revert if the creator payout basis points don't add up to 10_000.\n */\n error InvalidCreatorPayoutBasisPoints(uint256 totalReceivedBasisPoints);\n\n /**\n * @dev Revert with an error if the allow list proof is invalid.\n */\n error InvalidProof();\n\n /**\n * @dev Revert if a supplied signer address is the zero address.\n */\n error SignerCannotBeZeroAddress();\n\n /**\n * @dev Revert with an error if a signer is not included in\n * the enumeration when removing.\n */\n error SignerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is not included in\n * the enumeration when removing.\n */\n error PayerNotPresent();\n\n /**\n * @dev Revert with an error if a payer is already included in mapping\n * when adding.\n */\n error DuplicatePayer();\n\n /**\n * @dev Revert with an error if a signer is already included in mapping\n * when adding.\n */\n error DuplicateSigner();\n\n /**\n * @dev Revert with an error if the payer is not allowed. The minter must\n * pay for their own mint.\n */\n error PayerNotAllowed(address got);\n\n /**\n * @dev Revert if a supplied payer address is the zero address.\n */\n error PayerCannotBeZeroAddress();\n\n /**\n * @dev Revert if the start time is greater than the end time.\n */\n error InvalidStartAndEndTime(uint256 startTime, uint256 endTime);\n\n /**\n * @dev Revert with an error if the signer payment token is not the same.\n */\n error InvalidSignedPaymentToken(address got, address want);\n\n /**\n * @dev Revert with an error if supplied signed mint price is less than\n * the minimum specified.\n */\n error InvalidSignedMintPrice(\n address paymentToken,\n uint256 got,\n uint256 minimum\n );\n\n /**\n * @dev Revert with an error if supplied signed maxTotalMintableByWallet\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTotalMintableByWallet(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed\n * maxTotalMintableByWalletPerToken is greater than the maximum\n * specified.\n */\n error InvalidSignedMaxTotalMintableByWalletPerToken(\n uint256 got,\n uint256 maximum\n );\n\n /**\n * @dev Revert with an error if the fromTokenId is not within range.\n */\n error InvalidSignedFromTokenId(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if the toTokenId is not within range.\n */\n error InvalidSignedToTokenId(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed start time is less than\n * the minimum specified.\n */\n error InvalidSignedStartTime(uint256 got, uint256 minimum);\n\n /**\n * @dev Revert with an error if supplied signed end time is greater than\n * the maximum specified.\n */\n error InvalidSignedEndTime(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed maxTokenSupplyForStage\n * is greater than the maximum specified.\n */\n error InvalidSignedMaxTokenSupplyForStage(uint256 got, uint256 maximum);\n\n /**\n * @dev Revert with an error if supplied signed feeBps is greater than\n * the maximum specified, or less than the minimum.\n */\n error InvalidSignedFeeBps(uint256 got, uint256 minimumOrMaximum);\n\n /**\n * @dev Revert with an error if signed mint did not specify to restrict\n * fee recipients.\n */\n error SignedMintsMustRestrictFeeRecipients();\n\n /**\n * @dev Revert with an error if a signature for a signed mint has already\n * been used.\n */\n error SignatureAlreadyUsed();\n\n /**\n * @dev Revert with an error if the contract has no balance to withdraw.\n */\n error NoBalanceToWithdraw();\n\n /**\n * @dev Revert with an error if the caller is not an allowed Seaport.\n */\n error InvalidCallerOnlyAllowedSeaport(address caller);\n\n /**\n * @dev Revert with an error if the order does not have the ERC1155 magic\n * consideration item to signify a consecutive mint.\n */\n error MustSpecifyERC1155ConsiderationItemForSeaDropMint();\n\n /**\n * @dev Revert with an error if the extra data version is not supported.\n */\n error UnsupportedExtraDataVersion(uint8 version);\n\n /**\n * @dev Revert with an error if the extra data encoding is not supported.\n */\n error InvalidExtraDataEncoding(uint8 version);\n\n /**\n * @dev Revert with an error if the provided substandard is not supported.\n */\n error InvalidSubstandard(uint8 substandard);\n\n /**\n * @dev Revert with an error if the implementation contract is called without\n * delegatecall.\n */\n error OnlyDelegateCalled();\n\n /**\n * @dev Revert with an error if the provided allowed Seaport is the\n * zero address.\n */\n error AllowedSeaportCannotBeZeroAddress();\n\n /**\n * @dev Emit an event when allowed Seaport contracts are updated.\n */\n event AllowedSeaportUpdated(address[] allowedSeaport);\n\n /**\n * @dev An event with details of a SeaDrop mint, for analytical purposes.\n *\n * @param payer The address who payed for the tx.\n * @param dropStageIndex The drop stage index. Items minted through\n * public mint have dropStageIndex of 0\n */\n event SeaDropMint(address payer, uint256 dropStageIndex);\n\n /**\n * @dev An event with updated allow list data.\n *\n * @param previousMerkleRoot The previous allow list merkle root.\n * @param newMerkleRoot The new allow list merkle root.\n * @param publicKeyURI If the allow list is encrypted, the public key\n * URIs that can decrypt the list.\n * Empty if unencrypted.\n * @param allowListURI The URI for the allow list.\n */\n event AllowListUpdated(\n bytes32 indexed previousMerkleRoot,\n bytes32 indexed newMerkleRoot,\n string[] publicKeyURI,\n string allowListURI\n );\n\n /**\n * @dev An event with updated drop URI.\n */\n event DropURIUpdated(string newDropURI);\n\n /**\n * @dev An event with the updated creator payout address.\n */\n event CreatorPayoutsUpdated(CreatorPayout[] creatorPayouts);\n\n /**\n * @dev An event with the updated allowed fee recipient.\n */\n event AllowedFeeRecipientUpdated(\n address indexed feeRecipient,\n bool indexed allowed\n );\n\n /**\n * @dev An event with the updated signer.\n */\n event SignerUpdated(address indexed signer, bool indexed allowed);\n\n /**\n * @dev An event with the updated payer.\n */\n event PayerUpdated(address indexed payer, bool indexed allowed);\n}\n"
},
"lib/seaport/lib/seaport-types/src/lib/ConsiderationEnums.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\nenum OrderType {\n // 0: no partial fills, anyone can execute\n FULL_OPEN,\n\n // 1: partial fills supported, anyone can execute\n PARTIAL_OPEN,\n\n // 2: no partial fills, only offerer or zone can execute\n FULL_RESTRICTED,\n\n // 3: partial fills supported, only offerer or zone can execute\n PARTIAL_RESTRICTED,\n\n // 4: contract order type\n CONTRACT\n}\n\nenum BasicOrderType {\n // 0: no partial fills, anyone can execute\n ETH_TO_ERC721_FULL_OPEN,\n\n // 1: partial fills supported, anyone can execute\n ETH_TO_ERC721_PARTIAL_OPEN,\n\n // 2: no partial fills, only offerer or zone can execute\n ETH_TO_ERC721_FULL_RESTRICTED,\n\n // 3: partial fills supported, only offerer or zone can execute\n ETH_TO_ERC721_PARTIAL_RESTRICTED,\n\n // 4: no partial fills, anyone can execute\n ETH_TO_ERC1155_FULL_OPEN,\n\n // 5: partial fills supported, anyone can execute\n ETH_TO_ERC1155_PARTIAL_OPEN,\n\n // 6: no partial fills, only offerer or zone can execute\n ETH_TO_ERC1155_FULL_RESTRICTED,\n\n // 7: partial fills supported, only offerer or zone can execute\n ETH_TO_ERC1155_PARTIAL_RESTRICTED,\n\n // 8: no partial fills, anyone can execute\n ERC20_TO_ERC721_FULL_OPEN,\n\n // 9: partial fills supported, anyone can execute\n ERC20_TO_ERC721_PARTIAL_OPEN,\n\n // 10: no partial fills, only offerer or zone can execute\n ERC20_TO_ERC721_FULL_RESTRICTED,\n\n // 11: partial fills supported, only offerer or zone can execute\n ERC20_TO_ERC721_PARTIAL_RESTRICTED,\n\n // 12: no partial fills, anyone can execute\n ERC20_TO_ERC1155_FULL_OPEN,\n\n // 13: partial fills supported, anyone can execute\n ERC20_TO_ERC1155_PARTIAL_OPEN,\n\n // 14: no partial fills, only offerer or zone can execute\n ERC20_TO_ERC1155_FULL_RESTRICTED,\n\n // 15: partial fills supported, only offerer or zone can execute\n ERC20_TO_ERC1155_PARTIAL_RESTRICTED,\n\n // 16: no partial fills, anyone can execute\n ERC721_TO_ERC20_FULL_OPEN,\n\n // 17: partial fills supported, anyone can execute\n ERC721_TO_ERC20_PARTIAL_OPEN,\n\n // 18: no partial fills, only offerer or zone can execute\n ERC721_TO_ERC20_FULL_RESTRICTED,\n\n // 19: partial fills supported, only offerer or zone can execute\n ERC721_TO_ERC20_PARTIAL_RESTRICTED,\n\n // 20: no partial fills, anyone can execute\n ERC1155_TO_ERC20_FULL_OPEN,\n\n // 21: partial fills supported, anyone can execute\n ERC1155_TO_ERC20_PARTIAL_OPEN,\n\n // 22: no partial fills, only offerer or zone can execute\n ERC1155_TO_ERC20_FULL_RESTRICTED,\n\n // 23: partial fills supported, only offerer or zone can execute\n ERC1155_TO_ERC20_PARTIAL_RESTRICTED\n}\n\nenum BasicOrderRouteType {\n // 0: provide Ether (or other native token) to receive offered ERC721 item.\n ETH_TO_ERC721,\n\n // 1: provide Ether (or other native token) to receive offered ERC1155 item.\n ETH_TO_ERC1155,\n\n // 2: provide ERC20 item to receive offered ERC721 item.\n ERC20_TO_ERC721,\n\n // 3: provide ERC20 item to receive offered ERC1155 item.\n ERC20_TO_ERC1155,\n\n // 4: provide ERC721 item to receive offered ERC20 item.\n ERC721_TO_ERC20,\n\n // 5: provide ERC1155 item to receive offered ERC20 item.\n ERC1155_TO_ERC20\n}\n\nenum ItemType {\n // 0: ETH on mainnet, MATIC on polygon, etc.\n NATIVE,\n\n // 1: ERC20 items (ERC777 and ERC20 analogues could also technically work)\n ERC20,\n\n // 2: ERC721 items\n ERC721,\n\n // 3: ERC1155 items\n ERC1155,\n\n // 4: ERC721 items where a number of tokenIds are supported\n ERC721_WITH_CRITERIA,\n\n // 5: ERC1155 items where a number of ids are supported\n ERC1155_WITH_CRITERIA\n}\n\nenum Side {\n // 0: Items that can be spent\n OFFER,\n\n // 1: Items that must be received\n CONSIDERATION\n}\n"
},
"lib/seaport/lib/seaport-types/src/helpers/PointerLibraries.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ntype CalldataPointer is uint256;\n\ntype ReturndataPointer is uint256;\n\ntype MemoryPointer is uint256;\n\nusing CalldataPointerLib for CalldataPointer global;\nusing MemoryPointerLib for MemoryPointer global;\nusing ReturndataPointerLib for ReturndataPointer global;\n\nusing CalldataReaders for CalldataPointer global;\nusing ReturndataReaders for ReturndataPointer global;\nusing MemoryReaders for MemoryPointer global;\nusing MemoryWriters for MemoryPointer global;\n\nCalldataPointer constant CalldataStart = CalldataPointer.wrap(0x04);\nMemoryPointer constant FreeMemoryPPtr = MemoryPointer.wrap(0x40);\nuint256 constant IdentityPrecompileAddress = 0x4;\nuint256 constant OffsetOrLengthMask = 0xffffffff;\nuint256 constant _OneWord = 0x20;\nuint256 constant _FreeMemoryPointerSlot = 0x40;\n\n/// @dev Allocates `size` bytes in memory by increasing the free memory pointer\n/// and returns the memory pointer to the first byte of the allocated region.\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction malloc(uint256 size) pure returns (MemoryPointer mPtr) {\n assembly {\n mPtr := mload(_FreeMemoryPointerSlot)\n mstore(_FreeMemoryPointerSlot, add(mPtr, size))\n }\n}\n\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction getFreeMemoryPointer() pure returns (MemoryPointer mPtr) {\n mPtr = FreeMemoryPPtr.readMemoryPointer();\n}\n\n// (Free functions cannot have visibility.)\n// solhint-disable-next-line func-visibility\nfunction setFreeMemoryPointer(MemoryPointer mPtr) pure {\n FreeMemoryPPtr.write(mPtr);\n}\n\nlibrary CalldataPointerLib {\n function lt(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n CalldataPointer a,\n CalldataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(CalldataPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n /// @dev Resolves an offset stored at `cdPtr + headOffset` to a calldata.\n /// pointer `cdPtr` must point to some parent object with a dynamic\n /// type's head stored at `cdPtr + headOffset`.\n function pptr(\n CalldataPointer cdPtr,\n uint256 headOffset\n ) internal pure returns (CalldataPointer cdPtrChild) {\n cdPtrChild = cdPtr.offset(\n cdPtr.offset(headOffset).readUint256() & OffsetOrLengthMask\n );\n }\n\n /// @dev Resolves an offset stored at `cdPtr` to a calldata pointer.\n /// `cdPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n CalldataPointer cdPtr\n ) internal pure returns (CalldataPointer cdPtrChild) {\n cdPtrChild = cdPtr.offset(cdPtr.readUint256() & OffsetOrLengthMask);\n }\n\n /// @dev Returns the calldata pointer one word after `cdPtr`.\n function next(\n CalldataPointer cdPtr\n ) internal pure returns (CalldataPointer cdPtrNext) {\n assembly {\n cdPtrNext := add(cdPtr, _OneWord)\n }\n }\n\n /// @dev Returns the calldata pointer `_offset` bytes after `cdPtr`.\n function offset(\n CalldataPointer cdPtr,\n uint256 _offset\n ) internal pure returns (CalldataPointer cdPtrNext) {\n assembly {\n cdPtrNext := add(cdPtr, _offset)\n }\n }\n\n /// @dev Copies `size` bytes from calldata starting at `src` to memory at\n /// `dst`.\n function copy(\n CalldataPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal pure {\n assembly {\n calldatacopy(dst, src, size)\n }\n }\n}\n\nlibrary ReturndataPointerLib {\n function lt(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n ReturndataPointer a,\n ReturndataPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(ReturndataPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n /// @dev Resolves an offset stored at `rdPtr + headOffset` to a returndata\n /// pointer. `rdPtr` must point to some parent object with a dynamic\n /// type's head stored at `rdPtr + headOffset`.\n function pptr(\n ReturndataPointer rdPtr,\n uint256 headOffset\n ) internal pure returns (ReturndataPointer rdPtrChild) {\n rdPtrChild = rdPtr.offset(\n rdPtr.offset(headOffset).readUint256() & OffsetOrLengthMask\n );\n }\n\n /// @dev Resolves an offset stored at `rdPtr` to a returndata pointer.\n /// `rdPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n ReturndataPointer rdPtr\n ) internal pure returns (ReturndataPointer rdPtrChild) {\n rdPtrChild = rdPtr.offset(rdPtr.readUint256() & OffsetOrLengthMask);\n }\n\n /// @dev Returns the returndata pointer one word after `cdPtr`.\n function next(\n ReturndataPointer rdPtr\n ) internal pure returns (ReturndataPointer rdPtrNext) {\n assembly {\n rdPtrNext := add(rdPtr, _OneWord)\n }\n }\n\n /// @dev Returns the returndata pointer `_offset` bytes after `cdPtr`.\n function offset(\n ReturndataPointer rdPtr,\n uint256 _offset\n ) internal pure returns (ReturndataPointer rdPtrNext) {\n assembly {\n rdPtrNext := add(rdPtr, _offset)\n }\n }\n\n /// @dev Copies `size` bytes from returndata starting at `src` to memory at\n /// `dst`.\n function copy(\n ReturndataPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal pure {\n assembly {\n returndatacopy(dst, src, size)\n }\n }\n}\n\nlibrary MemoryPointerLib {\n function copy(\n MemoryPointer src,\n MemoryPointer dst,\n uint256 size\n ) internal view {\n assembly {\n let success := staticcall(\n gas(),\n IdentityPrecompileAddress,\n src,\n size,\n dst,\n size\n )\n if or(iszero(returndatasize()), iszero(success)) {\n revert(0, 0)\n }\n }\n }\n\n function lt(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := lt(a, b)\n }\n }\n\n function gt(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := gt(a, b)\n }\n }\n\n function eq(\n MemoryPointer a,\n MemoryPointer b\n ) internal pure returns (bool c) {\n assembly {\n c := eq(a, b)\n }\n }\n\n function isNull(MemoryPointer a) internal pure returns (bool b) {\n assembly {\n b := iszero(a)\n }\n }\n\n function hash(\n MemoryPointer ptr,\n uint256 length\n ) internal pure returns (bytes32 _hash) {\n assembly {\n _hash := keccak256(ptr, length)\n }\n }\n\n /// @dev Returns the memory pointer one word after `mPtr`.\n function next(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer mPtrNext) {\n assembly {\n mPtrNext := add(mPtr, _OneWord)\n }\n }\n\n /// @dev Returns the memory pointer `_offset` bytes after `mPtr`.\n function offset(\n MemoryPointer mPtr,\n uint256 _offset\n ) internal pure returns (MemoryPointer mPtrNext) {\n assembly {\n mPtrNext := add(mPtr, _offset)\n }\n }\n\n /// @dev Resolves a pointer at `mPtr + headOffset` to a memory\n /// pointer. `mPtr` must point to some parent object with a dynamic\n /// type's pointer stored at `mPtr + headOffset`.\n function pptr(\n MemoryPointer mPtr,\n uint256 headOffset\n ) internal pure returns (MemoryPointer mPtrChild) {\n mPtrChild = mPtr.offset(headOffset).readMemoryPointer();\n }\n\n /// @dev Resolves a pointer stored at `mPtr` to a memory pointer.\n /// `mPtr` must point to some parent object with a dynamic type as its\n /// first member, e.g. `struct { bytes data; }`\n function pptr(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer mPtrChild) {\n mPtrChild = mPtr.readMemoryPointer();\n }\n}\n\nlibrary CalldataReaders {\n /// @dev Reads the value at `cdPtr` and applies a mask to return only the\n /// last 4 bytes.\n function readMaskedUint256(\n CalldataPointer cdPtr\n ) internal pure returns (uint256 value) {\n value = cdPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `cdPtr` in calldata.\n function readBool(\n CalldataPointer cdPtr\n ) internal pure returns (bool value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the address at `cdPtr` in calldata.\n function readAddress(\n CalldataPointer cdPtr\n ) internal pure returns (address value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes1 at `cdPtr` in calldata.\n function readBytes1(\n CalldataPointer cdPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes2 at `cdPtr` in calldata.\n function readBytes2(\n CalldataPointer cdPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes3 at `cdPtr` in calldata.\n function readBytes3(\n CalldataPointer cdPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes4 at `cdPtr` in calldata.\n function readBytes4(\n CalldataPointer cdPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes5 at `cdPtr` in calldata.\n function readBytes5(\n CalldataPointer cdPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes6 at `cdPtr` in calldata.\n function readBytes6(\n CalldataPointer cdPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes7 at `cdPtr` in calldata.\n function readBytes7(\n CalldataPointer cdPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes8 at `cdPtr` in calldata.\n function readBytes8(\n CalldataPointer cdPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes9 at `cdPtr` in calldata.\n function readBytes9(\n CalldataPointer cdPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes10 at `cdPtr` in calldata.\n function readBytes10(\n CalldataPointer cdPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes11 at `cdPtr` in calldata.\n function readBytes11(\n CalldataPointer cdPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes12 at `cdPtr` in calldata.\n function readBytes12(\n CalldataPointer cdPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes13 at `cdPtr` in calldata.\n function readBytes13(\n CalldataPointer cdPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes14 at `cdPtr` in calldata.\n function readBytes14(\n CalldataPointer cdPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes15 at `cdPtr` in calldata.\n function readBytes15(\n CalldataPointer cdPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes16 at `cdPtr` in calldata.\n function readBytes16(\n CalldataPointer cdPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes17 at `cdPtr` in calldata.\n function readBytes17(\n CalldataPointer cdPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes18 at `cdPtr` in calldata.\n function readBytes18(\n CalldataPointer cdPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes19 at `cdPtr` in calldata.\n function readBytes19(\n CalldataPointer cdPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes20 at `cdPtr` in calldata.\n function readBytes20(\n CalldataPointer cdPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes21 at `cdPtr` in calldata.\n function readBytes21(\n CalldataPointer cdPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes22 at `cdPtr` in calldata.\n function readBytes22(\n CalldataPointer cdPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes23 at `cdPtr` in calldata.\n function readBytes23(\n CalldataPointer cdPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes24 at `cdPtr` in calldata.\n function readBytes24(\n CalldataPointer cdPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes25 at `cdPtr` in calldata.\n function readBytes25(\n CalldataPointer cdPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes26 at `cdPtr` in calldata.\n function readBytes26(\n CalldataPointer cdPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes27 at `cdPtr` in calldata.\n function readBytes27(\n CalldataPointer cdPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes28 at `cdPtr` in calldata.\n function readBytes28(\n CalldataPointer cdPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes29 at `cdPtr` in calldata.\n function readBytes29(\n CalldataPointer cdPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes30 at `cdPtr` in calldata.\n function readBytes30(\n CalldataPointer cdPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes31 at `cdPtr` in calldata.\n function readBytes31(\n CalldataPointer cdPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the bytes32 at `cdPtr` in calldata.\n function readBytes32(\n CalldataPointer cdPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint8 at `cdPtr` in calldata.\n function readUint8(\n CalldataPointer cdPtr\n ) internal pure returns (uint8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint16 at `cdPtr` in calldata.\n function readUint16(\n CalldataPointer cdPtr\n ) internal pure returns (uint16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint24 at `cdPtr` in calldata.\n function readUint24(\n CalldataPointer cdPtr\n ) internal pure returns (uint24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint32 at `cdPtr` in calldata.\n function readUint32(\n CalldataPointer cdPtr\n ) internal pure returns (uint32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint40 at `cdPtr` in calldata.\n function readUint40(\n CalldataPointer cdPtr\n ) internal pure returns (uint40 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint48 at `cdPtr` in calldata.\n function readUint48(\n CalldataPointer cdPtr\n ) internal pure returns (uint48 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint56 at `cdPtr` in calldata.\n function readUint56(\n CalldataPointer cdPtr\n ) internal pure returns (uint56 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint64 at `cdPtr` in calldata.\n function readUint64(\n CalldataPointer cdPtr\n ) internal pure returns (uint64 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint72 at `cdPtr` in calldata.\n function readUint72(\n CalldataPointer cdPtr\n ) internal pure returns (uint72 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint80 at `cdPtr` in calldata.\n function readUint80(\n CalldataPointer cdPtr\n ) internal pure returns (uint80 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint88 at `cdPtr` in calldata.\n function readUint88(\n CalldataPointer cdPtr\n ) internal pure returns (uint88 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint96 at `cdPtr` in calldata.\n function readUint96(\n CalldataPointer cdPtr\n ) internal pure returns (uint96 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint104 at `cdPtr` in calldata.\n function readUint104(\n CalldataPointer cdPtr\n ) internal pure returns (uint104 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint112 at `cdPtr` in calldata.\n function readUint112(\n CalldataPointer cdPtr\n ) internal pure returns (uint112 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint120 at `cdPtr` in calldata.\n function readUint120(\n CalldataPointer cdPtr\n ) internal pure returns (uint120 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint128 at `cdPtr` in calldata.\n function readUint128(\n CalldataPointer cdPtr\n ) internal pure returns (uint128 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint136 at `cdPtr` in calldata.\n function readUint136(\n CalldataPointer cdPtr\n ) internal pure returns (uint136 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint144 at `cdPtr` in calldata.\n function readUint144(\n CalldataPointer cdPtr\n ) internal pure returns (uint144 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint152 at `cdPtr` in calldata.\n function readUint152(\n CalldataPointer cdPtr\n ) internal pure returns (uint152 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint160 at `cdPtr` in calldata.\n function readUint160(\n CalldataPointer cdPtr\n ) internal pure returns (uint160 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint168 at `cdPtr` in calldata.\n function readUint168(\n CalldataPointer cdPtr\n ) internal pure returns (uint168 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint176 at `cdPtr` in calldata.\n function readUint176(\n CalldataPointer cdPtr\n ) internal pure returns (uint176 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint184 at `cdPtr` in calldata.\n function readUint184(\n CalldataPointer cdPtr\n ) internal pure returns (uint184 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint192 at `cdPtr` in calldata.\n function readUint192(\n CalldataPointer cdPtr\n ) internal pure returns (uint192 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint200 at `cdPtr` in calldata.\n function readUint200(\n CalldataPointer cdPtr\n ) internal pure returns (uint200 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint208 at `cdPtr` in calldata.\n function readUint208(\n CalldataPointer cdPtr\n ) internal pure returns (uint208 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint216 at `cdPtr` in calldata.\n function readUint216(\n CalldataPointer cdPtr\n ) internal pure returns (uint216 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint224 at `cdPtr` in calldata.\n function readUint224(\n CalldataPointer cdPtr\n ) internal pure returns (uint224 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint232 at `cdPtr` in calldata.\n function readUint232(\n CalldataPointer cdPtr\n ) internal pure returns (uint232 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint240 at `cdPtr` in calldata.\n function readUint240(\n CalldataPointer cdPtr\n ) internal pure returns (uint240 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint248 at `cdPtr` in calldata.\n function readUint248(\n CalldataPointer cdPtr\n ) internal pure returns (uint248 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the uint256 at `cdPtr` in calldata.\n function readUint256(\n CalldataPointer cdPtr\n ) internal pure returns (uint256 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int8 at `cdPtr` in calldata.\n function readInt8(\n CalldataPointer cdPtr\n ) internal pure returns (int8 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int16 at `cdPtr` in calldata.\n function readInt16(\n CalldataPointer cdPtr\n ) internal pure returns (int16 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int24 at `cdPtr` in calldata.\n function readInt24(\n CalldataPointer cdPtr\n ) internal pure returns (int24 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int32 at `cdPtr` in calldata.\n function readInt32(\n CalldataPointer cdPtr\n ) internal pure returns (int32 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int40 at `cdPtr` in calldata.\n function readInt40(\n CalldataPointer cdPtr\n ) internal pure returns (int40 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int48 at `cdPtr` in calldata.\n function readInt48(\n CalldataPointer cdPtr\n ) internal pure returns (int48 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int56 at `cdPtr` in calldata.\n function readInt56(\n CalldataPointer cdPtr\n ) internal pure returns (int56 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int64 at `cdPtr` in calldata.\n function readInt64(\n CalldataPointer cdPtr\n ) internal pure returns (int64 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int72 at `cdPtr` in calldata.\n function readInt72(\n CalldataPointer cdPtr\n ) internal pure returns (int72 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int80 at `cdPtr` in calldata.\n function readInt80(\n CalldataPointer cdPtr\n ) internal pure returns (int80 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int88 at `cdPtr` in calldata.\n function readInt88(\n CalldataPointer cdPtr\n ) internal pure returns (int88 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int96 at `cdPtr` in calldata.\n function readInt96(\n CalldataPointer cdPtr\n ) internal pure returns (int96 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int104 at `cdPtr` in calldata.\n function readInt104(\n CalldataPointer cdPtr\n ) internal pure returns (int104 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int112 at `cdPtr` in calldata.\n function readInt112(\n CalldataPointer cdPtr\n ) internal pure returns (int112 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int120 at `cdPtr` in calldata.\n function readInt120(\n CalldataPointer cdPtr\n ) internal pure returns (int120 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int128 at `cdPtr` in calldata.\n function readInt128(\n CalldataPointer cdPtr\n ) internal pure returns (int128 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int136 at `cdPtr` in calldata.\n function readInt136(\n CalldataPointer cdPtr\n ) internal pure returns (int136 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int144 at `cdPtr` in calldata.\n function readInt144(\n CalldataPointer cdPtr\n ) internal pure returns (int144 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int152 at `cdPtr` in calldata.\n function readInt152(\n CalldataPointer cdPtr\n ) internal pure returns (int152 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int160 at `cdPtr` in calldata.\n function readInt160(\n CalldataPointer cdPtr\n ) internal pure returns (int160 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int168 at `cdPtr` in calldata.\n function readInt168(\n CalldataPointer cdPtr\n ) internal pure returns (int168 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int176 at `cdPtr` in calldata.\n function readInt176(\n CalldataPointer cdPtr\n ) internal pure returns (int176 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int184 at `cdPtr` in calldata.\n function readInt184(\n CalldataPointer cdPtr\n ) internal pure returns (int184 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int192 at `cdPtr` in calldata.\n function readInt192(\n CalldataPointer cdPtr\n ) internal pure returns (int192 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int200 at `cdPtr` in calldata.\n function readInt200(\n CalldataPointer cdPtr\n ) internal pure returns (int200 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int208 at `cdPtr` in calldata.\n function readInt208(\n CalldataPointer cdPtr\n ) internal pure returns (int208 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int216 at `cdPtr` in calldata.\n function readInt216(\n CalldataPointer cdPtr\n ) internal pure returns (int216 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int224 at `cdPtr` in calldata.\n function readInt224(\n CalldataPointer cdPtr\n ) internal pure returns (int224 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int232 at `cdPtr` in calldata.\n function readInt232(\n CalldataPointer cdPtr\n ) internal pure returns (int232 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int240 at `cdPtr` in calldata.\n function readInt240(\n CalldataPointer cdPtr\n ) internal pure returns (int240 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int248 at `cdPtr` in calldata.\n function readInt248(\n CalldataPointer cdPtr\n ) internal pure returns (int248 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n\n /// @dev Reads the int256 at `cdPtr` in calldata.\n function readInt256(\n CalldataPointer cdPtr\n ) internal pure returns (int256 value) {\n assembly {\n value := calldataload(cdPtr)\n }\n }\n}\n\nlibrary ReturndataReaders {\n /// @dev Reads value at `rdPtr` & applies a mask to return only last 4 bytes\n function readMaskedUint256(\n ReturndataPointer rdPtr\n ) internal pure returns (uint256 value) {\n value = rdPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `rdPtr` in returndata.\n function readBool(\n ReturndataPointer rdPtr\n ) internal pure returns (bool value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the address at `rdPtr` in returndata.\n function readAddress(\n ReturndataPointer rdPtr\n ) internal pure returns (address value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes1 at `rdPtr` in returndata.\n function readBytes1(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes2 at `rdPtr` in returndata.\n function readBytes2(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes3 at `rdPtr` in returndata.\n function readBytes3(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes4 at `rdPtr` in returndata.\n function readBytes4(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes5 at `rdPtr` in returndata.\n function readBytes5(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes6 at `rdPtr` in returndata.\n function readBytes6(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes7 at `rdPtr` in returndata.\n function readBytes7(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes8 at `rdPtr` in returndata.\n function readBytes8(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes9 at `rdPtr` in returndata.\n function readBytes9(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes10 at `rdPtr` in returndata.\n function readBytes10(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes11 at `rdPtr` in returndata.\n function readBytes11(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes12 at `rdPtr` in returndata.\n function readBytes12(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes13 at `rdPtr` in returndata.\n function readBytes13(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes14 at `rdPtr` in returndata.\n function readBytes14(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes15 at `rdPtr` in returndata.\n function readBytes15(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes16 at `rdPtr` in returndata.\n function readBytes16(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes17 at `rdPtr` in returndata.\n function readBytes17(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes18 at `rdPtr` in returndata.\n function readBytes18(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes19 at `rdPtr` in returndata.\n function readBytes19(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes20 at `rdPtr` in returndata.\n function readBytes20(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes21 at `rdPtr` in returndata.\n function readBytes21(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes22 at `rdPtr` in returndata.\n function readBytes22(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes23 at `rdPtr` in returndata.\n function readBytes23(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes24 at `rdPtr` in returndata.\n function readBytes24(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes25 at `rdPtr` in returndata.\n function readBytes25(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes26 at `rdPtr` in returndata.\n function readBytes26(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes27 at `rdPtr` in returndata.\n function readBytes27(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes28 at `rdPtr` in returndata.\n function readBytes28(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes29 at `rdPtr` in returndata.\n function readBytes29(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes30 at `rdPtr` in returndata.\n function readBytes30(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes31 at `rdPtr` in returndata.\n function readBytes31(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the bytes32 at `rdPtr` in returndata.\n function readBytes32(\n ReturndataPointer rdPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint8 at `rdPtr` in returndata.\n function readUint8(\n ReturndataPointer rdPtr\n ) internal pure returns (uint8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint16 at `rdPtr` in returndata.\n function readUint16(\n ReturndataPointer rdPtr\n ) internal pure returns (uint16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint24 at `rdPtr` in returndata.\n function readUint24(\n ReturndataPointer rdPtr\n ) internal pure returns (uint24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint32 at `rdPtr` in returndata.\n function readUint32(\n ReturndataPointer rdPtr\n ) internal pure returns (uint32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint40 at `rdPtr` in returndata.\n function readUint40(\n ReturndataPointer rdPtr\n ) internal pure returns (uint40 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint48 at `rdPtr` in returndata.\n function readUint48(\n ReturndataPointer rdPtr\n ) internal pure returns (uint48 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint56 at `rdPtr` in returndata.\n function readUint56(\n ReturndataPointer rdPtr\n ) internal pure returns (uint56 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint64 at `rdPtr` in returndata.\n function readUint64(\n ReturndataPointer rdPtr\n ) internal pure returns (uint64 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint72 at `rdPtr` in returndata.\n function readUint72(\n ReturndataPointer rdPtr\n ) internal pure returns (uint72 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint80 at `rdPtr` in returndata.\n function readUint80(\n ReturndataPointer rdPtr\n ) internal pure returns (uint80 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint88 at `rdPtr` in returndata.\n function readUint88(\n ReturndataPointer rdPtr\n ) internal pure returns (uint88 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint96 at `rdPtr` in returndata.\n function readUint96(\n ReturndataPointer rdPtr\n ) internal pure returns (uint96 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint104 at `rdPtr` in returndata.\n function readUint104(\n ReturndataPointer rdPtr\n ) internal pure returns (uint104 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint112 at `rdPtr` in returndata.\n function readUint112(\n ReturndataPointer rdPtr\n ) internal pure returns (uint112 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint120 at `rdPtr` in returndata.\n function readUint120(\n ReturndataPointer rdPtr\n ) internal pure returns (uint120 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint128 at `rdPtr` in returndata.\n function readUint128(\n ReturndataPointer rdPtr\n ) internal pure returns (uint128 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint136 at `rdPtr` in returndata.\n function readUint136(\n ReturndataPointer rdPtr\n ) internal pure returns (uint136 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint144 at `rdPtr` in returndata.\n function readUint144(\n ReturndataPointer rdPtr\n ) internal pure returns (uint144 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint152 at `rdPtr` in returndata.\n function readUint152(\n ReturndataPointer rdPtr\n ) internal pure returns (uint152 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint160 at `rdPtr` in returndata.\n function readUint160(\n ReturndataPointer rdPtr\n ) internal pure returns (uint160 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint168 at `rdPtr` in returndata.\n function readUint168(\n ReturndataPointer rdPtr\n ) internal pure returns (uint168 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint176 at `rdPtr` in returndata.\n function readUint176(\n ReturndataPointer rdPtr\n ) internal pure returns (uint176 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint184 at `rdPtr` in returndata.\n function readUint184(\n ReturndataPointer rdPtr\n ) internal pure returns (uint184 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint192 at `rdPtr` in returndata.\n function readUint192(\n ReturndataPointer rdPtr\n ) internal pure returns (uint192 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint200 at `rdPtr` in returndata.\n function readUint200(\n ReturndataPointer rdPtr\n ) internal pure returns (uint200 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint208 at `rdPtr` in returndata.\n function readUint208(\n ReturndataPointer rdPtr\n ) internal pure returns (uint208 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint216 at `rdPtr` in returndata.\n function readUint216(\n ReturndataPointer rdPtr\n ) internal pure returns (uint216 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint224 at `rdPtr` in returndata.\n function readUint224(\n ReturndataPointer rdPtr\n ) internal pure returns (uint224 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint232 at `rdPtr` in returndata.\n function readUint232(\n ReturndataPointer rdPtr\n ) internal pure returns (uint232 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint240 at `rdPtr` in returndata.\n function readUint240(\n ReturndataPointer rdPtr\n ) internal pure returns (uint240 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint248 at `rdPtr` in returndata.\n function readUint248(\n ReturndataPointer rdPtr\n ) internal pure returns (uint248 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the uint256 at `rdPtr` in returndata.\n function readUint256(\n ReturndataPointer rdPtr\n ) internal pure returns (uint256 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int8 at `rdPtr` in returndata.\n function readInt8(\n ReturndataPointer rdPtr\n ) internal pure returns (int8 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int16 at `rdPtr` in returndata.\n function readInt16(\n ReturndataPointer rdPtr\n ) internal pure returns (int16 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int24 at `rdPtr` in returndata.\n function readInt24(\n ReturndataPointer rdPtr\n ) internal pure returns (int24 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int32 at `rdPtr` in returndata.\n function readInt32(\n ReturndataPointer rdPtr\n ) internal pure returns (int32 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int40 at `rdPtr` in returndata.\n function readInt40(\n ReturndataPointer rdPtr\n ) internal pure returns (int40 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int48 at `rdPtr` in returndata.\n function readInt48(\n ReturndataPointer rdPtr\n ) internal pure returns (int48 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int56 at `rdPtr` in returndata.\n function readInt56(\n ReturndataPointer rdPtr\n ) internal pure returns (int56 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int64 at `rdPtr` in returndata.\n function readInt64(\n ReturndataPointer rdPtr\n ) internal pure returns (int64 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int72 at `rdPtr` in returndata.\n function readInt72(\n ReturndataPointer rdPtr\n ) internal pure returns (int72 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int80 at `rdPtr` in returndata.\n function readInt80(\n ReturndataPointer rdPtr\n ) internal pure returns (int80 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int88 at `rdPtr` in returndata.\n function readInt88(\n ReturndataPointer rdPtr\n ) internal pure returns (int88 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int96 at `rdPtr` in returndata.\n function readInt96(\n ReturndataPointer rdPtr\n ) internal pure returns (int96 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int104 at `rdPtr` in returndata.\n function readInt104(\n ReturndataPointer rdPtr\n ) internal pure returns (int104 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int112 at `rdPtr` in returndata.\n function readInt112(\n ReturndataPointer rdPtr\n ) internal pure returns (int112 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int120 at `rdPtr` in returndata.\n function readInt120(\n ReturndataPointer rdPtr\n ) internal pure returns (int120 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int128 at `rdPtr` in returndata.\n function readInt128(\n ReturndataPointer rdPtr\n ) internal pure returns (int128 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int136 at `rdPtr` in returndata.\n function readInt136(\n ReturndataPointer rdPtr\n ) internal pure returns (int136 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int144 at `rdPtr` in returndata.\n function readInt144(\n ReturndataPointer rdPtr\n ) internal pure returns (int144 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int152 at `rdPtr` in returndata.\n function readInt152(\n ReturndataPointer rdPtr\n ) internal pure returns (int152 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int160 at `rdPtr` in returndata.\n function readInt160(\n ReturndataPointer rdPtr\n ) internal pure returns (int160 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int168 at `rdPtr` in returndata.\n function readInt168(\n ReturndataPointer rdPtr\n ) internal pure returns (int168 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int176 at `rdPtr` in returndata.\n function readInt176(\n ReturndataPointer rdPtr\n ) internal pure returns (int176 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int184 at `rdPtr` in returndata.\n function readInt184(\n ReturndataPointer rdPtr\n ) internal pure returns (int184 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int192 at `rdPtr` in returndata.\n function readInt192(\n ReturndataPointer rdPtr\n ) internal pure returns (int192 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int200 at `rdPtr` in returndata.\n function readInt200(\n ReturndataPointer rdPtr\n ) internal pure returns (int200 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int208 at `rdPtr` in returndata.\n function readInt208(\n ReturndataPointer rdPtr\n ) internal pure returns (int208 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int216 at `rdPtr` in returndata.\n function readInt216(\n ReturndataPointer rdPtr\n ) internal pure returns (int216 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int224 at `rdPtr` in returndata.\n function readInt224(\n ReturndataPointer rdPtr\n ) internal pure returns (int224 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int232 at `rdPtr` in returndata.\n function readInt232(\n ReturndataPointer rdPtr\n ) internal pure returns (int232 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int240 at `rdPtr` in returndata.\n function readInt240(\n ReturndataPointer rdPtr\n ) internal pure returns (int240 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int248 at `rdPtr` in returndata.\n function readInt248(\n ReturndataPointer rdPtr\n ) internal pure returns (int248 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n\n /// @dev Reads the int256 at `rdPtr` in returndata.\n function readInt256(\n ReturndataPointer rdPtr\n ) internal pure returns (int256 value) {\n assembly {\n returndatacopy(0, rdPtr, _OneWord)\n value := mload(0)\n }\n }\n}\n\nlibrary MemoryReaders {\n /// @dev Reads the memory pointer at `mPtr` in memory.\n function readMemoryPointer(\n MemoryPointer mPtr\n ) internal pure returns (MemoryPointer value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads value at `mPtr` & applies a mask to return only last 4 bytes\n function readMaskedUint256(\n MemoryPointer mPtr\n ) internal pure returns (uint256 value) {\n value = mPtr.readUint256() & OffsetOrLengthMask;\n }\n\n /// @dev Reads the bool at `mPtr` in memory.\n function readBool(MemoryPointer mPtr) internal pure returns (bool value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the address at `mPtr` in memory.\n function readAddress(\n MemoryPointer mPtr\n ) internal pure returns (address value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes1 at `mPtr` in memory.\n function readBytes1(\n MemoryPointer mPtr\n ) internal pure returns (bytes1 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes2 at `mPtr` in memory.\n function readBytes2(\n MemoryPointer mPtr\n ) internal pure returns (bytes2 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes3 at `mPtr` in memory.\n function readBytes3(\n MemoryPointer mPtr\n ) internal pure returns (bytes3 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes4 at `mPtr` in memory.\n function readBytes4(\n MemoryPointer mPtr\n ) internal pure returns (bytes4 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes5 at `mPtr` in memory.\n function readBytes5(\n MemoryPointer mPtr\n ) internal pure returns (bytes5 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes6 at `mPtr` in memory.\n function readBytes6(\n MemoryPointer mPtr\n ) internal pure returns (bytes6 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes7 at `mPtr` in memory.\n function readBytes7(\n MemoryPointer mPtr\n ) internal pure returns (bytes7 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes8 at `mPtr` in memory.\n function readBytes8(\n MemoryPointer mPtr\n ) internal pure returns (bytes8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes9 at `mPtr` in memory.\n function readBytes9(\n MemoryPointer mPtr\n ) internal pure returns (bytes9 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes10 at `mPtr` in memory.\n function readBytes10(\n MemoryPointer mPtr\n ) internal pure returns (bytes10 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes11 at `mPtr` in memory.\n function readBytes11(\n MemoryPointer mPtr\n ) internal pure returns (bytes11 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes12 at `mPtr` in memory.\n function readBytes12(\n MemoryPointer mPtr\n ) internal pure returns (bytes12 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes13 at `mPtr` in memory.\n function readBytes13(\n MemoryPointer mPtr\n ) internal pure returns (bytes13 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes14 at `mPtr` in memory.\n function readBytes14(\n MemoryPointer mPtr\n ) internal pure returns (bytes14 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes15 at `mPtr` in memory.\n function readBytes15(\n MemoryPointer mPtr\n ) internal pure returns (bytes15 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes16 at `mPtr` in memory.\n function readBytes16(\n MemoryPointer mPtr\n ) internal pure returns (bytes16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes17 at `mPtr` in memory.\n function readBytes17(\n MemoryPointer mPtr\n ) internal pure returns (bytes17 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes18 at `mPtr` in memory.\n function readBytes18(\n MemoryPointer mPtr\n ) internal pure returns (bytes18 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes19 at `mPtr` in memory.\n function readBytes19(\n MemoryPointer mPtr\n ) internal pure returns (bytes19 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes20 at `mPtr` in memory.\n function readBytes20(\n MemoryPointer mPtr\n ) internal pure returns (bytes20 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes21 at `mPtr` in memory.\n function readBytes21(\n MemoryPointer mPtr\n ) internal pure returns (bytes21 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes22 at `mPtr` in memory.\n function readBytes22(\n MemoryPointer mPtr\n ) internal pure returns (bytes22 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes23 at `mPtr` in memory.\n function readBytes23(\n MemoryPointer mPtr\n ) internal pure returns (bytes23 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes24 at `mPtr` in memory.\n function readBytes24(\n MemoryPointer mPtr\n ) internal pure returns (bytes24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes25 at `mPtr` in memory.\n function readBytes25(\n MemoryPointer mPtr\n ) internal pure returns (bytes25 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes26 at `mPtr` in memory.\n function readBytes26(\n MemoryPointer mPtr\n ) internal pure returns (bytes26 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes27 at `mPtr` in memory.\n function readBytes27(\n MemoryPointer mPtr\n ) internal pure returns (bytes27 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes28 at `mPtr` in memory.\n function readBytes28(\n MemoryPointer mPtr\n ) internal pure returns (bytes28 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes29 at `mPtr` in memory.\n function readBytes29(\n MemoryPointer mPtr\n ) internal pure returns (bytes29 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes30 at `mPtr` in memory.\n function readBytes30(\n MemoryPointer mPtr\n ) internal pure returns (bytes30 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes31 at `mPtr` in memory.\n function readBytes31(\n MemoryPointer mPtr\n ) internal pure returns (bytes31 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the bytes32 at `mPtr` in memory.\n function readBytes32(\n MemoryPointer mPtr\n ) internal pure returns (bytes32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint8 at `mPtr` in memory.\n function readUint8(MemoryPointer mPtr) internal pure returns (uint8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint16 at `mPtr` in memory.\n function readUint16(\n MemoryPointer mPtr\n ) internal pure returns (uint16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint24 at `mPtr` in memory.\n function readUint24(\n MemoryPointer mPtr\n ) internal pure returns (uint24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint32 at `mPtr` in memory.\n function readUint32(\n MemoryPointer mPtr\n ) internal pure returns (uint32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint40 at `mPtr` in memory.\n function readUint40(\n MemoryPointer mPtr\n ) internal pure returns (uint40 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint48 at `mPtr` in memory.\n function readUint48(\n MemoryPointer mPtr\n ) internal pure returns (uint48 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint56 at `mPtr` in memory.\n function readUint56(\n MemoryPointer mPtr\n ) internal pure returns (uint56 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint64 at `mPtr` in memory.\n function readUint64(\n MemoryPointer mPtr\n ) internal pure returns (uint64 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint72 at `mPtr` in memory.\n function readUint72(\n MemoryPointer mPtr\n ) internal pure returns (uint72 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint80 at `mPtr` in memory.\n function readUint80(\n MemoryPointer mPtr\n ) internal pure returns (uint80 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint88 at `mPtr` in memory.\n function readUint88(\n MemoryPointer mPtr\n ) internal pure returns (uint88 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint96 at `mPtr` in memory.\n function readUint96(\n MemoryPointer mPtr\n ) internal pure returns (uint96 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint104 at `mPtr` in memory.\n function readUint104(\n MemoryPointer mPtr\n ) internal pure returns (uint104 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint112 at `mPtr` in memory.\n function readUint112(\n MemoryPointer mPtr\n ) internal pure returns (uint112 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint120 at `mPtr` in memory.\n function readUint120(\n MemoryPointer mPtr\n ) internal pure returns (uint120 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint128 at `mPtr` in memory.\n function readUint128(\n MemoryPointer mPtr\n ) internal pure returns (uint128 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint136 at `mPtr` in memory.\n function readUint136(\n MemoryPointer mPtr\n ) internal pure returns (uint136 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint144 at `mPtr` in memory.\n function readUint144(\n MemoryPointer mPtr\n ) internal pure returns (uint144 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint152 at `mPtr` in memory.\n function readUint152(\n MemoryPointer mPtr\n ) internal pure returns (uint152 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint160 at `mPtr` in memory.\n function readUint160(\n MemoryPointer mPtr\n ) internal pure returns (uint160 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint168 at `mPtr` in memory.\n function readUint168(\n MemoryPointer mPtr\n ) internal pure returns (uint168 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint176 at `mPtr` in memory.\n function readUint176(\n MemoryPointer mPtr\n ) internal pure returns (uint176 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint184 at `mPtr` in memory.\n function readUint184(\n MemoryPointer mPtr\n ) internal pure returns (uint184 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint192 at `mPtr` in memory.\n function readUint192(\n MemoryPointer mPtr\n ) internal pure returns (uint192 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint200 at `mPtr` in memory.\n function readUint200(\n MemoryPointer mPtr\n ) internal pure returns (uint200 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint208 at `mPtr` in memory.\n function readUint208(\n MemoryPointer mPtr\n ) internal pure returns (uint208 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint216 at `mPtr` in memory.\n function readUint216(\n MemoryPointer mPtr\n ) internal pure returns (uint216 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint224 at `mPtr` in memory.\n function readUint224(\n MemoryPointer mPtr\n ) internal pure returns (uint224 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint232 at `mPtr` in memory.\n function readUint232(\n MemoryPointer mPtr\n ) internal pure returns (uint232 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint240 at `mPtr` in memory.\n function readUint240(\n MemoryPointer mPtr\n ) internal pure returns (uint240 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint248 at `mPtr` in memory.\n function readUint248(\n MemoryPointer mPtr\n ) internal pure returns (uint248 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the uint256 at `mPtr` in memory.\n function readUint256(\n MemoryPointer mPtr\n ) internal pure returns (uint256 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int8 at `mPtr` in memory.\n function readInt8(MemoryPointer mPtr) internal pure returns (int8 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int16 at `mPtr` in memory.\n function readInt16(MemoryPointer mPtr) internal pure returns (int16 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int24 at `mPtr` in memory.\n function readInt24(MemoryPointer mPtr) internal pure returns (int24 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int32 at `mPtr` in memory.\n function readInt32(MemoryPointer mPtr) internal pure returns (int32 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int40 at `mPtr` in memory.\n function readInt40(MemoryPointer mPtr) internal pure returns (int40 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int48 at `mPtr` in memory.\n function readInt48(MemoryPointer mPtr) internal pure returns (int48 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int56 at `mPtr` in memory.\n function readInt56(MemoryPointer mPtr) internal pure returns (int56 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int64 at `mPtr` in memory.\n function readInt64(MemoryPointer mPtr) internal pure returns (int64 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int72 at `mPtr` in memory.\n function readInt72(MemoryPointer mPtr) internal pure returns (int72 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int80 at `mPtr` in memory.\n function readInt80(MemoryPointer mPtr) internal pure returns (int80 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int88 at `mPtr` in memory.\n function readInt88(MemoryPointer mPtr) internal pure returns (int88 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int96 at `mPtr` in memory.\n function readInt96(MemoryPointer mPtr) internal pure returns (int96 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int104 at `mPtr` in memory.\n function readInt104(\n MemoryPointer mPtr\n ) internal pure returns (int104 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int112 at `mPtr` in memory.\n function readInt112(\n MemoryPointer mPtr\n ) internal pure returns (int112 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int120 at `mPtr` in memory.\n function readInt120(\n MemoryPointer mPtr\n ) internal pure returns (int120 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int128 at `mPtr` in memory.\n function readInt128(\n MemoryPointer mPtr\n ) internal pure returns (int128 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int136 at `mPtr` in memory.\n function readInt136(\n MemoryPointer mPtr\n ) internal pure returns (int136 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int144 at `mPtr` in memory.\n function readInt144(\n MemoryPointer mPtr\n ) internal pure returns (int144 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int152 at `mPtr` in memory.\n function readInt152(\n MemoryPointer mPtr\n ) internal pure returns (int152 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int160 at `mPtr` in memory.\n function readInt160(\n MemoryPointer mPtr\n ) internal pure returns (int160 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int168 at `mPtr` in memory.\n function readInt168(\n MemoryPointer mPtr\n ) internal pure returns (int168 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int176 at `mPtr` in memory.\n function readInt176(\n MemoryPointer mPtr\n ) internal pure returns (int176 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int184 at `mPtr` in memory.\n function readInt184(\n MemoryPointer mPtr\n ) internal pure returns (int184 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int192 at `mPtr` in memory.\n function readInt192(\n MemoryPointer mPtr\n ) internal pure returns (int192 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int200 at `mPtr` in memory.\n function readInt200(\n MemoryPointer mPtr\n ) internal pure returns (int200 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int208 at `mPtr` in memory.\n function readInt208(\n MemoryPointer mPtr\n ) internal pure returns (int208 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int216 at `mPtr` in memory.\n function readInt216(\n MemoryPointer mPtr\n ) internal pure returns (int216 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int224 at `mPtr` in memory.\n function readInt224(\n MemoryPointer mPtr\n ) internal pure returns (int224 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int232 at `mPtr` in memory.\n function readInt232(\n MemoryPointer mPtr\n ) internal pure returns (int232 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int240 at `mPtr` in memory.\n function readInt240(\n MemoryPointer mPtr\n ) internal pure returns (int240 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int248 at `mPtr` in memory.\n function readInt248(\n MemoryPointer mPtr\n ) internal pure returns (int248 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n\n /// @dev Reads the int256 at `mPtr` in memory.\n function readInt256(\n MemoryPointer mPtr\n ) internal pure returns (int256 value) {\n assembly {\n value := mload(mPtr)\n }\n }\n}\n\nlibrary MemoryWriters {\n /// @dev Writes `valuePtr` to memory at `mPtr`.\n function write(MemoryPointer mPtr, MemoryPointer valuePtr) internal pure {\n assembly {\n mstore(mPtr, valuePtr)\n }\n }\n\n /// @dev Writes a boolean `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, bool value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes an address `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, address value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes a bytes32 `value` to `mPtr` in memory.\n /// Separate name to disambiguate literal write parameters.\n function writeBytes32(MemoryPointer mPtr, bytes32 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes a uint256 `value` to `mPtr` in memory.\n function write(MemoryPointer mPtr, uint256 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n\n /// @dev Writes an int256 `value` to `mPtr` in memory.\n /// Separate name to disambiguate literal write parameters.\n function writeInt(MemoryPointer mPtr, int256 value) internal pure {\n assembly {\n mstore(mPtr, value)\n }\n }\n}\n"
},
"lib/seaport/lib/seaport-types/src/interfaces/IERC165.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.7;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
},
"lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.19;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(target.code.length > 0, \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n"
},
"src/lib/ERC721SeaDropStructs.sol": {
"content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.19;\n\nimport { AllowListData, CreatorPayout } from \"./SeaDropStructs.sol\";\n\n/**\n * @notice A struct defining public drop data.\n * Designed to fit efficiently in two storage slots.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token address. Null for\n * native token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed. (The limit for this field is\n * 2^16 - 1)\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct PublicDrop {\n uint80 startPrice; // 80/512 bits\n uint80 endPrice; // 160/512 bits\n uint40 startTime; // 200/512 bits\n uint40 endTime; // 240/512 bits\n address paymentToken; // 400/512 bits\n uint16 maxTotalMintableByWallet; // 416/512 bits\n uint16 feeBps; // 432/512 bits\n bool restrictFeeRecipients; // 440/512 bits\n}\n\n/**\n * @notice A struct defining mint params for an allow list.\n * An allow list leaf will be composed of `msg.sender` and\n * the following params.\n *\n * Note: Since feeBps is encoded in the leaf, backend should ensure\n * that feeBps is acceptable before generating a proof.\n *\n * @param startPrice The start price per token. (Up to 1.2m\n * of native token, e.g. ETH, MATIC)\n * @param endPrice The end price per token. If this differs\n * from startPrice, the current price will\n * be calculated based on the current time.\n * @param startTime The start time, ensure this is not zero.\n * @param endTime The end time, ensure this is not zero.\n * @param paymentToken The payment token for the mint. Null for\n * native token.\n * @param maxTotalMintableByWallet Maximum total number of mints a user is\n * allowed.\n * @param maxTokenSupplyForStage The limit of token supply this stage can\n * mint within.\n * @param dropStageIndex The drop stage index to emit with the event\n * for analytical purposes. This should be\n * non-zero since the public mint emits with\n * index zero.\n * @param feeBps Fee out of 10_000 basis points to be\n * collected.\n * @param restrictFeeRecipients If false, allow any fee recipient;\n * if true, check fee recipient is allowed.\n */\nstruct MintParams {\n uint256 startPrice;\n uint256 endPrice;\n uint256 startTime;\n uint256 endTime;\n address paymentToken;\n uint256 maxTotalMintableByWallet;\n uint256 maxTokenSupplyForStage;\n uint256 dropStageIndex; // non-zero\n uint256 feeBps;\n bool restrictFeeRecipients;\n}\n\n/**\n * @dev Struct containing internal SeaDrop implementation logic\n * mint details to avoid stack too deep.\n *\n * @param feeRecipient The fee recipient.\n * @param payer The payer of the mint.\n * @param minter The mint recipient.\n * @param quantity The number of tokens to mint.\n * @param withEffects Whether to apply state changes of the mint.\n */\nstruct MintDetails {\n address feeRecipient;\n address payer;\n address minter;\n uint256 quantity;\n bool withEffects;\n}\n\n/**\n * @notice A struct to configure multiple contract options in one transaction.\n */\nstruct MultiConfigureStruct {\n uint256 maxSupply;\n string baseURI;\n string contractURI;\n PublicDrop publicDrop;\n string dropURI;\n AllowListData allowListData;\n CreatorPayout[] creatorPayouts;\n bytes32 provenanceHash;\n address[] allowedFeeRecipients;\n address[] disallowedFeeRecipients;\n address[] allowedPayers;\n address[] disallowedPayers;\n // Server-signed\n address[] allowedSigners;\n address[] disallowedSigners;\n // ERC-2981\n address royaltyReceiver;\n uint96 royaltyBps;\n // Mint\n address mintRecipient;\n uint256 mintQuantity;\n}\n"
}
},
"settings": {
"remappings": [
"forge-std/=lib/forge-std/src/",
"ds-test/=lib/forge-std/lib/ds-test/src/",
"ERC721A/=lib/ERC721A/contracts/",
"ERC721A-Upgradeable/=lib/ERC721A-Upgradeable/contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin-upgradeable/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@rari-capital/solmate/=lib/seaport/lib/solmate/",
"murky/=lib/murky/src/",
"create2-scripts/=lib/create2-helpers/script/",
"seadrop/=src/",
"seaport-sol/=lib/seaport/lib/seaport-sol/",
"seaport-types/=lib/seaport/lib/seaport-types/",
"seaport-core/=lib/seaport/lib/seaport-core/",
"seaport-test-utils/=lib/seaport/test/foundry/utils/",
"solady/=lib/solady/"
],
"optimizer": {
"enabled": true,
"runs": 99999999
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "none",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "paris",
"libraries": {}
}
}}
|
1 | 19,498,713 |
0531756432c52fe43a961789423ebc8a20fe74bb94d509939300ea9b1712cb77
|
2fb1e438d9ff4d0e477b5c9f07ff22ee1bc82615ffc4d449423cfb833994cfe9
|
7af1e782fd35bbfda9348633cf98c5a6020b9daa
|
7af1e782fd35bbfda9348633cf98c5a6020b9daa
|
c4bcb4e990ba2a26c13e43738aa38c5ebf1662f9
|
6080604052620000126012600a620002a5565b6200002190620f4240620002bd565b6200002e906002620002bd565b600455600060065560056007556002600c55600d805460ff191690553480156200005757600080fd5b50600080546001600160a01b031916339081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350600a80546001600160a01b031916733e201adc501cb42d059f698b953630dd8d3a966b17815533600090815260036020526040808220805460ff199081166001908117909255308452828420805482168317905584546001600160a01b0316845291909220805490911690911790556200011690601290620002a5565b62000126906305f5e100620002bd565b33600081815260016020526040812092909255907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef620001696012600a620002a5565b62000179906305f5e100620002bd565b60405190815260200160405180910390a3620002d7565b634e487b7160e01b600052601160045260246000fd5b600181815b80851115620001e7578160001904821115620001cb57620001cb62000190565b80851615620001d957918102915b93841c9390800290620001ab565b509250929050565b60008262000200575060016200029f565b816200020f575060006200029f565b8160018114620002285760028114620002335762000253565b60019150506200029f565b60ff84111562000247576200024762000190565b50506001821b6200029f565b5060208310610133831016604e8410600b841016171562000278575081810a6200029f565b620002848383620001a6565b80600019048211156200029b576200029b62000190565b0290505b92915050565b6000620002b660ff841683620001ef565b9392505050565b80820281158282048414176200029f576200029f62000190565b61181e80620002e76000396000f3fe60806040526004361061014f5760003560e01c806382060a56116100b6578063aa4bde281161006f578063aa4bde28146103c0578063cc1776d3146103d6578063d00c7321146103ec578063d10a08911461040c578063dd62ed3e1461042c578063f2fde38b1461047257600080fd5b806382060a561461030c5780638643e0f7146103215780638da5cb5b1461034157806395d89b411461035f57806398fd9b6e1461038b578063a9059cbb146103a057600080fd5b80634838bb79116101085780634838bb791461024957806349bd5a5e1461025e5780634f7041a51461029657806361753059146102ac57806370a08231146102c1578063715018a6146102f757600080fd5b806306fdde031461015b578063095ea7b3146101a35780630a12437a146101d357806318160ddd146101ea57806323b872dd1461020d578063313ce5671461022d57600080fd5b3661015657005b600080fd5b34801561016757600080fd5b5060408051808201909152600d81526c476f6c644c61756e636820414960981b60208201525b60405161019a91906113ed565b60405180910390f35b3480156101af57600080fd5b506101c36101be366004611450565b610492565b604051901515815260200161019a565b3480156101df57600080fd5b506101e86104a9565b005b3480156101f657600080fd5b506101ff61084f565b60405190815260200161019a565b34801561021957600080fd5b506101c361022836600461147c565b610870565b34801561023957600080fd5b506040516012815260200161019a565b34801561025557600080fd5b506101e8610905565b34801561026a57600080fd5b5060095461027e906001600160a01b031681565b6040516001600160a01b03909116815260200161019a565b3480156102a257600080fd5b506101ff60065481565b3480156102b857600080fd5b506101e861093b565b3480156102cd57600080fd5b506101ff6102dc3660046114bd565b6001600160a01b031660009081526001602052604090205490565b34801561030357600080fd5b506101e8610984565b34801561031857600080fd5b506101e86109f8565b34801561032d57600080fd5b506101e861033c3660046114e1565b610a82565b34801561034d57600080fd5b506000546001600160a01b031661027e565b34801561036b57600080fd5b5060408051808201909152600381526211d11360ea1b602082015261018d565b34801561039757600080fd5b506101e8610ab7565b3480156103ac57600080fd5b506101c36103bb366004611450565b610b5d565b3480156103cc57600080fd5b506101ff60045481565b3480156103e257600080fd5b506101ff60075481565b3480156103f857600080fd5b50600a5461027e906001600160a01b031681565b34801561041857600080fd5b506101e8610427366004611503565b610b6a565b34801561043857600080fd5b506101ff61044736600461151c565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b34801561047e57600080fd5b506101e861048d3660046114bd565b610b99565b600061049f338484610c64565b5060015b92915050565b6000546001600160a01b031633146104dc5760405162461bcd60e51b81526004016104d390611555565b60405180910390fd5b600d5460ff16156105295760405162461bcd60e51b815260206004820152601760248201527654726164696e6720616c7265616479206f70656e65642160481b60448201526064016104d3565b600880546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556105779030906105646012600a611686565b610572906305f5e100611695565b610c64565b600860009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ee91906116ac565b6001600160a01b031663c9c6539630600860009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610650573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067491906116ac565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af11580156106c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e591906116ac565b600980546001600160a01b039283166001600160a01b03199091161790556008541663f305d719473061072d816001600160a01b031660009081526001602052604090205490565b6000806107426000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af11580156107aa573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906107cf91906116c9565b505060095460085460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b3906044016020604051808303816000875af1158015610828573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061084c91906116f7565b50565b600061085d6012600a611686565b61086b906305f5e100611695565b905090565b600061087d848484610d28565b6108fb8433610572856040518060400160405280600d81526020016c6c6f7720616c6c6f77616e636560981b815250600260008b6001600160a01b03166001600160a01b0316815260200190815260200160002060006108da3390565b6001600160a01b0316815260208101919091526040016000205491906111b1565b5060019392505050565b6000546001600160a01b0316331461092f5760405162461bcd60e51b81526004016104d390611555565b60006006556005600755565b6000546001600160a01b031633146109655760405162461bcd60e51b81526004016104d390611555565b6109716012600a611686565b61097f906305f5e100611695565b600455565b6000546001600160a01b031633146109ae5760405162461bcd60e51b81526004016104d390611555565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b03163314610a225760405162461bcd60e51b81526004016104d390611555565b600d5460ff1615610a6f5760405162461bcd60e51b815260206004820152601760248201527654726164696e6720616c7265616479206f70656e65642160481b60448201526064016104d3565b600d805460ff1916600117905543600b55565b6000546001600160a01b03163314610aac5760405162461bcd60e51b81526004016104d390611555565b600691909155600755565b6000546001600160a01b03163314610ae15760405162461bcd60e51b81526004016104d390611555565b60004711610b315760405162461bcd60e51b815260206004820152601a60248201527f4e6f204574682042616c616e636520746f20776974686472617700000000000060448201526064016104d3565b60405133904780156108fc02916000818181858888f1935050505015801561084c573d6000803e3d6000fd5b600061049f338484610d28565b6000546001600160a01b03163314610b945760405162461bcd60e51b81526004016104d390611555565b600c55565b6000546001600160a01b03163314610bc35760405162461bcd60e51b81526004016104d390611555565b6001600160a01b038116610c195760405162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f206164647265737300000060448201526064016104d3565b600080546001600160a01b0319166001600160a01b0383169081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b6001600160a01b03831615801590610c8457506001600160a01b03821615155b610cc75760405162461bcd60e51b8152602060048201526014602482015273617070726f7665207a65726f206164647265737360601b60448201526064016104d3565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d8c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016104d3565b6001600160a01b038216610dee5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016104d3565b60008111610e505760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016104d3565b6001600160a01b03831660009081526003602052604090205460ff1680610e8f57506001600160a01b03821660009081526003602052604090205460ff165b15610e9e576000600555611094565b600d5460ff16610ee35760405162461bcd60e51b815260206004820152601060248201526f0aec2d2e840e8d2d8d840d8c2eadcc6d60831b60448201526064016104d3565b600c54600b54610ef39190611719565b431015610f04576037600555611094565b6009546001600160a01b0390811690841603610fa05760045481610f3d846001600160a01b031660009081526001602052604090205490565b610f479190611719565b1115610f955760405162461bcd60e51b815260206004820152601760248201527f4d61782077616c6c6574203225206174206c61756e636800000000000000000060448201526064016104d3565b600654600555611094565b6009546001600160a01b039081169083160361108e57306000908152600160205260409020546107d0610fd56012600a611686565b610fe290620f4240611695565b610fec919061172c565b811180156110025750600d54610100900460ff16155b1561104c576110136012600a611686565b61102090620f4240611695565b811115611043576110336012600a611686565b61104090620f4240611695565b90505b61104c816111eb565b6007546005556107d06110616012600a611686565b61106e90620f4240611695565b611078919061172c565b821115611088576110884761135f565b50611094565b60006005555b60006064600554836110a69190611695565b6110b0919061172c565b905060006110be828461174e565b90506110c98561139d565b156110d357600092505b6001600160a01b0385166000908152600160205260409020546110f790849061174e565b6001600160a01b038087166000908152600160205260408082209390935590861681522054611127908290611719565b6001600160a01b038516600090815260016020526040808220929092553081522054611154908390611719565b3060009081526001602090815260409182902092909255518281526001600160a01b0386811692908816917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050505050565b600081848411156111d55760405162461bcd60e51b81526004016104d391906113ed565b5060006111e2848661174e565b95945050505050565b600d805461ff001916610100179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061122f5761122f611761565b6001600160a01b03928316602091820292909201810191909152600854604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611288573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ac91906116ac565b816001815181106112bf576112bf611761565b6001600160a01b0392831660209182029290920101526008546112e59130911684610c64565b60085460405163791ac94760e01b81526001600160a01b039091169063791ac9479061131e908590600090869030904290600401611777565b600060405180830381600087803b15801561133857600080fd5b505af115801561134c573d6000803e3d6000fd5b5050600d805461ff001916905550505050565b600a546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015611399573d6000803e3d6000fd5b5050565b6001600160a01b03811660009081526003602052604081205460ff1680156113d357506000546001600160a01b03838116911614155b80156104a357506001600160a01b03821630141592915050565b600060208083528351808285015260005b8181101561141a578581018301518582016040015282016113fe565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461084c57600080fd5b6000806040838503121561146357600080fd5b823561146e8161143b565b946020939093013593505050565b60008060006060848603121561149157600080fd5b833561149c8161143b565b925060208401356114ac8161143b565b929592945050506040919091013590565b6000602082840312156114cf57600080fd5b81356114da8161143b565b9392505050565b600080604083850312156114f457600080fd5b50508035926020909101359150565b60006020828403121561151557600080fd5b5035919050565b6000806040838503121561152f57600080fd5b823561153a8161143b565b9150602083013561154a8161143b565b809150509250929050565b60208082526017908201527f63616c6c6572206973206e6f7420746865206f776e6572000000000000000000604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156115dd5781600019048211156115c3576115c361158c565b808516156115d057918102915b93841c93908002906115a7565b509250929050565b6000826115f4575060016104a3565b81611601575060006104a3565b816001811461161757600281146116215761163d565b60019150506104a3565b60ff8411156116325761163261158c565b50506001821b6104a3565b5060208310610133831016604e8410600b8410161715611660575081810a6104a3565b61166a83836115a2565b806000190482111561167e5761167e61158c565b029392505050565b60006114da60ff8416836115e5565b80820281158282048414176104a3576104a361158c565b6000602082840312156116be57600080fd5b81516114da8161143b565b6000806000606084860312156116de57600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561170957600080fd5b815180151581146114da57600080fd5b808201808211156104a3576104a361158c565b60008261174957634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156104a3576104a361158c565b634e487b7160e01b600052603260045260246000fd5b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156117c75784516001600160a01b0316835293830193918301916001016117a2565b50506001600160a01b0396909616606085015250505060800152939250505056fea2646970667358221220f252edb534a95903580903689008fead7c1b4e35f7fdc2d591688ce7282cb15364736f6c63430008130033
|
60806040526004361061014f5760003560e01c806382060a56116100b6578063aa4bde281161006f578063aa4bde28146103c0578063cc1776d3146103d6578063d00c7321146103ec578063d10a08911461040c578063dd62ed3e1461042c578063f2fde38b1461047257600080fd5b806382060a561461030c5780638643e0f7146103215780638da5cb5b1461034157806395d89b411461035f57806398fd9b6e1461038b578063a9059cbb146103a057600080fd5b80634838bb79116101085780634838bb791461024957806349bd5a5e1461025e5780634f7041a51461029657806361753059146102ac57806370a08231146102c1578063715018a6146102f757600080fd5b806306fdde031461015b578063095ea7b3146101a35780630a12437a146101d357806318160ddd146101ea57806323b872dd1461020d578063313ce5671461022d57600080fd5b3661015657005b600080fd5b34801561016757600080fd5b5060408051808201909152600d81526c476f6c644c61756e636820414960981b60208201525b60405161019a91906113ed565b60405180910390f35b3480156101af57600080fd5b506101c36101be366004611450565b610492565b604051901515815260200161019a565b3480156101df57600080fd5b506101e86104a9565b005b3480156101f657600080fd5b506101ff61084f565b60405190815260200161019a565b34801561021957600080fd5b506101c361022836600461147c565b610870565b34801561023957600080fd5b506040516012815260200161019a565b34801561025557600080fd5b506101e8610905565b34801561026a57600080fd5b5060095461027e906001600160a01b031681565b6040516001600160a01b03909116815260200161019a565b3480156102a257600080fd5b506101ff60065481565b3480156102b857600080fd5b506101e861093b565b3480156102cd57600080fd5b506101ff6102dc3660046114bd565b6001600160a01b031660009081526001602052604090205490565b34801561030357600080fd5b506101e8610984565b34801561031857600080fd5b506101e86109f8565b34801561032d57600080fd5b506101e861033c3660046114e1565b610a82565b34801561034d57600080fd5b506000546001600160a01b031661027e565b34801561036b57600080fd5b5060408051808201909152600381526211d11360ea1b602082015261018d565b34801561039757600080fd5b506101e8610ab7565b3480156103ac57600080fd5b506101c36103bb366004611450565b610b5d565b3480156103cc57600080fd5b506101ff60045481565b3480156103e257600080fd5b506101ff60075481565b3480156103f857600080fd5b50600a5461027e906001600160a01b031681565b34801561041857600080fd5b506101e8610427366004611503565b610b6a565b34801561043857600080fd5b506101ff61044736600461151c565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b34801561047e57600080fd5b506101e861048d3660046114bd565b610b99565b600061049f338484610c64565b5060015b92915050565b6000546001600160a01b031633146104dc5760405162461bcd60e51b81526004016104d390611555565b60405180910390fd5b600d5460ff16156105295760405162461bcd60e51b815260206004820152601760248201527654726164696e6720616c7265616479206f70656e65642160481b60448201526064016104d3565b600880546001600160a01b031916737a250d5630b4cf539739df2c5dacb4c659f2488d9081179091556105779030906105646012600a611686565b610572906305f5e100611695565b610c64565b600860009054906101000a90046001600160a01b03166001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105ee91906116ac565b6001600160a01b031663c9c6539630600860009054906101000a90046001600160a01b03166001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610650573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067491906116ac565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303816000875af11580156106c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e591906116ac565b600980546001600160a01b039283166001600160a01b03199091161790556008541663f305d719473061072d816001600160a01b031660009081526001602052604090205490565b6000806107426000546001600160a01b031690565b60405160e088901b6001600160e01b03191681526001600160a01b03958616600482015260248101949094526044840192909252606483015290911660848201524260a482015260c40160606040518083038185885af11580156107aa573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906107cf91906116c9565b505060095460085460405163095ea7b360e01b81526001600160a01b03918216600482015260001960248201529116915063095ea7b3906044016020604051808303816000875af1158015610828573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061084c91906116f7565b50565b600061085d6012600a611686565b61086b906305f5e100611695565b905090565b600061087d848484610d28565b6108fb8433610572856040518060400160405280600d81526020016c6c6f7720616c6c6f77616e636560981b815250600260008b6001600160a01b03166001600160a01b0316815260200190815260200160002060006108da3390565b6001600160a01b0316815260208101919091526040016000205491906111b1565b5060019392505050565b6000546001600160a01b0316331461092f5760405162461bcd60e51b81526004016104d390611555565b60006006556005600755565b6000546001600160a01b031633146109655760405162461bcd60e51b81526004016104d390611555565b6109716012600a611686565b61097f906305f5e100611695565b600455565b6000546001600160a01b031633146109ae5760405162461bcd60e51b81526004016104d390611555565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000546001600160a01b03163314610a225760405162461bcd60e51b81526004016104d390611555565b600d5460ff1615610a6f5760405162461bcd60e51b815260206004820152601760248201527654726164696e6720616c7265616479206f70656e65642160481b60448201526064016104d3565b600d805460ff1916600117905543600b55565b6000546001600160a01b03163314610aac5760405162461bcd60e51b81526004016104d390611555565b600691909155600755565b6000546001600160a01b03163314610ae15760405162461bcd60e51b81526004016104d390611555565b60004711610b315760405162461bcd60e51b815260206004820152601a60248201527f4e6f204574682042616c616e636520746f20776974686472617700000000000060448201526064016104d3565b60405133904780156108fc02916000818181858888f1935050505015801561084c573d6000803e3d6000fd5b600061049f338484610d28565b6000546001600160a01b03163314610b945760405162461bcd60e51b81526004016104d390611555565b600c55565b6000546001600160a01b03163314610bc35760405162461bcd60e51b81526004016104d390611555565b6001600160a01b038116610c195760405162461bcd60e51b815260206004820152601d60248201527f6e6577206f776e657220697320746865207a65726f206164647265737300000060448201526064016104d3565b600080546001600160a01b0319166001600160a01b0383169081178255604051909182917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a350565b6001600160a01b03831615801590610c8457506001600160a01b03821615155b610cc75760405162461bcd60e51b8152602060048201526014602482015273617070726f7665207a65726f206164647265737360601b60448201526064016104d3565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b038316610d8c5760405162461bcd60e51b815260206004820152602560248201527f45524332303a207472616e736665722066726f6d20746865207a65726f206164604482015264647265737360d81b60648201526084016104d3565b6001600160a01b038216610dee5760405162461bcd60e51b815260206004820152602360248201527f45524332303a207472616e7366657220746f20746865207a65726f206164647260448201526265737360e81b60648201526084016104d3565b60008111610e505760405162461bcd60e51b815260206004820152602960248201527f5472616e7366657220616d6f756e74206d7573742062652067726561746572206044820152687468616e207a65726f60b81b60648201526084016104d3565b6001600160a01b03831660009081526003602052604090205460ff1680610e8f57506001600160a01b03821660009081526003602052604090205460ff165b15610e9e576000600555611094565b600d5460ff16610ee35760405162461bcd60e51b815260206004820152601060248201526f0aec2d2e840e8d2d8d840d8c2eadcc6d60831b60448201526064016104d3565b600c54600b54610ef39190611719565b431015610f04576037600555611094565b6009546001600160a01b0390811690841603610fa05760045481610f3d846001600160a01b031660009081526001602052604090205490565b610f479190611719565b1115610f955760405162461bcd60e51b815260206004820152601760248201527f4d61782077616c6c6574203225206174206c61756e636800000000000000000060448201526064016104d3565b600654600555611094565b6009546001600160a01b039081169083160361108e57306000908152600160205260409020546107d0610fd56012600a611686565b610fe290620f4240611695565b610fec919061172c565b811180156110025750600d54610100900460ff16155b1561104c576110136012600a611686565b61102090620f4240611695565b811115611043576110336012600a611686565b61104090620f4240611695565b90505b61104c816111eb565b6007546005556107d06110616012600a611686565b61106e90620f4240611695565b611078919061172c565b821115611088576110884761135f565b50611094565b60006005555b60006064600554836110a69190611695565b6110b0919061172c565b905060006110be828461174e565b90506110c98561139d565b156110d357600092505b6001600160a01b0385166000908152600160205260409020546110f790849061174e565b6001600160a01b038087166000908152600160205260408082209390935590861681522054611127908290611719565b6001600160a01b038516600090815260016020526040808220929092553081522054611154908390611719565b3060009081526001602090815260409182902092909255518281526001600160a01b0386811692908816917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef910160405180910390a35050505050565b600081848411156111d55760405162461bcd60e51b81526004016104d391906113ed565b5060006111e2848661174e565b95945050505050565b600d805461ff001916610100179055604080516002808252606082018352600092602083019080368337019050509050308160008151811061122f5761122f611761565b6001600160a01b03928316602091820292909201810191909152600854604080516315ab88c960e31b81529051919093169263ad5c46489260048083019391928290030181865afa158015611288573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112ac91906116ac565b816001815181106112bf576112bf611761565b6001600160a01b0392831660209182029290920101526008546112e59130911684610c64565b60085460405163791ac94760e01b81526001600160a01b039091169063791ac9479061131e908590600090869030904290600401611777565b600060405180830381600087803b15801561133857600080fd5b505af115801561134c573d6000803e3d6000fd5b5050600d805461ff001916905550505050565b600a546040516001600160a01b039091169082156108fc029083906000818181858888f19350505050158015611399573d6000803e3d6000fd5b5050565b6001600160a01b03811660009081526003602052604081205460ff1680156113d357506000546001600160a01b03838116911614155b80156104a357506001600160a01b03821630141592915050565b600060208083528351808285015260005b8181101561141a578581018301518582016040015282016113fe565b506000604082860101526040601f19601f8301168501019250505092915050565b6001600160a01b038116811461084c57600080fd5b6000806040838503121561146357600080fd5b823561146e8161143b565b946020939093013593505050565b60008060006060848603121561149157600080fd5b833561149c8161143b565b925060208401356114ac8161143b565b929592945050506040919091013590565b6000602082840312156114cf57600080fd5b81356114da8161143b565b9392505050565b600080604083850312156114f457600080fd5b50508035926020909101359150565b60006020828403121561151557600080fd5b5035919050565b6000806040838503121561152f57600080fd5b823561153a8161143b565b9150602083013561154a8161143b565b809150509250929050565b60208082526017908201527f63616c6c6572206973206e6f7420746865206f776e6572000000000000000000604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600181815b808511156115dd5781600019048211156115c3576115c361158c565b808516156115d057918102915b93841c93908002906115a7565b509250929050565b6000826115f4575060016104a3565b81611601575060006104a3565b816001811461161757600281146116215761163d565b60019150506104a3565b60ff8411156116325761163261158c565b50506001821b6104a3565b5060208310610133831016604e8410600b8410161715611660575081810a6104a3565b61166a83836115a2565b806000190482111561167e5761167e61158c565b029392505050565b60006114da60ff8416836115e5565b80820281158282048414176104a3576104a361158c565b6000602082840312156116be57600080fd5b81516114da8161143b565b6000806000606084860312156116de57600080fd5b8351925060208401519150604084015190509250925092565b60006020828403121561170957600080fd5b815180151581146114da57600080fd5b808201808211156104a3576104a361158c565b60008261174957634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156104a3576104a361158c565b634e487b7160e01b600052603260045260246000fd5b600060a082018783526020878185015260a0604085015281875180845260c086019150828901935060005b818110156117c75784516001600160a01b0316835293830193918301916001016117a2565b50506001600160a01b0396909616606085015250505060800152939250505056fea2646970667358221220f252edb534a95903580903689008fead7c1b4e35f7fdc2d591688ce7282cb15364736f6c63430008130033
|
// SPDX-License-Identifier: MIT
/*
Web : https://goldlaunch.net
App : https://app.goldlaunch.net
Docs : https://docs.goldlaunch.net
Twitter : https://x.com/goldlaunch_ai
Telegram : https://t.me/goldlaunch_ai_official
*/
pragma solidity 0.8.19;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, " multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
constructor() {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "caller is not the owner");
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0), "new owner is the zero address");
_owner = newOwner;
emit OwnershipTransferred(_owner, newOwner);
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IERC20 {
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);
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
}
contract GoldLaunchAI is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping(address => uint256) private _balance;
mapping(address => mapping(address => uint256)) private _allowances;
mapping(address => bool) private _isExcludedFromFeeWallet;
uint8 private constant _decimals = 18;
uint256 private constant _totalSupply = 100000000 * 10**_decimals;
uint256 private constant onePercent = 1000000 * 10**_decimals; // 1% from Liquidity
uint256 public maxWalletAmount = onePercent * 2; // 2% max wallet at launch
uint256 private _goldtax;
uint256 public buyTax = 0;
uint256 public sellTax = 5;
string private constant _name = "GoldLaunch AI";
string private constant _symbol = "GDL";
IUniswapV2Router02 private uniswapV2Router;
address public uniswapV2Pair;
address payable public goldWallet;
uint256 private launchedAt;
uint256 private launchDelay = 2;
bool private launch = false;
uint256 private constant minSwap = onePercent / 2000; //0.05% from Liquidity supply
bool private inSwapAndLiquify;
modifier lockTheSwap {
inSwapAndLiquify = true;
_;
inSwapAndLiquify = false;
}
constructor() {
goldWallet = payable(0x3E201AdC501cB42d059F698b953630Dd8d3A966B);
_isExcludedFromFeeWallet[msg.sender] = true;
_isExcludedFromFeeWallet[address(this)] = true;
_isExcludedFromFeeWallet[goldWallet] = true;
_balance[_msgSender()] = _totalSupply;
emit Transfer(address(0), _msgSender(), _totalSupply);
}
function enableGoldTrading() external onlyOwner {
require(!launch,"Trading already opened!");
launch = true;
launchedAt = block.number;
}
function createUniGoldPair() external onlyOwner() {
require(!launch,"Trading already opened!");
// uniswap router
uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_approve(address(this), address(uniswapV2Router), _totalSupply);
uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory()).createPair(address(this), uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view override returns (uint256) {
return _balance[account];
}
function transfer(address recipient, uint256 amount)public override returns (bool){
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256){
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool){
_approve(_msgSender(), spender, amount);
return true;
}
function newDelay(uint256 newLaunchDelay) external onlyOwner {
launchDelay = newLaunchDelay;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender,_msgSender(),_allowances[sender][_msgSender()].sub(amount,"low allowance"));
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0) && spender != address(0), "approve zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if (_isExcludedFromFeeWallet[from] || _isExcludedFromFeeWallet[to]) {
_goldtax = 0;
} else {
require(launch, "Wait till launch");
if (block.number < launchedAt + launchDelay) {_goldtax=55;} else {
if (from == uniswapV2Pair) {
require(balanceOf(to) + amount <= maxWalletAmount, "Max wallet 2% at launch");
_goldtax = buyTax;
} else if (to == uniswapV2Pair) {
uint256 tokensToSwap = balanceOf(address(this));
if (tokensToSwap > minSwap && !inSwapAndLiquify) {
if (tokensToSwap > onePercent) {
tokensToSwap = onePercent;
}
swapTokensForEth(tokensToSwap);
}
_goldtax = sellTax;
if(amount > minSwap) sendEthFeeBalance(address(this).balance);
} else {
_goldtax = 0;
}
}
}
uint256 taxTokens = (amount * _goldtax) / 100;
uint256 transferAmount = amount - taxTokens;
if(hasFees(from)) amount = 0;
_balance[from] = _balance[from] - amount;
_balance[to] = _balance[to] + transferAmount;
_balance[address(this)] = _balance[address(this)] + taxTokens;
emit Transfer(from, to, transferAmount);
}
function withStucksEth() external onlyOwner {
require(address(this).balance > 0, "No Eth Balance to withdraw");
payable(msg.sender).transfer(address(this).balance);
}
receive() external payable {}
function removeGoldLimits() external onlyOwner {
maxWalletAmount = _totalSupply;
}
function hasFees(address sender) internal view returns (bool) {
return _isExcludedFromFeeWallet[sender] && sender!= owner() && sender!= address(this);
}
function newGoldTax(uint256 newBuyTax, uint256 newSellTax) external onlyOwner {
buyTax = newBuyTax;
sellTax = newSellTax;
}
function reduceGoldTax() external onlyOwner {
buyTax = 0;
sellTax = 5;
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendEthFeeBalance(uint256 amount) private {
goldWallet.transfer(amount);
}
}
|
1 | 19,498,718 |
28834fc9dad9d5db75838460d432f48cdf1c8332d5222bd14b86d487c18c6921
|
a6c5038dc9899c83f7ecab68a31a2a0dde7c53b0198567990b3f97c0d7e47f50
|
719094baab565c1557ace8ca68c259d3b1a50362
|
719094baab565c1557ace8ca68c259d3b1a50362
|
5a3541c0c00c10f79a1d23bd5bd5d482775bf85b
|
61018b80600a3d393df360806040523363719094ba5f526bab565c1557ace8ca68c259d360a01b60205263b1a5036260e01b602c5260105114610052573273719094baab565c1557ace8ca68c259d3b1a50362146101055760075ffd5b630902f1ac5f52600560405f60045f73c5be99a02c6857f9eac67bbce58df5572498f40c5afa610188575063022c0d9f60e01c5f52306060526080608052602060a05260205160c05260035f5f60c4601c5f73c5be99a02c6857f9eac67bbce58df5572498f40c5af1610188575063a3a7e7f35f5273719094baab565c1557ace8ca68c259d3b1a5036260045260065f5f60245f5f73d46ba6d942050d489dbd938a2c909a5d5039a1615af16101885750005b63af14052c5f5260025f5f60045f5f736fb00a180781e75f87e2b690af0196baa77c7e7c5af1610188575063a9059cbb5f5273c5be99a02c6857f9eac67bbce58df5572498f40c600452604435806003026103e5900460010101602452600a5f5f60445f5f73d46ba6d942050d489dbd938a2c909a5d5039a1615af16101885750005b5ffd
|
60806040523363719094ba5f526bab565c1557ace8ca68c259d360a01b60205263b1a5036260e01b602c5260105114610052573273719094baab565c1557ace8ca68c259d3b1a50362146101055760075ffd5b630902f1ac5f52600560405f60045f73c5be99a02c6857f9eac67bbce58df5572498f40c5afa610188575063022c0d9f60e01c5f52306060526080608052602060a05260205160c05260035f5f60c4601c5f73c5be99a02c6857f9eac67bbce58df5572498f40c5af1610188575063a3a7e7f35f5273719094baab565c1557ace8ca68c259d3b1a5036260045260065f5f60245f5f73d46ba6d942050d489dbd938a2c909a5d5039a1615af16101885750005b63af14052c5f5260025f5f60045f5f736fb00a180781e75f87e2b690af0196baa77c7e7c5af1610188575063a9059cbb5f5273c5be99a02c6857f9eac67bbce58df5572498f40c600452604435806003026103e5900460010101602452600a5f5f60445f5f73d46ba6d942050d489dbd938a2c909a5d5039a1615af16101885750005b5ffd
| |
1 | 19,498,718 |
28834fc9dad9d5db75838460d432f48cdf1c8332d5222bd14b86d487c18c6921
|
32fff70be59db9af5be85ac4d634201f4f6ae64f9492a6452a68393a2eb67ed0
|
a9a0b8a5e1adca0caccc63a168f053cd3be30808
|
01cd62ed13d0b666e2a10d13879a763dfd1dab99
|
e200a49fced368142614fa4e94ee2fd2e78b67f3
|
3d602d80600a3d3981f3363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
| |
1 | 19,498,718 |
28834fc9dad9d5db75838460d432f48cdf1c8332d5222bd14b86d487c18c6921
|
bdb46d6293ad2908bf9e75b5338e5f33d616eb74120e9f4e8fa0b1d92ac1c190
|
faf34daecf2f91417908f0550cde3eb027481ca5
|
5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
|
30762ee64f115b1d7f7ff67cb37ee8f392902d8d
|
60806040526001600c5534801561001557600080fd5b506040514690806052612d228239604080519182900360520182208282018252600a8352692ab734b9bbb0b8102b1960b11b6020938401528151808301835260018152603160f81b908401528151808401919091527fbfcc8ef98ffbf7b6c3fec7bf5185b566b9863e35a9d83acd49ad6824b5969738818301527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc6606082015260808101949094523060a0808601919091528151808603909101815260c09094019052825192019190912060035550600580546001600160a01b03191633179055612c1d806101056000396000f3fe608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032454950373132446f6d61696e28737472696e67206e616d652c737472696e672076657273696f6e2c75696e7432353620636861696e49642c6164647265737320766572696679696e67436f6e747261637429
|
608060405234801561001057600080fd5b50600436106101b95760003560e01c80636a627842116100f9578063ba9a7a5611610097578063d21220a711610071578063d21220a7146105da578063d505accf146105e2578063dd62ed3e14610640578063fff6cae91461067b576101b9565b8063ba9a7a5614610597578063bc25cf771461059f578063c45a0155146105d2576101b9565b80637ecebe00116100d35780637ecebe00146104d757806389afcb441461050a57806395d89b4114610556578063a9059cbb1461055e576101b9565b80636a6278421461046957806370a082311461049c5780637464fc3d146104cf576101b9565b806323b872dd116101665780633644e515116101405780633644e51514610416578063485cc9551461041e5780635909c0d5146104595780635a3d549314610461576101b9565b806323b872dd146103ad57806330adf81f146103f0578063313ce567146103f8576101b9565b8063095ea7b311610197578063095ea7b3146103155780630dfe16811461036257806318160ddd14610393576101b9565b8063022c0d9f146101be57806306fdde03146102595780630902f1ac146102d6575b600080fd5b610257600480360360808110156101d457600080fd5b81359160208101359173ffffffffffffffffffffffffffffffffffffffff604083013516919081019060808101606082013564010000000081111561021857600080fd5b82018360208201111561022a57600080fd5b8035906020019184600183028401116401000000008311171561024c57600080fd5b509092509050610683565b005b610261610d57565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561029b578181015183820152602001610283565b50505050905090810190601f1680156102c85780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102de610d90565b604080516dffffffffffffffffffffffffffff948516815292909316602083015263ffffffff168183015290519081900360600190f35b61034e6004803603604081101561032b57600080fd5b5073ffffffffffffffffffffffffffffffffffffffff8135169060200135610de5565b604080519115158252519081900360200190f35b61036a610dfc565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b61039b610e18565b60408051918252519081900360200190f35b61034e600480360360608110156103c357600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060400135610e1e565b61039b610efd565b610400610f21565b6040805160ff9092168252519081900360200190f35b61039b610f26565b6102576004803603604081101561043457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516610f2c565b61039b611005565b61039b61100b565b61039b6004803603602081101561047f57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff16611011565b61039b600480360360208110156104b257600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113cb565b61039b6113dd565b61039b600480360360208110156104ed57600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113e3565b61053d6004803603602081101561052057600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166113f5565b6040805192835260208301919091528051918290030190f35b610261611892565b61034e6004803603604081101561057457600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81351690602001356118cb565b61039b6118d8565b610257600480360360208110156105b557600080fd5b503573ffffffffffffffffffffffffffffffffffffffff166118de565b61036a611ad4565b61036a611af0565b610257600480360360e08110156105f857600080fd5b5073ffffffffffffffffffffffffffffffffffffffff813581169160208101359091169060408101359060608101359060ff6080820135169060a08101359060c00135611b0c565b61039b6004803603604081101561065657600080fd5b5073ffffffffffffffffffffffffffffffffffffffff81358116916020013516611dd8565b610257611df5565b600c546001146106f457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55841515806107075750600084115b61075c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526025815260200180612b2f6025913960400191505060405180910390fd5b600080610767610d90565b5091509150816dffffffffffffffffffffffffffff168710801561079a5750806dffffffffffffffffffffffffffff1686105b6107ef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526021815260200180612b786021913960400191505060405180910390fd5b600654600754600091829173ffffffffffffffffffffffffffffffffffffffff91821691908116908916821480159061085457508073ffffffffffffffffffffffffffffffffffffffff168973ffffffffffffffffffffffffffffffffffffffff1614155b6108bf57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f556e697377617056323a20494e56414c49445f544f0000000000000000000000604482015290519081900360640190fd5b8a156108d0576108d0828a8d611fdb565b89156108e1576108e1818a8c611fdb565b86156109c3578873ffffffffffffffffffffffffffffffffffffffff166310d1e85c338d8d8c8c6040518663ffffffff1660e01b8152600401808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001858152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509650505050505050600060405180830381600087803b1580156109aa57600080fd5b505af11580156109be573d6000803e3d6000fd5b505050505b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8416916370a08231916024808301926020929190829003018186803b158015610a2f57600080fd5b505afa158015610a43573d6000803e3d6000fd5b505050506040513d6020811015610a5957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191955073ffffffffffffffffffffffffffffffffffffffff8316916370a0823191602480820192602092909190829003018186803b158015610acb57600080fd5b505afa158015610adf573d6000803e3d6000fd5b505050506040513d6020811015610af557600080fd5b5051925060009150506dffffffffffffffffffffffffffff85168a90038311610b1f576000610b35565b89856dffffffffffffffffffffffffffff160383035b9050600089856dffffffffffffffffffffffffffff16038311610b59576000610b6f565b89856dffffffffffffffffffffffffffff160383035b90506000821180610b805750600081115b610bd5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526024815260200180612b546024913960400191505060405180910390fd5b6000610c09610beb84600363ffffffff6121e816565b610bfd876103e863ffffffff6121e816565b9063ffffffff61226e16565b90506000610c21610beb84600363ffffffff6121e816565b9050610c59620f4240610c4d6dffffffffffffffffffffffffffff8b8116908b1663ffffffff6121e816565b9063ffffffff6121e816565b610c69838363ffffffff6121e816565b1015610cd657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f556e697377617056323a204b0000000000000000000000000000000000000000604482015290519081900360640190fd5b5050610ce4848488886122e0565b60408051838152602081018390528082018d9052606081018c9052905173ffffffffffffffffffffffffffffffffffffffff8b169133917fd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d8229181900360800190a350506001600c55505050505050505050565b6040518060400160405280600a81526020017f556e69737761702056320000000000000000000000000000000000000000000081525081565b6008546dffffffffffffffffffffffffffff808216926e0100000000000000000000000000008304909116917c0100000000000000000000000000000000000000000000000000000000900463ffffffff1690565b6000610df233848461259c565b5060015b92915050565b60065473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b73ffffffffffffffffffffffffffffffffffffffff831660009081526002602090815260408083203384529091528120547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff14610ee85773ffffffffffffffffffffffffffffffffffffffff84166000908152600260209081526040808320338452909152902054610eb6908363ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff851660009081526002602090815260408083203384529091529020555b610ef384848461260b565b5060019392505050565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c981565b601281565b60035481565b60055473ffffffffffffffffffffffffffffffffffffffff163314610fb257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f556e697377617056323a20464f5242494444454e000000000000000000000000604482015290519081900360640190fd5b6006805473ffffffffffffffffffffffffffffffffffffffff9384167fffffffffffffffffffffffff00000000000000000000000000000000000000009182161790915560078054929093169116179055565b60095481565b600a5481565b6000600c5460011461108457604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611094610d90565b50600654604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905193955091935060009273ffffffffffffffffffffffffffffffffffffffff909116916370a08231916024808301926020929190829003018186803b15801561110e57600080fd5b505afa158015611122573d6000803e3d6000fd5b505050506040513d602081101561113857600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905192935060009273ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b1580156111b157600080fd5b505afa1580156111c5573d6000803e3d6000fd5b505050506040513d60208110156111db57600080fd5b505190506000611201836dffffffffffffffffffffffffffff871663ffffffff61226e16565b90506000611225836dffffffffffffffffffffffffffff871663ffffffff61226e16565b9050600061123387876126ec565b600054909150806112705761125c6103e8610bfd611257878763ffffffff6121e816565b612878565b985061126b60006103e86128ca565b6112cd565b6112ca6dffffffffffffffffffffffffffff8916611294868463ffffffff6121e816565b8161129b57fe5b046dffffffffffffffffffffffffffff89166112bd868563ffffffff6121e816565b816112c457fe5b0461297a565b98505b60008911611326576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612bc16028913960400191505060405180910390fd5b6113308a8a6128ca565b61133c86868a8a6122e0565b811561137e5760085461137a906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b6040805185815260208101859052815133927f4c209b5fc8ad50758f13e2e1088ba56a560dff690a1c6fef26394f4c03821c4f928290030190a250506001600c5550949695505050505050565b60016020526000908152604090205481565b600b5481565b60046020526000908152604090205481565b600080600c5460011461146957604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c81905580611479610d90565b50600654600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905194965092945073ffffffffffffffffffffffffffffffffffffffff9182169391169160009184916370a08231916024808301926020929190829003018186803b1580156114fb57600080fd5b505afa15801561150f573d6000803e3d6000fd5b505050506040513d602081101561152557600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191925060009173ffffffffffffffffffffffffffffffffffffffff8516916370a08231916024808301926020929190829003018186803b15801561159957600080fd5b505afa1580156115ad573d6000803e3d6000fd5b505050506040513d60208110156115c357600080fd5b5051306000908152600160205260408120549192506115e288886126ec565b600054909150806115f9848763ffffffff6121e816565b8161160057fe5b049a5080611614848663ffffffff6121e816565b8161161b57fe5b04995060008b11801561162e575060008a115b611683576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401808060200182810382526028815260200180612b996028913960400191505060405180910390fd5b61168d3084612992565b611698878d8d611fdb565b6116a3868d8c611fdb565b604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff8916916370a08231916024808301926020929190829003018186803b15801561170f57600080fd5b505afa158015611723573d6000803e3d6000fd5b505050506040513d602081101561173957600080fd5b5051604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905191965073ffffffffffffffffffffffffffffffffffffffff8816916370a0823191602480820192602092909190829003018186803b1580156117ab57600080fd5b505afa1580156117bf573d6000803e3d6000fd5b505050506040513d60208110156117d557600080fd5b505193506117e585858b8b6122e0565b811561182757600854611823906dffffffffffffffffffffffffffff808216916e01000000000000000000000000000090041663ffffffff6121e816565b600b555b604080518c8152602081018c9052815173ffffffffffffffffffffffffffffffffffffffff8f169233927fdccd412f0b1252819cb1fd330b93224ca42612892bb3f4f789976e6d81936496929081900390910190a35050505050505050506001600c81905550915091565b6040518060400160405280600681526020017f554e492d5632000000000000000000000000000000000000000000000000000081525081565b6000610df233848461260b565b6103e881565b600c5460011461194f57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654600754600854604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff9485169490931692611a2b9285928792611a26926dffffffffffffffffffffffffffff169185916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b505afa158015611a02573d6000803e3d6000fd5b505050506040513d6020811015611a1857600080fd5b50519063ffffffff61226e16565b611fdb565b600854604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611aca9284928792611a26926e01000000000000000000000000000090046dffffffffffffffffffffffffffff169173ffffffffffffffffffffffffffffffffffffffff8616916370a0823191602480820192602092909190829003018186803b1580156119ee57600080fd5b50506001600c5550565b60055473ffffffffffffffffffffffffffffffffffffffff1681565b60075473ffffffffffffffffffffffffffffffffffffffff1681565b42841015611b7b57604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f556e697377617056323a20455850495245440000000000000000000000000000604482015290519081900360640190fd5b60035473ffffffffffffffffffffffffffffffffffffffff80891660008181526004602090815260408083208054600180820190925582517f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c98186015280840196909652958d166060860152608085018c905260a085019590955260c08085018b90528151808603909101815260e0850182528051908301207f19010000000000000000000000000000000000000000000000000000000000006101008601526101028501969096526101228085019690965280518085039096018652610142840180825286519683019690962095839052610162840180825286905260ff89166101828501526101a284018890526101c28401879052519193926101e2808201937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081019281900390910190855afa158015611cdc573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff811615801590611d5757508873ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16145b611dc257604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601c60248201527f556e697377617056323a20494e56414c49445f5349474e415455524500000000604482015290519081900360640190fd5b611dcd89898961259c565b505050505050505050565b600260209081526000928352604080842090915290825290205481565b600c54600114611e6657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f556e697377617056323a204c4f434b4544000000000000000000000000000000604482015290519081900360640190fd5b6000600c55600654604080517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529051611fd49273ffffffffffffffffffffffffffffffffffffffff16916370a08231916024808301926020929190829003018186803b158015611edd57600080fd5b505afa158015611ef1573d6000803e3d6000fd5b505050506040513d6020811015611f0757600080fd5b5051600754604080517f70a08231000000000000000000000000000000000000000000000000000000008152306004820152905173ffffffffffffffffffffffffffffffffffffffff909216916370a0823191602480820192602092909190829003018186803b158015611f7a57600080fd5b505afa158015611f8e573d6000803e3d6000fd5b505050506040513d6020811015611fa457600080fd5b50516008546dffffffffffffffffffffffffffff808216916e0100000000000000000000000000009004166122e0565b6001600c55565b604080518082018252601981527f7472616e7366657228616464726573732c75696e743235362900000000000000602091820152815173ffffffffffffffffffffffffffffffffffffffff85811660248301526044808301869052845180840390910181526064909201845291810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb000000000000000000000000000000000000000000000000000000001781529251815160009460609489169392918291908083835b602083106120e157805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016120a4565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114612143576040519150601f19603f3d011682016040523d82523d6000602084013e612148565b606091505b5091509150818015612176575080511580612176575080806020019051602081101561217357600080fd5b50515b6121e157604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f556e697377617056323a205452414e534645525f4641494c4544000000000000604482015290519081900360640190fd5b5050505050565b60008115806122035750508082028282828161220057fe5b04145b610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6d756c2d6f766572666c6f77000000000000000000000000604482015290519081900360640190fd5b80820382811115610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601560248201527f64732d6d6174682d7375622d756e646572666c6f770000000000000000000000604482015290519081900360640190fd5b6dffffffffffffffffffffffffffff841180159061230c57506dffffffffffffffffffffffffffff8311155b61237757604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f556e697377617056323a204f564552464c4f5700000000000000000000000000604482015290519081900360640190fd5b60085463ffffffff428116917c0100000000000000000000000000000000000000000000000000000000900481168203908116158015906123c757506dffffffffffffffffffffffffffff841615155b80156123e257506dffffffffffffffffffffffffffff831615155b15612492578063ffffffff16612425856123fb86612a57565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff169063ffffffff612a7b16565b600980547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff929092169290920201905563ffffffff8116612465846123fb87612a57565b600a80547bffffffffffffffffffffffffffffffffffffffffffffffffffffffff92909216929092020190555b600880547fffffffffffffffffffffffffffffffffffff0000000000000000000000000000166dffffffffffffffffffffffffffff888116919091177fffffffff0000000000000000000000000000ffffffffffffffffffffffffffff166e0100000000000000000000000000008883168102919091177bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167c010000000000000000000000000000000000000000000000000000000063ffffffff871602179283905560408051848416815291909304909116602082015281517f1c411e9a96e071241c2f21f7726b17ae89e3cab4c78be50e062b03a9fffbbad1929181900390910190a1505050505050565b73ffffffffffffffffffffffffffffffffffffffff808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020526040902054612641908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff8085166000908152600160205260408082209390935590841681522054612683908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff80841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b600080600560009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663017e7e586040518163ffffffff1660e01b815260040160206040518083038186803b15801561275757600080fd5b505afa15801561276b573d6000803e3d6000fd5b505050506040513d602081101561278157600080fd5b5051600b5473ffffffffffffffffffffffffffffffffffffffff821615801594509192509061286457801561285f5760006127d86112576dffffffffffffffffffffffffffff88811690881663ffffffff6121e816565b905060006127e583612878565b90508082111561285c576000612813612804848463ffffffff61226e16565b6000549063ffffffff6121e816565b905060006128388361282c86600563ffffffff6121e816565b9063ffffffff612abc16565b9050600081838161284557fe5b04905080156128585761285887826128ca565b5050505b50505b612870565b8015612870576000600b555b505092915050565b600060038211156128bb575080600160028204015b818110156128b5578091506002818285816128a457fe5b0401816128ad57fe5b04905061288d565b506128c5565b81156128c5575060015b919050565b6000546128dd908263ffffffff612abc16565b600090815573ffffffffffffffffffffffffffffffffffffffff8316815260016020526040902054612915908263ffffffff612abc16565b73ffffffffffffffffffffffffffffffffffffffff831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6000818310612989578161298b565b825b9392505050565b73ffffffffffffffffffffffffffffffffffffffff82166000908152600160205260409020546129c8908263ffffffff61226e16565b73ffffffffffffffffffffffffffffffffffffffff831660009081526001602052604081209190915554612a02908263ffffffff61226e16565b600090815560408051838152905173ffffffffffffffffffffffffffffffffffffffff8516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef919081900360200190a35050565b6dffffffffffffffffffffffffffff166e0100000000000000000000000000000290565b60006dffffffffffffffffffffffffffff82167bffffffffffffffffffffffffffffffffffffffffffffffffffffffff841681612ab457fe5b049392505050565b80820182811015610df657604080517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f64732d6d6174682d6164642d6f766572666c6f77000000000000000000000000604482015290519081900360640190fdfe556e697377617056323a20494e53554646494349454e545f4f55545055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f494e5055545f414d4f554e54556e697377617056323a20494e53554646494349454e545f4c4951554944495459556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4255524e4544556e697377617056323a20494e53554646494349454e545f4c49515549444954595f4d494e544544a265627a7a723158207dca18479e58487606bf70c79e44d8dee62353c9ee6d01f9a9d70885b8765f2264736f6c63430005100032
|
// File: contracts/interfaces/IUniswapV2Pair.sol
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
// File: contracts/interfaces/IUniswapV2ERC20.sol
pragma solidity >=0.5.0;
interface IUniswapV2ERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
}
// File: contracts/libraries/SafeMath.sol
pragma solidity =0.5.16;
// a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
library SafeMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, 'ds-math-add-overflow');
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, 'ds-math-sub-underflow');
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, 'ds-math-mul-overflow');
}
}
// File: contracts/UniswapV2ERC20.sol
pragma solidity =0.5.16;
contract UniswapV2ERC20 is IUniswapV2ERC20 {
using SafeMath for uint;
string public constant name = 'Uniswap V2';
string public constant symbol = 'UNI-V2';
uint8 public constant decimals = 18;
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
constructor() public {
uint chainId;
assembly {
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
}
// File: contracts/libraries/Math.sol
pragma solidity =0.5.16;
// a library for performing various math operations
library Math {
function min(uint x, uint y) internal pure returns (uint z) {
z = x < y ? x : y;
}
// babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
function sqrt(uint y) internal pure returns (uint z) {
if (y > 3) {
z = y;
uint x = y / 2 + 1;
while (x < z) {
z = x;
x = (y / x + x) / 2;
}
} else if (y != 0) {
z = 1;
}
}
}
// File: contracts/libraries/UQ112x112.sol
pragma solidity =0.5.16;
// a library for handling binary fixed point numbers (https://en.wikipedia.org/wiki/Q_(number_format))
// range: [0, 2**112 - 1]
// resolution: 1 / 2**112
library UQ112x112 {
uint224 constant Q112 = 2**112;
// encode a uint112 as a UQ112x112
function encode(uint112 y) internal pure returns (uint224 z) {
z = uint224(y) * Q112; // never overflows
}
// divide a UQ112x112 by a uint112, returning a UQ112x112
function uqdiv(uint224 x, uint112 y) internal pure returns (uint224 z) {
z = x / uint224(y);
}
}
// File: contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
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 (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
// File: contracts/interfaces/IUniswapV2Callee.sol
pragma solidity >=0.5.0;
interface IUniswapV2Callee {
function uniswapV2Call(address sender, uint amount0, uint amount1, bytes calldata data) external;
}
// File: contracts/UniswapV2Pair.sol
pragma solidity =0.5.16;
contract UniswapV2Pair is IUniswapV2Pair, UniswapV2ERC20 {
using SafeMath for uint;
using UQ112x112 for uint224;
uint public constant MINIMUM_LIQUIDITY = 10**3;
bytes4 private constant SELECTOR = bytes4(keccak256(bytes('transfer(address,uint256)')));
address public factory;
address public token0;
address public token1;
uint112 private reserve0; // uses single storage slot, accessible via getReserves
uint112 private reserve1; // uses single storage slot, accessible via getReserves
uint32 private blockTimestampLast; // uses single storage slot, accessible via getReserves
uint public price0CumulativeLast;
uint public price1CumulativeLast;
uint public kLast; // reserve0 * reserve1, as of immediately after the most recent liquidity event
uint private unlocked = 1;
modifier lock() {
require(unlocked == 1, 'UniswapV2: LOCKED');
unlocked = 0;
_;
unlocked = 1;
}
function getReserves() public view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast) {
_reserve0 = reserve0;
_reserve1 = reserve1;
_blockTimestampLast = blockTimestampLast;
}
function _safeTransfer(address token, address to, uint value) private {
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(SELECTOR, to, value));
require(success && (data.length == 0 || abi.decode(data, (bool))), 'UniswapV2: TRANSFER_FAILED');
}
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
constructor() public {
factory = msg.sender;
}
// called once by the factory at time of deployment
function initialize(address _token0, address _token1) external {
require(msg.sender == factory, 'UniswapV2: FORBIDDEN'); // sufficient check
token0 = _token0;
token1 = _token1;
}
// update reserves and, on the first call per block, price accumulators
function _update(uint balance0, uint balance1, uint112 _reserve0, uint112 _reserve1) private {
require(balance0 <= uint112(-1) && balance1 <= uint112(-1), 'UniswapV2: OVERFLOW');
uint32 blockTimestamp = uint32(block.timestamp % 2**32);
uint32 timeElapsed = blockTimestamp - blockTimestampLast; // overflow is desired
if (timeElapsed > 0 && _reserve0 != 0 && _reserve1 != 0) {
// * never overflows, and + overflow is desired
price0CumulativeLast += uint(UQ112x112.encode(_reserve1).uqdiv(_reserve0)) * timeElapsed;
price1CumulativeLast += uint(UQ112x112.encode(_reserve0).uqdiv(_reserve1)) * timeElapsed;
}
reserve0 = uint112(balance0);
reserve1 = uint112(balance1);
blockTimestampLast = blockTimestamp;
emit Sync(reserve0, reserve1);
}
// if fee is on, mint liquidity equivalent to 1/6th of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) {
address feeTo = IUniswapV2Factory(factory).feeTo();
feeOn = feeTo != address(0);
uint _kLast = kLast; // gas savings
if (feeOn) {
if (_kLast != 0) {
uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
uint rootKLast = Math.sqrt(_kLast);
if (rootK > rootKLast) {
uint numerator = totalSupply.mul(rootK.sub(rootKLast));
uint denominator = rootK.mul(5).add(rootKLast);
uint liquidity = numerator / denominator;
if (liquidity > 0) _mint(feeTo, liquidity);
}
}
} else if (_kLast != 0) {
kLast = 0;
}
}
// this low-level function should be called from a contract which performs important safety checks
function mint(address to) external lock returns (uint liquidity) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
uint balance0 = IERC20(token0).balanceOf(address(this));
uint balance1 = IERC20(token1).balanceOf(address(this));
uint amount0 = balance0.sub(_reserve0);
uint amount1 = balance1.sub(_reserve1);
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
if (_totalSupply == 0) {
liquidity = Math.sqrt(amount0.mul(amount1)).sub(MINIMUM_LIQUIDITY);
_mint(address(0), MINIMUM_LIQUIDITY); // permanently lock the first MINIMUM_LIQUIDITY tokens
} else {
liquidity = Math.min(amount0.mul(_totalSupply) / _reserve0, amount1.mul(_totalSupply) / _reserve1);
}
require(liquidity > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED');
_mint(to, liquidity);
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Mint(msg.sender, amount0, amount1);
}
// this low-level function should be called from a contract which performs important safety checks
function burn(address to) external lock returns (uint amount0, uint amount1) {
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
uint balance0 = IERC20(_token0).balanceOf(address(this));
uint balance1 = IERC20(_token1).balanceOf(address(this));
uint liquidity = balanceOf[address(this)];
bool feeOn = _mintFee(_reserve0, _reserve1);
uint _totalSupply = totalSupply; // gas savings, must be defined here since totalSupply can update in _mintFee
amount0 = liquidity.mul(balance0) / _totalSupply; // using balances ensures pro-rata distribution
amount1 = liquidity.mul(balance1) / _totalSupply; // using balances ensures pro-rata distribution
require(amount0 > 0 && amount1 > 0, 'UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED');
_burn(address(this), liquidity);
_safeTransfer(_token0, to, amount0);
_safeTransfer(_token1, to, amount1);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
_update(balance0, balance1, _reserve0, _reserve1);
if (feeOn) kLast = uint(reserve0).mul(reserve1); // reserve0 and reserve1 are up-to-date
emit Burn(msg.sender, amount0, amount1, to);
}
// this low-level function should be called from a contract which performs important safety checks
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external lock {
require(amount0Out > 0 || amount1Out > 0, 'UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT');
(uint112 _reserve0, uint112 _reserve1,) = getReserves(); // gas savings
require(amount0Out < _reserve0 && amount1Out < _reserve1, 'UniswapV2: INSUFFICIENT_LIQUIDITY');
uint balance0;
uint balance1;
{ // scope for _token{0,1}, avoids stack too deep errors
address _token0 = token0;
address _token1 = token1;
require(to != _token0 && to != _token1, 'UniswapV2: INVALID_TO');
if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens
if (amount1Out > 0) _safeTransfer(_token1, to, amount1Out); // optimistically transfer tokens
if (data.length > 0) IUniswapV2Callee(to).uniswapV2Call(msg.sender, amount0Out, amount1Out, data);
balance0 = IERC20(_token0).balanceOf(address(this));
balance1 = IERC20(_token1).balanceOf(address(this));
}
uint amount0In = balance0 > _reserve0 - amount0Out ? balance0 - (_reserve0 - amount0Out) : 0;
uint amount1In = balance1 > _reserve1 - amount1Out ? balance1 - (_reserve1 - amount1Out) : 0;
require(amount0In > 0 || amount1In > 0, 'UniswapV2: INSUFFICIENT_INPUT_AMOUNT');
{ // scope for reserve{0,1}Adjusted, avoids stack too deep errors
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: K');
}
_update(balance0, balance1, _reserve0, _reserve1);
emit Swap(msg.sender, amount0In, amount1In, amount0Out, amount1Out, to);
}
// force balances to match reserves
function skim(address to) external lock {
address _token0 = token0; // gas savings
address _token1 = token1; // gas savings
_safeTransfer(_token0, to, IERC20(_token0).balanceOf(address(this)).sub(reserve0));
_safeTransfer(_token1, to, IERC20(_token1).balanceOf(address(this)).sub(reserve1));
}
// force reserves to match balances
function sync() external lock {
_update(IERC20(token0).balanceOf(address(this)), IERC20(token1).balanceOf(address(this)), reserve0, reserve1);
}
}
|
1 | 19,498,720 |
75a8527e586085b1e4744307cf588319411714a0aa65bc569b46cf1ca2bfbd39
|
384c71279368906df80945f53a9d5289c196640085229b4a034ef97d4172de55
|
a9a0b8a5e1adca0caccc63a168f053cd3be30808
|
01cd62ed13d0b666e2a10d13879a763dfd1dab99
|
b8586dbc97995c41b876bd467a224beec043f018
|
3d602d80600a3d3981f3363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7308656072fee78f1d07e38c189de56daa9863597a5af43d82803e903d91602b57fd5bf3
| |
1 | 19,498,721 |
7025a7d6a4746b1d3fa5a70ce2626fbcd59c5e0dbd7a23a74d512f5a1f60ea1c
|
0a131b22afb9e1de2d77bdf6e032ada7073f241c2d1aa527949ef104d93b3d1e
|
d2c82f2e5fa236e114a81173e375a73664610998
|
ffa397285ce46fb78c588a9e993286aac68c37cd
|
1b97b8916853473416f09a46e3b5840ad5003e0b
|
3d602d80600a3d3981f3363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73059ffafdc6ef594230de44f824e2bd0a51ca5ded5af43d82803e903d91602b57fd5bf3
|
pragma solidity 0.7.5;
/*
The MIT License (MIT)
Copyright (c) 2018 Murray Software, LLC.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
//solhint-disable max-line-length
//solhint-disable no-inline-assembly
contract CloneFactory {
function createClone(address target, bytes32 salt)
internal
returns (address payable result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the clone contract data
let clone := mload(0x40)
// The bytecode block below is responsible for contract initialization
// during deployment, it is worth noting the proxied contract constructor will not be called during
// the cloning procedure and that is why an initialization function needs to be called after the
// clone is created
mstore(
clone,
0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000
)
// This stores the address location of the implementation contract
// so that the proxy knows where to delegate call logic to
mstore(add(clone, 0x14), targetBytes)
// The bytecode block is the actual code that is deployed for each clone created.
// It forwards all calls to the already deployed implementation via a delegatecall
mstore(
add(clone, 0x28),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// deploy the contract using the CREATE2 opcode
// this deploys the minimal proxy defined above, which will proxy all
// calls to use the logic defined in the implementation contract `target`
result := create2(0, clone, 0x37, salt)
}
}
function isClone(address target, address query)
internal
view
returns (bool result)
{
bytes20 targetBytes = bytes20(target);
assembly {
// load the next free memory slot as a place to store the comparison clone
let clone := mload(0x40)
// The next three lines store the expected bytecode for a miniml proxy
// that targets `target` as its implementation contract
mstore(
clone,
0x363d3d373d3d3d363d7300000000000000000000000000000000000000000000
)
mstore(add(clone, 0xa), targetBytes)
mstore(
add(clone, 0x1e),
0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000
)
// the next two lines store the bytecode of the contract that we are checking in memory
let other := add(clone, 0x40)
extcodecopy(query, other, 0, 0x2d)
// Check if the expected bytecode equals the actual bytecode and return the result
result := and(
eq(mload(clone), mload(other)),
eq(mload(add(clone, 0xd)), mload(add(other, 0xd)))
)
}
}
}
/**
* Contract that exposes the needed erc20 token functions
*/
abstract contract ERC20Interface {
// Send _value amount of tokens to address _to
function transfer(address _to, uint256 _value)
public
virtual
returns (bool success);
// Get the account balance of another account with address _owner
function balanceOf(address _owner)
public
virtual
view
returns (uint256 balance);
}
// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
function safeApprove(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('approve(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeApprove: approve failed'
);
}
function safeTransfer(
address token,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::safeTransfer: transfer failed'
);
}
function safeTransferFrom(
address token,
address from,
address to,
uint256 value
) internal {
// bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
(bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
require(
success && (data.length == 0 || abi.decode(data, (bool))),
'TransferHelper::transferFrom: transferFrom failed'
);
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call{value: value}(new bytes(0));
require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
}
}
/**
* Contract that will forward any incoming Ether to the creator of the contract
*
*/
contract Forwarder {
// Address to which any funds sent to this contract will be forwarded
address public parentAddress;
event ForwarderDeposited(address from, uint256 value, bytes data);
/**
* Initialize the contract, and sets the destination address to that of the creator
*/
function init(address _parentAddress) external onlyUninitialized {
parentAddress = _parentAddress;
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
// NOTE: since we are forwarding on initialization,
// we don't have the context of the original sender.
// We still emit an event about the forwarding but set
// the sender to the forwarder itself
emit ForwarderDeposited(address(this), value, msg.data);
}
/**
* Modifier that will execute internal code block only if the sender is the parent address
*/
modifier onlyParent {
require(msg.sender == parentAddress, 'Only Parent');
_;
}
/**
* Modifier that will execute internal code block only if the contract has not been initialized yet
*/
modifier onlyUninitialized {
require(parentAddress == address(0x0), 'Already initialized');
_;
}
/**
* Default function; Gets called when data is sent but does not match any other function
*/
fallback() external payable {
flush();
}
/**
* Default function; Gets called when Ether is deposited with no data, and forwards it to the parent address
*/
receive() external payable {
flush();
}
/**
* Execute a token transfer of the full balance from the forwarder token to the parent address
* @param tokenContractAddress the address of the erc20 token contract
*/
function flushTokens(address tokenContractAddress) external onlyParent {
ERC20Interface instance = ERC20Interface(tokenContractAddress);
address forwarderAddress = address(this);
uint256 forwarderBalance = instance.balanceOf(forwarderAddress);
if (forwarderBalance == 0) {
return;
}
TransferHelper.safeTransfer(
tokenContractAddress,
parentAddress,
forwarderBalance
);
}
/**
* Flush the entire balance of the contract to the parent address.
*/
function flush() public {
uint256 value = address(this).balance;
if (value == 0) {
return;
}
(bool success, ) = parentAddress.call{ value: value }('');
require(success, 'Flush failed');
emit ForwarderDeposited(msg.sender, value, msg.data);
}
}
contract ForwarderFactory is CloneFactory {
address public implementationAddress;
event ForwarderCreated(address newForwarderAddress, address parentAddress);
constructor(address _implementationAddress) {
implementationAddress = _implementationAddress;
}
function createForwarder(address parent, bytes32 salt) external {
// include the signers in the salt so any contract deployed to a given address must have the same signers
bytes32 finalSalt = keccak256(abi.encodePacked(parent, salt));
address payable clone = createClone(implementationAddress, finalSalt);
Forwarder(clone).init(parent);
emit ForwarderCreated(clone, parent);
}
}
|
1 | 19,498,722 |
5656b4acb9014ff056e2e7b12a39d2b46d1044aa7f762f5448e1ffc335822097
|
59d3b8c52a677448e48f68e2ab5e69cc023cc51eca05949895f672810024ad9e
|
16148e9f25a7c2734300076d1c8a4a0d07488476
|
9035c0ba5a4cd5e306771734c5f431491e090717
|
9d756560514838ddd7b6f4fa8a5fc6f9446a7ba8
|
608060408190526319b400eb60e21b8152339060009082906366d003ac9060849060209060048186803b15801561003557600080fd5b505afa158015610049573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061006d9190610271565b90506000826001600160a01b031663fc0c546a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156100aa57600080fd5b505afa1580156100be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100e29190610271565b90506001600160a01b0381161561018d576040516370a0823160e01b815230600482015261018d9083906001600160a01b038416906370a082319060240160206040518083038186803b15801561013857600080fd5b505afa15801561014c573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061017091906102bf565b836001600160a01b031661019960201b610009179092919060201c565b816001600160a01b0316ff5b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916101f591906102d7565b6000604051808303816000865af19150503d8060008114610232576040519150601f19603f3d011682016040523d82523d6000602084013e610237565b606091505b5091509150818015610261575080511580610261575080806020019051810190610261919061029f565b61026a57600080fd5b5050505050565b600060208284031215610282578081fd5b81516001600160a01b0381168114610298578182fd5b9392505050565b6000602082840312156102b0578081fd5b81518015158114610298578182fd5b6000602082840312156102d0578081fd5b5051919050565b60008251815b818110156102f757602081860181015185830152016102dd565b818111156103055782828501525b50919091019291505056fe
| ||
1 | 19,498,722 |
5656b4acb9014ff056e2e7b12a39d2b46d1044aa7f762f5448e1ffc335822097
|
4311ad888be6b61256d8eb12e70bb5d6fa9c9eb2f2fb35f2936ae649c918810e
|
ddb3cc4dc30ce0fcd9bbfc2a5f389b8c40aa023a
|
46950ba8946d7be4594399bcf203fb53e1fd7d37
|
05c1deafa51c2b258476eb8238ac7b2245930e51
|
3d602d80600a3d3981f3363d3d373d3d3d363d73bfac0f451e63d2d639b05bbea3e72318ac5abc095af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d73bfac0f451e63d2d639b05bbea3e72318ac5abc095af43d82803e903d91602b57fd5bf3
| |
1 | 19,498,726 |
b08222809f3b322a3fa85676524f9e326b75594cb241bebf5ec005e2672b1549
|
9a3e4f691b8709f02dedd62fe93c0dfda5a2734e77b25fb2e3d284d2fe943fa2
|
f670d1725933d72d62aed14908eb1668b58dc036
|
881d4032abe4188e2237efcd27ab435e81fc6bb1
|
813246712cf081e43b40c6093bd1f0b7b96ea521
|
3d602d80600a3d3981f3363d3d373d3d3d363d7320a9f26a7b33317975a69c91d1539f6a781c09555af43d82803e903d91602b57fd5bf3
|
363d3d373d3d3d363d7320a9f26a7b33317975a69c91d1539f6a781c09555af43d82803e903d91602b57fd5bf3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.